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: Abdul Malik Khan
Subject: Re: [avr-gcc-list] Using PORTB with variables, PORTB = var
Date: Sat, 22 Apr 2006 11:38:30 +0500

Hi,

PORTB = 1;

is equivalent to

var = 1;
PORTB = var;

in your code whatever you have in var, it will soon become zero (in 8 cycles) and all port pins should become logically low.

are you getting low on all port pins?


On 4/22/06, address@hidden <address@hidden > wrote:
Hiya,

The var is an int.

I don't see any specific error except unexpected behaviour.  What I am seeing is
that when I use a variable instead of a number in my code, it doesn't work.  The
code I have below is exactly what I have.  Again when I change the line:
PORTB = var;
to
PORTB = 1;

it works as expected, but I want to make it a bit more dynamic, and that's where
I want to use a variable.

I hope I answered your question.

Chris-

On Sat, 22 Apr 2006 11:22:06 +0500
"Abdul Malik Khan" <address@hidden > wrote:

> Hi,
>
> what is the type and size of var?
>
> What error you are geting?
>
>
> On 4/22/06, address@hidden <address@hidden>
> wrote:
> >
> > Hiyas,
> >
> >   How can I use the PORTB constant with variables? eg:
> >
> > while (1) {
> >   var <<= 1;
> >   PORTB = var
> > }
> >
> > That is what I'm trying to acheive.  I'd like to be able to do it with
> > variables
> > like I do above, but it doesn't seem to work.  Once I replace "var" with
> > an
> > actual number, it works as expected.
> >
> > Can someone help me out here?  URL? reference?
> >
> > Thanks,
> >
> > Chris-
> >
> >
> > _______________________________________________
> > AVR-GCC-list mailing list
> > address@hidden
> > http://lists.nongnu.org/mailman/listinfo/avr-gcc-list
> >
>
>
>
> --
> Abdul Malik Khan



--
Abdul Malik Khan

reply via email to

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