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

WHEN WE GET UART_DRIVER_ERROR?HOW TO AVOID IT?

i am using uart communication between nordic and some device ,communication was fine upto some time but after some random amount of time i am getting uart_driver error...why this error will come?what will exactly happens if it comes?


in my code i am using the uart_event_handler of app_uart_fifo.c .In which we have like this..

 else if (p_event->type == NRF_DRV_UART_EVT_ERROR)
 65     {
 66         app_uart_event.evt_type                 = APP_UART_COMMUNICATION_ERROR;
 67         app_uart_event.data.error_communication = p_event->data.error.error_mask;
 68         (void)nrf_drv_uart_rx(rx_buffer, 1);
 69         m_event_handler(&app_uart_event);
 70     }

why we are reading the data even if we have errors.as it will enable the rx_rdy interrupt?or any other reason?


in my code i have uart event handle like this..

void uart_event_handle(app_uart_evt_t * p_event)
120 {
121     static uint8_t r_data;//, send_on_nxt_call = 0, send_st_index = 0, send_ed_index = 0;
122     uint32_t err_type;
123 
124 //    nrf_gpio_pin_set(PROBE_PIN2);
125     /* Reading Error Source */
126   err_type = (uint32_t)(p_event->data.error_communication);
127   //  err_type = (uint32_t)(nrf_drv_uart_errorsrc_get());
128     /* Function clears error sources after reading. */
129 
130     if(err_type & NRF_UART_ERROR_FRAMING_MASK) {     // If a framing error occured
131         UART0_Status._bit.FRAME_ERROR = 1;          // Set the status bit
132             ble_nus_string_send(&m_nus, (uint8_t *)"FR",2);
133 }
134     if(err_type & NRF_UART_ERROR_PARITY_MASK)  {     // If an parity error occured
135         UART0_Status._bit.PARITY_ERROR = 1;         // parity Error for UART
136             ble_nus_string_send(&m_nus, (uint8_t *)"pA",2);
137 }
138     if(err_type & NRF_UART_ERROR_OVERRUN_MASK) {     // If an overrun error occured
139         UART0_Status._bit.OVERRUN_ERROR = 1;        // Set the status bit
140             ble_nus_string_send(&m_nus, (uint8_t *)"ov",2);
141 }
142     if(err_type & NRF_UART_ERROR_BREAK_MASK) {     // If an overrun error occured
143             ble_nus_string_send(&m_nus, (uint8_t *)"BK",2);
144 }
145     app_uart_get(&r_data);
146 
147     if((u_int)uart0_inf.ct == sizeof(uart0_rbf)){
148     }else{
149         uart0_rbf[uart0_inf.inptr++] = r_data;
......

if i am using line 126 for knowing error value which was updated by uart_event_handler when error we are getting all errors contiunuously but as i said i am able to communicate in this case also?is that statement 126 is correct? what is the reason?


if i use nrf_drv_uart_errorsrc_get() and try to print use in ble prints will we get the data correctly is there any change i little and big endian like this?

Related