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

Countermeasures for shortening STOP bit in UART transmission processing

Hello Nordic Support!
The stop bit of the last character is short in the Uart output part, and the other MPUy cannot receive the character.
How do I fix it until I send the STOP bit completely?
The waveform and the transmission program are described below.
void aUartInterface_SendData(uint8_t *data, uint16_t len)
{
    uint32_t timeout;
    uint32_t start_tick;
    uint32_t current_tick;
    uint8_t sleep = 0;
   
    if(len == 0)
        return;
   
    timeout = TIMEOUT_TICKS*len;
    start_tick = cnt_get();
   
    // check sleep or not
    if(mUartProcessing == 0)
    {
        uart_wakeup();
        sleep = 1;
    }
   
    NRF_GPIO->OUTSET = ((uint32_t)1 << PIN_UART_SENDING);
   
    NRF_UART0->TASKS_STARTTX = 1;
    for(uint16_t i=0; i<len; i++)
    {
        NRF_UART0->TXD = data[i];
        while(NRF_UART0->EVENTS_TXDRDY==0)
        {
            //
            current_tick = cnt_get();
            if( cnt_diff_compute(current_tick, start_tick) > timeout)
            {
                NRF_UART0->EVENTS_TXDRDY = 0;
                NRF_UART0->TASKS_STOPTX = 1;
                NRF_GPIO->OUTCLR = ((uint32_t)1 << PIN_UART_SENDING);
                return;
            }
        }
        NRF_UART0->EVENTS_TXDRDY = 0;
    }
    NRF_UART0->TASKS_STOPTX = 1;
   
    NRF_GPIO->OUTCLR = ((uint32_t)1 << PIN_UART_SENDING);
   
    if(sleep)
        uart_sleep();
}
let me know.
Best Regards
Hirotoshi NAGAO
CHINO Corporation
Parents
  • Hello everyone.
    In a configuration in which UART communication is performed between the NRF52 and another MCU, since the nRF52 alone cannot perform the sleep state and the low power consumption control by the UART interrupt processing, the UART control is performed by using the GPIO together with Wakeup / Sleep.
    At this time, the event to complete TX could not be found in the MDK ARM register description, so a delay of STOP bit length was set before executing TXSTOP. As a result, the UART command to the opposing MPU passed including the last byte, and the communication trouble was solved.
    nrf_delay_us(200);   <----- Insert
    NRF_UART0->TASKS_STOPTX = 1;  
     NRF_GPIO->OUTCLR = ((uint32_t)1 << PIN_UART_SENDING);
       
        if(sleep)
            uart_sleep();
    }

    Attach the scope image at this time. (You can confirm that the final STOP bit is slightly wider.)
    However, it is not known how to monitor the task completion state of the UART transmission unit of the nRF52 is the original method.
    Please explain this.
    let me know.
    Best Regards
    CHINO) Hirotoshi NAGAO
  • When using the legacy UART peripheral, there is no support for EasyDMA. This means that you will have to update the TXD/RXD register for every byte transmitted or received. The EVENTS_TXRDY/EVENTS_RXRDY events tell you when a byte has been successfully transmitted or received. This is the event you should wait for before triggering the STOP task.

Reply Children
No Data
Related