When compiled with ‘mbed compile’ using GCC compiler and run on LPC1768, this never returns from the first ThisThread::sleep_for(BLINKING_RATE); in main().
If I replace ThisThread::sleep_for(BLINKING_RATE); with wait_us(500000) in main() both leds flash as expected.
So ThisThread::sleep_for works in the blink() thread but not in main()
All the examples show Thread::sleep_for being used in main() - but for me it does not work!
OK, my bad, I missed out the lines defining P_LEDG and P_LEDR - they are defined as port pins and there is, of course, #include “mbed.h” otherwise it wouldn’t compile!
#define P_LEDG P0_16 #define P_LEDR P2_8
I also missed out that this is our custom LPC1768 board. So there is no firmware to load - I am loading the output from compiling this code (the *.elf file) directly into the board using JTAG.
My observation is that
ThisThread::sleep_for
works fine when it is in the thread method.
But when it is used in main() it never returns. It’s almost like main() is not in a thread??
I originally started with the mbed-os-example-blinky and just modified for my led ports.
To have the LED1 in the main thread I replaced P_LEDR with LED1 and P_LEDG with LED2 and
it works also on these LPC1768 custom boards (with no firmware):