I2CChip.com: Mixing I2C and SPI on the same pins:

Contents Graham North wrote "Is there such a thing as an SPI port expander? I know there is such an I2C > device (I2C Parallel port). As I am running out of I/O and the design uses > SPI peripherals"

 You can normally mix I2C and SPI on the same pins with no problems.

You can normally mix I2C and SPI on the same pins. I2C only does something between START and STOP.

START is when SCL is HI, SDA goes to HI->LO.

STOP is when SCL is HI and SDA goes LO->HI.

So if you arrange your code such that SDA only changes value when SCL is LO, there will be no problems. The I2C will not notice any SPI transactions. Of course all the SPI devices have thier own individual CS pin, but this is the disadvantage of SPI.

So to spell it out.


Other Serial Devices for Expansion

MM5451/2/3: A 35 output non-multiplexed LED driver with 12V capable outputs. This uses CLK & DATA, but doesn't have a CS pin. Instead it uses a start bit like a UART. You can connect CLK to SCL. Then you need to have a separate pin for DATA (instead of CS), or you can use a CS pin, that connects DATA to SDA (eg via a gate or 4053). To ensure this device is in a known state, the reset routine clocks LO into it 36 times. The I2C-2-PC can connect one of these to an I2C bus, and write to it using the "Y" command. See the Digit Display Modules that use these.
74HC4094: Shift register. My personal favorite. No issues
Counters:

74HC4040

You can also use counters for specialist functions like LED drivers. A 4040 type counter can be used to drive 12 LEDs with a 16 pin package.

A PIC takes less than 10ms to clock the counter to any output value. The brief flicker of the leds is no problem. I generally use a single pin, and use an R-C with a timeconstant of 10uS, from the clock pin to the reset line. First I set the pin high for 20us. The 4040 resets. Then low for 20us so the RC discharges. Then clock with a series of 1us high pulse.The duty cycle is kept < 1/4 during clocking, so the RC ensures there won't be any resets. Then leave the clock line to idle LO.

(This is a uP only type trick. Don't do it through the I2C-2-PC).

LCD Drivers Most non-mux LCD drivers can be sued as an output port. Just set the backplane (BP) input to a fixed state.
   
   
   

 

 

Back to Top
Back to Home

Contact Information

sales@i2cchip.com
http://www.i2cchip.com
Phone +64 21 623-402

Back to Top

Comments and Suggestions

Please send us mail telling us what you think about this page and how we might improve it.

Back to Top