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

Sending HF Clock directly to gpio

We are trying to find a way to send the High Frequency Clock directly out to a gpio pin. The reference manuals don't seem to have anything obvious.

Is there a way to do this on a nordic board? Thanks in advance.

  • Hi Alex

    You can toggle an GPIO pin with 16MHz by directly using the gpiote_example in the SDK. Just modify the value of the CC[0] register to 1UL. This is possible with the most recent version of the nRF51822 chip.

    However, if you are using other versions then you must use two CC compare registers to generate the 16MHz frequency toggle on an IO pin. A single CC register can only generate an 8MHz toggling, see anomaly #33 in the nRF51822-PAN v2.0. The PAN also shows for which chip versions the anomaly is present.

    Update 28.10.2014 In order to get 8MHz square wave out on GPIO, you must also set the prescaler to 0 as done in the gpiote_example in the SDK

  • Hi Stefan, I am trying to achieve the same thing and I had some questions that i was hoping you might be able to help me with. The relevant lines in the GPIOTE example are below:

    NRF_TIMER0->PRESCALER = 4;                // Prescaler 4 results in 1 tick equals 1 microsecond.
    NRF_TIMER0->CC[0]     = 200*1000UL;       // 1 tick equals 1µ , multiply by 1000 for ms value.
    
       Is it sufficient to change the CC[0] register to 1UL to output a 16Mhz clock or do I have to change the prescalar as well? if so, can I set the prescalar to 0 ( to get f_timer to be HFCLK/2^0 )? 
       Also in the reference manual for the nRF51822, it mentions the following: " The PRESCALER register and the BITMODE register must only be updated when the timer is stopped. If these registers are updated while the TIMER is started then this may result in unpredictable behavior. "
       So in this example, should the prescalar be set before the NRF_CLOCK->TASKS_HFCLKSTART    = 1; command is issued?
       Many thanks for your assistance!
    

    Karthik

  • Note that "16MHz frequency toggle" is an 8 MHz square wave. This is not HFCLK.

Related