I2C Not Working
Hello all,
I'm trying to learn I2C communications on the propeller, but am having trouble getting it to work. I've loaded the EEPROM test code from the Learn folder (as described here: http://learn.parallax.com/propeller-c-simple-protocols/eeprom-test-code), but it reports "testStr = " without the "abcdef" part. I am using the Propeller Education Kit. Can anyone explain what may be going wrong? Thanks in advance!
I'm trying to learn I2C communications on the propeller, but am having trouble getting it to work. I've loaded the EEPROM test code from the Learn folder (as described here: http://learn.parallax.com/propeller-c-simple-protocols/eeprom-test-code), but it reports "testStr = " without the "abcdef" part. I am using the Propeller Education Kit. Can anyone explain what may be going wrong? Thanks in advance!

Comments
Ray
Not sure what part I was unclear about... The code is found in the link, but here it is anyway:
/* Test 24LC512 with I2C.c Test writes data to I2C EEPROM, then reads it back and displays it. */ #include "simpletools.h" // Include simpletools header i2c *eeBus; // I2C bus ID int main() // Main function { eeBus = i2c_newbus(28, 29, 0); // Set up I2C bus, get bus ID // Use eeBus to write to device i2c_out(eeBus, 0b1010000, // with I2C address 0b1010000, 32768, 2, "abcdefg", 8); // send 2 byte address of 32768 // and 8 byte data string. while(i2c_busy(eeBus, 0b1010000)); // Wait for EEPROM to finish char testStr[] = {0, 0, 0, 0, 0, 0, 0, 0}; // Set up test string // Use eeBus to read from device i2c_in(eeBus, 0b1010000, // with I2C address 0b1010000, 32768, 2, testStr, 8); // send 2 byte address of 32768 // & store data in 8 byte array. print("testStr = %s \n", testStr); // Display result }And a perfect graphical representation of the wiring is given here:
I do only have the 32kb ic, but changing the starting address to one within range of my smaller EEPROM didn't help. After looking more at the tutorial, I'm thinking the problem may be that the code provided requires pullup resistors on the i2c lines... Do you happen to know if the primary (program memory) EEPROM uses the propeller's internal pullups by default?
Per the schematic on page 27 of the PEK manual, you should have a 10K resistor from SDA to 3.3V bus. Without this pullup, I2C more often than not, will not work. I would also suggest putting a 10K pullup on the SCL line.
You should put pullups on the I2C lines. The Propeller has no internal pullups. All of the current boards (including Dave's QuickStart) have pullups. There were some early boards that I believe did not have pullups and also, the PEK doesn't specify pullups. I recall reading somewhere that the Propeller itself has no issue using the EEPROM for loading/booting without pullups but beyond those uses, it should have pullups. Worth a try - surely won't hurt anything.
There is no way for it to "protect" the lower 32K from your program, so you can easily blow your toes off if you decide to write to the lower 32k and not knowing exactly what you are writing to. (Don't worry too much, F11 will give you your toes back!)
The library allows for either driving the clock or pulling it down (pull up on SCL).