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

(nRF51822) uart rx loss data after start advertising

Hello! everyone: I use nRF51822 UART Demo(ble_app_uart),test uart interrupt receive data, baudrate is 38400. if start advertising ,rx loss data ,else rx receive data perfect. so i think soft device disturb uart
interrupt.

uart configeration is:

void simple_uart_config(  uint8_t rts_pin_number,
                          uint8_t txd_pin_number,
                          uint8_t cts_pin_number,
                          uint8_t rxd_pin_number,
                          bool    hwfc)

{

/** @snippet [Configure UART RX and TX pin] */

    nrf_gpio_cfg_output(txd_pin_number);
    nrf_gpio_cfg_input (rxd_pin_number, NRF_GPIO_PIN_NOPULL);  

    NRF_UART0->PSELTXD = txd_pin_number;
    NRF_UART0->PSELRXD = rxd_pin_number;
/** @snippet [Configure UART RX and TX pin] */

    if (hwfc)
    {
        nrf_gpio_cfg_output(rts_pin_number);
        nrf_gpio_cfg_input (cts_pin_number, NRF_GPIO_PIN_NOPULL);
        NRF_UART0->PSELCTS = cts_pin_number;
        NRF_UART0->PSELRTS = rts_pin_number;
        NRF_UART0->CONFIG  = (UART_CONFIG_HWFC_Enabled << UART_CONFIG_HWFC_Pos);
    }

    NRF_UART0->BAUDRATE         = (UART_BAUDRATE_BAUDRATE_Baud115200 << 
                                                     UART_BAUDRATE_BAUDRATE_Pos);
    NRF_UART0->ENABLE           = (UART_ENABLE_ENABLE_Enabled <<   
                                                     UART_ENABLE_ENABLE_Pos);
    NRF_UART0->TASKS_STARTTX    = 1;	
    NRF_UART0->TASKS_STARTRX    = 1;
    NRF_UART0->EVENTS_RXDRDY    = 0;

} 

uart interrupt handler is:

void UART0_IRQHandler(void)
{
    if (NRF_UART0->EVENTS_RXDRDY != 0)		
    {	

        //res=(uint8_t)NRF_UART0->RXD; 
        NRF_UART0->EVENTS_RXDRDY = 0;     //       
        USART0_RX_BUF[USART0_RX_STA++] =(uint8_t)NRF_UART0->RXD; 
    }
}
Parents
  • You're going to have problems running at 38,400 baud with the softdevice enabled and no hardware flow control. That's your problem. Use a slower baud rate, enable HWFC and it will help to use the latest revision nrf51 and latest softdevices (as they interrupt the CPU less). What SDK/softdevice and nrf51 are you actually using .. just for reference.

  • That's a strange combination of stuff. What actual revision of the device are you running on? If you are on revision 2, the latest is SDK 6.1 with softdevice 7.1, no need to be using an old beta softdevice. If you have a revision 3 chip however you can use softdevice revision 8 with one of the more recent SDKs, like SDK 8.1 or newer. That will reduce the amount of time the softdevice uses a bit. However .. without HWFC or a much slower baud rate, if you start really doing a lot of BTLE transmissions, you're going to start losing UART data.

Reply
  • That's a strange combination of stuff. What actual revision of the device are you running on? If you are on revision 2, the latest is SDK 6.1 with softdevice 7.1, no need to be using an old beta softdevice. If you have a revision 3 chip however you can use softdevice revision 8 with one of the more recent SDKs, like SDK 8.1 or newer. That will reduce the amount of time the softdevice uses a bit. However .. without HWFC or a much slower baud rate, if you start really doing a lot of BTLE transmissions, you're going to start losing UART data.

Children
No Data
Related