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:

  • Let me make it a little bit clearer about code.

    uint32_t drv_uart_enable(  )
    {
    	nrf_uarte_enable( NRF_UARTE0 );
    	return NRF_SUCCESS;
    }
    
    
    uint32_t drv_uart_disable(  )
    {
    	nrf_uarte_disable( NRF_UARTE0 );
    	return NRF_SUCCESS;
    }
    

    Thank you at all~

  • 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

  • Strangely i see the same problem. When using Init and Unint functions it works well but when using Enable and Disable functions the 7th byte is missing. I need to use enable/disable in order to wake up fast in response to incoming data. Any suggestions?

    p.s. this is with nRF52833, SDK 17.1.0

  • Hi

    This case is almost a year old at this point, and I think it would be best if you create a new case where you can link to this one and share some more information on what you do (and possibly share your project so we can recreate this on our end). For example, do you also only see the one byte missing, do you transmit more than 10 bytes like the original poster or more/less?

    Best regards,

    Simon

Related