Shop OBEX P1 Docs P2 Docs Learn Events
BS2px & 24LC256 — Parallax Forums

BS2px & 24LC256

JDJD Posts: 570
edited 2011-08-03 12:27 in BASIC Stamp
I2C_test.bpxI hope I am just having a debunked brain moment. I keep getting zero values once I read the 24LC256 EEPROM after I write to it. I’m using I2COUT & I2CIN and I have the proper 4.7k resistors, like the diagram in the BASIC Stamp Syntax & Reference Manual. I've attached the simple code that I'm using below.

I have verified that the sample code works and I can write to the EEPROM with the Propeller (to verify that it’s a working unit) but for some reason I can’t get the BS2px to work with it.

Any thoughts?


I have review the Johnny Macs code for the BS2px, however the addressing is a little confusing. Can I not use the addressing that starts at 0?

Comments

  • gschreibgschreib Posts: 16
    edited 2011-08-01 12:15
    Hi JD,
    Try changing to "I2COUT datpin, $A0, 0\0, [value]" and ""I2CIN datpin, $A1, 0\0, [result]", if you haven't done it already. The addresses on this chip take two bytes, since there are 32k addresses. And of course, pin "6" of the EEPROM has to go to Port 0 on the BS2px. I know that this works on the BS2p because I just coded it.
  • JDJD Posts: 570
    edited 2011-08-01 23:12
    Thanks for the reply gschreib - :smile:

    I tried your advice and I only get 255 as the value from the EEPROM. There has to be something I am doing wrong, but since I have the Propeller working perfectly using the same 24LC256; I can't seem to put my finger on it using the BASIC Stamps. I've tried 2 different controllers and I get the same issue, very curious to say the least.
  • gschreibgschreib Posts: 16
    edited 2011-08-02 00:23
    JD,
    Sorry for the problem. I know how frustrating it can be. I just spent two and a half weeks getting the 23K256 SSRAM to work with the BS2p. I felt that the problem would turn out to be something I overlooked, or took for granted, and that did indeed end up being the case. I had just finished the code for the 24LC256 when I happened to read your post. I'm going to try to send you my code. (I'm new at this and I've only managed to attach
    a code page to this forum successfully once). Once you get the code you can load it (with the Directive changed), and see if it works. Like I said, it worked on the BS2p, and I don't see any large differences between the BS2px and the BS2p except for the operating current. I'll post this reply now and then try to attach in the next post...
  • gschreibgschreib Posts: 16
    edited 2011-08-02 00:54
  • gschreibgschreib Posts: 16
    edited 2011-08-02 01:08
    Sorry, I meant to take out that "switch" statement. Just delete that "sw" stuff. I left it in by accident. I always connect a push-button switch on my setups to make running the program a little easier. I didn't catch it until after I posted it. Anyway, please let me know how it turns out. If it doesn't work I've got a couple of other possibilities to look into... - gschreib
  • JDJD Posts: 570
    edited 2011-08-02 23:49
    Oddly, I am still getting 255 for the values. Thank you for the sample code though, sometimes it's just good to know if I'm using correct code. :smile:

    What resistors are you using on the DAT and CLK lines? I currently have 4.7k
  • gschreibgschreib Posts: 16
    edited 2011-08-03 05:48
    JD,
    Yes. I see that. It's quite extraordinary. Your code returns 255 on my setup too. (I am using 4.7k's); but my code works. At this moment, however, I can see no functional difference between my code and yours. They're both written to return the input to the debug screen. Well. This is fascinating. Of course I changed the Directive to indicate the BS2p (I don't have a px on hand...). Now I've got this splinter in my mind... I'm gonna play with it today. There has to be a simple explanation. I just can't see it yet. What the .... is going on here?...
  • gschreibgschreib Posts: 16
    edited 2011-08-03 06:49
    JD,
    I took your code and changed the Directive to BS2p. Then I put in "0\0" in the address arguments of the "WriteEEPROM" and "ReadEEPROM" GOSUB's. It works fine over here. Have you done this yet? (your Directive is BS2px, of course). Have you connected pin "6" of the 24LC256 physically to PORT 1 of the BS2px? Both those pins are, as you know, bidirectional for the I2C protocol.
    I had forgotten about those address statements when I wrote the last reply. Sorry about that. I'm gonna try to send you the "modified" code with the directive changed for your BS2px in the following reply. In case you haven't done it yet, those addresses are 32K, which needs 15 bits. (Two bytes with the MSBit ignored, as ",highbyte\lowbyte,"). I was getting 255 returns until I changed those address formats. Oh well, I don't always think properly in the morning before I gulp my coffee... So please let me know how it works. If it doesn't, we'll have some investigatin' to do... By the way, you don't need 250 ms to do a WRITE. I found that 2ms works, but I put in 5 for safety. And you don't need any delay on the READ statement. So let me try to send it over to you...
  • gschreibgschreib Posts: 16
    edited 2011-08-03 07:06
  • Mike GreenMike Green Posts: 23,101
    edited 2011-08-03 07:23
    I suggest you post a fresh copy of your most recent code and a diagram of your complete circuit showing all the pins of the 24LC256 (make sure this is drawn from your actual wiring, not what you think you have), then put a call in to Parallax Tech Support. Often puzzling problems like this one are more easily solved with a live one-on-one interaction.
  • JDJD Posts: 570
    edited 2011-08-03 09:20
    Thanks Mike and gschreib.

    Here is the latest code and now I have gschreib and I scratching our heads. I will draw up my wiring when I get home tonight, but here is a close up picture of what I have so far. The red and black wires go to Vdd (5V) and Vss (Gnd) respectively and the rest you can see pretty clearly. I can't figure out what I have wrong and there is only a handful of possibilities it can be, it's not like I have some huge wiring or coding project going on.. :-D


    I hope this helps.

    JD

    Wiring Photo -
    wiring.jpg

    Updated Code - I2C_test.bsp
    1024 x 765 - 126K
  • gschreibgschreib Posts: 16
    edited 2011-08-03 09:43
    JD,
    PORT 0 goes to SDA (pin 5 on the memory). PORT 1 goes to SCL (pin 6 on the memory). (You gotta flip the blue and the yellow around.) And it wouldn't hurt to put a couple of caps between the red and black
    wires. Like .1 uf and 10 uf. for "bypassing". Tell us if that works... - gschreib
  • JDJD Posts: 570
    edited 2011-08-03 10:27
    your kidding... opps... I thought I checked that like million times over.. :-D ... gschreib thanks a ton, now I can maybe add an LED to the project.. GND goes to Vdd right? hahaha no I'm just playing but thank you for your help.. I knew it was something simple that I was overlooking.
  • gschreibgschreib Posts: 16
    edited 2011-08-03 12:27
    JD,

    Yeah, like in life, it's the ones that you don't see that getcha.... This supports Mike Green's powerful suggestion to attach a schematic to the questions posed in this forum, (along with the code). I just haven't figured out how to do that schematic thing without learning the stupid and inscrutable Orcad again. So I'm working on DipTrace to do those jobs. It seems a lot easier to intuit. Well anyway, congrats on the EEPROM. Now you can store stuff... - gschreib
Sign In or Register to comment.