Shop OBEX P1 Docs P2 Docs Learn Events
Using I2C with a BS1 — Parallax Forums

Using I2C with a BS1

RonHarshRonHarsh Posts: 1
edited 2013-03-12 07:57 in BASIC Stamp
Sorry if this has been beat to death already but I would like to use some serial EEPROMs with a BS1. Has anyone written code to perform I2C two wire serial with the BS1?

Carry On!
RonHarsh

Comments

  • Mike GreenMike Green Posts: 23,101
    edited 2013-03-11 14:22
    You can use SPI serial EEPROMS with a BS1, but I2C is too complex for the amount of memory available in a BS1. Look at the BS1 Application Notes for examples.
  • SapphireSapphire Posts: 496
    edited 2013-03-11 18:28
    RonHarsh,

    You can do I2C with a BS1 but you have to do it manually (bit-banging) because there are no built-in I2C functions in the BS1. I have attached a demo program I wrote for the BS1 that reads the seconds from a DS1307 RTC and sends the ones digit out to a PCF8574A port extender as a binary clock. The I2C routines and the main program take up about 1/2 of the BS1 memory, so there is still space left if you aren't doing anything too complex with the data.

    The I2C routines are optimized for this application. Specifically, only one byte can be read at a time, as an ACK is not sent after the byte is read from the I2C bus. This tells the I2C device to stop sending more data. If you want to read more than one byte at a time, you will need to modify the I2C receiver routine to send an ACK for all but the last byte.
  • Mike GreenMike Green Posts: 23,101
    edited 2013-03-12 07:57
    Nice job Sapphire. I'm still not sure you could do the same for serial I2C EEPROMs and still have room for anything else. The serial EEPROMs require the device selection for writing, then a 1 or 2 byte address, then the data if writing. For a read, you still need the selection for writing and the 2 byte address, then you need to re-select the device for reading, then actually read the data.
Sign In or Register to comment.