Society of Robots - Robot Forum

Software => Software => Topic started by: greywanderer012345 on August 16, 2012, 12:53:31 AM

Title: Control MCU frequency
Post by: greywanderer012345 on August 16, 2012, 12:53:31 AM
I'm using an atmega328p and AVRStudio4. The MCU is supposed to be 8MHz, but it processes as if it is running at 1MHz, eg. the _delay_ms() function works correctly when F_CPU is defined as 1000000UL. Do I have some fuses set to slow it down or something? I had the $50 robot halfway built over a year ago, but had to get out of it for a while. I got the time to get back into robotics about a month ago. This is one of the things that has been bothering me. I halfway remember there being a way to slow the processor to save battery. Am I mistaken? Thanks for any help.
Title: Re: Control MCU frequency
Post by: newInRobotics on August 16, 2012, 02:43:09 AM
As far as I know ATmega328P by default has CKDIV8 fuse on. If You clear it, uC will run @ 8MHz. Don't forget to change F_CPU to 8000000UL to get all timings correct. Don't touch any other fuses if You don't know what they do.

(http://gettheworkdone.net/images/ATmega168_Fuses.jpg)
Title: Re: Control MCU frequency
Post by: greywanderer012345 on August 16, 2012, 05:33:34 PM
Thank you. That has to be the fastest, most thorough answer I've received. I knew it had to be something simple, but I was loath to start playing with the fuses. Thanks again!