7.5.7, 7.7.1 CCP
CPU_CCP = 0xD8; //IOREG magic key
//now have 4 cpu instructions to write to protected ioreg
9.2.1
nice color clock diagram
9.3.5
shows which CLKCTRL registers are protected by CCP
9.5.3
Bit 0 – LOCKEN Lock Enable
Writing this bit to '1' will lock the CLKCTRL.MCLKCTRLA and CLKCTRL.MCLKCTRLB registers, and, if
applicable, the calibration settings for the current main clock source from further software updates. Once
locked, the CLKCTRL.MCLKLOCK registers cannot be accessed until the next hardware Reset.
This provides protection for the CLKCTRL.MCLKCTRLA and CLKCTRL.MCLKCTRLB registers and
calibration settings for the main clock source from unintentional modification by software.
At Reset, the LOCKEN bit is loaded based on the OSCLOCK bit in FUSE.OSCCFG.
Once locked, it stays locked until reset
If fuse config is set to lock, cannot change at all
not sure why you are playing around with this bit
so, to turn off prescaller it probably goes something like-
CPU_CCP = CCP_IOREG_gc; //unlock ioreg
CLKCTRL_MCLKCTRLB = 0; //PEN=0 (prescaler off)
No need to dump on Microchip because you have trouble understanding the datasheet and headers.
I know nothing of the mega4809, but I have the datasheet and header just to play along, it looks to me like its pretty good.