Measuring 1hz to 1Mhz Input frequency on up to 6 GPIOs with maximum possible high accuracy.

My board is nRF5340Dk with NCS 2.6.1 and toolchain 2.6.1.

At this development stage I want to measure continuously incoming frequency ranging from 1Hz to 1MHz with high accuracy possible. I have tried looking into some previous similar question and implemented the code from that project on to my project but I could not get past the NRF_PPI section, which I believe now is NRF_DPPI for nrf5340 boards. But how do I implement  NRF_DPPI without extensively changing existing code? Because the way NRF_PPI was used is not similar to NRF_DPPI.

Is there a best way to measure up to 6 frequencies through GPIOS?

This is the current code :

and prj.conf

This code/project primarily has been taken from this question on devzone which was running on nRF52840 and a different SDK.

I have issues in 

static void ppi_timer_stop_counter_init() and in 
static void ppi_gpiote_counter_init() 

Although, I have changed the name, NRF_PPI to NRF_DPPI in my code to check if that works, it doesn't and I have no clue how to implement that EEP or TEP.

It would be helpful to get some directions on these requirements.

Parents Reply Children
  • I have tried your program,

    It didn't run properly on NCS 2.6.1 , it showed :

    Also, It couldn't find

     

    So, I have changed header files to  

    Would you mind checking it?

  • Hi!

    Try this:

    pulse_counter.rar

    Connect a jumper-wire between P0.05 and P0.28 to test.

  • Thank you so much for the code. I appreciate your time. However, I have tested this frequency measurement based on Counting pulse at 100ms and it varies +- 150 at only 105KHz. 

    The variations are quite rough. Is it the highest limit of an nRF5340? 

    Although, I didn't provide the pin 28 a stable known frequency but my current setup did result stable frequency measurement on an Arduino Uno mini like this :-

  • Hi!

    Do you have a logic analyzer to check what the frequency deviation actually is? e.g. a saleae logic analyzer. 

  • I do not have a logic analyser.

    right now my input frequency is coming from a Schmitt trigger output so I will try to check with a PWM input from another nrf microcontroller.