|
|
View previous topic :: View next topic |
Author |
Message |
soonc
Joined: 03 Dec 2013 Posts: 215
|
I2C how to get Master chips attention |
Posted: Tue Dec 03, 2013 7:05 pm |
|
|
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: 19549
|
|
Posted: Wed Dec 04, 2013 2:06 am |
|
|
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
|
Re: I2C how to get Master chips attention |
Posted: Wed Dec 04, 2013 3:13 am |
|
|
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
|
I2C Slave getting Master chips Attention |
Posted: Wed Dec 04, 2013 9:01 am |
|
|
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.
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. |
|
|
|
|
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
|