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

rtc

Dear experts, please tell me, how can I switch the frequency source for the RTS from STAL to internal RC generator when the processor is running?
command sequence does not work:
NRF_CLOCK->LFCLKSRC = (CLOCK_LFCLKSRC_SRC_Xtal << CLOCK_LFCLKSRC_SRC_Pos) |
(1 << 16) | // Set bit 16 in LFCLKSRC to enable (use with rail-to-rail external source)
(1 << 17); // Set bit 17 in LFCLKSRC to enable use of external source instead of Xtal (SRC needs to be set to Xtal)

NRF_CLOCK->LFCLKSRC = (CLOCK_LFCLKSRC_SRC_Xtal << CLOCK_LFCLKSRC_SRC_Pos) ;

Thanks!

Parents
  • You need to stop the LFCLK, set the source and then start it up again.

    The LFCLK clock is stopped by triggering the LFCLKSTOP task.

    It is not allowed to write to register LFCLKSRC when the LFCLK is running.

    A LFCLKSTOP task will stop the LFCLK oscillator. However, the LFCLKSTOP task can only be triggered after the STATE field in register LFCLKSTAT indicates a 'LFCLK running' state.

    Before setting your clock source, you need to do this: 

    NRF_CLOCK->TASKS_LFCLKSTOP = 1; //stop the clock
    NRF_CLOCK->LFCLKSRC = (CLOCK_LFCLKSRC_SRC_Xtal << CLOCK_LFCLKSRC_SRC_Pos) ; //set your source
    
    NRF_CLOCK->TASKS_LFCLKSTART = 1; //start the clock again

  • Thank you, but this is the first thing I tried. I initialize RTС2 from an external source. Then, in the RTС2 interrupt, I turn off the external source and change the source to the PC. Then I turn on WDT from it ... and nothing happens - WDT does not work! What else should i try?

    I want to start at the beginning of the program RTС2 from an external source. After the interrupt of RTC2, switch to the internal source of the RC and run the WDT for 10 seconds. Then after restarting the program, start the RTC2 again and so on ...

  • So, when you tried this, what happened? Did it compile? Did it run? Did it work? Are you sure that it is the WDT that isn't set up incorrectly?

    Why do you need to use the LFXTAL at first, and then switch?

  • Yes, it works. I forgot to disable the interrupt of the RTC after it triggers in order to wait for the WDT. Thanks!

Reply Children
No Data
Related