avr-gcc-list
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [avr-gcc-list] light up and led


From: Vincent Trouilliez
Subject: Re: [avr-gcc-list] light up and led
Date: Thu, 06 Oct 2005 13:17:39 +0200

> ok i made it turn on. now i've attempted to make it blink, 
> unsuccessfully. the light just stays off now.
>     unsigned char i;
>     DDRA |= 1<<PA0;
>     while (1) {
>         for (i=0; i<20000; i++) wait();
>         PORTA |= 1<<PA0;

That's normal I think. You turn the LED on when i reaches 20,000, but
you have declared i as a byte, so it will never exceed 255.
You should declare i as unsigned int, not unsigned char.

> also, is there a more elegant way of doing time delays? 

Your "wait" function is mostly useless I think, you could just remove it
altogether, and increase the loop count a bit to compensate

But you might prefer using the built-in "delay" functions, have a look
in the avr-libc documentation, page 22: "busy-wait delay loops".




--
Vince





reply via email to

[Prev in Thread] Current Thread [Next in Thread]