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.

Reply
  • 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.

Children
Related