2 years, 9 months ago.

Why is wait() different when using mbed and mbed-os libraries?

When using mbed library the wait() function works properly; for example when using blinky the time on and off of the LED is correct. However, when using the mbed-os library the wait function waits 10x as long. This was observed using an LPC1768

2 Answers

2 years, 8 months ago.

Hi Sandra,

The reason why mbed wait is faster than mbed-os is because mbed-os contain an RTOS while mbed is not. For >1ms waits, the thread can be preempted to save power in mbed-os. To fix it, you will need to put the time-sensitive code in a critical section.

critical section


Please let me know if you have any questions!

- Peter, team Mbed

If this solved your question, please make sure to click the "Thanks" link below!