Beware that this post is related to an SDK in maintenance mode
More Info: Consider nRF Connect SDK for new designs
This post is older than 2 years and might not be relevant anymore
More Info: Consider searching for newer posts

uart_init() triggering interrupt immediately

Hi

I am facing a problem similar to the one in Case ID228253.

I am using a custom 52810 board and have configured the UART pins on P0.12(Tx) and P0.14(Rx), defined in the board file pca10040.h. (I have copied the defaults into a different header file and set the new pin assignments, then included my header file in boards.h.

On the custom board, the UART TX and RX lines are by default left floating and used only for debugging. I do not use the UART to send receive data, the data comes from an ADC channel and goes to the mobile app.

The software application is based on the ble_app_uart example.

As soon as the uart init() is called, i have a printf call to tell me that the initialization is done. But when the execution hits this call,

the code goes into the error handler.

When i debug the code, i find that it is coming into the uart_event_handle () function and landing at the following switch case in function uart_event_handler() in file app_uart_fifo.c file

case NRF_DRV_UART_EVT_ERROR:
            app_uart_event.evt_type                 = APP_UART_COMMUNICATION_ERROR;
            app_uart_event.data.error_communication = p_event->data.error.error_mask;
            (void)nrf_drv_uart_rx(&app_uart_inst, rx_buffer, 1);
            m_event_handler(&app_uart_event);
            break;

The call stack shows the execution going into the error handler after all the characters in the printf string are sent out of the uart., please check it out at this link:

https://drive.google.com/file/d/1uxJfikgmhw4lHbLqVzcKtdD6ZFBr2VHV/view?usp=sharing

When i comment out the call to the error handler, in function uart_event_handle( ), like this

case APP_UART_COMMUNICATION_ERROR:

              //  APP_ERROR_HANDLER(p_event->data.error_communication);
            break;

then it does not stop but works fine, i am able to get the module to advertise and connect to the phone, send/receive data...

However, this is not the right way to proceed !! Please let me know how to resolve this .....

Regards

Chary BS

Parents
  • Hello,

    If you do not intend to use the UART at all, I suggest that you just uncomment the uart_init() function.

    As you probably saw, the APP_UART_COMMUNICATION_ERROR is triggering when the RX pin is left floating, and the event is used to tell you that there is data coming in on the RX line, that the UART peripheral wasn't able to interpret correctly. This is a common case when you are either using the wrong UART baudrate or if the pin is floating. 

    If you intend to use the UART from time to time, buf leave it floating the rest, you can comment out the APP_ERROR_HANDLER() call, like you did. But if you do not intend to use it at all, you should leave out uart_init(). It will save some power as well, in case your device is battery operated.

    Best regards,

    Edvin

Reply
  • Hello,

    If you do not intend to use the UART at all, I suggest that you just uncomment the uart_init() function.

    As you probably saw, the APP_UART_COMMUNICATION_ERROR is triggering when the RX pin is left floating, and the event is used to tell you that there is data coming in on the RX line, that the UART peripheral wasn't able to interpret correctly. This is a common case when you are either using the wrong UART baudrate or if the pin is floating. 

    If you intend to use the UART from time to time, buf leave it floating the rest, you can comment out the APP_ERROR_HANDLER() call, like you did. But if you do not intend to use it at all, you should leave out uart_init(). It will save some power as well, in case your device is battery operated.

    Best regards,

    Edvin

Children
No Data
Related