9 years, 3 months ago.

Another nRF51822 Ticker bug

I believe there may be an issue with Tickers and possibly with app_timer on nRF51822 platforms.

The problem occurs when a Ticker is used on the nrf51822 along with a BLEDevice. The ticker hangs after a while if the timeout is short enough (around 1ms or less, with 2ms or more being OK). The same ticker works fine if no BLE device is created. The bug was confirmed on both a Nordic nRF51-Dongle and a RedBearLab BLE Nano using the latest BLE_API, mbed-src and nRF51822 libraries as of Jan 3rd 2015.

My unconfirmed wild guess is that the bug may be somewhere in mbed-src/targets/hal/TARGET_NORDIC/TARGET_MCU_NRF51822/Lib/app_common/app_timer.c and may be triggered by the BLE stack interrupts delaying the Ticker beyond its next timeout.

I wrote a sample project that blinks the onboard LED 5 times per second via a 1ms ticker that switches the LED state once every 100 invocations. When BLE support is enabled, the LED blinks a few times and then stops. When BLE support is disabled, the LED keeps blinking forever.

Here's a link to the project:

Import programnRF51822_Ticker_Bug

This code shows a problem that occurs when a Ticker is used on the nrf51822 along with a BLEDevice. The ticker hangs after a while if the timeout is short enough (around 1ms or less, with 2ms or more being OK). The same ticker works fine if no BLE device is created. The bug was confirmed on both a Nordic nRF51-Dongle and a RedBearLab BLE Nano using the latest BLE_API, mbed-src and nRF51822 libraries as of Jan 3rd 2015.

(sorry- I meant to post this in the Forum but in ended up in the Questions instead)

Thanks for the sample. I used it to reproduce under the debugger. I will start investigating later in the day.

Thanks,

Adam

posted by Adam Green 04 Jan 2015

I have reproduced your problem and looked at it under the debugger. I can see what is happening but I don't have a good solution. I have further documented the issue over here on github.

I know this doesn't really help you much but hopefully it will get the ball rolling to have someone more knowledgeable than me pick up the investigation.

posted by Adam Green 05 Jan 2015

Great that you are working on the issue, there are 4 posts related to that same nRF51822 Ticker bug

posted by rosco pekolt 05 Jan 2015

This may or may not be related but in my initial report I forgot to mention that the APP_TIMER_INIT call in us_ticker.c currently uses hardcoded and potentially inadequate values rather than the appropriate ones from projectconfig.h:

APP_TIMER_INIT(0 /*CFG_TIMER_PRESCALER*/ , 1 /*CFG_TIMER_MAX_INSTANCE*/, 1 /*CFG_TIMER_OPERATION_QUEUE_SIZE*/, false /*CFG_SCHEDULER_ENABLE*/);

Raising the values by itself did not fix the Ticker issue but limiting the max number of timers and max number of operations to 1 doesn't sound right, and may even be related to the NRF_ERROR_NO_MEM code reported by Adam Green on github.

posted by m buddy 07 Jan 2015

1 Answer

9 years, 3 months ago.

While we don't currently have a solution I thought I would actually fill in the answer field here so that it doesn't show up as a completely unanswered question. It is being actively discussed over on github: https://github.com/mbedmicro/mbed/issues/832