Hi,
I'm trying to read an uncompensated, unamplified pressure sensor whose output is connected to AIN0 and AIN1 pins on a CC2541 board based on reference designs. The sensor is connected to VCC and GND and should behave pretty much like a Wheatstone bridge, outputing a voltage proportional to VCC depending on the pressure it is sensing.
The board is being powered by the CC Debugger. I've attached the relevant part of the schematic.
I've searched but I haven't been able to find an example or documentation on how to read a differential ADC value.
The HAL API has this function:
uint16 HalAdcRead (uint8 channel, uint8 resolution)
So I use that in my program attempting to read in a function called during the performPeriodicTask() function like this:
static void readPressure( void )
{
pressureReading = 0; // Global variable to keep the pressure reading
// Read from ADC using channels 0 and 1 as differential input
pressureReading = HalAdcRead( HAL_ADC_CHN_A0A1 , HAL_ADC_RESOLUTION_8 );
pressureReading++;
}
I use HAL_ADC_CHN_A0A1 since I think it is the differential channel, and I use HAL_ADC_RESOLUTION_8 since the sensor's readings span from 0 to 150 psi.
However, I always get zero returned from HalAdcRead().
While debugging HalAdcRead() I watch the reading variable to be some value that then gets turned into zero because of this right-shifting code:
switch (resolution)
{
case HAL_ADC_RESOLUTION_8:
reading >>= 8;
break;
// and so on for different resolutions
What could I be doing wrong? Could it be that I'm not using the right resolution? or do I need to configure the ADC differently?
Any leads would be greatly appreciated.
