CCS C Software and Maintenance Offers
FAQFAQ   FAQForum Help   FAQOfficial CCS Support   SearchSearch  RegisterRegister 

ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 

CCS does not monitor this forum on a regular basis.

Please do not post bug reports on this forum. Send them to support@ccsinfo.com

PIC16F87x using a pointer

 
Post new topic   Reply to topic    CCS Forum Index -> General CCS C Discussion
View previous topic :: View next topic  
Author Message
ahmet2005



Joined: 10 Nov 2005
Posts: 2

View user's profile Send private message

PIC16F87x using a pointer
PostPosted: Wed Nov 23, 2005 9:13 am     Reply with quote

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

View user's profile Send private message Send e-mail

PostPosted: Wed Nov 23, 2005 9:32 am     Reply with quote

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.
Display posts from previous:   
Post new topic   Reply to topic    CCS Forum Index -> General CCS C Discussion All times are GMT - 6 Hours
Page 1 of 1

 
Jump to:  
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


Powered by phpBB © 2001, 2005 phpBB Group