could not set system clock prescale

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

hi guys,

im trying to set my system clock prescaler on my Atmega48.

The datasheet says

1. Write the Clock Prescaler Change Enable (CLKPCE) bit to one and all other
bitsin CLKPR to zero.
2. Within four cycles, write the desired value to CLKPS while writing a zero to
CLKPCE.

my code was

CLKPR = 0x80;
CLKPR = 0x01;

but when i check my pulse width modulation on one of the pins, the frequency is still the same.

any ideas what is wrong ?

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

Quote:
Within four cycles,

This criteria is probably not being met. You can try different optimization levels, or you can do it with inline assembly.

Regards,
Steve A.

The Board helps those that help themselves.