Using High Resolution Oscillator for zephyr timer

Dear Nordic Team,

I had questions concerning the use of the High resolution oscillator

Question 1 :

Could you provide the detailed step needed to enable the HFXO ?

Some previous ticket mentioned that “ NRF_CLOCK->TASKS_HFCLKSTART  = 1;” should enable it, is it the only thig to do ?

What about the whole Clock control API of zephyr, is something like “clock_control_on(clock0, CLOCK_CONTROL_NRF_SUBSYS_HF);” needed ?

Eventually, is there a simple example on how to switch the oscillator ? 

 

Question 2: 

If the HFXO is enable, will the Zephyr timer use this HFXO for generating time duration ?  

(for example if using  “k_timer_start(&my_status_timer, K_USEC(200), K_NO_WAIT);”  , will the 200us counted using the HFXO ?)

I’ m asking that because we are having issue with very short timer delay , it seems that the zephyr timer can’t handle a value smaller than 100us, because we are using the LFXO 32.768 kHz. For our project we need to be able to generate very short timer duration. (around 10us) 

 

(I’ m using an NRF52840 DK , SDK v2.5.2)

 

Thanks for you help

 

Gregoire

Parents
  • Hi, 

    If you want to start the HFCLK, the simplest form is NRF_CLOCK->TASKS_HFCLKSTART=1;, then wait and clear the EVENTS_HFCLKSTARTED event. , but I would suggest to use the clock subsys. See this post to on how to enable HFXO as the timer

    Regards,
    Amanda H.

  • Good Morning, 

    Thanks for your response. Enabling the HFXO with the clock subsys seems to work. However, even with the HFXO enabled, I am not able to generate timer durations under 100 µs.

    For example, when using a periodic timer of 50 µs with k_timer_start(&my_status_timer, K_USEC(0), K_USEC(50));, the duration of 50 µs is not observed (we monitor a pin toggle with an oscilloscope to test this). We always have a minimum duration of around 120 µs.

    I know that the Zephyr documentation states:

    "Note that the timer’s duration and period parameters specify minimum delays that will elapse. Because of internal system timer precision (and potentially runtime interactions like interrupt delay) it is possible that more time may have passed as measured by reads from the relevant system time APIs. But at least this much time is guaranteed to have elapsed."

    Does this mean that we can't generate delays smaller than 100 µs using Zephyr timers?

    How should we proceed if we want to generate very short duration timers (in the order of 10 µs)?

    Thanks for your help.

    Gregoire 

  • Good Morning, 

    Thanks again for the help. I have tested the exemple code using nrfx timers. It work great and I am able to generate delays of the order of 10 us. Our problem is that when it comes to toggling a pin using those nrfx timer in a bigger application , the duration are not right. 

    Is there a simple way in zephyr to just generate standalone very short impulse on a gpio, in the order of 10us ? 

    In the case we would want to even shorter impulse (like 2/3 us) , is it also possible or are there some harware or processing time limitation that make that impossible ? 

    Best regards, 

    Gregoire

  • This would need to use GPIOTE+TIMER+PPI, do you need only 1 pulse or several?

Reply Children
Related