Shop OBEX P1 Docs P2 Docs Learn Events
BS2p I2C device problem! — Parallax Forums

BS2p I2C device problem!

SunztSunzt Posts: 9
edited 2007-03-20 17:37 in BASIC Stamp
I have a BS2px and i"m trying to read and write to some flash NVRAM using I2C. I looked all over the forums and some of the Nuts and Volts articles about I2C, but I still cannot get my RAM to work! Everytime I read from memory it's always 255 (FFFF) at each location!!!

Here's the specs on the RAM, it's a 512k Ferro-Magnetic Ram:
http://ramtron.com/lib/literature/datasheets/FM24C512ds_r1.0.pdf

I put 5.1k pull-up resistors (only had 5.1k's around) on the SDA and SCL line. I made sure the SDA connects to pin 8 and SCL connects to pin 9. I checked both the SDA and SCL line with an oscilloscope and the voltages act like information is going through the lines as I run the read and write code. It has power with Vdd = 4.97V. I'm not sure if there's anything wrong with my code. I tried writing with letters and numbers, but I always read back 255. Any help you guys might have would be greatly appreciated.



Here's the code I'm using for Writing:

Idx VAR Word

Main: 'Writes Flash Mem

DEBUG CR, "MemWrite", CR
PAUSE 1000

FOR Idx = 0 TO 32767 'Writes lower half of memory, which ends at 7FFF
I2COUT 8, $A0, Idx.HIGHBYTE\Idx.LOWBYTE, [noparse][[/noparse] 3 ] 'Writes Memory starting at Address 0
DEBUG "Addr: ", HEX4 Idx,
NEXT


Code for Reading:

MemValue VAR Byte
Idx VAR Word

Main: ' Reads flash memory

DEBUG CR, "MemRead", CR
PAUSE 1000

FOR Idx = 0 TO 32767 'reads lower half of memory, which ends at 7FFF
I2CIN 8, $A1, Idx.HIGHBYTE\Idx.LOWBYTE, [noparse][[/noparse]MemValue] 'Reads bytes of Memory starting at Address 0
DEBUG "Addr: ", HEX4 Idx, " " MemValueL: ", DEC MemValue, CR
NEXT

Post Edited (Sunzt) : 3/18/2007 1:18:20 AM GMT

Comments

  • Phil Pilgrim (PhiPi)Phil Pilgrim (PhiPi) Posts: 23,514
    edited 2007-03-17 23:32
    Did you remember to connect A1 and A2 on the FRAM to Vss? Also, in your code to write data, you're not writing anything: there are no [noparse][[/noparse]bracketed] arguments after the comma representing value(s) to write. (I'm surprised this didn't cause a syntax error, BTW.)

    -Phil
  • SunztSunzt Posts: 9
    edited 2007-03-18 01:16
    I thought A1 and A2 are internally grounded. As for the code, that was my typo. I accidentally deleted it.
  • SunztSunzt Posts: 9
    edited 2007-03-20 00:59
    I attached A1 and A2 to ground and I still read in 255 each time. The specs says that the max SCL clock frequency is 1Mhz. Is my BS2px sending and receiving data faster than that?
  • Chris SavageChris Savage Parallax Engineering Posts: 14,406
    edited 2007-03-20 17:37
    Hello,

    In looking through the documentation it appears the address lines and WP are internally pulled down. This is not the same as internally grounded since that suggests they cannot be changed. In any event it appears your code should work but I wonder if you’re sure of the pins you’ve connected to. Surface mount parts can be tricky, even to find pin 1 sometimes. As for I2C speed, the BS2px is well below the 1 MHz rating for this part. These numbers (speeds) are located in the Help File and the BASIC Stamp Manual under the I2CIN/I2COUT commands. Take care.

    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
    Chris Savage
    Parallax Tech Support
Sign In or Register to comment.