How to add UART/ printf to ss_twr_responder example

Hi,
I would like to add uart to the ss_twr_responder program given from github.

In the ss_twr_init program printf does send the desired data over UART which i can monitor in segger studio through the serial terminal.
I would like to do the same in the responder program but cannot get it to work. If i add printf to the program i get the following error:
Building ‘ss_twr_resp’ from solution ‘ss_twr_resp’ in configuration ‘nrf52832_xxaa’
Linking ss_twr_resp.elf
C:/Program Files/SEGGER/SEGGER Embedded Studio for ARM 5.20/lib/libc_v7em_fpv4_sp_d16_hard_t_le_eabi.a(libc2.o): in function printf': libc2.c:(.text.libc.printf+0x3c): undefined reference to __putchar’
Build failed

Any suggestions how to do this?
Thanks in advance
Regards,
Bas

Meanwhile i have copied my resp main and ss_resp_main.c to the ss_twr_init solution. After this i can compile the project successfully but when downloaded to the device with the use of printf in the code the device hangs. When trying to open the serial terminal it shows error ‘com xx port not available’.
The moment i remove the printf command in my code the responder works like expected.

Any suggestions would be much appreciated.

Thanks in advance.

I found the issue and solved it.

The best for the community and your karma is to disclose the solution. Maybe that would help others.

Correct!

This is what i did to activate the use of printf. It was a trial and error method so excuse me if it doesn’t make much sense;)

First i copied the app_uart_fifo.c and retarget.c libraries under nRF_Libraries and the uart.c library from the ss_init project to the ss_resp project. Then i include them in the preprocessor include directories.

Now i used:
/Initialization UART/
boUART_Init ();
printf(“Singled Sided Two Way Ranging ResponderExample \r\n”);
in the main.c program to initialize UART and use the printf command with succes.

1 Like

Hey!

We’ve encountered the exact same problem! We’ve tried to apply what you’re stating on your last comment, but we still can’t manage to get it running. There’s somethings you say that we don’t understand well though. Could you maybe explain in more detail how you made it work? How did you exactly copy the “app_uart_fifo.c” and “retarget.c” libraries under nRF_Libraries. How did you copy “uart.c” in the ss_resp project? And what is all about the preprocessor include directories?

Your solution sounds simple, but maybe we’re missing an important extra piece of info, because it still doesn’t work.

Thanks a lot!

Guillem

Please sir, we’re completely blocked on this.