4 years, 10 months ago.

Nucleo F091RC - serial data erratic behaviour

Hi, I am using the following code:

/////////

  1. include "mbed.h"

Ticker toggle_led_ticker; Serial pc(USBTX,USBRX); DigitalOut led1(LED1);

void toggle_led() { led1 = !led1; }

int main() { int i=1; pc.baud(115200); Init the ticker with the address of the function (toggle_led) to be attached and the interval (100 ms) toggle_led_ticker.attach(&toggle_led, 0.5); while (true) { Do other things... pc.printf("Testing..... \n"); pc.printf("This program runs since %d seconds.\n", i++); wait(1); } } ////////

I am getting very erratic results on my serial window. I am using a MAC with arduino's serial monitor. I sometimes get the first line only, then other times nothing at all, then sometimes few words and it all stops after that. LED keeps blinking as expected. Is there something I am doing wrong here?

1 Answer