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

Odd behavior with nRF52810 UART transmission

I seem to be getting odd behavior of the UARTE0. Actually, this same behavior happens with the standard UART0.

I have a loop that sends a two byte message every 1 second. But actually, the message is sent at random times.

When the message is sent, it is correct data and bit timing is as expected with 9600 baudrate. I checked the loop

by illuminating an LED and it is 1 second as expected. I've studied the nRF52810 data sheet and it seems like I

have all the configuration registers set properly. Hopefully someone has some tips.

void uart_init( void )
{
    NRF_UARTE0->PSEL.RXD = TESTRX;                      /// Set UARTE0 Rx pin
    NRF_UARTE0->PSEL.TXD = TESTTX;                      /// Set UARTE0 Tx pin
    NRF_UARTE0->BAUDRATE = UARTBAUD;                    /// Set UARTE0 baudrate
    NRF_UARTE0->TXD.PTR = (uint32_t)&uarte0TxBuffer;    /// Assign UARTE0 Tx buffer
    NRF_UARTE0->RXD.PTR = (uint32_t)&uarte0RxBuffer;    /// Assign UARTE0 Rx buffer
    NRF_UARTE0->TXD.MAXCNT = TXBUFMAX;                  /// Set Tx buffer max size to 8 bytes
    NRF_UARTE0->RXD.MAXCNT = RXBUFMAX;                  /// Set Rx buffer max size to 8 bytes
    NRF_UARTE0->ENABLE = 0x08;                          /// Enable UART0
    nrf_delay_ms(1);
}

while (nrf_gpio_pin_read(TESTMODE) == LOW)
    {
        // do stuff

        uarte0TxBuffer[0] = 0xDF;
        uarte0TxBuffer[1] = 0xA2;
        NRF_UARTE0->TASKS_STARTTX = true;

        nrf_delay_ms(1000);

    }

Parents
  • Hi,

    You should wait for the nRF to generate ENDTX event that indicate that the transfers is complete by adding this after you have started the transfer:

      while (NRF_UARTE0->EVENTS_ENDTX == 0)
      {
      }

    regards

    Jared

  • Yes, I tried waiting for the ENDTX flag and still got the same behavior.

    A couple details I forgot to include:

    Declaration of the buffer variable:

    static volatile int8_t uarte0TxBuffer[8];                                       // UARTE0 Tx buffer

    SES version 4.30a

    nRF52 SDK 15.3.0

    I attached a scope plot. As you can see, the messages are sent at random times, but synchronized with the loop timing.

    It's like the STARTTX task is not being triggered every time.

    UART Trace

Reply
  • Yes, I tried waiting for the ENDTX flag and still got the same behavior.

    A couple details I forgot to include:

    Declaration of the buffer variable:

    static volatile int8_t uarte0TxBuffer[8];                                       // UARTE0 Tx buffer

    SES version 4.30a

    nRF52 SDK 15.3.0

    I attached a scope plot. As you can see, the messages are sent at random times, but synchronized with the loop timing.

    It's like the STARTTX task is not being triggered every time.

    UART Trace

Children
Related