Well, I'm using Code::Blocks as the IDE, and Win AVR as the compiler. F_CPU is selected as 8000000UL. I'm writing code for Atmega32. But when I run my written code (*.hex file) in Proteus design suite (ISIS) the _delay_ms(1000) doesn't give a delay for 1sec. I don't know if it is write or wrong, I've selected CKSEL fuses to be (0100) Int.RC 8MHz in edit component. What's wrong? please....
0
votes
The internal RC oscillator's frequency is not exact. If you want a precise delay, use an external quartz crystal oscillator.
- user529758
It's a computer simulation. Well, I'm not opting for exact 1sec delay. But, the delay func. executes in a blink.
- ponir
Also don't expect a simulator to work properly. It won't. Try on the actual device. Then it will.
- user529758
3 Answers
2
votes
Have you tried setting the compiler optimization to something other than -O0? From the avr-libc docs regarding delay* functions.
In order for these functions to work as intended, compiler optimizations must be enabled, and the delay time must be an expression that is a known constant at compile-time.
2
votes