Dear all,
I am expanding the eddystone example for my nRF52832 (nRF52-DK) with some extra functionality. I wanted to create a periodic impulse with a timer (timer 1), all hardware driven via PPI, toggling a GPIO, still via PPI. The timer is configured so it will clear via a short at the count of 256 (16 bit timer). Then I have a PPI channel toggling a gpio every time the timer resets. Here is my code:
However, when the softdevice is running and I have beacon transmission, I can see the timer occasionally "skipping a beat" meaning that the on time is 257 cycles instead of 256 as expected, I measured it quite clearly with the scope, it is exactly an extra 16MHz clock cycle, and this happens exactly in correspondence of the eddystone beacon transmission.
I could deduce that the problem is the timer "strectching its period" and not the GPIO being delayed because I can see that these delays accumulate over consecutive cycles.
EDIT:
I actually made an additional test, I wanted to see problem was happening when the timer was resetting (PPI issue) or if the whole system was actually skipping a clock cycle. So instead of toggling the gpio I set up two compares, one with counter = 2 to set the pin and the next one with counter = 253 to clear the pin, so an impulse is generated for every timer cycle.
If the problem only happens when the timer is resetting I would expect to see this clock glitch on the first rising edge after the trigger but not on the falling edge of the impulse. However I can see the glitch on the falling edge, and between rising edge and falling edge of the GPIO there is no TIMER_CLEAR. So this hints to the fact that the whole system might be skipping a cycle.
I wonder is this is due to interference of the bluetooth antenna with the clock oscillator on the nRF52-DK board. Is there any way to keep the softdevice running but disable sources of potential interference like the antenna?
Thank you very much