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

SERIAL PORT RECEIVE

Hello, 

I have nrf52 and configure uart0 for connection with external device. 
I have configured it as NRF_SERIAL_MODE_DMA and  set irq_handler .receive NRF_SERIAL_EVENT_DRV_ERR event.

Please help to fix issue.
Thanks in advance!

  • Sorry for mistakes I have wrote from mobile.
    I have received NRF_SERIAL_EVENT_DRV_ERR  event in handler.

  • Please post code showing how you configure UART and how you send/receive data.

  • Hi ,
    I am receiving/transmitting by nrf_serial_read/nrf_serial_write functions

    Bellow are configuration of serial:

    static void serial_event_handler(struct nrf_serial_s const * p_serial,
    nrf_serial_event_t event) 
    {
    switch (event)
    {
    case NRF_SERIAL_EVENT_TX_DONE:
    break;
    case NRF_SERIAL_EVENT_RX_DATA:
    {
    ret_code_t ret;
    char c;
    //Read one char from queue
    ret = nrf_queue_read(p_serial->p_ctx->p_config->p_queues->p_rxq, &c, sizeof(c));
    //printf('%c\r\n', c);
    //Echo char back to port
    //(void)nrf_serial_write(p_serial, &c, sizeof(c), NULL, 0);
    }
    break;
    case NRF_SERIAL_EVENT_DRV_ERR:
    
    break;
    case NRF_SERIAL_EVENT_FIFO_ERR:
    printf("Error\r\n");
    break;
    default:
    break;
    }
    
    }
    #define OP_QUEUES_SIZE 3
    #define APP_TIMER_PRESCALER NRF_SERIAL_APP_TIMER_PRESCALER
    
    
    #define RBP_UARTE0_RX_PIN_NUMBER NRF_GPIO_PIN_MAP(0,RX_PIN)
    #define RBP_UARTE0_TX_PIN_NUMBER NRF_GPIO_PIN_MAP(0,TX_PIN)
    #define RBP_UARTE0_CTS_PIN_NUMBER NRF_UART_PSEL_DISCONNECTED
    #define RBP_UARTE0_RTS_PIN_NUMBER NRF_UART_PSEL_DISCONNECTED
    #define RBP_UARTE0_HWFC false
    
    
    
    NRF_SERIAL_DRV_UART_CONFIG_DEF(m_uart0_drv_config,
    RBP_UARTE0_RX_PIN_NUMBER,
    RBP_UARTE0_TX_PIN_NUMBER,
    RBP_UARTE0_RTS_PIN_NUMBER,
    RBP_UARTE0_CTS_PIN_NUMBER,
    RBP_UARTE0_HWFC,
    NRF_UART_PARITY_EXCLUDED,
    NRF_UART_BAUDRATE_115200,
    UART_DEFAULT_CONFIG_IRQ_PRIORITY);
    
    
    
    
    #define SERIAL_FIFO_TX_SIZE 1024
    #define SERIAL_FIFO_RX_SIZE 1024
    NRF_SERIAL_QUEUES_DEF(serial0_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(serial0_buffs, SERIAL_BUFF_TX_SIZE, SERIAL_BUFF_RX_SIZE);
    
    
    NRF_SERIAL_CONFIG_DEF(serial0_config, NRF_SERIAL_MODE_DMA,
    &serial0_queues, &serial0_buffs, nrf_serial_event_t, NULL);
    
    NRF_SERIAL_UART_DEF(serial0_uart, 0);

  • Can you try debugging the application, set a breakpoint inside the NRF_DRV_UART_EVT_ERROR case in uart_event_handler (line 161 in nrf_serial.c), and check what the error_mask is set to (p_event->data.error.error_mask)?

     

Related