I'm trying to use a 8MHz Oscillator on an atmega328p. this a part of the whole schematic :
to that I've set the Fuse byte as calculated enter image description here[2]
then I've set the calculate values in the project :
To make sure that the uc ist correctly runnion on 8MHz, since I don't have an oscilloscope, I'm trying to toggle a LED each 1 sec, here is the code I've wrote for that :
#define F_CPU 8000000
#include <avr/io.h>
#include <util/delay.h>
int main(void)
{
DDRD |= (1 << PD5);
while(1){
PORTD |= (1 << PD5);
_delay_ms(1000);
PORTD &= ~(1 << PD5);
_delay_ms(1000);
}
return 0;
}
As far as I can see the lED take 8sec to change its status ! when I change the value of F_CPU
to 1MHz the toggle is than correct, which means to me that I'm still running the internal oscillator ?
Any idea what I'm missing here ? thanks in advance !
1 Answer 1
You checked the divided by 8 fuse bit. So the CPU runs at 8mhz/8. Uncheck it.
-
\$\begingroup\$ The devil is in the details. I've often wished for a "fuses wizard" in the Atmel Studio software that appears when starting a new project, one that asks some simple questions about the engineer's intentions and suggests a set of fuses that fit the task. It would be so helpful for those of us less familiar with the platform. \$\endgroup\$user98663– user986632017年02月11日 13:10:24 +00:00Commented Feb 11, 2017 at 13:10