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

nrf52 DK: UART problems

Hello,

I integrated the relevant code from the "uart" example into the "ble_app_uart" example(this is all the code in the main routine):

uint8_t cr;        
uart_init();
	printf("\r\nUART Start!\r\n");

  while (true){
		        
    while (app_uart_get(&cr) != NRF_SUCCESS);
    while (app_uart_put(cr) != NRF_SUCCESS);

    if (cr == 'q' || cr == 'Q')
    {
        printf(" \r\nExit!\r\n");

        while (true)
        {
            // Do nothing.
        }
    }
}

Now have the problem that the program is stuck in this line:

while (app_uart_get(&cr) != NRF_SUCCESS);

The return value of the function is not "NRF_SUCCESS".

The echo function in the "uart" example was working fine.

The only difference between the uart_inits of both is uart_error_handle and uart_event_handle and the Flow Control. But even if I set this to enable it won't work:

UART: UART example

BLE_APP_UART: BLE_APP_UART example

Also if I flash the code, I can't download the softdevice to the board. Maybe there are conflicts but I have no clue.

Thanks in advance Hannes

  • OK, thank you for making that clear. So that's the difference I already pointed out in my initial question but lacking knowledge of the internal UART procedures, I couldn't conclude which impact "error" or "event handle" would have. I still don't understand how during the "APP_UART_FIFO_INIT", "error" or "uart handle" are passed without the required "p_event" pointer. Can you please also explain that to me?

  • FormerMember
    0 FormerMember in reply to H4NNE5

    In APP_UART_FIFO_INIT, the function name for the event handler is passed as an argument. As you can see in the source code: APP_UART_FIFO_INIT() --> app_uart_init(), the UART event handler is assigned to m_event_handler (app_uart_fifo.c). In case of an UART event, uart_event_handler (app_uart_fifo.c) will pass the event to the assigned m_event_handler.

    In app_uart_fifo.c, uart_event_handler() is set to be the event handler function in app_uart_init() --> nrf_drv_uart_init().

Related