Frequency counter on NRF52805

Hi, I want to use an NRF52805 with a voltage to frequency detector. If I understand the datasheet, there is one timer/counter and RTC on that chip. Is it possible to set the RTC as the timing gate, and  use the T/C as an input pulse counter through the event system? I'm planning to use a single clock source (prob. 32MHz) and synthesize the LF clock required for the RTC from it.

I will be happy to know if this is a good way to go before fully adopting the hardware.

Cheers,

Parents
  • Hi

    4. It seems like NRF_TIMER0->CC[0] is set to 3, which I think will set the timer to run at 8/3 MHz. Can you try tweaking this to 1 for example? Where exactly did you find this gpio_clock_8m() function? It doesn't seem familiar and I can't find it in the nRFConnect nor nRF5 SDKs.

    5. I'm sorry you're having trouble, what IDE are you using exactly, Visual Studios Code or SEGGER Embedded Studios? We're constantly working on adding more sample projects and drivers to the nRF Connect SDK and are striving to make it as user friendly as possible.

    Best regards,

    Simon

Reply
  • Hi

    4. It seems like NRF_TIMER0->CC[0] is set to 3, which I think will set the timer to run at 8/3 MHz. Can you try tweaking this to 1 for example? Where exactly did you find this gpio_clock_8m() function? It doesn't seem familiar and I can't find it in the nRFConnect nor nRF5 SDKs.

    5. I'm sorry you're having trouble, what IDE are you using exactly, Visual Studios Code or SEGGER Embedded Studios? We're constantly working on adding more sample projects and drivers to the nRF Connect SDK and are striving to make it as user friendly as possible.

    Best regards,

    Simon

Children
  • Hi,

    Thanks, I know. My point was that if I change the compare value to less than 3, the count value shows always zero.

    I looked in the nrf52-DK schematic files and couldn't find anything that would suggest why this would occur. I've also moved the test clock pin to p0.12 to shorten the line and avoid LED load, to no avail. I will check with an oscilloscope once I can. In the meantime any insights will be welcome!

    Thanks again

  • 1. I see. Sorry, I didn't catch that in your last reply. Do you get any error messages when setting this value to less than 3?

    2. If you'd like, we can do a HW review of your design for you to make sure that your design doesn't have any obvious issues. You can create a private ticket and upload schematics and gerber files, and we'll get right on it.

    Best regards,

    Simon

  • Hi Simon, thanks again for the reply.

    I am not using any hardware, just the nrf52-DK, with a wire connecting directly the clock-gen pin to the counter pin.. no need to review anything since it's your kit..

  • Well.. partial success in timing improvement. Apparently the errata that's relevant to NRF52840 is relevant for NRF52810, and I assumed that it will also hold here.

    Nordic Semiconductor Infocenter

    I added this to main:

    //solve errata for event above 750khz
        *(volatile uint32_t *)(NRF_GPIOTE_BASE + 0x600 + (4 * NRFX_GPIOTE_CHANNELS_USED)) = 1;
    Now I can measure up to about 3.7MHz accurately, and above 4MHz The count becomes inaccurate, but not zero anymore. Still a bit low as Arduino can do up to 5MHz with a 16MHz clock (FreqCount library).
    What baffles me is that I now ported this code to a BLE app with NUS, and I'm getting very inaccurate counts. A dead-on 1MHz source is counted as ~1028000 with large variations. With just the counter code the count was at a steady 1MHz. What's going on? this is supposed to be a purely HW counter implementation.
    Any help will be greatly appreciated.
    Cheers!
  • If you are getting wild variations, make sure you are using crystal (HFCLK I think?) not RC as your high speed clock source.

Related