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

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

Re: [avr-gcc-list] Using PORTB with variables, PORTB = var


From: Ben Jackson
Subject: Re: [avr-gcc-list] Using PORTB with variables, PORTB = var
Date: Sat, 22 Apr 2006 11:34:57 -0700
User-agent: Mutt/1.5.6i

> void change() {
>   var <<= 1;
> }

That's a shift, not a rotation, so var is going to become 0.

>   while (1) {
>     int var=1;
>     while (var != 0) {
>       PORTB = var;
>       var <<= 1;
>     }
>   }

Also, 'int var' is going to be 16 bits wide, so in this version which
rotates the bit it's going to spend half its time in high bits and
PORTB is going to be 0.





reply via email to

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