delay is not working right.

Status
Not open for further replies.

david90

Advanced Member level 1
Joined
May 5, 2004
Messages
423
Helped
9
Reputation
18
Reaction score
4
Trophy points
1,298
Activity points
3,611
Code:
#include <avr/io.h>
#include <uart.h>
#include <delay.h>

#define BAUDRATE 19200
#define xtalCpu 8000000
	

int main(void)
{
DDRB=0xFF;
uart_init(19200);
while(1)
{

   //uart_putc('U');
	_delay_ms(5000);
	PORTB=0xFF;
	_delay_ms(5000);
	NutSleep=0x0;
	_delay_ms(500);
}
return 0;
}

For some reason, my LED blinks way faster than 5sec. Is there anything wrong with my code?
 

Are they blinking at all?

where are u making PORTB = 0x00; ????
what is this??????
Code:
NutSleep=0x0;

Also check for watchdog
 

you must use PORTB ^= 0xFF; instead
 

it is blinking(i can see) but just too fast.

ignore "NutSleep=0x0;" I forgot to take it out.
 

Status
Not open for further replies.
Cookies are required to use this site. You must accept them to continue using the site. Learn more…