[Icc-avr] dumb pointer question

Paul Mateer paul.aa9gg at gmail.com
Tue Oct 9 14:04:14 PDT 2007


thanks...that was it!

On 10/9/07, John Woods <john at idea-tech.com> wrote:
>
> Hi Paul,
>
> You want to use the '*' in front oft he P_PORT when doing accesses so
> that bit operators work on the port and not the pointer itself. For
> example:
>
> *P_PORT &= ~w_pin;
>
> Paul Mateer wrote:
> > Hello All.....
> > Please tell me what I'm doing wrong here:
> >
> > void Process_Cmd(void)
> > {
> >   unsigned char *P_PORT;
> >   int w_port, w_pin;
> >
> >   w_port = WHICH_PORT & 0xF0;
> >   w_pin = WHICH_PORT & 0x0F;
> >
> >   if(w_port == 0x10) P_PORT = &PORTA;   // PORT A
> >   if(w_port == 0x20) P_PORT = &PORTB;   // PORT B
> >   if(w_port == 0x30) P_PORT = &PORTC;   // PORT C
> >   if(w_port == 0x40) P_PORT = &PORTD;   // PORT D
> >
> >   if(w_pin != 8)
> >    {
> >      if(PORT_CMD == OFF) P_PORT &= ~w_pin;
> >      if(PORT_CMD == ON) P_PORT |= w_pin;
> >    }else
> >      {
> >        if(PORT_CMD == OFF) P_PORT = 0;
> >        if(PORT_CMD == ON) P_PORT = 0xFF;
> >      }
> > }
> >
> >
> //------------------------------------------------------------------------------------------------
> >
> > I always seem to stumble when it comes to pointers
> > --
> > Paul Mateer, AA9GG
> > Elan Engineering Corp.
> > www.elanengr.com <http://www.elanengr.com>
> > ------------------------------------------------------------------------
> >
> > _______________________________________________
> > Icc-avr mailing list
> > Icc-avr at imagecraft.com
> > http://dragonsgate.net/mailman/listinfo/icc-avr
> >
>
> --
> John Woods                      Phone: (780) 431 1843
> Idea Technologies Inc.          Fax:   1 866 293 5883
> 6746 75 St.                     Email: john at idea-tech.com
> Edmonton, Alberta,              Web:   www.idea-tech.com
> Canada, T6E 6T9
>
> _______________________________________________
> Icc-avr mailing list
> Icc-avr at imagecraft.com
> http://dragonsgate.net/mailman/listinfo/icc-avr
>



-- 
Paul Mateer, AA9GG
Elan Engineering Corp.
www.elanengr.com
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://dragonsgate.net/pipermail/icc-avr/attachments/20071009/855cb3f8/attachment.html


More information about the Icc-avr mailing list