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

Problem with retarget.c

Hi

I'm using PCA10028. it has nrf51422 with softdevice s110. For getting printf in console I'm using 'app_uart.c with FIFO' and 'retarget.c'. When i try to print something I'm getting only the first character in console.

printf("starting");
printf("TWI initialized \n");

If I'm printing the above I will get output as

sT

I tried to edit the function fputc(int ch, FILE * p_file) in retarget.c as below,

UNUSED_PARAMETER(p_file);

// UNUSED_VARIABLE(app_uart_put((uint8_t)ch));
	
while(app_uart_put((uint8_t)ch) != NRF_SUCCESS);
		
return ch;

Then I'm getting the output on the console correctily. But I'm using an app_timer in the program. When this timer expires one handler will be called. Inside this handler I'm using printf. When it starts printing it gets stuck at

while(app_uart_put((uint8_t)ch) != NRF_SUCCESS);

This app_uart_put((uint8_t)ch) never returns NRF_SUCCESS and keeps on iterating.

Please help me...

Related