// run from internal 32.768kHz void clock_init(void){ //CCP=CCP_IOREG_gc; // unlock writing to CLK.PSCTRL (optional) //CLK.PSCTRL = CLK_PSADIV_1_gc; // Set up prescalers (optional) OSC.CTRL = OSC_RC32KEN_bm; // start external clock while (!(OSC.STATUS & OSC_RC32KRDY_bm)){}; // wait until oscillator is stabilized CCP=CCP_IOREG_gc; // unlock writing to CLK_CTRL CLK.CTRL = CLK_SCLKSEL_RC32K_gc; // select internal 32.768kHz as system clock }