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.
7 years, 2 months ago.
how to get the outcome of "printf" function, when using mbed complier
- 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
7 years, 2 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.