Shop OBEX P1 Docs P2 Docs Learn Events
Problem getting I2C to work — Parallax Forums

Problem getting I2C to work

blacksheep45blacksheep45 Posts: 41
edited 2009-01-22 11:52 in BASIC Stamp
I have set up the circuit the way it is in the·Basic Stamp·syntax and reference manual and i am using the sample code I2C.bsp, but this is not working. When the code is at the reading part it debugs "Error at location 000" "Found: 255, Expected: 000".
I am not sure what is wrong, can someone help.

Kind Regards

Shaun

Comments

  • dandreaedandreae Posts: 1,375
    edited 2009-01-19 16:18
    Can you attach your code as a .bsp file so that we can look at it?



    Regards,



    Dave

    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
    Dave Andreae

    Parallax Tech Support·
  • blacksheep45blacksheep45 Posts: 41
    edited 2009-01-19 16:36
    Hi Dave,

    Here is the code that i am using.

    Kind Regards

    Shaun
  • Chris SavageChris Savage Parallax Engineering Posts: 14,406
    edited 2009-01-19 17:26
    Shaun,

    You may want to post a high-resolution picture of your circuit as well. We may spot something from that.

    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
    Chris Savage
    Parallax Engineering
  • Mike GreenMike Green Posts: 23,101
    edited 2009-01-19 17:27
    Are you sure you have a 24LC16B EEPROM? Are you sure you hooked it up correctly?

    The output you showed suggests that the writing is not occurring. Did you connect WP (write protect - pin 7) to Vss (ground)?
  • blacksheep45blacksheep45 Posts: 41
    edited 2009-01-19 17:41
    I am unable to get a picture of the board but will try to get 1 tomorrow. Also i am using a 24LC32A EEPROM chip. Would the code or the wiring be different for this chip as i thought it might just be the same.
    I have connected WP to Vss, as well asA0, A1, A2 and Vss.
    Pin 8 (Vdd) on the EEPROM is connected to Vdd as ar pins 5 and 6 via a 4700 ohm resistor.
    Pin 5 on the EEPROM is also connected to pin 0 on the BS2p40
    Pin 6 on the EEPROM is also connected to pin 1 on the BS2p40

    I hope someone can help. I will try to get a pic of the circuit tomorrow.

    Kind Regards

    Shaun
  • servelloservello Posts: 113
    edited 2009-01-19 22:03
    Is this the circuit? This is taken from page 219 of the BASIC Stamp Manual.

    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
    Deus tantum me iudicabit
    283 x 216 - 20K
  • Mike GreenMike Green Posts: 23,101
    edited 2009-01-19 23:56
    The wiring is the same, but the 24LC32a requires a two byte address while the 24LC16B requires a one byte address plus it puts some of the address bits in the select code. Read the datasheets for the differences.

    The PBasic Manual describes how to produce a two byte address with the I2CIN and I2COUT statements.· I don't have mine handy, but it's pretty clear

    Post Edited (Mike Green) : 1/20/2009 12:02:45 AM GMT
  • Chris SavageChris Savage Parallax Engineering Posts: 14,406
    edited 2009-01-20 00:06
    blacksheep45 said...(trimmed)
    I am unable to get a picture of the board but will try to get 1 tomorrow. Also i am using a 24LC32A EEPROM chip. Would the code or the wiring be different for this chip as i thought it might just be the same.
    Shaun,

    ·· There is no need for the picture now...you have provided the information that was missing.· Your initial post indicated everything was the same as the example, but in fact you're using a different chip which is not directly compatible with that code (as Mike idientified).· This is why it is important to be clear about details and provide as much information as possible.· Take care.

    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
    Chris Savage
    Parallax Engineering
  • PJAllenPJAllen Banned Posts: 5,065
    edited 2009-01-20 00:14
    24LC32.bs2
  • blacksheep45blacksheep45 Posts: 41
    edited 2009-01-20 14:46
    In the stamp book that i have, for the low address argument it simply says if tha address is 2050 use 8 as the address and 2 as the low address (8*256 + 2 =2050).
    So does this mean that the low address is only used after·the address 255 on the EEPROM, also·using the sample code that i attached earlier, would i put the \low address after addr·variable? or after the block variable on the I2C commands. I would have thought after the addr but im not 100%.

    Thank you for the code PJ Allen however, i only have a bs2p just now, so i was wondering if anyone had code for this using a BS2p.

    Kind Regards

    Shaun
    ·
  • kelvin jameskelvin james Posts: 531
    edited 2009-01-20 17:37
    Try this.


    **
  • blacksheep45blacksheep45 Posts: 41
    edited 2009-01-21 13:26
    hello,

    sorry kelvin but that code is not working either, it just displays 255 fifteen time accross 1 row, im guessing its supposed to display all the numbers in the string instead.

    I think it must be my wiring that is wrong, i have taken pics of the circuit but i cant find the cd with the software to connect my phone to my computer, but i'll post them as soon as i can.

    Kind Regards

    Shaun
  • blacksheep45blacksheep45 Posts: 41
    edited 2009-01-21 16:48
    Sorry Kelvin your code did work. I forgot that i tried connecting the SCL and SDA to pins 8 and 9 on the stamp. When i realised this and changed them back to match the code it worked.

    Regards

    Shaun
  • kelvin jameskelvin james Posts: 531
    edited 2009-01-21 17:31
    Good to hear it works. I forgot about this example program that was in stampworks you could look at. Just change the pin definitions to 0 and 1 in the program.

    **
  • blacksheep45blacksheep45 Posts: 41
    edited 2009-01-22 11:52
    Would it be possible to connect two bs2p40 modules together via the EEPROM and if so would the second stamp be connected to the EEPROM in the same way as the 1st. Also would the 2 stamps need to have pins connected together and how would the 1st stamp signal the 2nd stamp to begin?

    kind regards

    Shaun
Sign In or Register to comment.