Important changes to forums and questions
All forums and questions are now archived. To start a new conversation or read the latest updates go to forums.mbed.com.
6 years, 2 months ago.
EFM32 Giant Gecko mbed printf
Hello
I cannot get printf to work under MbedOS.
The wikipage states that you dont have to do any configuration if using printf and the virtual com port.
My code looks like this:
- include "mbed.h"
int main(){ while(1){ printf("Hei dette er en fint test \n"); wait_ms(100); } }
It does not print anything to the terminal.
My serial settings on the terminal reader program is
115200 8 bits 1 stop bit no parity
What could be wrong?
Question relating to:
1 Answer
6 years, 2 months ago.
Hello Thomas,
When using global printf
in mbed the bit rate for the serial terminal shall be set to 9600.
Another option is to keep 115200 bps for the serial terminal and create a new serial object for the serial terminal. Change its bit rate to 115200 and instead of the global printf
call its printf
method:
#include "mbed.h" Serial pc(USBTX, USBRX); // create a new serial object for the virtual serial port int main() { pc.baud(115200); // change the bit rate (from 9600) to 115200 while (1) { pc.printf("Hei dette er en fint test \n"); // call the printf method of pc object wait_ms(100); } }
ADVISE: To have a more readable code published here (on mbed pages) try to mark it up as below (with <<code>> and <</code>>
tags, each on separate line at the begin and end of your code)
<<code>> text of your code <</code>>