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

UARTE lost a byte after uarte disable and enable again.

Hi,all~

void gpio_evt_handler(nrfx_gpiote_pin_t pin, nrf_gpiote_polarity_t action)
{
    switch (pin_no)
    {
        case   PIN_NRF_SLEEP:
        {
            if(! nrf_gpio_pin_read(PIN_NRF_SLEEP) )
            {
                drv_uart_enable();
                app_master_led_state_change(LED_ON);
            }else{
                drv_uart_disable();
                app_master_led_state_change(LED_OFF);
            }
        }
        default:
            break;
    }
}

The program runs on nRF52833. At the beginning, MCU sends data to nRF52833 through serial port, and the data can be received correctly(pic one). When I use THE GPIO control module to disable and enable the serial port again, the MCU is sending data, you can see that the UARTE0 register is missing the seventh byte of data(see pic two).The SDK version is NRF5_SDK_17.0.2_D674DDE.

pic one:

pic two:

PC send log:

Parents
  • Hi

    This seems very strange indeed. If you were to lose a byte, I would imagine it was the last one and not one in the middle of your transmission. When you enable the UART driver again, is I.E. the buffer size the same as when enabled initially? Do you use the same enable function for enabling it during startup as well? 

    When disabling the UART, can you also try uninitializing the UART after disabling it by calling app_uart_close() and reinitializing it when you're enabling it again?

    Best regards,

    Simon

  • Hi,Simon

    Thank for your reply.

    When i enable UART driver again,the buffer size is 256 bytes, the same as when enabled initially. But the second enable function is not the same as first.The process is set the register Disabled and Enabled After Initializing.

    Then I tried the method you suggested,it worked well.I take this approach, although it's a little complicated.If you have time, try to reproduce this problem using the nrf_uarte_enable function, which is fun.

    Best regards,

    Jing

Reply
  • Hi,Simon

    Thank for your reply.

    When i enable UART driver again,the buffer size is 256 bytes, the same as when enabled initially. But the second enable function is not the same as first.The process is set the register Disabled and Enabled After Initializing.

    Then I tried the method you suggested,it worked well.I take this approach, although it's a little complicated.If you have time, try to reproduce this problem using the nrf_uarte_enable function, which is fun.

    Best regards,

    Jing

Children
Related