I am having problems changing the PLL frequency; search in the forum did not produce any results
It is running at 32MHz and I want to change it to 16MHz:
#define XTLFRQ 8000000
#define SYSFRQ 16000000
......
/* running happily at 32 MHz */
......
CPU_CCP = 0xd8; /* switch to internal rc */
CLK_CTRL = 0b0000;
asm volatile("nop");
asm volatile("nop");
asm volatile("nop");
asm volatile("nop");
OSC.CTRL = 0b00001001; /* disable pll */
OSC.PLLCTRL = 0b11000000 | (SYSFRQ / XTLFRQ);
OSC.CTRL = 0b00011001; /* enable pll */
while (!(OSC.STATUS & OSC_PLLRDY_bm))
;
CPU_CCP = 0xd8; /* switch to pll */
CLK_CTRL = 0b0100;......
Problem is it keeps running at 32MHz. Is there more to be done than disabling it before changing? That's all I could find in the documentation. The nops cover the 4 clocks for source switch over.
Has anybody changed the PLL frequency successfully?