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

User avatar
By RFZ
#86629
eriksl wrote:I don't know the mnemonics you're using. You mean these:

UART_TXFIFO_CNT = 0x000000ff, /* REG_UART_BASE(i) + 0x20) */

that's what I was referring to. This value should auto-increment each time you add a byte to the queue and auto-decrement for each byte actually sent. So it should go 0 -> 1 -> 0 if you send one byte.


https://github.com/esp8266/Arduino/blob ... eri.h#L207
This is what I am referring to...

eriksl wrote:If you need real precise control of the bit pattern, you may need to look at alternatives and how to "abuse" them, like the SPI interface or the I2S interface.

SPI is already in use... I don't need control of the pattern, just the timing of one pulse.

eriksl wrote:Actually there may very well be a register that mirrors the pin, but as usual it's not documented so we'll never know. Blame Espressif.

Sure, there is one, and it's documented:
https://github.com/esp8266/Arduino/blob ... eri.h#L253
This is the one that is not working in my example code. I'm really curious though why the USTX flag is not working as it should. Either I misunderstood what it is supposed to do, or I found a hardware bug...

Also, I tried what happens if I generate another pulse before the first one finished. In this case, a second pulse is immediately appended after the first one.

I think this is because UART1 only has a one register fifo and immediately starts sending the data when you write to the fifo. My observation implies that the fifo then also immediately would accept new data since the first four bytes are already handled by the UART hardware.

This would imply that if I only send on byte (which is what I do), the interrupt or flag that would tell me if the fifo is ready to accept new data, would immediately fire after the pulse started, but not actually when it finished.
User avatar
By eriksl
#86632 It could very well be that this flag isn't documented (from Espressif themselves), indeed, because it's simply not working. Or it's working but otherwise than the name suggests.

UART1 is exactly the same module as UART0. The only difference is that you can't use it for input because simply the input pin isn't connected to any external pin. So both have a transmit and receive queue of 128 bytes. Both have exactly the same register set, just a bit offset in address space.

BTW IMHO if you're so tight on timing, I wouldn't be using arduino in the first place? Who knows what takes place under the surface, not even counted interrupt service routines and timers you don't control? And if only because they are using they're own names for things that Espressif already has named?

BTW2 if you describe the problem you're trying to solve, we might come up with a solution in a completely different way but simply works.
User avatar
By RFZ
#86636 Sorry. but I won't discuss why I am using the Arduino framework. It won't matter anyways when I'm writing just to a register. C is C. I also won't discuss different solutions. Using UART1 is a design choice I've already made.

My question is simple: Is there a way to know either if UART1 finished sending data or TX of UART1 is HIGH.

Edit: not when, if...