I2C EEPROM PASM Driver (AT24C512, etc)
Cluso99
Posts: 18,069
I am writing the I2C code to read and write the AT24C512 (or others) on the Prop Proto Board for use with the (thread)...
Post Boot PASM COG Loader?·· http://forums.parallax.com/showthread.php?p=776824
Can anyone answer the following question:
Before using the eeprom, I think it wise to ensure the eeprom is in a proper initialisation state. This can be achieved by sending 9 clocks (SCL) and checking if the SDA is high while SCL is high. Code I have seen truncates the number of clocks when SDA returns high. Then a START condition is sent. The data sheets do not spell out an answer to my question. Is there anything wrong with continuing the full 9 clocks? I believe this will not cause a problem, and if so I can considerably shorten my code by reusing a routine.
FYI: I have parameterised the driving of the I2C so the page size is set by the user program. When done I will post the code here.
▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
Prop Tools under Development or Completed (Index)
http://forums.parallax.com/showthread.php?p=753439
My cruising website http://www.bluemagic.biz
Post Boot PASM COG Loader?·· http://forums.parallax.com/showthread.php?p=776824
Can anyone answer the following question:
Before using the eeprom, I think it wise to ensure the eeprom is in a proper initialisation state. This can be achieved by sending 9 clocks (SCL) and checking if the SDA is high while SCL is high. Code I have seen truncates the number of clocks when SDA returns high. Then a START condition is sent. The data sheets do not spell out an answer to my question. Is there anything wrong with continuing the full 9 clocks? I believe this will not cause a problem, and if so I can considerably shorten my code by reusing a routine.
FYI: I have parameterised the driving of the I2C so the page size is set by the user program. When done I will post the code here.
▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
Prop Tools under Development or Completed (Index)
http://forums.parallax.com/showthread.php?p=753439
My cruising website http://www.bluemagic.biz
Comments
There also seems to be an extra clock required to allow for SDA to be placed low (as it ends high for NO ACK) during the next SCL low, in order for the STOP command to be issued (SDA goes high after SCL goes high).
Also, SCL should be open drain like SDA. Chip's code and the Basic_I2C_driver in the Obex drive the SCL both high and low (instead of using dira).
I would like to get it right, so does anyone have any experience they can shed???
▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
Prop Tools under Development or Completed (Index)
http://forums.parallax.com/showthread.php?p=753439
My cruising website http://www.bluemagic.biz
▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
Links to other interesting threads:
· Prop Tools under Development or Completed (Index)
· Emulators (Micros eg Altair, and Terminals eg VT100) - index
My cruising website is ·www.bluemagic.biz
▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
Airspace V - international hangar flying!
www.airspace-v.com/ggadgets for tools & toys
1) You probably don't have to worry about initialising the EEPROM chip. By the time you get to it, it's already done! If not, then the Propeller probably would not have got as far as it did.
2) The timing of Chip's read is fogiven by the fact that the Propeller is SOOO much faster than I2C clocking rates - 20Mhz as opposed to 100kHz or 400kHz.
3) It is generally okay to drive the SCL line in both directions, as the Propeller is always going to be the I2C master (the master drives the clock). Now if ever the Propeller becomes an I2C slave, or other devices are going to talk amongst themselves on the I2C bus then this assumption is no longer valid. Strictly speaking, the pullup resistor could probably be omitted on SCL for most Propeller applications, although it does help define pre-boot conditions.
Regards,
▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
Carl Jacobs
JDForth - Forth to Spin Compiler http://www.jacobsdesign.com.au/software/jdforth/jdforth.php
Includes: FAT16 support for SD cards. Bit-bash Serial at 2M baud. 32-bit floating point maths.·Fib(28) in 0.86 seconds. ~3x faster than spin, ~40% larger than spin.