ADC121C021 I2C problems


Closed Thread
Results 1 to 5 of 5
  1. #1
    Join Date
    Jun 2009
    Location
    Cambridge, England
    Posts
    9

    Default ADC121C021 I2C problems

    I am having problems reading a ADC121C021 12 bit ADC with PBP.

    From the data sheet it appears that the slave address is 54h and the conversion result register is 0h.

    However, when I use the code below I get a read error.

    I have written a routine to cycle addresses from 0 to 255 to see if I could find a slave address that does work.

    I have found that a slave address of $A8 does return a result but whilst the result for an input of 0 to 5 volts produces an output of 0 to 4096, there seems to be gaps of 8 in the result i.e. 356,364,380 etc.

    I'm not sure what is going on.

    Any thoughts?

    i2cclock var portb.2
    i2cdata var portb.1
    slave_address var byte
    data_read var word
    adc_register var byte
    slave_address=$54
    adc_register=0
    I2Cread i2cdata,i2cclock,slave_address,adc_register,[data_read],error
    hserout [#data_read,13,10]
    program continues --

    error:
    hserout ["Read error",13,10]
    Attached Images Attached Images

  2. #2
    Join Date
    Jul 2003
    Location
    Colorado Springs
    Posts
    4,959


    Did you find this post helpful? Yes | No

    Default

    I didn't notice the attachment at first, and searched online for the datasheet.

    Your's was from 2008, and I found this one at National from April, 2009.
    There are considerable differences in the addressing scheme between the two.

    And the big question is ... are you using the MSOP-8 package?

    See section 1.7.4 I2C Slave (Hardware) Address
    http://www.national.com/ds/DC/ADC121C021.pdf

    It shows that the addresses should be between A0 and A6, depending on PIN configurations.
    <br>
    DT

  3. #3
    Join Date
    Jun 2009
    Location
    Cambridge, England
    Posts
    9


    Did you find this post helpful? Yes | No

    Default

    I'm using the TSOT package which has a fixed slave address. The ADDR pin is used as an alert on this one.

    I think using an address of A3 should work on my device but it doesn't. I get a response from the device with addresses of A8 and A9. These appear to return the lowest and highest conversion values.

    I haven't messed around with the result register pointer as I think it should be at 0h.

  4. #4
    Join Date
    Jul 2003
    Location
    Colorado Springs
    Posts
    4,959


    Did you find this post helpful? Yes | No

    Default

    Ok, I see what happened ...

    The address listed in the datasheet is only 7-bits 1010100.
    When you add the read/write bit it becomes $A8, 1010:1000

    And I think the pointer address should be sent with I2CWRITE before an I2CREAD, instead of in the I2CREAD.
    Yes it's default to 0, but this should work for all registers ...
    Code:
    slave_address=$A8
    adc_register=0
    I2CWRITE i2cdata,i2cclock,slave_address,[adc_register]
    I2Cread i2cdata,i2cclock,slave_address,[data_read.Byte0, data_read.Byte1],error
    hth,
    DT

  5. #5
    Join Date
    Jun 2009
    Location
    Cambridge, England
    Posts
    9


    Did you find this post helpful? Yes | No

    Default

    Thanks for that Darrel

    Unfortunately this gives me the same result as previous. This works ok but it is only in steps of 8. Typical values from the adc are 288,280,272 etc. This means my actual resolution is only 10 bits, not 12.

    The overall output is correct, with zero input I get about zero output from the adc, and for 5 volts input I get about 4000 out.

    I'll have another look at the data sheet. I don't think this is a PBP problem but I would welcome any suggestions.

    Thanks

    RS

Similar Threads

  1. I2C Master/Slave 16F88/16F767 working code
    By DanPBP in forum Code Examples
    Replies: 2
    Last Post: - 23rd October 2012, 22:31
  2. HARDWARE I2C SAMPLE CODE question
    By Michael Wakileh in forum Code Examples
    Replies: 2
    Last Post: - 16th June 2009, 21:07
  3. I2C Read/Write problems
    By Dispersion123 in forum mel PIC BASIC Pro
    Replies: 23
    Last Post: - 5th April 2008, 15:11
  4. I2C Master Slave issues.
    By cpayne in forum mel PIC BASIC Pro
    Replies: 9
    Last Post: - 29th March 2008, 19:33
  5. Please help with i2cslave i2c slave
    By cycle_girl in forum mel PIC BASIC Pro
    Replies: 2
    Last Post: - 1st December 2005, 13:55

Members who have read this thread : 0

You do not have permission to view the list of names.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts