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

Addressing SFRs

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








Addressing SFRs
PostPosted: Thu Apr 16, 2009 4:04 pm     Reply with quote

I know how to do this:

Code:

 word ADCON1 = 0x02A0
.
.
.
.
bit_set(ADCON1,15);


But what do I need to define so that I can just say

Code:

ADCON1bits.ADON = 1;


yes, I realize that there are prewritten functions to turn on the ADC. But there are no prewritten functions to simultaneously sample 4 inputs. So I'm having to deal with lots of SFRs. Some of the microchip application notes have been very helpful, and I've actually gotten it to work.

Maybe this is heresy, but I'd like to use them in the same manner that C30 allows you to.
PCM programmer



Joined: 06 Sep 2003
Posts: 21708

View user's profile Send private message

PostPosted: Thu Apr 16, 2009 4:11 pm     Reply with quote

You didn't post your PIC. I don't know what PIC has ADCON1 at 0x2A0.

I'm going to assume you're using the 16F-series. Here is Mark's header
file for accessing SFR registers:
http://www.ccsinfo.com/forum/viewtopic.php?t=20186
rnielsen



Joined: 23 Sep 2003
Posts: 852
Location: Utah

View user's profile Send private message

PostPosted: Thu Apr 16, 2009 5:05 pm     Reply with quote

Here's the way you can declare registers and then use the bit's name to assign values. This is a register for a PIC16F77:

Code:
#byte SSPCON = 0x14

//SSPCON bits
#bit SSPM0 = SSPCON.0
#bit SSPM1 = SSPCON.1
#bit SSPM2 = SSPCON.2
#bit SSPM3 = SSPCON.3
#bit CKP = SSPCON.4
#bit SSPEN = SSPCON.5
#bit SSPOV = SSPCON.6
#bit WCOL = SSPCON.7


CKP = 1;


Hope that helps.

Ronald
asmboy



Joined: 20 Nov 2007
Posts: 2128
Location: albany ny

View user's profile Send private message AIM Address

PostPosted: Fri Apr 17, 2009 7:14 am     Reply with quote

these two related methods have always worked well for me in SFR land

#bit T0IF = 0x0B.2 // flag in reg

#byte PORT_B = 0x06
#BIT AUTOBOOSTOK = PORT_B.6 // inlet sense
#BIT BINTEG = PORT_B.7 // inlet sense
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