I am trying to access specific I/O pins on a PIC16F87x using a pointer in C. However this doesn't work why?
char *Dir = (unsigned)&PORTB*8+0 producess Dir = 0x0030;
*Dir = 1; (supposed to set RB0) does nothing.
Using the header file which states that
RB0 @ &PORTB*8+0; the following does set bit RB0 = 1;
Problem is I need to change a clock signal from one pin to another dynamically depending on the input.
Mark
Joined: 07 Sep 2003 Posts: 2838 Location: Atlanta, GA
Posted: Wed Nov 23, 2005 9:32 am
You can't have a pointer to bits (or I/O). You can only have a pointer to the port. Port B is located at 0x06. You multiplied this by 0x08 which gave you 0x30. You will need to point to the port and use bit_set, bit_clear CCS functions or 'OR' with a bitmask and 'AND' with an inverted bit mask.
You cannot post new topics in this forum You cannot reply to topics in this forum You cannot edit your posts in this forum You cannot delete your posts in this forum You cannot vote in polls in this forum