Delay function for Atmega32

Status
Not open for further replies.

bmn123

Banned
Joined
Nov 23, 2006
Messages
12
Helped
0
Reputation
0
Reaction score
0
Trophy points
1,281
Activity points
0
on delay atmega32

Guys, I am trying to use a delay function in Atmega32. I tried the one given by Bibin John and somehow, AVRstudio doesn't handle it properly. I found this function:-

void del100us(unsigned int n){
//delay n 100us
unsigned int x;

while(n--){
x=?????;
while(x--);
}
}

What value of x should I use for the following frequencies?

1M,4M,8M,16M? The value for 16M is given to be 260
 

atmega32 delay function

If it's Winavr (AVR GCC) , the use delays from delay.h

Make sure to set F_CPU t the xtal clock , and make sure to compile with optimisation enabled ... -Os

Do read about the maximum values for the loops (found in the avr-libc , pdf documentation)

/Bingo
 

Status
Not open for further replies.

Similar threads

Cookies are required to use this site. You must accept them to continue using the site. Learn more…