Hello everyone! I'm doing a little project with an ATtiny817 and I have a problem when setting the clock. As some will know and as the datasheet says on page 80, after a reset of the micro the CLK_MAIN is configured as the internal oscillator of 16 / 20MHZ (according to the FUSES, in my case 20MHz) and with a prescale with a factor of division equal to 6:
My problem is that when I start my program, in the main function I change the prescale to 2, since I am interested in having 10MHz, but the changes are not carried out. This I checked on the oscilloscope with a PWM signal and doing the corresponding debugging from Atmel Studio. Here I show you a screenshot of the value of the record, MCLKCTRLB = 0x11, when I want its value to be MCLKCTRLB = 0x01.
CLKCTRL.MCLKCTRLA=0b00000001; // The CLKOUT pin is disable and the source for de main clock is "16/20MHz internal oscillator" CLKCTRL.MCLKCTRLB=0x01; // The prescaler is enable and the prescale is "/2"
I hope you can lend me a hand because I have no idea why the changes are not carried out. Thank you very much in advance. A greeting.