This post is older than 2 years and might not be relevant anymore
More Info: Consider searching for newer posts

Restarted Timer is not executed for long time(S132)

Hey,

SHORT VERSION: Timer (every Second) gets started when connecting (BLE with nRF Connect) to my DK (SDK12.2, Softdevice S132). Timer gets stopped when disconnecting. After reconnecting it takes more than 15Sec for the Timer to call the handler again. When the handler finally gets called again it gets called often directly after each call, afterwards it starts to work normal again.

LONG VERSION: At the moment I`m implementing my first own Service into ble_app_template (SDK 12.2, Softdevice S132) Everything works fine so far, so I wanted to Implement a feature, that the Timer is only started, when in a valid BLE connection.

So I start my timer, when I get an BLE_GAP_EVT_CONNECTED and I stop it when I get BLE_GAP_EVT_DISCONNECTED. The first time I connect through nRF Connect (After DK reset) everything works fine and I get my NRF_LOG_INFO everytime my Timer is called instantly. Also my Characteristic updates when I Enable notifications. When I disconnect the timer stops and I don't get updates anymore through my LOG.

Now comes the part, that confuses me. If I reconnect now, I get my NRF_LOG_INFO, that I went through the function that starts my timer again, and the return Code of starting the Timer is NRF_SUCCESS. Nevertheless most of the time nothing happens for even longer than 15 Seconds (But sometimes really quick). Afterwards all the past Interrupts get handled at once (I have one every second) and afterwards everything works fine and the handler gets called every second.

While waiting for the Timer to start again it is no problem to get value updates from nRF Connect or enable / disable notifications. The only thing delayed is the timer.

QUESTIONS: Is the Chip busy for such a long time so my timeouts get queued? But if it`s busy, why can I read values through the nRF Connect app? Is this behavior normal? Does it help if I switch to a scheduler? How can I speed this up?

Greetings

P.S.: It's hard to give you code because, the ble_app_template is quite huge itself, but if it helps, I can upload the whole project.

Related