printf prevents UART app working when debugger not connected

    This site uses cookies. By continuing to browse this site, you are agreeing to our Cookie Policy.

    • printf prevents UART app working when debugger not connected

      When debugging, printf directs to the debug terminal - the app seems to function
      When I build a release version I need to comment out printf otherwise the app will freeze
      How can I redirect printf output to the com port so as to prevent this?
      How is stdio set in the ses environment?

      (I am using a JLINK Edu with a Nordic development board to develop an app using a UART for serial comms)

      Many thanks for any help


      Rob
    • Check the blocking mode used in RTT: in sdk_config.h, the macro SEGGER_RTT_CONFIG_DEFAULT_MODE decides what should happen when the RTT buffer is full (not cleared by your J-Link). I bet it is set to "2" ("BLOCK, Wait until there is space in the buffer"). Switch to a non-blocking mode and recompile.
    • New

      Jev
      Belated thanks for the sound advice. Unfortunately it did not fix it.
      I found a similar suggestion from Nordic:
      devzone.nordicsemi.com/f/nordi…default_mode-blocking-app

      I get the same problem when I include the lines below in in sdk_config.h. The printf statement prevents the code running without an RTT console

      Source Code

      1. // <o> SEGGER_RTT_CONFIG_DEFAULT_MODE - RTT behavior if the buffer is full.
      2. // <i> The following modes are supported:
      3. // <i> - SKIP - Do not block, output nothing.
      4. // <i> - TRIM - Do not block, output as much as fits.
      5. // <i> - BLOCK - Wait until there is space in the buffer.
      6. // <0=> SKIP
      7. // <1=> TRIM
      8. // <2=> BLOCK_IF_FIFO_FULL
      9. #ifndef SEGGER_RTT_CONFIG_DEFAULT_MODE
      10. #define SEGGER_RTT_CONFIG_DEFAULT_MODE 0
      11. #endif
      Display All




      :(