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

I2C how to get Master chips attention

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



Joined: 03 Dec 2013
Posts: 215

View user's profile Send private message

I2C how to get Master chips attention
PostPosted: Tue Dec 03, 2013 7:05 pm     Reply with quote

I have a PIC18F4523 as a hardware I2C Slave, and another PIC18F4523 as hardware I2C Master.

The main data flow is from Master to Slave and transferring data from Master to Slave works fine. The Slave Sensor is waiting for the master to send it data and this works because the #INT_SSP routine just works fine.

Sometimes I need the Slave to contact the Master. How can I use the I2C to get the Master chips attention ?

I thought of reversing the functions but the Master chip talks to several other I2C chips.

I could grab the Master chips attention if I had a spare pin on the master chip. There are NO spare pins on the Master chip so that's not possible.

Suggestions ?
Ttelmah



Joined: 11 Mar 2010
Posts: 19552

View user's profile Send private message

PostPosted: Wed Dec 04, 2013 2:06 am     Reply with quote

You say 'no spare pins', but it is surprising how often it is possible to save one.
For instance, switching to EC, rather than HS, with an external oscillator. Or if driving multiple CS lines, adding a 2 to 4 line decoder. It really is the easiest way to go....

The basic answer is 'no'. However remember the same is true of USB, yet devices can have quite rapid responses, by being polled frequently. If you setup the slave code, so a single read, performed without setting a register address, returns a 'status' byte, with a bit saying 'service me', then you can poll the chip at say 50* per second, without using much bus time, and the master can then service the slave with quite low latency. This is the way it is done on most chips that require relatively rapid responses. The rest all implement an interrupt, which will need an extra pin.

Best Wishes
RF_Developer



Joined: 07 Feb 2011
Posts: 839

View user's profile Send private message

Re: I2C how to get Master chips attention
PostPosted: Wed Dec 04, 2013 3:13 am     Reply with quote

soonc wrote:

Sometimes I need the Slave to contact the Master. How can I use the I2C to get the Master chips attention ?


SMBus, which is based on I2C, includes a SMBALERT# line for this purpose, but it is a separate signal, not sent on the I2C. I2C is master-slave where slaves cannot send anything unless the master asks for it, i.e. initiates and controls the transaction.

Without implementing the SMBus SMBALERT#, frequent polling for slave status is the way to go.
soonc



Joined: 03 Dec 2013
Posts: 215

View user's profile Send private message

I2C Slave getting Master chips Attention
PostPosted: Wed Dec 04, 2013 9:01 am     Reply with quote

Thank you Telmah and RF_Developer.
Normally the software polling for a "service me" sounds like a reasonable solution.
The I2C slave is on an adapter add-in board so adding extra chips on the master board for more IO is not practical as 3000+ master boards are already "out there".
Telmah's comment: "but it is surprising how often it is possible to save one" gave me time to study the schematic again, and of course there is an extra pin the ICSP B6 and B7 and these are also interrupt pins. Very Happy

I don't like using them because of the need to isolate them if hardware programming is needed in the future. As the add-in adapter can be unplugged using a FFC that really is all taken care of if hardware programming is ever needed.

Thanks again for the help.
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