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

BLE Connect Events Cause Delays in App_Timer and PPI

I was using TIMER1 PPI and GPIOTE to setup a PWM signal on a GPIO line. This PWM will start and stop after 1 seconds. I used led.c to based my code. I was starting the Timer1 when the BLE_CONNECT_EVT came in but noticed that the PWM signal was locked up for about 4-5seconds before turning off. It worked fine if I trigger the PWM start on a button push, or system start-up. But if I used it at BLE_CONNECT_EVT, everything locks up. I re-tested with only using app_timers to blink and LED on the same CONNECT event, and same the thing happens. Since I use an app_timer to control both led and buzzer, the root cause may be app-timers. Has anyone encountered this?

Thanks guys

p.s. I'm not using the scheduler for any of my timers.

  • It wouldn't. Which PPI are you using? The softdevice reserves some for itself, you get to use the other ones only (and should use the sd_ functions to access them too). What are your interrupt priorities come to that, might be a factor.

  • Thanks for the reply. I am using PPI channels 0 and 1. I setup the channels through the sd_ppi_channel_assign function. I also don't use any interrupts and simply reset the TIMER using the SHORT register; NRF_TIMER2->SHORTS = TIMER_SHORTS_COMPARE0_CLEAR_Enabled << TIMER_SHORTS_COMPARE0_CLEAR_Pos;

  • I got a response from Nordic that I thought I'd post here in case anyone else found this issue. Apparently this is recently discovered bug. This affects App Timers you wish to start/stop within close time proximity to BLE_CONNECT and BLE_DISCONNECT events. A work around is to use the scheduler to setup the start/stops of these app timers. This ensures that the proper functions run in the expected order. I have not had any problems since implementing this fix. Thanks as always for the great support Nordic!

Related