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

Referencing I/O Pins.

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



Joined: 05 Aug 2006
Posts: 52

View user's profile Send private message Visit poster's website AIM Address MSN Messenger

Referencing I/O Pins.
PostPosted: Thu Sep 28, 2006 3:51 am     Reply with quote

Hi,

According to,
http://www.phanderson.com/PIC/PICC/CCS_PCM/tmr0.html

Even though that's very old it seems at CCS at a time supported referencing pins as

Quote:
#define LED_FL_PIN rb3 // RB3
#define SPKR_PIN rb2

#define LED_FL_DIR trisb3
#define SPKR_DIR trisb2


and performing,

Quote:
SPKR_DIR = 0; // make SPKR and LED_FL outputs
LED_FL_DIR = 0;

LED_FL_PIN = 0;
SPKR_PIN = 0;


In my current code I'm using something along the lines of,

#define xPin PORTB.0
#define xTris TRISB.0

while defining

#define PORTA 0x05
etc etc

and that works. However, 'xPin=0;' doesn't work and I'm forced to use output_low(xPin);

Any ideas on this?
bsodmike



Joined: 05 Aug 2006
Posts: 52

View user's profile Send private message Visit poster's website AIM Address MSN Messenger

PostPosted: Thu Sep 28, 2006 5:18 am     Reply with quote

I've noticed another problem.

Even defining,

#define xPin PORTB.0

and

output_low(xPin); //doesn't work!

However, '#define xPin PIN_B0' causes it to work, as in the headerfile these are defined in the 'register*8+pin' format (so in this case 6*8+0, as 0x06 is the PORTB register.

Some googling and I found Phanderson's definitions for the 16f84,

Code:
// DEFS_F84.H (CCS PCM)
//
// Definitions of file registers and bits.
//
// PIC16F84.  These agree with Microchip.
//
// Note that bits are lower case for C, upper case for assembly.
//
// copyright Peter H. Anderson, Scotland Co, NC, Mar, '99

// register definitions
#define W 0
#define F 1

// register files
#byte INDF          =0x00
#byte TMR0          =0x01
#byte PCL           =0x02
#byte STATUS        =0x03
#byte FSR           =0x04
#byte PORTA         =0x05
#byte PORTB         =0x06
#byte EEDATA        =0x08
#byte EEADR         =0x09
#byte PCLATH        =0x0a
#byte INTCON        =0x0b

#byte OPTION_REG    =0x81
#byte TRISA         =0x85
#byte TRISB         =0x86
#byte EECON1        =0x88
#byte EECON2        =0x89

#bit ra4   =0x05.4
#bit ra3   =0x05.3
#bit ra2   =0x05.2
#bit ra1   =0x05.1
#bit ra0   =0x05.0

#bit rb7   =0x06.7
#bit rb6   =0x06.6
#bit rb5   =0x06.5
#bit rb4   =0x06.4
#bit rb3   =0x06.3
#bit rb2   =0x06.2
#bit rb1   =0x06.1
#bit rb0   =0x06.0

#bit trisa4   =0x85.4
#bit trisa3   =0x85.3
#bit trisa2   =0x85.2
#bit trisa1   =0x85.1
#bit trisa0   =0x85.0

#bit trisb7   =0x86.7
#bit trisb6   =0x86.6
#bit trisb5   =0x86.5
#bit trisb4   =0x86.4
#bit trisb3   =0x86.3
#bit trisb2   =0x86.2
#bit trisb1   =0x86.1
#bit trisb0   =0x86.0


/me slaps head! #bit/#byte, maybe these'll help, will test in a bit.

Update: Works now, it was the #bit/#byte that sorted it out...

Thanks!
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