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

change clock speed nrf52

I have some troubles to understand the system clock functionality. I am using a Module from Rigado which uses the nRF52 and has an external 32Mhz osc. on board.

In the nrv_drv_config.h file follwing value is set for the HFCLK controller.

#define CLOCK_CONFIG_XTAL_FREQ          NRF_CLOCK_XTALFREQ_Default

If I understand it correctly this should equal a system clock of 64 Mhz. However, in my main loop I have nothing else than nrf_gpio_pin_toggle(LED_4);

No interrupts are used and no Softdevice is running.

The frequenzy I get on the LED pin is about 300 Khz.

Can anyone explain why it is only 300 KHz I would have expected something around a few MHz.

I run into this problem because I was debugging a problem where the processing of COMP interrupts took to long and I wanted to make sure that the nRF52 is running as fast as possible.

so two questions:

  1. Why is the pin toggle frequency so low ?
  2. How do I change the system clock from ?

thanks in advanced best, Timur

Parents
  • You can't change the system clock, it's 64MHz and that's it.

    How are you measuring 300kHz on the LED pin? I just compiled nrf_gpio_pin_toggle() and counted the instructions and it's about 30, call it 32, so if all you have is that in a loop there's no way you can be getting 300kHz, should be 6 times that, that is really all your code,

    while(1)
        nrf_gpio_pin_toggle( LED_4);
    
  • This all my code: err_code = nrf_drv_clock_init(); APP_ERROR_CHECK(err_code);

    while(1)
    {
    	nrf_gpio_pin_toggle(LED_4);
    }
    

    And I am measuring the frequency with an Tektronix oscilloscope. I had on button poll left which I have deleted now and now I am getting close to 500 Khz.

    The gcc optimaziation is off, how can I see the instructions count.

    image description

Reply
  • This all my code: err_code = nrf_drv_clock_init(); APP_ERROR_CHECK(err_code);

    while(1)
    {
    	nrf_gpio_pin_toggle(LED_4);
    }
    

    And I am measuring the frequency with an Tektronix oscilloscope. I had on button poll left which I have deleted now and now I am getting close to 500 Khz.

    The gcc optimaziation is off, how can I see the instructions count.

    image description

Children
No Data
Related