Squirrels have fuzzy tails.
0 Members and 1 Guest are viewing this topic.
_delay_ms(500000);
Quote_delay_ms(500000);is 500000 a valid input value for the _delay_ms function?Look at the source code and function prototype for the _delay_ms function to see what the variable is defined as.
for(i=0;i<10;i++) delay_ms(50000);
If I remember right, it only accepts 16 bit values. That means the highest time you can do is 65536, not 500000.
I am using AVR Studio 4 and I put in the confuguration 16000000hz but it dont work because it give me 100000=27sec.
Function Documentationvoid _delay_ms ( double __ms ) Perform a delay of __ms milliseconds, using _delay_loop_2().The macro F_CPU is supposed to be defined to a constant defining the CPU clock frequency (in Hertz).The maximal possible delay is 262.14 ms / F_CPU in MHz.When the user request delay which exceed the maximum possible one, _delay_ms() provides a decreased resolution functionality. In this mode _delay_ms() will work with a resolution of 1/10 ms, providing delays up to 6.5535 seconds (independent from CPU frequency). The user will not be informed about decreased resolution.
void _delay_loop_2 ( uint16_t __count ) Delay loop using a 16-bit counter __count, so up to 65536 iterations are possible. (The value 65536 would have to be passed as 0.) The loop executes four CPU cycles per iteration, not including the overhead the compiler requires to setup the counter register pair.Thus, at a CPU speed of 1 MHz, delays of up to about 262.1 milliseconds can be achieved.
but it dont work because 65000ms give me 16sec (65000ms=16sec), please help me