
Description
Description
- Type: Bug
- Related issue: Ticker issues with NRF52 platform, especially while using event queue call_every timer function. #4893, mbed-os-example-blinky breaks on NRF52_DK when NDEBUG set #4621
- Priority: ?
This might be duplicate, but it's hard to say.
Bug
Target
Nordic NRF52
Toolchain:
GCC_ARM
Toolchain version:
6.x
mbed-cli version:
1.2.0
mbed-os sha:
99a8467 (current master)
db4be94 (5.5.5 tag)
DAPLink version:
How do you find out? does it matter?
Expected behavior
I expect the llights to start on (on startup) then turn off for X milliseconds once the interrupt is fired and then turn back on again.
Actual behavior
When compiled via the debug profile all is well, but on the release profile it acts like so:
Lights start on, then the interrupt fires, lights go off, then on for a fraction of a second, and stay off and the logic becomes reversed as the interrupt now turns the lights on for a fraction of a second and then off.
here's the relevant code snipped.
void onAgain(void)
{
toggleLights(true); // is just two DigitalOut set to true|false
}
void onImpact(uint8_t zone)
{
if (gameServicePtr->isGameActive() || !gameStartRequired) {
gameServicePtr->updateAdvPayload();
gameServicePtr->updateHitCounter(zone);
toggleLights(false);
eventQueue.call_in(MBED_CONF_APP_LIGHTS_BLINK_TIME, onAgain);
}
}
void sensor1PressedCallback(void)
{
eventQueue.call(Callback<void(uint8_t)>(onImpact), 1);
}
void sensor2PressedCallback(void)
{
eventQueue.call(Callback<void(uint8_t)>(onImpact), 2);
}
int main() {
initLights(!gameStartRequired);
BLE &ble = BLE::Instance();
ble.onEventsToProcess(scheduleBleEventsProcessing);
ble_error_t error = ble.init(bleInitComplete);
if (error != BLE_ERROR_NONE) {
ble_print_error(error, "BLE initialisation failed");
return 0;
}
sensor1.fall(eventQueue.event(sensor1PressedCallback));
sensor2.fall(eventQueue.event(sensor2PressedCallback));
eventQueue.dispatch_forever();
return 0;
}
Excuse the poor code, I'm still learning C++.