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

SoftDevice and TIMER3

nRF52840, SDK16.0.0, S132v7.0.1

I'm checking the accuracy of an LFXO 32KHz oscillator for manufacturing test purposes.

My rough plan is:

  1. Initialize and clear TIMER3 (HFXO)
  2. Set the TIMER3 comparison value to the duration of my test, converted to counter values.
  3. Sample RTC1 and store it as the "before" time.
  4. Enable TIMER3 with an ISR event handler.
  5. Wait
  6. In my event handler, sample RTC1 again, store it as the "after" time.
  7. Back in my application, example "after - before" for accuracy based on the duration of my test.

The wrinkle here is that SoftDevice is actively advertising during this time, and possibly servicing BLE connections. Will SD defer or delay my TIMER3 event handler? My strategy requires very little latency around TIMER3.

Thanks,

Charles

Parents
  • Hi Charles,

    SoftDevice has a highest priority level, so your interrupt handler can be delayed. The best way is to do sampling by hardware: set CC[0] and CC[1] of rtc to measure some distinct interval and connect COMPARE[0,1] events of rtc to CAPTURE[0,1] tasks of timer via PPI channels - you will get two time values with 62.5 ns resolution.

  • That is correct. The softdevice always uses the highest priority, so it may be that your TIMER3 events are delayed if the softdevice is doing something else. 

    It is also a good idea to use PPI for timing critical measurements, as this doesn't require the CPU to run.

    If you only intend to test the XTAL, the easiest way to do so would probably be to not use the softdevice at all. But you can use PPI. I don't know if you plan to do this on all devices during the runtime of your product, or only once (now) before production.

Reply
  • That is correct. The softdevice always uses the highest priority, so it may be that your TIMER3 events are delayed if the softdevice is doing something else. 

    It is also a good idea to use PPI for timing critical measurements, as this doesn't require the CPU to run.

    If you only intend to test the XTAL, the easiest way to do so would probably be to not use the softdevice at all. But you can use PPI. I don't know if you plan to do this on all devices during the runtime of your product, or only once (now) before production.

Children
No Data
Related