Beware that this post is related to an SDK in maintenance mode
More Info: Consider nRF Connect SDK for new designs
This discussion has been locked.
You can no longer post new replies to this discussion. If you have a question you can start a new discussion

nRF52840DK UART example with nRF5 SDK printf is not working as expected

Dear support,

    I am using nRF52840DK (PCA10056) and nRF5 SDK version: nRF5_SDK_17.0.2_d674dde. I am trying to make all the prints in my application to be displayed properly via UART correctly. So, i am using the sample application as per the path: <SDK>/examples/peripheral/uart. Flashing is successful and when i connect the board using UART interface as shown in the image below and using minicom terminal on /dev/ttyACM0 to view the UART output.

      The initial print which is present in the example main.c file is not printed at all. "printf("\r\nUART example started.\r\n");". 

      Also in the same main function and subsequent functions (which i have added myself for debugging purpose) invoked by this main function, if multiple printf( ) statements have been put continuously, then only a immediate printff( ) is displayed and subsequent printf( ) is displayed partially. Any more printf( ) statements present are not displayed at all.

example: 

" printf("Hello World \r\n");  

  printf("Hello World \r\n"); 

  printf("Hello World \r\n"); "

then the print on terminal is as below:

" Hello World

  Hello W" < second printf is displayed partially and subsequent prints are not displayed at all. >

 

   So, i tried the following options to solve this problem but was not working as expected.

1) added fflush(stdout) between subsequent printf( ), not working.

2) tried changing value for NRF_LOG_DEFERRED in config/sdk_config.h, not working

3) tried increasing value for UART_RX_BUF_SIZE and UART_TX_BUF_SIZE from 128 upto 8192,  in config/sdk_config.h,  not working

4) changed priority value for APP_UART_FIFO_INIT( ) from APP_IRQ_PRIORITY_LOWEST to APP_IRQ_PRIORITY_HIGHEST, in main.c not working

   

        The following is working but not desired (adding information for adding clarity to problem statement):

1) Put a delay via nrf_delay_ms(500); between subsequent prints, then both the prints are displayed properly

" printf(" Hello World \r\n"); nrf_delay_ms(500); printf(" nRF52840DK board working \r\n"); "

2) Invoke app_uart_get( ); in between 2 consecutive printf( ), then both the prints are displayed properly.

" printf(" Hello World \r\n"); while(app_uart_get(&cr) != NRF_SUCCESS); printf(" nRF52840DK board working \r\n"); "

       I am trying to adapt a custom embedded RTOS to be able run on nRF52840DK, so i cannot control the frequency and occurrence of printf( ) in the code. I want to get all printf() working as expected without loosing any prints, how to achieve that?

Thanks,

Nagesh

  • Hi there,

    Are you using a completely unmodified version of the UART peripheral example? If not, can you share your code?

    What is the program doing when it stops the printing of logs? Could you use the debugger and see if the program enters the error handler? If it enters the error handler, what does the call stack look like? Does it specify from where the error handler was called from?

    regards

    Jared 

  • sorry for the trouble, that was an issue in my application code. it is rectified now.

Related