darahayes
Joined: 05 Mar 2009 Posts: 15
|
No I2C interrupt for General Call PIC18F |
Posted: Thu May 09, 2019 1:27 am |
|
|
I have a simple 4 slave one master on an I2C bus (all are pic 18f258 devices) The slaves are all working fine when receiving bytes sent to their individual address's.
However from time to time I want to be able to address all of the slaves with a single command byte, and so in each slave I2C Set up code
I set the appropriate SSPCON2 bit to allow for a general call to generate an interrupt, ...... "bit_set(SSPCON2,7)".
I transmit a write to Address 0x00 and follow it with a single "command" byte and then a Stop as follows:
Code: |
I2C_Start();
I2C_Write(0x00);
I2C_Write(command);
I2C_Stop();
|
I generate a scope trigger each time the I2C interrupt is fired but this only occurs when each slave address is written to but not when address zero is written. Despite the SSPCON2,7 being set in each slave,
none of the four slaves generate an interrupt when I send a write to address zero from the master on the I2C bus.
Below are snippets of my slave code:
Code: |
// SLAVE HEADER FILE SET UP
#use delay(clock=16000000)
#use I2C (SLAVE,SDA=PIN_C4,SCL=PIN_C3)
#fuses NOWDT,HS, NOPUT, NOPROTECT, BROWNOUT, NOLVP, NOCPD, NOWRT, NODEBUG
**********************************************************
// SET UP SLAVE ADDRESS AND I2C GLOBAL CALL ENABLE
SSPADD= Slave_Adds; // set the I2C slave address
bIT_set(SSPCON2,7); // ALLOW GLOBAL calls
**********************************************************
// SLAVE I2C INTERRUPT CODE
#INT_SSP
void I2CInterrupt(void)
{ // I2C INTERRUPT
BYTE mystat;
// GENERATE DEBUG SIGNAL FOR OSCILLOSCOPE ON INTERRUPT
bit_set(Blatch,7);
output_b(Blatch);
delay_cycles(9);
bit_clear(Blatch,7);
output_b(Blatch);
mystat = SSPSTAT;
// first see if its READ OR WRITE BIT 2 READ WRITE
if(bit_test(mystat,2)==0) // BIT 2 LOW = WRITE
{ // we are in a write mode
|
Any ideas or thoughts on using the General Call Adds Zero ?
I simply want to get all slaves to act on a single byte sent to them all.
No response is needed or desired for this byte sent to adds zero.
Dara Hayes
([email protected]) |
|