Problems with A/D Converter (twl4030-madc driver?)

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



I have been having some issues with the A/D converter on the OMAP3530
platform, using the TWL4030.  The hardware I am using is the Logic
OMAP3530 LV SOM Zoom2 Development Kit.  I created a driver which uses
the twl4030-madc driver to obtain the A/D values for ADCIN3 and
ADCIN4.  I am not getting valid values back from the MADC driver.  For
instance, I am getting 0 for ADCIN3 and 24496 for ADCIN4.  (24496 is
obviously wrong as it is out of the range of the 10-bit A/D...)  Even
if I vary the voltage on these inputs, I get the same results.  Here
is the structure that I am sending into the twl4030_conversion()
function:

// ** start code

    struct twl4030_madc_request req;
    int tempX, tempY;

    req.channels = 0x0000 | TWL4030_MADC_ADCIN3 | TWL4030_MADC_ADCIN4;
    req.do_avg = 0;
    req.method = TWL4030_MADC_SW1;
    req.active = 0;
    req.type = TWL4030_MADC_WAIT;
    req.func_cb = NULL;
    twl4030_madc_conversion(&req);
    if(&req == NULL)
    {
        printk("req is NULL after conversion request!\n");
    }
    else if(req.rbuf == NULL)
    {
        printk("req.rbuf is NULL after conversion request!\n");
    }
    else
    {
        tempX = (u16)req.rbuf[4];
        tempY = (u16)req.rbuf[3];

        printk("Received A/D values, tempX = %d, tempY = %d\n", tempX, tempY);
    }

// ** end code

I also tried implementing two other versions using 'req.channels =
TWL4030_MADC_ADCIN3' or 'req.channels = TWL4030_MADC_ADCIN4' instead
of the combined version shown above and I am getting the same bogus
results.

Is there some issue with what I am doing here?

Has anyone successfully utilized this driver?

I looked into the issue further by sending/receiving i2c commands
straight to the TWL4030 using i2cset and i2cget in a shell script.
Here is the sequence of commands that I used:

# ** start shell script
i2cset -f -y 1 0x49 0x91 0x90
i2cset -f -y 1 0x4a 0x00 0x01
i2cset -f -y 1 0x4a 0x06 0xff
i2cset -f -y 1 0x4a 0x07 0xff
i2cset -f -y 1 0x4a 0x97 0x02
i2cset -f -y 1 0x4a 0x12 0x20

sleep 1

GPCH3_LSB=`i2cget -f -y 1 0x4a 0x3d`
GPCH3_MSB=`i2cget -f -y 1 0x4a 0x3e`

GPCH4_LSB=`i2cget -f -y 1 0x4a 0x3f`
GPCH4_MSB=`i2cget -f -y 1 0x4a 0x40`

let ADC3=`printf %d $GPCH3_LSB`/64+`printf %d $GPCH3_MSB`*4
let ADC4=`printf %d $GPCH4_LSB`/64+`printf %d $GPCH4_MSB`*4

let VAL3=($ADC3*2444)/1000
let VAL4=($ADC4*2444)/1000

echo "ADC3  value is $ADC3 , $VAL3 millivolts    GP analog input"
echo "ADC4  value is $ADC4 , $VAL4 millivolts    GP analog input"
# ** end shell script

>From this script, I am getting 6 for both ADC outputs, even with
varying voltages.

Is there something I am doing wrong here?

Any help would be greatly appreciated.  Thanks in advance.

-Steve Ziegler
--
To unsubscribe from this list: send the line "unsubscribe linux-omap" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at  http://vger.kernel.org/majordomo-info.html

[Index of Archives]     [Linux Arm (vger)]     [ARM Kernel]     [ARM MSM]     [Linux Tegra]     [Linux WPAN Networking]     [Linux Wireless Networking]     [Maemo Users]     [Linux USB Devel]     [Video for Linux]     [Linux Audio Users]     [Yosemite Trails]     [Linux Kernel]     [Linux SCSI]

  Powered by Linux