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

printf / UART debug does not work properly on nRF51822 s110 ble_app_hts example.

Hi,

Thanks for taking the time looking into issue. We are using Keil uVision 5.14. Our target is a custom board (BMD200 eval Module based on nRF51822) We were able to run uart example with expected outputs to Putty through the UART by following the example from: developer.nordicsemi.com/.../a00054.html Which is awesome.

We switched the project to ble_app_hts (developer.nordicsemi.com/.../a00071.html), copied what worked in the uart example and add printf() to places like main(), device_manager_evt_handler(), on_ble_evt(), on_adv_evt, etc, etc. However only the printfs in main() works. We also tried adding the "ENABLE_DEBUG_LOG_SUPPORT" define to the project c/c++ tab, and use the app_trace_init(). The only thing that's printed was a '[' character. We then added "printf("Hello!: \n\r");" right after app_trace_init();, and "Hel" was then printed, nothing more.

What's more interesting is in the uart example, instead of initializing uart in main(), we use the app_trace.c API, and it still works as expected.

So in summary, without "ENABLE_DEBUG_LOG_SUPPORT" defined, by using printf() and uart initialization in main() of the ble_app_hts example, every print statement within main() work, just not outside of main(). with "ENABLE_DEBUG_LOG_SUPPORT" defined, and using the app_trace.c API, only a few characters are printed. Just wondering if anyone has encountered this...

Also, this might be considered a separate question (if so, I can start a new thread.) I thought the printf() did not work in functions other than main() because they are callbacks running from different context invoked by the softdevice layer (I am really new at this, so just make assumptions here.), So I decided to use an enum to track which functions/callbacks the program has executed and print the enum in the main() loop. However, the enum value doesn't change at all after the "advertise" state.

It doesn't seem to make sense because we have the nRF master control app running, and connected to it, and requesting notifications (battery level) from it. We also changed the enum value in "hts_sim_measurement(ble_hts_meas_t * p_meas)" function, which is supposed to be executed very x seconds. But still, the enum value just doesn't change. Did I miss anything here?

Thank you! (Please find attached the main.c. It's quite messy with our modification. The purpose is to illustrate the issues I have mentioned, where we used printf()s and where we use the enum value to indicate the state of the program.)main.c

Parents
  • The SEGGER_RTT API and JLink RTT Viewer works like a charm. Detailed set up steps can be found here: devzone.nordicsemi.com/.../ Thanks a lot Alex!

    @Aryan, I think I found the reason why the printf()s and the state enum values didn't work in the first place - My Mistake. The version of the softdevice running on my module is 7.0.1. But On Keil, it looks like I am developing with 8.0.0. So after updating the softdevice to 8.0.0 using nRFgo Studio, the examples works as expected. Thanks a lot for your help.

Reply
  • The SEGGER_RTT API and JLink RTT Viewer works like a charm. Detailed set up steps can be found here: devzone.nordicsemi.com/.../ Thanks a lot Alex!

    @Aryan, I think I found the reason why the printf()s and the state enum values didn't work in the first place - My Mistake. The version of the softdevice running on my module is 7.0.1. But On Keil, it looks like I am developing with 8.0.0. So after updating the softdevice to 8.0.0 using nRFgo Studio, the examples works as expected. Thanks a lot for your help.

Children
No Data
Related