Shop OBEX P1 Docs P2 Docs Learn Events
I2CIN command should return 16 bits... — Parallax Forums

I2CIN command should return 16 bits...

ArthurArthur Posts: 2
edited 2006-10-15 20:44 in BASIC Stamp
Starting from an example I2C program I want to read the temperature from 2 LM76 chips from National Semiconductor. Some response is generated, so HW and SW work, even from both chips. So far so good.
But the response I get is not the 13Bit data that the chip should send, but only a fraction. And I found out that it is "temperature related", but it is only the MSB part.
My impression is that the I2CIN command is not reading the 13Bit (or more) but only 8Bit.

Is there a programming error? Can the I2CIN read more than 8 bits data?

Thanks,

Arthur

PS. the LM76 datasheet is available at www.national.com

Comments

  • Chris SavageChris Savage Parallax Engineering Posts: 14,406
    edited 2006-10-13 16:37
    Arthur,
    ·
    ·· If you’re trying to get 13 bits, you’ll need to input 2 bytes into your WORD variable.· For example, if you have a word variable called temperature you would need to do something like:
    I2CIN SDA, addr,0\0,[noparse][[/noparse]temperature.HIGHBYTE, temperature.LOWBYTE]
    

    These may need to be reversed depending on which order the device sends the data.· I hope this helps.· Take care.

    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
    Chris Savage
    Parallax Tech Support
  • metron9metron9 Posts: 1,100
    edited 2006-10-13 17:02
    If you are only reading 8 bits the chip will stop functioning until another 9 clock cycles have been clocked into the device. It will hold the SDA LOW until such time

    Datasheet page 9

    "An inadvertent 8-bit read from a 16-bit register, with the D7
    bit low, can cause the LM76 to stop in a state where the SDA
    line is held low as shown in Figure 4. This can prevent any
    further bus communication until at least 9 additional clock
    cycles have occurred. Alternatively, the master can issue
    clock cycles until SDA goes high, at which time issuing a
    “Stop” condition will reset the LM76."

    Before communication or in an event where the chip is not responding you can check for a low SDA line and issue clock cycles until the line is released (HIGH) and then issue a "Stop" condition

    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
    Think outside the BOX!
  • ArthurArthur Posts: 2
    edited 2006-10-15 20:44
    Hello Chris,

    Thanks very much for the advice! It works perfect. I can continue programming now.
    Regards,
    Arthur

    PS. Metron9, I am aware of the fact that further bus communication might be disturbed, but it didn't. The results were reproducible. But it is a good hint to check for a low SDA; I shall put extra tests in my code.

    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
    Skype arthurcloet
Sign In or Register to comment.