i2c help, I'm a propeller newb and I need help to get the i2c running to drive
FireHopper
Posts: 180
www.sparkfun.com/commerce/product_info.php?products_id=8579
It looks easy to use.. but I need a bit of help.. I looked at some of the I2c objects, but they seem to be for eeproms mostly.. not very helpfull.
thanks for any help I can get.
It looks easy to use.. but I need a bit of help.. I looked at some of the I2c objects, but they seem to be for eeproms mostly.. not very helpfull.
thanks for any help I can get.
Comments
Where is it, I didnt see it on the exchange. I'm reading the i2c demo app v2 and am reading it.. Its a bit over my head, but I'm slowly making headway
http://www.rayslogic.com/propeller/Programming/I2C/I2C.htm
Someone took it and posted it to OBEX.· Normally, this would annoy me, but since it was really Mike Green's code anyway, I don't complain!
If you search OBEX for I2C, you'll find it there too...
Ray
▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
My Prop Info&Apps: ·http://www.rayslogic.com/propeller/propeller.htm
Below is an example from some code I just grabbed. Note that there is first a 'start' condition that includes the SCL pin number. Then the address plus write bit. Then another byte that tells the I2C device where (the register address) to read from. After setting this info, there is a 'stop' sent. Next there is another 'start' condition, address plus READ bit (1), read the first byte, then read the next byte while putting the data into a WORD correctly using bitshift, then a STOP. After the data was read, return with the info requested. Of course what you are trying to accomplish will be different, but the datasheet will usually tell you what is required to either read or write from the device.
Post Edited (TChapman) : 5/14/2009 1:09:19 AM GMT
but to test it I only need to send commands to address $00 (broadcast addie)
[noparse][[/noparse]/code]
Using the minimali2cdriver I posted, it translates to something like this:
Theoretically if you have everything hooked up right, you should get RED. You may be able to delete the 'f' fade line and have it still work without a fade.
Post Edited (TChapman) : 5/14/2009 2:06:27 AM GMT
I'm going to order one or two of those blink M's so I can test code and stuff.
Using the minimali2cdriver I posted, it translates to something like this:
Theoretically if you have everything hooked up right, you should get RED. You may be able to delete the 'f' fade line and have it still work without a fade.
where you have it sending $09, I think you have the binary value wrong.. that looks to be $08, should be %0000_1001 I think.
anyway.. my blinkm's should arrive tomorrow. so I'll see if this works and hack it to do what I want
will fiddle some more a bit later.
Post Edited (TChapman) : 5/15/2009 6:42:19 PM GMT
I'm connecting it up via the diagram in the manual, gnd, 5 volt, and sda and sclk
sda is on 23, and scl is 22
00 - broadcast blinkm
18 - blinkm(2 of them default address.)
160 - eeprom address.
so I'm getting there [noparse]:)[/noparse]
now all I need to do is to try the other code bit.
CON
· _clkmode·············· = xtal1 + pll16x
· _xinfreq·············· = 5_000_000·
··· 'Physical Inputs
··· i2cSCL············· = 0···· '<<<<<<set your actual pins here
··· i2cSDA············· = 1
OBJ
··· i2c······· : "minimali2cdriver"················
PUB Start
····· i2c.i2cstart(i2cSCL)
····· TES·· 'run the i2c method below
········ repeat·· 'stay alive
PUB TES
·· i2c.i2cstart(i2cSCL)··· 'start condition··· send SCL pin number
·· i2c.i2cwrite(i2cSCL, %0001_0010)··· 'send address $09 plus write bit '0'
·· i2c.i2cwrite(i2cSCL, "n")····· 'not sure here about this i2c driver sending 'f' as a ascii, may need to convert to hex first?· someone comment
·· i2c.i2cwrite(i2cSCL, $FF)··· 'value for red channel to $FF
·· i2c.i2cwrite(i2cSCL, $00)··· 'value for blue channel to $00
·· i2c.i2cwrite(i2cSCL, $00)··· 'value for green channel $00
·· i2c.i2cstop(i2cSCL)····· 'stop condition
▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔ D Rat
Dave Ratcliff· N6YEE
Post Edited (ratronic) : 5/15/2009 10:03:50 PM GMT
everything else seems to work though
pub set························································································
· i2c.i2cstart(i2cSCL)······················ 'start condition··· send SCL pin number······························
· i2c.i2cwrite(i2cSCL, %0000_0000)··· 'send general call address of '0'························
· i2c.i2cwrite(i2cSCL, "A")·················'send·set address command of·'A'
· i2c.i2cwrite(i2cSCL, %0000_1001)··· 'new address you want (x09) for blinkm···················
· i2c.i2cwrite(i2cSCL, $d0)················'send 'd0'
· i2c.i2cwrite(i2cSCL, $0d)················'send '0d'
· i2c.i2cwrite(i2cSCL, %0000_1001)··· 'new address you want (x09)for blinkm (repeated)
· i2c.i2cstop(i2cSCL)······················· 'stop condition·····················································
▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔ D Rat
Dave Ratcliff· N6YEE
once I do that, then I can setup a program to do that one at a time for each one I get.
▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔ D Rat
Dave Ratcliff· N6YEE
this now works.. I had to use this code to set each blinkm's address..
it does work. so I'm happy.. I think my issue with the address set was that I was using f11 which put it in eeprom, so that as soon as I powered it up with both blinkm's installed. it would set both again [noparse]:)[/noparse] so when I do the set address I'm doing it as f10, which only programmed the ram.