1
\$\begingroup\$

I'm trying to use a 8MHz Oscillator on an atmega328p. this a part of the whole schematic :

enter image description here

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 :

enter image description here

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 !

asked Feb 11, 2017 at 9:47
\$\endgroup\$

1 Answer 1

2
\$\begingroup\$

You checked the divided by 8 fuse bit. So the CPU runs at 8mhz/8. Uncheck it.

answered Feb 11, 2017 at 10:30
\$\endgroup\$
1
  • \$\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\$ Commented Feb 11, 2017 at 13:10

Your Answer

Draft saved
Draft discarded

Sign up or log in

Sign up using Google
Sign up using Email and Password

Post as a guest

Required, but never shown

Post as a guest

Required, but never shown

By clicking "Post Your Answer", you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.