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

NRF_SERIAL_EVENT_RX_DATA never triggered

Hi

I am trying to use the serial library with IRQ and callback function, but the event NRF_SERIAL_EVENT_RX_DATA  is never triggered. No other event than NRF_SERIAL_EVENT_TX_DONE is passed to the callback function. I'm aware of a similar case, https://devzone.nordicsemi.com/f/nordic-q-a/37270/nrf_serial_event_rx_data-never-triggered, but reducing the amount of code in the interrupt handler didn't work for me.

I'm using SDK15.2 

this is the setup:

static void serial_cb(struct nrf_serial_s const *p_serial, nrf_serial_event_t event);

NRF_SERIAL_DRV_UART_CONFIG_DEF(m_uart0_drv_config,
                      RX_PIN_NUMBER, TX_PIN_NUMBER,
                      RTS_PIN_NUMBER, CTS_PIN_NUMBER,
                      NRF_UART_HWFC_DISABLED, NRF_UART_PARITY_EXCLUDED,
                      NRF_UART_BAUDRATE_115200,
                      UART_DEFAULT_CONFIG_IRQ_PRIORITY);


#define SERIAL_FIFO_TX_SIZE 128
#define SERIAL_FIFO_RX_SIZE 128

NRF_SERIAL_QUEUES_DEF(serial_queues, SERIAL_FIFO_TX_SIZE, SERIAL_FIFO_RX_SIZE);

#define SERIAL_BUFF_TX_SIZE 1
#define SERIAL_BUFF_RX_SIZE 1

NRF_SERIAL_BUFFERS_DEF(serial_buffs, SERIAL_BUFF_TX_SIZE, SERIAL_BUFF_RX_SIZE);

NRF_SERIAL_CONFIG_DEF(serial_config, NRF_SERIAL_MODE_IRQ, &serial_queues, &serial_buffs, serial_cb, NULL);

NRF_SERIAL_UART_DEF(serial_uart, 0);

and the initialization:

void 
msgInit (void)
{
    ret_code_t err_code;

    err_code = nrf_serial_init(&serial_uart, &m_uart0_drv_config, &serial_config);
    APP_ERROR_CHECK(err_code);
}

and the callback function:

  

static void serial_cb(struct nrf_serial_s const *p_serial, nrf_serial_event_t event) {
    ret_code_t ret;
    char c;    

    if (event != NRF_SERIAL_EVENT_TX_DONE) {
        ret = c;
    }
    switch (event)
    {
        case NRF_SERIAL_EVENT_TX_DONE:
            break;
        case NRF_SERIAL_EVENT_RX_DATA:
            ret = c;
            break;
        case NRF_SERIAL_EVENT_DRV_ERR:
        case NRF_SERIAL_EVENT_FIFO_ERR:
            break;
        default:
            break;
    }  
}

Setting a breakpoint at line 6 or line 13 never triggers. 

Data sent (blue) and received (red) look fine

Any suggestion on how to proceed?

Parents
  • I changed the callback function to include reading rx data

            case NRF_SERIAL_EVENT_RX_DATA:
                while (!nrf_queue_is_empty(p_serial->p_ctx->p_config->p_queues->p_rxq)) {
                    //Read one char from queue
                    ret = nrf_queue_read(p_serial->p_ctx->p_config->p_queues->p_rxq, &c, sizeof(c));
                    // Put char in Rx msg FIFO  
                    ret = nrf_queue_push(&rx_queue, &c);
                    APP_ERROR_CHECK(ret);                
                    if (c==0) {
    //                    NRF_LOG_RAW_INFO("null detect\n");
                        uint32_t context = 0;
                        app_sched_event_put(&context, sizeof(context), msgInterprete); 
                    }
                }
                break;
    

    and changed the initialization sequence to:

        msgInit();
    
    /*  code to start external device (only gpio setting)
        -> lots of data at RX pin */
    
        nrf_delay_ms(1000); // no more initial RX data after this
    
        // restart serial interface
        msgUnInit();
        msgInit();
    
        // Start execution.
        advertising_start();
        application_timers_start();
    

    Now it works!

    It seems like the serial driver didn't cope with the large amount of data just after starting the external device, and somehow disabled the RX interrupt (?) .

  • Great to hear that you found a solution. Did you check the other events in the callback to make sure there were no NRF_SERIAL_EVENT_DRV_ERR/NRF_SERIAL_EVENT_FIFO_ERR events? Could it be that you got some OVERRUN errors, or that the FIFO filled up?

  • I did see OVERRUN error in ERRORSRC when booting/restarting. And the FIFO were probably also overfilled. But still, I was thinking that the Serial driver would recover.... it didn't.  

Reply Children
No Data
Related