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 !

\$\endgroup\$

1 Answer 1

2
\$\begingroup\$

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

\$\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\$
    – user98663
    Feb 11, 2017 at 13:10

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

Not the answer you're looking for? Browse other questions tagged or ask your own question.