|
|
View previous topic :: View next topic |
Author |
Message |
mlosso1
Joined: 21 Mar 2006 Posts: 9
|
16F876A SSPADD Register value (General Call Addressing) |
Posted: Tue Mar 21, 2006 2:29 am |
|
|
Background Info:
PIC: 16F876A
Protocol: I2C
I am communicating with a PIC through I2C using general call addressing. From what I understand, in your code the SSPADD should be assigned the address you give your PIC so it can be referenced when needed. If the PIC is acknoledge by the general call address, will the SSPADD register then hold the general address (0x0000h) |
|
|
Ttelmah Guest
|
|
Posted: Tue Mar 21, 2006 3:28 am |
|
|
The pic will interrupt,when an address is received, matching the address in SSPADD. However it can also be programmed to interrupt, when a general call address is received _as well_ (hence the chip will respond to both addresses). This is done by setting the GCEN bit in SSPCON2. So, you enable this, with:
Code: |
#byte SSPCON2 = 0x91
#bit GCEN=SSPCON2.7
#byte SSPBUFF = 0x13
//Then in the initialisation code:
GCEN=TRUE;
//Will enable general call interrupts
|
In your interrupt code, when I2C_ISR_STATE=0, which signifies that a 'write' has been triggered, or I2C_ISR_STATE=0x80, which is the first transaction on a read, if you look at the value in the SSPBUF register, it will hold the address that matched. So if you test for this being '0', or '1', then these are the 'general call' conditions. This allows you to program different responses (if required), to a general call, from one that matches the programmed address in the device (in SSPADD).
Best Wishes |
|
|
|
|
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
|