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

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

Re: [avr-gcc-list] GCC Functions


From: Joerg Wunsch
Subject: Re: [avr-gcc-list] GCC Functions
Date: Tue, 27 Nov 2001 10:59:52 +0100 (MET)

Patrick Lanphier <address@hidden> wrote:

> void led1(void);
> int ledlight;
> 
> int main(void) {
>   outp(0xff, DDRB);           // port B all outputs
>   outp(0xff, PORTB);          // turn all leds off
>   led1();

What happens if you don't call led1(), but just continue?

>   for(;;){
>     outp(ledlight, PORTB);        // turn led on
>   }
> }
> 
> void led1(void){
>   ledlight = 0x0;
> };

This is basically a do-nothing, since ledlight is already 0x0 (per
definition, since it's a global variable).

I can't see anything that would be wrong with the code though.

What would be more interesting is:

void led1(void) {
  ledlight ^= 0xff;
}

....
  for (;;) {
    led1();
    outp(ledlight, PORTB);
  }

This should make all pins on Port B oscillate with the same frequency.
Alternatively, make led1() count ledlight up:

void led1(void) {
  ledlight++;
}

This should make all pins oscillate with frequencies divided by 2
each.

-- 
J"org Wunsch                                           Unix support engineer
address@hidden        http://www.interface-systems.de/~j/



reply via email to

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