Tutorial on I2C w/ BS2
Crux
Posts: 74
Hello guys I need a simple tutorial on I2C using BS2. Some advice me to refer to the nuts and bolts article title: "I2C For Fun",I still find it hard to comprehend so if you some of you knows how to do it. I would be very grateful if you share it to me.
Comments
http://forums.parallax.com/forums/default.aspx?f=21&m=144987
▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
Think Inside the box first and if that doesn't work..
Re-arrange what's inside the box then...
Think outside the BOX!
Here's I2C code for writing/read an I2C EEPROM, a 24LC32:
Writes data to EEPROM:
' 24LC32EEPROM SDA on 8; SCL on 9
I2Cpin CON 8
Wr2432 CON %10100010 ' write to 24LC32
addr VAR Word ' EE address
data VAR Word
addr = addr+1
I2COUT I2Cpin,Wr2432,addr.HIGHBYTE\addr.LOWBYTE,[noparse][[/noparse]data]
'''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''
Reads tIn from 24LC32 EEPROM memory chip:
Taddr VAR Word ' EE address
Rd2432 CON Wr2432 | 1 ' read from 24LC32
tIn VAR Byte ' value read from EEPROM
Taddr=Taddr+1
I2CIN I2Cpin,Rd2432,Taddr.HIGHBYTE\Taddr.LOWBYTE,[noparse][[/noparse]tIn] 'read back
''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''