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

i2c Global address

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



Joined: 07 May 2004
Posts: 263

View user's profile Send private message

i2c Global address
PostPosted: Tue Aug 07, 2007 5:28 pm     Reply with quote

I've seen that alot of I2C devices that will respond to their address or adress 0. Is there a way to set up a pic to do this?
Thanks,
Ringo
_________________
Ringo Davis
PCM programmer



Joined: 06 Sep 2003
Posts: 21708

View user's profile Send private message

PostPosted: Tue Aug 07, 2007 5:31 pm     Reply with quote

From the 16F877 data sheet:
Quote:

SSPCON2: SYNC SERIAL PORT CONTROL REGISTER2 (ADDRESS 91h)

bit 7 GCEN: General Call Enable bit (In I 2 C Slave mode only)
1 = Enable interrupt when a general call address (0000h)
is received in the SSPSR
0 = General call address disabled


Also see this section in the data sheet:
Quote:
9.2.2 GENERAL CALL ADDRESS
Ringo42



Joined: 07 May 2004
Posts: 263

View user's profile Send private message

PostPosted: Tue Aug 07, 2007 6:26 pm     Reply with quote

cool thanks.
I'm using a pic16f876A
I need to set bit 7 to 1 of the sspcon2 register which is at 0x91.

can I just say

#define SSPCON2 0x91
SSPCON2 =SSPCON2 & 0x80;

will this work?
_________________
Ringo Davis
Ringo42



Joined: 07 May 2004
Posts: 263

View user's profile Send private message

PostPosted: Tue Aug 07, 2007 6:38 pm     Reply with quote

I'm assuming this is how it is done
#BYTE SSPCON2 = 0x91

bit_set(SSPCON2,7);
_________________
Ringo Davis
Ttelmah
Guest







PostPosted: Wed Aug 08, 2007 2:07 am     Reply with quote

Or:
#BYTE SSPCON2 = 0x91
#BIT GCEN=SSPCON2.7

Then just:

GCEN=TRUE;

or:

GCEN=FALSE;

To turn it on/off.
Prsonally, I think this makes what is going on easier to read, and it results in efficient code as well. :-)

Best Wishes
Ringo42



Joined: 07 May 2004
Posts: 263

View user's profile Send private message

PostPosted: Wed Aug 08, 2007 6:30 am     Reply with quote

cool, I like it, Thanks
Ringo
_________________
Ringo Davis
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