Use this forum to chat about hardware specific topics for the ESP8266 (peripherals, memory, clocks, JTAG, programming)

User avatar
By RFZ
#86641
Pablo2048 wrote:Maybe you can try to read UART_STATUS register bit 31 (txd) - read https://www.espressif.com/sites/default ... nce_en.pdf , page 115, Appendix 3 UART registers.
Edit: Oh, I overlooked that you have already tried this...


Yeah, I tried this, but I used a different header file defining these registers, so maybe the header file is wrong...
The PDF also is unclear to me. What is the base address of the UART1 status register?

In https://github.com/esp8266/Arduino/blob ... eri.h#L207
U1S is ESP8266_REG(0xF1C) which translates to 0x60000F1C and USTX is bit 31 of this register.
User avatar
By RFZ
#86647 Hmm, never heard of loopback mode. I'll look it up.
For now, I'll just document my finding about U1S. Actually, the complete register will not change if you send one chunk of data. But when you write a second time to the fifo while it is still sending, U1S actually changes.
Here is the code:

Code: Select all#include <Arduino.h>
#include <Ticker.h>
Ticker tick;
// U1 TX: GPIO_02 / D4
#define P_DEBUG 14 // D5
#define DEBUG_HIGH GPOS = 1<<P_DEBUG
#define DEBUG_LOW GPOC = 1<<P_DEBUG

void ICACHE_RAM_ATTR send() {
  DEBUG_HIGH;
  DEBUG_LOW;
  U1F = 0x80;
}

void setup() {
  Serial1.begin(9600);
  pinMode(P_DEBUG,OUTPUT);
  U1S |= 0x01 << USTXC;
  U1D = 10*50; // 50µs pulse
  tick.attach(0.001, send); // every 1ms
}

void loop() {
  static uint32_t _U1S;
  // Toggle on every change of U1S
  if(U1S != _U1S) {
    _U1S = U1S;
    DEBUG_HIGH;
  } else {
    DEBUG_LOW;
  }
}


Code: Select all// What I get:
// IO_02: ‾‾‾‾|________|‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾|_
// DEBUG: ____|______________________________________|_


And here with three times writing to U1F:

Code: Select all#include <Arduino.h>
#include <Ticker.h>
Ticker tick;
// U1 TX: GPIO_02 / D4
#define P_DEBUG 14 // D5
#define DEBUG_HIGH GPOS = 1<<P_DEBUG
#define DEBUG_LOW GPOC = 1<<P_DEBUG

void ICACHE_RAM_ATTR send() {
  DEBUG_HIGH;
  DEBUG_LOW;
  U1F = 0x80;
  U1F = 0x80;
  U1F = 0x80;
}

void setup() {
  Serial1.begin(9600);
  pinMode(P_DEBUG,OUTPUT);
  U1S |= 0x01 << USTXC;
  U1D = 10*50; // 50µs pulse
  tick.attach(0.001, send); // every 1ms
}

void loop() {
  static uint32_t _U1S;
  // Toggle on every change of U1S
  if(U1S != _U1S) {
    _U1S = U1S;
    DEBUG_HIGH;
  } else {
    DEBUG_LOW;
  }
}


Code: Select all// What I get:
// IO_02: ‾‾‾‾|________|‾‾|________|‾‾|________|‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾|_
// DEBUG: ____|_|‾|_________|‾|_________|‾|______________________|_


I guess this is USTXC (TX FIFO COUNT) that is telling me how many bits/bytes/packets are in the Buffer after the one that is currently processed. Therefore it won't change at all if I only send once...

So USTXC is not helpful in my case.

This also again shows that USTX is either broken in hardware, not labeled/documented correctly or misunderstood by me...

Here is the real timing :)
2020-04-18 18_44_06-Window.png
You do not have the required permissions to view the files attached to this post.