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 CCS Technical Support

No I2C interrupt for General Call PIC18F

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



Joined: 05 Mar 2009
Posts: 15

View user's profile Send private message Send e-mail

No I2C interrupt for General Call PIC18F
PostPosted: Thu May 09, 2019 1:27 am     Reply with quote

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])
Ttelmah



Joined: 11 Mar 2010
Posts: 19544

View user's profile Send private message

PostPosted: Thu May 09, 2019 1:45 am     Reply with quote

Try turning off SSPEN, before setting the GCEN bit, then turning it back on.
A lot of settings like this can only be done when the peripheral is actually
'off'....
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