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

measuring input GPIO pin frequency with soft device running

Hello,

is it possible to measure frequency from 1Hz up to 400kHz (50% duty cycle) on gpio pin having soft device enabled with Peripheral functionality? The measurement will be invoked on demand by the connected central device. I will use nRF51822, rev. 3, S110 or S130, SDK 8 or 9.

If this is not possible, please tell me if following scenario would be ok:

  • invoke measurement
  • disable soft device (disconnection from central)
  • manage measurement (what's the best way: which timer?, PPI? GPIOTE?)
  • enable soft device

Thank you!

btw, what is the maximum frequency that can be measure on gpio pin?

Parents
  • ah I see. It is doable Configure Timer1 in timer mode to generate an event in X seconds. This event should be converted to TASK_STOP using a PPI Configure other peripherals as below but do not enable the last block timer 2 yet.

    image description

    When you want to start the measurements, START the timer1 and timer2.

    After X number of seconds, Timer2 counter will have counted the number of rising edges of the pin in X seconds. get the value into timer CC[n] by triggering a CAPTURE[n] task on timer 2.

    Divide Timer2->CC[n] by X and you have your frequency. This should work even with softdevice as we are not using any interrupts.

Reply
  • ah I see. It is doable Configure Timer1 in timer mode to generate an event in X seconds. This event should be converted to TASK_STOP using a PPI Configure other peripherals as below but do not enable the last block timer 2 yet.

    image description

    When you want to start the measurements, START the timer1 and timer2.

    After X number of seconds, Timer2 counter will have counted the number of rising edges of the pin in X seconds. get the value into timer CC[n] by triggering a CAPTURE[n] task on timer 2.

    Divide Timer2->CC[n] by X and you have your frequency. This should work even with softdevice as we are not using any interrupts.

Children
Related