View Full Version : I2C Between SX28 and Propeller (Help!)

10-15-2006, 12:30 AM
Can someone please help me with a little code.. I want to set up an I2C Link between an SX28 and a Propeller.

I have tried and failed, mostly because I don't understand completely... I2C functionality.

I just want to send 1 byte from the SX28 and receive it on the Propeller.

Can anyone help?

Mike Green
10-15-2006, 01:20 AM
The existing I2C routines only handle the case where the Propeller is the master. I don't know what the SX28 routines will do. If you can affort a total of 3 lines between the two devices, this would be trivial to do with SPI. If you can only afford 2 lines, you could still use SPI, but would have to figure out how to reestablish synchronization if something goes wrong on either side. Asynchronous serial is also easy and would only require 1 line. Do you really need I2C?

10-15-2006, 01:43 AM
If the propeller is the master, and if you are using SX/B I2C routines, that makes the SX28 a master. You have to create a master/slave condition. If you want to try something new, try installing, on the SX28, an I2C slave VP which is asm code of course, then that should work for you. Unfortunately, SX/B does not support I2C slave commands.


10-15-2006, 09:29 AM

No I don't specifically need I2C, I just thought that after trying to keep time with·Serial comms that I would try something Syncronous(sp) I2C Came to mind... Tell me more about SPI.


Mike Green
10-15-2006, 09:46 AM
You can lookup SPI on the internet. There are plenty of examples in the Stamp tutorials and PBasic manual under the SHIFTOUT and SHIFTIN commands and some examples in the Propeller Object Exchange. Basically, it requires 3 to 4 I/O pins, one for a select line, one for a clock, and one or two for data lines depending on the device. You could look at the BS2 compatibility object under SHIFTOUT and SHIFTIN if you want to use some canned routines.

The select line is brought usually from a HIGH to a LOW where it remains throughout the transfer. The clock line is taken from HIGH to LOW to HIGH. Depending on the device, the data line is read just before the HIGH to LOW transition or the LOW to HIGH transition. Similarly, if there's a data out line, it must be stable at either the HIGH to LOW transition or the LOW to HIGH transition. Since you have control of both ends of the connection, you can define whatever convention you want.

Very often, the device always outputs data and inputs data so there's an interchange of a byte with each transfer. Again, you don't have to do that if you don't want it.