This post is older than 2 years and might not be relevant anymore
More Info: Consider searching for newer posts

UARTE ENDTX event latency

According to the User Guide,

After each byte has been sent over the TXD line, a TXDRDY event will be generated.


When all bytes in the TXD buffer, as specified in the TXD.MAXCNT register, have been transmitted, the
UARTE transmission will end automatically and an ENDTX event will be generated.

Are the above events generated when the stop bit of the last byte is transmitted? Or are these events generated as soon as the last byte is shifted out of internal HW shift register (6-byte internal HW FIFO)?

If we have a strict time requirement to set a IO line immediately (within 10 micro secs) after sending the last byte, is that possible? What kind of latency to be expected between the stop bit of the last byte and ENDTX event published? We plan to use 1M BAUD.

Parents
  • Hello,

    I tested with 115200 baud rate, and a PPI set up to change a pin at the ENDTX event. As you can see, the event is set at the very end of the last payload bit, and right before the stop bit. Screenshot below shows the TX line on Channel 0 and the pin that switched on ENDTX on Channel 1.

    I also tested it with the 1M baudrate. As you can see there is a tiny delay, but it is less than 0.3µs.

    The same delay is on the 115200 baudrate, but of course it is neglectable with that baudrate.

    Best regards,

    Edvin

  • If you want to test yourself, here is the piece of code that I used to test:

    void attach_ENDTX_to_pin(uint32_t pinselect)
    {
        NRF_GPIOTE->CONFIG[ENDTX_GPIOTE_CH] =   GPIOTE_CONFIG_MODE_Task << GPIOTE_CONFIG_MODE_Pos |
                                                GPIOTE_CONFIG_POLARITY_Toggle << GPIOTE_CONFIG_POLARITY_Pos |
                                                pinselect << GPIOTE_CONFIG_PSEL_Pos |
                                                GPIOTE_CONFIG_OUTINIT_High << GPIOTE_CONFIG_OUTINIT_Pos;
        
        NRF_PPI->CH[ENDTX_GPIOTE_CH_A].EEP  =   (uint32_t)&NRF_UARTE0->EVENTS_ENDTX;
        NRF_PPI->CH[ENDTX_GPIOTE_CH_A].TEP  =   (uint32_t)&NRF_GPIOTE->TASKS_CLR[ENDTX_GPIOTE_CH];
        
        NRF_PPI->CHENSET = (1 << ENDTX_GPIOTE_CH_A);
    }
    
    int main(void)
    {
        ...init_uart...
        
        attach_ENDTX_to_pin(22);    //use e.g. pin 20 to use LED4 (nRF52832)
        
        printf("Start: \r\n");
    
    }

  • Thanks Edvin.

    For our use case, the transmit section and receive section of hardware cannot be enabled at the same time. If I have to wait until all the bytes are completely transmitted, this method may not work because the transmit section would be turned off before the stop bit of the last byte is transmitted. Ther could be framing errors on other side.

    Some MCUs have TX_COMPLETE interrupt which is asserted after stop bit is sent out.

    How do I address this scenario?

Reply
  • Thanks Edvin.

    For our use case, the transmit section and receive section of hardware cannot be enabled at the same time. If I have to wait until all the bytes are completely transmitted, this method may not work because the transmit section would be turned off before the stop bit of the last byte is transmitted. Ther could be framing errors on other side.

    Some MCUs have TX_COMPLETE interrupt which is asserted after stop bit is sent out.

    How do I address this scenario?

Children
No Data
Related