-
Notifications
You must be signed in to change notification settings - Fork 3k
mbed-events breaks Timeout on STM32F4 #3543
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Comments
May also be of interest to @geky |
Hi @DavidPowell, thanks for raising the issue and example. Looks like this was a simple bug in the non-rtos port of mbed-events. Interestingly, it wasn't an issue with critical sections, but actually an unchecked overflow when the event queue tries to create a timeout before going to sleep. This line didn't check for -1, which is used in mbed-events to represent an infinite wait/dispatch: The result was a timeout with some ridiculously large delay, which would mostly work on platforms (for ~50 days). Oddly enough it seemed to kill any other timeouts on the STM32F4 boards. Raised a pr here #3550 and ARMmbed/mbed-events#27, let me know if that doesn't fix the problem. |
@geky Thanks for the fix. I applied it manually, and confirmed that it solves both the problem both in my example code above, and in my real code. |
Description
Bug
Target
STM32F4
Toolchain:
GCC_ARM
mbed version:
Revision 131 (bundled with platformio)
Expected behavior
Using
Timeout
to creating a callback to turn off a pin after 50us, I expect to see the pin turn off when looking with an oscilloscope. I am create anEventQueue
from mbed-events, which is not expected to interact with theTimeout
.Actual behavior
On NUCLEO L053R8: The callback turns off the pin after 78us
On NUCLEO F401RE , the pin goes high, and stays high. Debugging with GDB indicates that the callback never gets called. (same behaviour on Discovery F4 after changing
my_pin
to a valid pin for this board)Replacing the call to
queue.dispatch()
withwhile (1) {}
means that the callback is now called properly on both targets. This suggests that some code called by the queue is blocking interrupts.The issue has some similarities to ARMmbed/mbed-events#16, where the
sleep()
function in the HAL is a suspect. Since the behaviour depends on the target, I have raised the issue here, where all target dependent code livesSteps to reproduce
The following example code illustrates the problem:
The text was updated successfully, but these errors were encountered: