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.
6 years, 4 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
6 years, 4 months ago.
Hello Sandra,
It could be due to old firmware. Try to update.
Similar issues:
https://os.mbed.com/questions/81086/Wait-function-is-too-long-in-offline-com/
https://os.mbed.com/questions/78806/LPC1768-MBED-OS-5-wait_ms/
6 years, 4 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
core_util_critical_section_enter(); do_timing_thing(); wait(0.5); core_util_critical_section_exit();
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!