2 years, 8 months ago.

how to get the outcome of "printf" function, when using mbed complier

  1. include "mbed.h" DigitalOut led_red(LED_RED); InterruptIn sw2(SW2); void sw2_release(void) { led_red = !led_red; printf("On-board button SW2 was released.\n"); }

int main() { sw2.rise(&sw2_release); while (true) { } }

On the K22 board , how to see the printout ? I am using the picocom and configured to /dev/ttyACM0 and 115200 braut in a linux environment , but didn't get any serial infomation printed out.

2 Answers

2 years, 8 months ago.

Try at 9600 for printf, and use Serial pc(USBTX, USBRX) for higher baudrate

2 years, 8 months ago.

One thing to keep in mind is that you shouldn't call printf from an interrupt context. See this link (https://os.mbed.com/blog/entry/Simplify-your-code-with-mbed-events/) for ways to get around this.