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

UART doesn't work well with GCC

I try to move my project from Keil to GCC but I get some different behavior. To show the difference I use examples/ble_peripheral/ble_app_uart

The part of the code below writes "Starting" wait 500ms "." wait 500ms "." etc...

...
#include "nrf_delay.h"
...
...
...
printf("\n");
printf("Starting ");
for (int dot = 0; dot <5; dot ++)
{
   nrf_delay_ms(500);
   printf(".");
}
printf("\n");
    
printf("UART Start!\n");
...

With Keil it works as expected but with GCC it shows nothing until "\n" append and then print everything at a time.

Could you help me to fix this problem, I need to have correct UART behavior with GCC also? Is it a bug somewhere ?

Thanks for helping.

Parents
  • I use a custom board without J-Link so I think NRF_LOG couldn't work in that case.

    For now as a workaround solution I created a custom printf including app_uart_put() which is working fine. But if somebody is able to use printf with GCC i'm interested to know how to to that. It seem that it is a very common feature, I don't understand why nobody can give me a clear answer !

    As retarget.c contains #elif defined(GNUC) means that it is not only for Keil ?

Reply
  • I use a custom board without J-Link so I think NRF_LOG couldn't work in that case.

    For now as a workaround solution I created a custom printf including app_uart_put() which is working fine. But if somebody is able to use printf with GCC i'm interested to know how to to that. It seem that it is a very common feature, I don't understand why nobody can give me a clear answer !

    As retarget.c contains #elif defined(GNUC) means that it is not only for Keil ?

Children
No Data
Related