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 CCS Technical Support

Using special function registers, not the built in functions

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



Joined: 03 Jun 2008
Posts: 2

View user's profile Send private message

Using special function registers, not the built in functions
PostPosted: Tue Jun 03, 2008 9:58 am     Reply with quote

For personal reasons I would like to call the special function registers directly. Rather than use the built in functions.

There is a program called Chipedit, where "registers" can be selected then "Make include file" this looks to produce the right information, but it conflicts with something else and I cannot get the project to compile.

Does somebody has a process to generate a H file that can be included, where the special function registers can be called by name? Currently I am using a 16F628.

Thank you.
Heath



Joined: 21 Dec 2007
Posts: 41

View user's profile Send private message

PostPosted: Tue Jun 03, 2008 10:07 am     Reply with quote

Could you just use the "#byte" directive?

example:

Code:
#BYTE TXSTA2 = 0xF6C
Ttelmah
Guest







PostPosted: Tue Jun 03, 2008 10:15 am     Reply with quote

There is a complete list in topic 14755 (for the 18 chips). There was one in the forum for the 16 chips somewhere, but I can't seem to find it at the moment. The normal approach, is just to type #bit, or #byte definitions for the few registers normally needed.

Best Wishes
PCM programmer



Joined: 06 Sep 2003
Posts: 21708

View user's profile Send private message

PostPosted: Tue Jun 03, 2008 11:45 am     Reply with quote

The 16F87x header file done by Mark is in the Code Library:
http://www.ccsinfo.com/forum/viewtopic.php?t=20186

Here's the header file that Ttelmah mentioned, for the 18F series PICs.
http://www.ccsinfo.com/forum/viewtopic.php?t=14755&start=3
Guest








PostPosted: Tue Jun 03, 2008 1:43 pm     Reply with quote

Thank you for your responses. It was quite a shock coming from 5 years of programming PICs in C which I was very happy with, to start a new job with this new compiler, it's like a new language.

Would you suggest following the built-in procedure programming method, or defining the SFRs, or does it not really matter? I want to set out from the start on the best method without hitting a pitfall.

I use PICs to an advanced level (time critical, sometimes in-line assembler, multi master i2c etc...)
PCM programmer



Joined: 06 Sep 2003
Posts: 21708

View user's profile Send private message

PostPosted: Tue Jun 03, 2008 1:52 pm     Reply with quote

There are two types of programmers with CCS. One type doesn't trust
the CCS functions because they don't know what's in them, so they
write all their own functions. The other type is into rapid development
and uses the CCS functions. Testing will show if there is a bug, and then
a look at the .LST file will tell what it is. I'm in the 2nd group.
RLScott



Joined: 10 Jul 2007
Posts: 465

View user's profile Send private message

PostPosted: Tue Jun 03, 2008 2:11 pm     Reply with quote

Just to let you know, not everyone who talks to SFRs directly is in the Flat Earth Society. I also access SFR's directly and avoid most CCS library functions that deal with them. I do use bit_set() and bit_clear() because I know that they compile into single machine instructions. I find the Microchip documentation of their SFRs to be quite good, so I don't need some additional layer of interface to protect me from the "awful details" of the SFRs. In most cases, even if you use the CCS library interface, you need to understand those details anyway.

However, I think if I ever develop a USB application, I will go with the CCS interface. The complexity of USB is much greater than, say, a UART or a CCP module.

Robert Scott
Real-Time Specialties
PCM programmer



Joined: 06 Sep 2003
Posts: 21708

View user's profile Send private message

PostPosted: Tue Jun 03, 2008 2:17 pm     Reply with quote

I didn't mean Flat Earth. I understand the other side.
RLScott



Joined: 10 Jul 2007
Posts: 465

View user's profile Send private message

PostPosted: Tue Jun 03, 2008 2:58 pm     Reply with quote

I know. Just kidding.

Robert Scott
Ken Johnson



Joined: 23 Mar 2006
Posts: 197
Location: Lewisburg, WV

View user's profile Send private message

PostPosted: Tue Jun 03, 2008 5:12 pm     Reply with quote

I thought everybody fell off the other side (of the flat earth).

Hmmm . . .

Ken
mkent



Joined: 09 Sep 2003
Posts: 37
Location: TN, USA

View user's profile Send private message

PostPosted: Tue Jun 03, 2008 7:04 pm     Reply with quote

It would appear that all the PCD folk did??? LOL
ckielstra



Joined: 18 Mar 2004
Posts: 3680
Location: The Netherlands

View user's profile Send private message

PostPosted: Wed Jun 04, 2008 4:29 am     Reply with quote

Just my two cents:

The CCS wrapper functions make it easy to change to another processor type if needs arise. Often the only thing you have to change is the processor include file. With the direct register approach you would have to make a lot of changes migrating for example from a PIC16 to PIC18.

On the other hand the direct register approach is easier to port to another compiler.

I think the CCS functions make for easier code reading than the direct register approach. To me this is the most important issue and that's why I use the CCS functions (but I keep an eye at the generated assembly to check efficiency).
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