View previous topic :: View next topic |
Author |
Message |
Ringo42
Joined: 07 May 2004 Posts: 263
|
i2c Global address |
Posted: Tue Aug 07, 2007 5:28 pm |
|
|
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
|
|
Posted: Tue Aug 07, 2007 5:31 pm |
|
|
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
|
|
Posted: Tue Aug 07, 2007 6:26 pm |
|
|
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
|
|
Posted: Tue Aug 07, 2007 6:38 pm |
|
|
I'm assuming this is how it is done
#BYTE SSPCON2 = 0x91
bit_set(SSPCON2,7); _________________ Ringo Davis |
|
|
Ttelmah Guest
|
|
Posted: Wed Aug 08, 2007 2:07 am |
|
|
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
|
|
Posted: Wed Aug 08, 2007 6:30 am |
|
|
cool, I like it, Thanks
Ringo _________________ Ringo Davis |
|
|
|