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

Strange UART behaviour

Hello fellow devlopers.

I am experienceing very odd behaviour from the UART peripheral. I am trying to ouput a uint8_t[48] array from the UART termainl. I am using this simple code

while (i <48) 
{
uint8_t UART_Val;
UART_Val = Meta_data[i];
NRF_UART0->TXD = UART_Val;
while (NRF_UART0->EVENTS_TXDRDY != 1)
{
    // Wait for TXD data to be sent.
}
NRF_UART0->EVENTS_TXDRDY = 0;
i = i+1;
}

ofcourse I have prviously defined i as a 0 integer. The thing is, I only get the first 2 or three elements of the array to show up when I run the code. More stragnly, If I debugg the device to see what is wrong, all elements end up showing up. I think this is a case of synchonisation. Does anybody have a comment to add to this. Thanks in Advance.

Parents
  • You need to trigger a task.

    I would try

    while (i < 48) {

    uint8_t UART_Val; UART_Val = Meta_data[i];

    NRF_UART0->EVENTS_TXDRDY = 0;

    NRF_UART0->NRF_UART_TASK_STARTTX = 1;

    NRF_UART0->TXD = UART_Val;

    while (NRF_UART0->EVENTS_TXDRDY != 1) {

    // Wait for TXD data to be sent.
    

    }

    i++; }

    but check out the example uart code in the SDK. and why arent you using that - it simplifies things?

    let me know if it works!

    -Mike

Reply
  • You need to trigger a task.

    I would try

    while (i < 48) {

    uint8_t UART_Val; UART_Val = Meta_data[i];

    NRF_UART0->EVENTS_TXDRDY = 0;

    NRF_UART0->NRF_UART_TASK_STARTTX = 1;

    NRF_UART0->TXD = UART_Val;

    while (NRF_UART0->EVENTS_TXDRDY != 1) {

    // Wait for TXD data to be sent.
    

    }

    i++; }

    but check out the example uart code in the SDK. and why arent you using that - it simplifies things?

    let me know if it works!

    -Mike

Children
Related