How do I printf to keil's debug (printf) viwer?

I've did my homework and googling but got more confused than ever.

Basically I'm trying to printf to the debug (printf) viwer window to help me demonstrate certain information.

Thing is, online tutorials tend to be outdated and the config windows looks quite different from what I have.

My setup:

Keil V5.36, segger Jlink with driver version 5.12f? The project is a customized one based on a rather early version SDK, so all the tutorials I found didn't really apply 100%.

What are the things that I must do to make sure I can printf messages to that window?

Parents
  • Hello,

    Would it be an option for you to use the logger module instead of the printf function directly?
    It is the RETARGET library that forwards standard io functions like printf to the UART, but there are no options to make it retarget them to RTT unfortunately.
    The SES Debug terminal is an RTT terminal, so you will need to output your messages to RTT in order to have them show up there. The nRF Logger module has an RTT backend available, and so you may use it to display loggings in the SES Debug terminal.

    Best regards,
    Karl

  • Thank you for your reply Karl!

    >Would it be an option for you to use the logger module instead of the printf function directly?

    Oh absolutely, except I'm seemingly having problem with the logger function. If I enable it, a lot of logs will be enabled and some of them don't seem to function all that well.

    >The nRF Logger module has an RTT backend available, and so you may use it to display loggings in the SES Debug terminal.

    So... now the question becomes... how exactly do I do that?

  • HelmetWithHornInstalledInside said:
    Thank you for your reply Karl!

    No problem at all, I am happy to help!

    HelmetWithHornInstalledInside said:
    Oh absolutely, except I'm seemingly having problem with the logger function. If I enable it, a lot of logs will be enabled and some of them don't seem to function all that well.

    Could you elaborate on what you mean when you say that some of them do not function well?
    If you are seeing unrelevant logs you may change the NRF_LOG_DEFAULT_LEVEL to increase/decrease the amount of logs displayed. Alternatively, you could disable the logging for each module/library that you are not interested in seeing, for example by disabling UART_CONFIG_LOG_ENABLED for the UART peripheral's logging.

    HelmetWithHornInstalledInside said:
    So... now the question becomes... how exactly do I do that?

    The logger module's configuration are made in the sdk_config.h file, you will need to define NRF_LOG_BACKEND_RTT_ENABLED to 1, and define to 0 or remove the NRF_LOG_BACKEND_UART_ENABLED define.

    Best regards,
    Karl

Reply
  • HelmetWithHornInstalledInside said:
    Thank you for your reply Karl!

    No problem at all, I am happy to help!

    HelmetWithHornInstalledInside said:
    Oh absolutely, except I'm seemingly having problem with the logger function. If I enable it, a lot of logs will be enabled and some of them don't seem to function all that well.

    Could you elaborate on what you mean when you say that some of them do not function well?
    If you are seeing unrelevant logs you may change the NRF_LOG_DEFAULT_LEVEL to increase/decrease the amount of logs displayed. Alternatively, you could disable the logging for each module/library that you are not interested in seeing, for example by disabling UART_CONFIG_LOG_ENABLED for the UART peripheral's logging.

    HelmetWithHornInstalledInside said:
    So... now the question becomes... how exactly do I do that?

    The logger module's configuration are made in the sdk_config.h file, you will need to define NRF_LOG_BACKEND_RTT_ENABLED to 1, and define to 0 or remove the NRF_LOG_BACKEND_UART_ENABLED define.

    Best regards,
    Karl

Children
No Data
Related