Rasmus Larsen
posted this on April 26, 2011 11:32
Q:
How can I use the SWO pin to output printf() statements to IAR?
A:
1) Add #include <stdio.h> to the beginning of the file where you want to write your printf statement.
2) Enable SWO Output.
The simplest way of enabling the SWO line in the EFM32 is by using the setupSWO function. You can find this function in the energyAware Profiler, in the left pane, when you open up the program. Once this is run, the SWO output will be enabled to the correct pin on the Development Kit or the Starter Kit.
3) Configure the project in IAR to send printf statements through SWO:
4) Write printf("Hello world"); in your code after you have enabled the SWO output.
5) Compile the code and download it to the Starter Kit/Development Kit. Enter a debug session.
6) Once you are in debug mode, you should set the correct SWO clock speed (14 MHz) in J-link->SWO Configuration...:
7) Open up View->Terminal I/O.
8) When you hit Go you should see the printf statement show up as below: