Basic I2C Driver help [SOLVED]
Bobb Fwed
Posts: 1,119
What am I doing wrong here?
I am trying to write "test" to my eeprom.
But it looks like it isn't all being written. All I get back when I read the address it "t".
▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
April, 2008: when I discovered the answers to all my micro-computational-botherations!
Post Edited (Bobb Fwed) : 8/3/2009 10:46:59 PM GMT
I am trying to write "test" to my eeprom.
But it looks like it isn't all being written. All I get back when I read the address it "t".
CON _CLKMODE = XTAL1' + PLL4X _XINFREQ = 5_000_000 ' 5MHz Crystal start_table = $3FFF OBJ DEBUG : "FullDuplexSerial" i2c : "Basic_I2C_Driver" VAR BYTE val[noparse][[/noparse]32] PUB Main | i, v DEBUG.start(31, 30, 0, 57600) waitcnt(clkfreq + cnt) DEBUG.tx($0D) i2c.Initialize(i2c#BootPin) bytefill(@val, 0, 32) bytemove(@val, string("test"), 32) write_table REPEAT i FROM 0 TO 32 v := read_table(start_table + i) IF (v == 0) quit DEBUG.tx(v) DEBUG.tx($0D) PUB write_table | time IF i2c.WritePage(i2c#BootPin, i2c#EEPROM, start_table, @val, 32) abort time := cnt repeat while i2c.WriteWait(i2c#BootPin, i2c#EEPROM, start_table) if cnt - time > clkfreq / 10 abort PUB read_table (addr) : ret_val IF i2c.ReadPage(i2c#BootPin, i2c#EEPROM, addr, @val, 1) abort return val
▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
April, 2008: when I discovered the answers to all my micro-computational-botherations!
Post Edited (Bobb Fwed) : 8/3/2009 10:46:59 PM GMT
Comments
To show you that it works with the internal EEPROM I enabled a section of my demo right a string to the EERPROM and then read it back. The mechanism I use may be helpful, i.e., you don't have to read back one character at a time.
▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
April, 2008: when I discovered the answers to all my micro-computational-botherations!
Thanks.
▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
April, 2008: when I discovered the answers to all my micro-computational-botherations!
▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
April, 2008: when I discovered the answers to all my micro-computational-botherations!
Obex item /464/ contains maybe the smallest and correct SPIN I2C driver for boot EEPROMS. Although, it is not the fastest! Supplied with a plethora of SPIN I2C drivers, I am still waiting for a stand alone I2C driver in PASM to appear somewhere. This delay is·a good excuse for me not to update the I2C protocol based driver·of the FPU on OBEX.
Cheers,
Istvan
(P.S.: I mean, that the basic I2C driver task is maybe NOT SOLVED yet.)
Post Edited (cessnapilot) : 8/4/2009 8:34:52 AM GMT
Different part, I'm using an MCP3221, but I'm a total I2C newbie and the examples in the obex all assumed that I knew more than I did - I couldn't get any of them to work, even one that was supposed to be written specifically for the MCP3xxx series parts.
But just last night I finally got it working perfectly, thanks to Jon's example code attached to this thread. His code was just short and simple enough to make sense with the part documentation.
Thanks, Jon!
▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
April, 2008: when I discovered the answers to all my micro-computational-botherations!
i believe the code i wrote (for the 8th time) is legit and follows the timing diagrams well (for SPIN) i would like to make a PASM version but i'm not willing to make one thats going to communicate wrong with a device.
▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
Quicker answers in the #propeller chat channel on freenode.net. Don't know squat about IRC? Download Pigin! So easy a caveman could do it...
http://folding.stanford.edu/ - Donating some CPU/GPU downtime just might lead to a cure for cancer! My team stats.