ASF switch clock from 32mhz to 2mhz

Go To Last Post
2 posts / 0 new
Author
Message
#1
  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

Hi guys! I need to change clock from 32mhz internal to 2mhz internal. I have success set 32mhz but cant change it back to 2mhz.

ccp_write_io(&CLK.CTRL, CLK_SCLKSEL_RC2M_gc); is not working

im using atxemga16A4U

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

SLOVED:

asf do not able to change clock source "on fly"

im using this code:

big thx to condemned

   OSC.CTRL |= OSC_RC32MEN_bm | OSC_RC2MEN_bm | OSC_RC32KEN_bm;
   while((OSC.STATUS & OSC_RC32MRDY_bm)==0){} // wait until stable
   while((OSC.STATUS & OSC_RC2MRDY_bm)==0){} // wait until stable
   while((OSC.STATUS & OSC_RC32KRDY_bm)==0){} // wait until stable

   // enable DFLL (on both RC clocks)
   DFLLRC32M.CTRL = DFLL_ENABLE_bm ;
   DFLLRC2M.CTRL = DFLL_ENABLE_bm ;

   // And now switch to the 32M as a clocksource.
   CCP = CCP_IOREG_gc;            // protected write follows   
   CLK.CTRL = CLK_SCLKSEL_RC32M_gc;   // The System clock is now the 32Mhz internal RC