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

Header files

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



Joined: 27 May 2006
Posts: 2

View user's profile Send private message

Header files
PostPosted: Sat May 27, 2006 6:07 pm     Reply with quote

Hello

I've started using PCM compiler. And I have a question: why I have to do myself header file with definitions of all special function registers like: TMR0, INDF, STATUS and so on ?? There are significant difference
in many registers between PIC chips. I found in few places in internet header files for some chips, but it seems like there were no such files in CCS. And I need such header files for pic16f84a, pic10f200, 12f508, 16f872, 16f628. Where is it or how can make it easily (automatic)?

PS I found file called "Sfr.txt" and it looks like it has all the data but with strange format
dyeatman



Joined: 06 Sep 2003
Posts: 1923
Location: Norman, OK

View user's profile Send private message

PostPosted: Sat May 27, 2006 7:00 pm     Reply with quote

...

Last edited by dyeatman on Sat May 27, 2006 8:50 pm; edited 1 time in total
Mark



Joined: 07 Sep 2003
Posts: 2838
Location: Atlanta, GA

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

Re: Header files
PostPosted: Sat May 27, 2006 7:46 pm     Reply with quote

szlovak wrote:
Hello

I've started using PCM compiler. And I have a question: why I have to do myself header file with definitions of all special function registers like: TMR0, INDF, STATUS and so on ?? There are significant difference
in many registers between PIC chips. I found in few places in internet header files for some chips, but it seems like there were no such files in CCS. And I need such header files for pic16f84a, pic10f200, 12f508, 16f872, 16f628. Where is it or how can make it easily (automatic)?

PS I found file called "Sfr.txt" and it looks like it has all the data but with strange format


You are correct. There have been some posted that you could use or make your own. CCS does not include register definitions in their header files.
Ttelmah
Guest







PostPosted: Sun May 28, 2006 3:10 am     Reply with quote

It is worth saying though, that for 99% of programs, you should not need these definitions. CCS attempts to encourage you not to directly access such registers, because as soon as you do this, it potentially makes the code 'non portable' to other PICs.

Best Wishes
szlovak



Joined: 27 May 2006
Posts: 2

View user's profile Send private message

PostPosted: Mon May 29, 2006 6:09 am     Reply with quote

So when it is very necessary and can't be done without direct access?
rwyoung



Joined: 12 Nov 2003
Posts: 563
Location: Lawrence, KS USA

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

PostPosted: Mon May 29, 2006 8:18 am     Reply with quote

szlovak wrote:
So when it is very necessary and can't be done without direct access?


If you absolutely can't do it with built-in functions or if it is for personal reasons, then just write your own.

But keep in mind that your code is now MUCH less portable among chip variations. Especially if you cross between families (10F to 12F to 16F to 18F etc).

Since the #include you need for each part has a unique identifier for the chip, you could write your register header such that it took advantage of the #defines.
_________________
Rob Young
The Screw-Up Fairy may just visit you but he has crashed on my couch for the last month!
PCM programmer



Joined: 06 Sep 2003
Posts: 21708

View user's profile Send private message

PostPosted: Mon May 29, 2006 4:17 pm     Reply with quote

Quote:
So when it is very necessary and can't be done without direct access?

If you really think this is essential, you could write a small DOS program
program in C, with MSVC, to parse the Microchip ".inc" files that are
provided with MPLAB and convert them to your header files.

For example, P16F628.H has a lot of equates in it like this:
Code:

INDF         EQU     H'0000'
TMR0         EQU     H'0001'
PCL          EQU     H'0002'
STATUS       EQU     H'0003'
FSR          EQU     H'0004'
PORTA        EQU     H'0005'
PORTB        EQU     H'0006'


The conversion program would produce output like this:
Code:

#byte INDF =   0x00
#byte TMR0 =   0x01
#byte PCL  =   0x02
#byte STATUS = 0x03
#byte FSR   =  0x04
#byte PORTA =  0x05
#byte PORTB =  0x06
Mark



Joined: 07 Sep 2003
Posts: 2838
Location: Atlanta, GA

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

PostPosted: Thu Jun 01, 2006 12:14 pm     Reply with quote

I almost always define my own registers and rarely use the in-built functions. This requires more programming but I have more control and less problems with compiler "features". This will also force you to read the datasheet and gain a better understanding of the chip.
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