Shop OBEX P1 Docs P2 Docs Learn Events
i2c help please! — Parallax Forums

i2c help please!

ksrenterprises1ksrenterprises1 Posts: 8
edited 2008-03-24 03:53 in BASIC Stamp
I need help with i2c. I am trying to communicate with a winbond chipcorder 5116. I have a stamp bs2pe. I have two pull up 4.7k resistors on the i2c lines. One on the sda and one on the scl. my sda line is on pin 8 and scl line is on pin 9. You can·see the manual here:·········································· ······························· http://www.winbond-usa.com/products/isd_products/chipcorder/datasheets/5100/ISD5100g.pdf

the command codes are as follows(all hex);(see pg 18 in manual)
power up· 80
analog record· 90

here is the code im trying: i2cout 8, $80, [noparse][[/noparse]$80, $90]

'the first $80 is my adress. (both the a0 and a1 pins are grounded on the chipcorder)
' the second $80 is my power up command
'the $90 is my analog record command.

Is this right? if so why doesn't it work? If not then how do i do this?

Sorry if i seem stupid but this is my very first project with a microcontroller. I only program ladder logic plc.

Comments

  • PJAllenPJAllen Banned Posts: 5,065
    edited 2008-03-23 06:12
    Are two bytes allowed in one I2COUT ?· All of the examples in PBASIC Help and the Nuts&Volts articles show only one byte with I2COUT.

    I2COUT·8, $80, [noparse][[/noparse]$80]
    I2COUT·8, $80, [noparse][[/noparse]$90]

    Post Edit -- I see there are uses of arrays (STR), but no specific instance of one value succeeded by another as output data in the same argument.

    Post Edited (PJ Allen) : 3/23/2008 6:17:40 AM GMT
  • Mike GreenMike Green Posts: 23,101
    edited 2008-03-23 06:35
    PJ,
    Multiple bytes are allowed, but they have specific purposes. One I2COUT statement is a single transaction with an I2C start sequence at the beginning, then the device code and any address bytes, then the data bytes followed by a stop sequence. For EEPROMs, as an example, this causes a paged write to be performed. There are restrictions on how much data can be supplied with a paged write and the amount of data and starting EEPROM address is important or you can write the data to the wrong locations in the EEPROM. Different devices handle multiple data bytes in different ways. Different devices may only require one address byte or no address bytes. The device datasheets usually show detailed diagrams of what's expected.

    Looking at the Winbond documentation, what they call the slave address is the I2C device select code in the I2C statements and there is no address information. Everything else is considered data. The default slave address is $80. You're absolutely correct that the command bytes ($80 and $90) need to be sent as separate I2COUT statements because they're separate transactions.

    Post Edited (Mike Green) : 3/23/2008 6:44:45 AM GMT
  • Beau SchwabeBeau Schwabe Posts: 6,568
    edited 2008-03-23 06:44
    PJ Allen,
    ·
    I believe that you are correct. You can find more information·from within·the Stamp Editor, if you type and highlight the word I2COUT and press F1 you will get a help screen.
    ·
    Basically you have ...
    ·
    (START)(Slave ID)(ACK)(Address)(ACK)(Data)(ACK)(STOP)
    ·
    ... in the line:
    i2cout 8, $80, [noparse][[/noparse]$80, $90]
    ·
    .... $90 is viewed as being 'Data' and not an Address (or Command)
    ·
    According to the pdf datasheet ( top of page 15 ) there is nothing that should be after the command byte, so ...
    ·
    I2COUT·8, $80, [noparse][[/noparse]$80]
    I2COUT·8, $80, [noparse][[/noparse]$90]
    ·
    ...looks to be the correct way to send data in this case.
    ·




    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
    Beau Schwabe

    IC Layout Engineer
    Parallax, Inc.
  • ksrenterprises1ksrenterprises1 Posts: 8
    edited 2008-03-23 17:24
    Ok, so I tried this and nothing. So i guess i better check my wiring. also the chipcorder is powered by 3volts, but i have my i2c powered by 5 volts. Does that matter? and should i have pin a0 and a1 on the chipcorder grounded? as far as volume and mic in and all that i shouldn't have to adjust any of that should i?(maybe the chipcorder needs configured before it works.)
  • Mike GreenMike Green Posts: 23,101
    edited 2008-03-23 17:57
    There is a long discussion in this thread http://forums.parallax.com/showthread.php?p=585920 about interfacing 5V I2C logic to the 3.3V Propeller. The same information applies to using a 3.3V I2C device on a 5V I2C bus. Directly connecting a 5V I2C bus to 3.3V I2C logic can be a problem because the 5V from the pullup resistors can cause the protective diodes on the 3.3V part to conduct into the +3.3V supply on chip. Usually the pullup resistors will limit the current enough so the part won't be damaged, but it can still cause problems with noise.

    Any address select pins on the chipcorder need to be connected to ground through pulldown resistors unless the datasheet says you can ground them directly (in order to use the zero device address. As with anything like this, read the datasheet thoroughly for information on how to control it, what command sequences are needed, and what kind of initialization is required.
  • ksrenterprises1ksrenterprises1 Posts: 8
    edited 2008-03-24 02:32
    I rewired the board and now all i have connected are the two i2c lines with 4.7k pull ups and my 3v regulator to power chipcorder. for some reason my regulator is putting out 4.5 volts but i think that is not too high to hurt the chipcorder. now in order to read the voltage drop on the i2c lines during communication will i need to use an osciliscope? I have tried using a multimeter and i see it go from like 4.7v to 4.5v. shouldn't it drop lower?
  • Bruce BatesBruce Bates Posts: 3,045
    edited 2008-03-24 03:40
    The first thing I would do at this juncture is to try to determine why the output of the voltage regulator isn't 3.0 VDC or whatever it should be for your needs. Whether it will hurt the chipcorder may not be all that important, it's a sign that something is wrong in the design of the circuit, or it may indicate a faulty regulator. Check the datasheet for the regulator for the appropriate wiring, and circuit component values.

    The multimeter should be fine for measuring the voltage, but if the voltage is too high to start, then you will probably get readings that are higher than you may expect.

    Regards,

    Bruce Bates

    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
    Involvement and committment can be best understood by looking at a plate of ham and eggs. The chicken was involved, but the pig was committed. ANON
  • ksrenterprises1ksrenterprises1 Posts: 8
    edited 2008-03-24 03:53
    ok. i fixed the regulator. BUT, i had the pinouts wrong on the chipcorder. i thought the pinouts were: pin1 at top left and pin 15 at top right. they are actually pin 1 top left and pin 14 BOTTOM right.

    Damn! I guess i will call winbond and see if there is a way to check if i hurt the chipcorder or not. I also noticed that at the beginning of the chipcorder data sheet it says pin 1 and 3 are the i2c pins but at the end of the data sheet it says they are pin 1 and 2. thanks for the help and i will get back with you guys after i get word from winbond.
Sign In or Register to comment.