Shop OBEX P1 Docs P2 Docs Learn Events
I2C Between SX28 and Propeller (Help!) — Parallax Forums

I2C Between SX28 and Propeller (Help!)

SailerManSailerMan Posts: 337
edited 2006-10-15 02:46 in Propeller 1
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?

Comments

  • Mike GreenMike Green Posts: 23,101
    edited 2006-10-14 18:20
    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?
  • RsadeikaRsadeika Posts: 3,824
    edited 2006-10-14 18:43
    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.

    Ray
  • SailerManSailerMan Posts: 337
    edited 2006-10-15 02:29
    Mike,

    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.

    Eric
  • Mike GreenMike Green Posts: 23,101
    edited 2006-10-15 02:46
    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.
Sign In or Register to comment.