Shop OBEX P1 Docs P2 Docs Learn Events
BS2p and MAX127 ADC — Parallax Forums

BS2p and MAX127 ADC

edited 2008-12-30 02:44 in BASIC Stamp
Hello. I like to connect my BS2p to a MAX127 12Bit ADC. My problem is how to write I2C command.

I need to initialize the device like:

START | SlaveAddr-Byte |A| Control-Byte |A| STOP

...to read the device:

START | SlaveAddr-Byte |A| Data-Byte (D11-D4) |A| Data-Byte (D3-D0 + 0000) |A| STOP


Is there anybody who can explain me how to write this program? Please!!!

Comments

  • Mike GreenMike Green Posts: 23,101
    edited 2008-12-30 02:26
    Read the chapters in the Stamp Basic Syntax and Reference Manual on the I2C statements (I2CIN / I2COUT). These statements will take care of the start and stop transitions and the acknowledge bits. You only have to deal with the actual data bytes.
  • edited 2008-12-30 02:36
    I read it already, but I don´t know how to do. Could u give me a hint? Please. I don´t want a complet program,just how to use this command.

    I tried the 24C16 EEPROM program. That works fine, but this ADC don´t wanne communicate with my BS2p (Hardware is double-checkt).
  • Mike GreenMike Green Posts: 23,101
    edited 2008-12-30 02:44
    I don't have my manual handy, but you would use the I2COUT and I2CIN·statements, something like
    I2COUT <pin>,<slave address>,[noparse][[/noparse]<control byte>]
    I2CIN <pin>,<slave address>,[noparse][[/noparse] dataByte1, dataByte2 ]

    dataByte1 and dataByte2 are byte variables that store the received values.

    I think <pin> is 0 or 8 since the SCL and SDA lines have to be connected to pins 0/1 or pins 8/9.

    <slave address> is the device select value. The Stamp takes care of the input/output bit.

    <control byte> is a control value or register number (depending on the device)

    I may have some of this wrong, but you should be able to correct it with the manual chapter.
    The Stamp does a write transfer first to send the control information. It then readdresses the
    device for a read transfer for the information expected.
Sign In or Register to comment.