how to use timer1 capture function ?

A wave come to bluetooth pin-18 like this image description

how use timer1 to get every slot time length of the wave ? Thank you!

  • Hi

    The TIMER CC registers are both compare and capture registers. You can start a TIMER peripheral and then capture the timing on rising and/or falling edge of the signal.

    The following example is a frequency counter draft made for nRF51 SDK 7.2.0, but I think it should still be valid for more recent nRF51 SDKs. It sets TIMER0 into counter mode an increses the TIMER value on rising and falling edges of an input signal. PPI channel is used to connect together the GPIOTE IN rising/falling edge event and the counter task of TIMER0. To make high frequency changes visible, a LED is toogled on every 500,000 rising/falling edges. Further explanation is given at the top of the main file in the example.

    Frequency_counter.zip

    In order to modify this example to measure timing between signal edges, just set TIMER0 into "timer" mode instead of "counter" mode, and start the timer as shown in this example.

    Then instead of increasing the TIMER on every falling/rising edge, capture the TIMER value instead into e.g. CC[2] register, something like:

    NRF_PPI->CH[0].TEP = (uint32_t)&NRF_TIMER0->TASKS_CAPTURE[2];
    

    Let me know if my provided information is sufficient or not

  • Thank you,I capture the time length

Related