BS2P and 24LC256 EEPROM
Hello group!
Does anyone have any experience with the I2CIN and I2COUT commands
for the BS2P? I've gotten the other "flavors" of BS2 to work with the
24LC256 using the routines from my I2C tutorial
http://www.high-techgarage.com/tutorial/i2c.php but cannot do the
same thing with the built-in commands. I2CIN and I2COUT are much more
compact (probably faster too).
This is the code I am using. It should just write 32 bytes and then
read them back. The '256 is physically wired for address A2,A1,A0 =
000.
<
Start code
>
' {$stamp bs2p}
dta var byte
idx var byte
pause 100
for idx = 0 to 31
I2COUT 0,$A0,$00\idx,[noparse][[/noparse]idx*2]
pause 5
next
pause 1000
debug cls
for idx = 0 to 31
I2CIN 0,$A1,$00\idx,[noparse][[/noparse]dta]
debug "Loc: ", dec idx,tab,tab,"Data: ",dec dta,cr
next
<
End code
>
Thanks in advance,
--Jeff Wallace
* Add a RTC, 256k EEPROM and an I2C bus to your BS2
http://www.high-techgarage.com/products/timekeeper.php
Does anyone have any experience with the I2CIN and I2COUT commands
for the BS2P? I've gotten the other "flavors" of BS2 to work with the
24LC256 using the routines from my I2C tutorial
http://www.high-techgarage.com/tutorial/i2c.php but cannot do the
same thing with the built-in commands. I2CIN and I2COUT are much more
compact (probably faster too).
This is the code I am using. It should just write 32 bytes and then
read them back. The '256 is physically wired for address A2,A1,A0 =
000.
<
Start code
>
' {$stamp bs2p}
dta var byte
idx var byte
pause 100
for idx = 0 to 31
I2COUT 0,$A0,$00\idx,[noparse][[/noparse]idx*2]
pause 5
next
pause 1000
debug cls
for idx = 0 to 31
I2CIN 0,$A1,$00\idx,[noparse][[/noparse]dta]
debug "Loc: ", dec idx,tab,tab,"Data: ",dec dta,cr
next
<
End code
>
Thanks in advance,
--Jeff Wallace
* Add a RTC, 256k EEPROM and an I2C bus to your BS2
http://www.high-techgarage.com/products/timekeeper.php
Comments
to stamp pin 0 and SLC on i2c chip must be on stamp pin 1.
Chuck[/font]
this so frustrating!
--- In basicstamps@y..., CHIPKEN@a... wrote:
> Do you have 4.7k pullups on pins 0 and 1? SDA on i2c chip must be
connected
> to stamp pin 0 and SLC on i2c chip must be on stamp pin 1.
> Chuck
-Steve
At 05:00 PM 05/31/2001 -0000, you wrote:
>Yes. It is wired correctly and has the resistors. That is what makes
>this so frustrating!
>
>--- In basicstamps@y..., CHIPKEN@a... wrote:
>> Do you have 4.7k pullups on pins 0 and 1? SDA on i2c chip must be
>connected
>> to stamp pin 0 and SLC on i2c chip must be on stamp pin 1.
>> Chuck
>
>
>To UNSUBSCRIBE, just send mail to:
> basicstamps-unsubscribe@yahoogroups.com
>from the same email address that you subscribed with. Text in the Subject
and Body of the message will be ignored.
>
>
>Your use of Yahoo! Groups is subject to http://docs.yahoo.com/info/terms/
>
>
Nice web site you have....
Regards,
-Steve
At 12:25 PM 05/31/2001 -0500, you wrote:
>Doesn't the address variable need to be word length?
>
>-Steve
>
>
>
>
>At 05:00 PM 05/31/2001 -0000, you wrote:
>>Yes. It is wired correctly and has the resistors. That is what makes
>>this so frustrating!
>>
>>--- In basicstamps@y..., CHIPKEN@a... wrote:
>>> Do you have 4.7k pullups on pins 0 and 1? SDA on i2c chip must be
>>connected
>>> to stamp pin 0 and SLC on i2c chip must be on stamp pin 1.
>>> Chuck
>>
>>
>>To UNSUBSCRIBE, just send mail to:
>> basicstamps-unsubscribe@yahoogroups.com
>>from the same email address that you subscribed with. Text in the Subject
>and Body of the message will be ignored.
>>
>>
>>Your use of Yahoo! Groups is subject to http://docs.yahoo.com/info/terms/
>>
>>
>
>To UNSUBSCRIBE, just send mail to:
> basicstamps-unsubscribe@yahoogroups.com
>from the same email address that you subscribed with. Text in the Subject
and Body of the message will be ignored.
>
>
>Your use of Yahoo! Groups is subject to http://docs.yahoo.com/info/terms/
>
>
Thanks for checking out the website! The 24LC256 does need a word
address. However, the I2C bus can only handle bytes (8-bits) at a
time. That was what the $00\idx part of the code did. The highbyte
was $00 and the lowbyte was idx. The word address is then (when
idx=1) $0001.
Thanks again!
--Jeff Wallace
*Add a RTC, 256k EEPROM and an I2C bus to your BS2
http://www.high-techgarage.com/products/timekeeper.php
--- In basicstamps@y..., sargent@s... wrote:
> Oh Yeah,
>
> Nice web site you have....
>
> Regards,
>
> -Steve
>
>
>
>
> At 12:25 PM 05/31/2001 -0500, you wrote:
> >Doesn't the address variable need to be word length?
> >
> >-Steve
> >
> >
> >
> >
> >At 05:00 PM 05/31/2001 -0000, you wrote:
> >>Yes. It is wired correctly and has the resistors. That is what
makes
> >>this so frustrating!
> >>
> >>--- In basicstamps@y..., CHIPKEN@a... wrote:
> >>> Do you have 4.7k pullups on pins 0 and 1? SDA on i2c chip must
be
> >>connected
> >>> to stamp pin 0 and SLC on i2c chip must be on stamp pin 1.
> >>> Chuck
> >>
> >>
> >>To UNSUBSCRIBE, just send mail to:
> >> basicstamps-unsubscribe@y...
> >>from the same email address that you subscribed with. Text in
the Subject
> >and Body of the message will be ignored.
> >>
> >>
> >>Your use of Yahoo! Groups is subject to
http://docs.yahoo.com/info/terms/
> >>
> >>
> >
> >To UNSUBSCRIBE, just send mail to:
> > basicstamps-unsubscribe@y...
> >from the same email address that you subscribed with. Text in the
Subject
> and Body of the message will be ignored.
> >
> >
> >Your use of Yahoo! Groups is subject to
http://docs.yahoo.com/info/terms/
> >
> >
It was a shot in the dark, I've never used the Stamps built in I2C
commands. After glancing at the manual, it sure appears to be complicated
sending a word sized variable for the address? The manual has some examples
on writing and reading, which I'm sure you have seen... You may want to
start out just trying to write a single byte? I've found the 24LC256 to be
a very forgiving and robust part
good luck,
Steve
I agree with you on the I2C commands. They aren't very flexible....
Maybe I'm just not understaning them. For example, most EEPROM have a
sequential read/write feature which allows you to write 16,32,64 etc.
bytes in a "burst mode." As far as I can tell, you cannot do that
with the I2C commands. I took the sample routines from the tutorial
and the data wrote/read perfectly. It takes up more room and is
slightly slower, but it DOES work.
Thanks for the input!
--Jeff
* Add a RTC, 256k EEPROM and an I2C bus for under $40!
http://www.high-techgarage.com/products/timekeeper.php
have a bad pin connection on the stamp. Try stamp pins 8 and 9 instead.
Chuck[/font]
writes:
Maybe I'm just not understaning them. For example, most EEPROM have a
sequential read/write feature which allows you to write 16,32,64 etc.
bytes in a "burst mode." As far as I can tell, you cannot do that
with the I2C commands. I took the sample routines from the tutorial
and the data wrote/read perfectly. It takes up more room and is
slightly slower, but it DOES work.
You can move an number of bytes from an I2C device into the BS2P's scratchpad
RAM with this syntax:
I2CIN pin,slave_addr,hi_addr\lo_addr,[noparse][[/noparse]SPSTR x]
Where x is the number of bytes you want to transfer from the I2C device into
the Stamp's scratchpad RAM. ·Once it's there, you can deal with it
accordingly (retrieve with GET). ·You can also use this technique to transfer
data into a byte array.
HTH
-- Jon Williams
-- Dallas, TX
-- Applications Engineer, Parallax[/font]
Thank you for the pointer! That significantly increases the power of
the I2C commands (and my understanding of them!). Regarding the
sample code you gave: can you specify what part of the RAM it starts
transfering from? Does it always start at 0 or can you specify an
offset?
If you have a minute, would you mind looking at the original code I'm
using? (It looks OK to me, but now I'm pullin' clumps of hair) I have
the EEPROM set up with slave address (A2,A1,A0), with pull-up
resistors (4.7k) and WP grounded. The SDA and SCL lines are properly
connected. My I2C routines work fine, so I know it isn't the chip or
the connections.
Here is the original code:
<
Start code
>
' {$stamp bs2p}
dta var byte
idx var byte
pause 100
for idx = 0 to 31
I2COUT 0,$A0,$00\idx,[noparse][[/noparse]idx*2]
pause 5
next
pause 1000
debug cls
for idx = 0 to 31
I2CIN 0,$A1,$00\idx,[noparse][[/noparse]dta]
debug "Loc: ", dec idx,tab,tab,"Data: ",dec dta,cr
next
<
End code
>
>
> You can move an number of bytes from an I2C device into the BS2P's
> scratchpad RAM with this syntax:
>
> I2CIN pin,slave_addr,hi_addr\lo_addr,[noparse][[/noparse]SPSTR x]
>
> Where x is the number of bytes you want to transfer from the I2C
> device into the Stamp's scratchpad RAM. Once it's there, you can
> deal with it accordingly (retrieve with GET). You can also use
> this technique to transfer data into a byte array.
You check, and you check, and then recheck.... I was concentrating so
hard on the code, I neglected to check the value of the resistor. It
works now....
Thanks for the help!
--- In basicstamps@y..., CHIPKEN@a... wrote:
> Your software is OK. I tried it out on a 24LC64 and it worked fine.
> You may have a bad pin connection on the stamp. Try stamp pins 8
> and 9 instead.
writes:
the I2C commands (and my understanding of them!). Regarding the
sample code you gave: can you specify what part of the RAM it starts
transfering from? Does it always start at 0 or can you specify an
offset?
SPSTR always starts at address 0 in the scratchpad and works its way up. ·If
you're using PUT to save things the SPRAM, it's a good idea to save those
things toward the top (from location 126 and on down) to avoid any conflicts.
using? (It looks OK to me, but now I'm pullin' clumps of hair) I have
the EEPROM set up with slave address (A2,A1,A0), with pull-up
resistors (4.7k) and WP grounded. The SDA and SCL lines are properly
connected. My I2C routines work fine, so I know it isn't the chip or
the connections.
So...what's the problem? ·Did Chuck Gracey not comment on an earlier thread
that you may have a bad pin on your BS2p? ·Have you tried the pin 8/9 group?
<
Start code
>
' {$stamp bs2p}
dta ···var ···byte
idx ···var ···byte
pause 100
for idx = 0 to 31
I2COUT 0,$A0,$00\idx,[noparse][[/noparse]idx*2]
pause 5
next
pause 1000
debug cls
for idx = 0 to 31
I2CIN 0,$A1,$00\idx,[noparse][[/noparse]dta]
debug "Loc: ", dec idx,tab,tab,"Data: ",dec dta,cr
next
Looks good to me too....[/font]
values were wrong. Swapped them with 10k and the code works on both
ports. Thanks for the help!
--JW
> scratchpad RAM with this syntax:
>
> I2CIN pin,slave_addr,hi_addr\lo_addr,[noparse][[/noparse]SPSTR x]
>
> Where x is the number of bytes you want to transfer from the I2C
> device into the Stamp's scratchpad RAM. Once it's there, you can
> deal with it accordingly (retrieve with GET). You can also use
> this technique to transfer data into a byte array.
Does this SPSTR modifier continue generating ACK's after each byte is
received, or does it go through the START-STOP procedure for each
byte? Also, most of the EEPROMs I've used require a NACK during
reads. Does the I2CIN routine generate a NACK? (There is no mention
of it in the manual, and the timing diagrams show an ACK before a
STOP). Is there anyway to use the SPSTR command in reverse? I.e. can
I write 64 bytes sequentially without needing a START and STOP
condition for each byte?
I'm trying to get this snippet of code which uses the SPSTR modifier,
but I'm running into a wall. When I get each of the 64 bytes
individually, I can debug the proper value on the screen. However,
when I use the SPSTR modifier, all of the values are 255 with the
exception of the 64th byte which is 0. Here is the code I'm using:
<
Start code snippet
>
for index = 0 to 63
I2COUT 0,$A0,$00\index,[noparse][[/noparse]index]
pause 10
next
pause 1000
I2CIN 0,$A1,$00\$00,[noparse][[/noparse]SPSTR 64]
for index = 0 to 63
get index,i2cbyte
debug "Loc: ",dec index,tab,tab,"Data: ", dec i2cbyte,cr
next
<
End of code snippet
>
Thanks in advance!
--Jeff Wallace
http://www.high-techgarage.com/