Hi John,
Yes IOPIN is a memory mapped register in a header file.
#define IOPIN (*((volatile unsigned long *) 0xE0028000))
I use " IOPIN" in an ARM7 device to determine the status (high or
low) and "AND" it with my "RENC1A" which is the quadrature rotary
encoder pin A register.
So "IOPIN AND RENC1A" should be 0 to be true.
The problem that I was having was while porting from Basic to C got me
confused . I didn't know how to state the "else" command .
I googled it shortly after I sent off my message . Then felt pretty
stupid :(
I didn't know if you actually write out the "else" word . My compiler
didn't give me any errors when I had a statement like:
if (whatever){
do this;
}
{
do else;
}
which I know now is is false. And Tyler kindly pointed it out to me.
It requires the "else" statement as well. Just like in BASIC.
Thanks, John for your help
Csaba
On Apr 2, 2009, at 7:54 AM, John Matthews wrote:
> --- In [email protected], Csaba Zvekan <czve...@...> wrote:
> >
> > Here is my little sub routine in C:
> >
> > static void encoderRead(void)
> > {
> > if (IOPIN &(1<<RENC1A)){ // true if button released (active low)
> > Csaba
>
> Hi Csaba - I'm interested in your definition of IOPIN. Is it memory
> mapped eg.
>
> #define IOPIN (*(unsigned char *)0x1234)
>
> Because in C it can help to use the volatile keyword to prevent the
> compiler optimising out successive reads of IOPIN, which it would
> otherwise assume to return the same value:
>
> #define IOPIN (*(volatile unsigned char *)0x1234
>
> John
[Non-text portions of this message have been removed]