Hi
I am having the following configuration for ADS1130. All VDD pins connected to +3.2V all analog and digital ground pins grounded. REFP = 3.2V REFN = 0(GND).
SPEED = 3.2V. PDWN = 1.
the problem.
The adc output is kind of stuck to 0x00233F95. Even if I vary the load from full scale to 0 the output doesn't change. I am using msp2011 mcu.
Below is the code for reference.
Thanks in advance
============================================================================================================================
//=========================================================================
#include <msp430f2011.h>
#define LOAD_CELL_ENABLE 0x10;
#define ADC_ENABLE 0x80;
#define DELAY_20_MS 40000;
#define DATA_READY (0x01) //p1.0
#define SCLK (0x08) // p1.3
//=========================================================================
// used to count number of samples taken
//static unsigned int SampleValue = 0;
// Indicates max number of samples
//static unsigned int SampleNum = 512;
// Used to store current ADCValue
long int CurrentADCValue, ADCValue;
//static unsigned int ADCOffset;
// Used to store previous ADC value
//..static unsigned long int LastADCValue;
//static unsigned int VoltageSettleCtr;
//static unsigned int int_val_adc = 0;
//static unsigned int ReadTemperature;
// Used along with the delay set this to the desired delay
static unsigned long int DelayVal;
//=========================================================================
// function prototypes
//=========================================================================
void InitializeDevice(void) ;
void delay (void);
void GetNewValues(void);
void ReadADCData(void);
//=========================================================================
// M A I N P R O G R A M
//=========================================================================
void main(void) {
// Device initialisation
InitializeDevice();
while (1) {
GetNewValues();
}
// GO to low power mode
// _BIS_SR(LPM0_bits + GIE);
//
}
//==========================================================================
// This function polls for the new conversion values avaliable. And reads the
// values into the variables
//==========================================================================
void GetNewValues(void) {
unsigned int adcDataCnt = 0;
// Enable the load Cells
P1OUT |= LOAD_CELL_ENABLE;
// Enable the ADC
// P2OUT |= ADC_ENABLE;
// Wait for the voltage to get settled
DelayVal = DELAY_20_MS;
delay();
ADCValue = 0;
for (adcDataCnt = 0; adcDataCnt <100; adcDataCnt++) {
// Enable the ADC
P2OUT |= ADC_ENABLE;
//DelayVal = 100;
//delay();
ReadADCData();
//CurrentADCValue = 10;
ADCValue = ADCValue + CurrentADCValue;
}
ADCValue = ADCValue/(1000);
// Disable the load cells and ADC
//P1OUT &= LOAD_CELL_ENABLE;
_NOP();
// Disable the ADC
//P2OUT &= ADC_ENABLE;
}
//==========================================================================
//ReadADCData
//==========================================================================
void ReadADCData(void) {
unsigned int temp_adc_val = 0;
unsigned int clk_count = 0;
// Wait for data Ready
CurrentADCValue = 0;
P1OUT &= ~SCLK;
while (P1IN & DATA_READY) {
_NOP();
}
// Toggle clock and get the ADC value in CurrentADCValue;
for (clk_count = 0; clk_count <23; clk_count++) {
P1OUT ^= SCLK;
_NOP();
// Valid ADC bits are only 18 rest clocks are applied to force the drdy high
if (clk_count < 18) {
temp_adc_val = (P1IN & DATA_READY);
//temp_adc_val = (temp_adc_val/8);
// Move the data right once
CurrentADCValue = CurrentADCValue << 1;
CurrentADCValue |= temp_adc_val;
}
P1OUT ^= SCLK;
_NOP();
}
P1OUT |= SCLK;
while ((P1IN & DATA_READY) == 0) {
temp_adc_val++;
_NOP();
}
_NOP();
}
//===========================================================================
// This function configurations
// PORT
// WDT
// clock selection
// Initialise local variables
//
//
//===========================================================================
void InitializeDevice(void) {
//===========================================================================
// Program port directions
//===========================================================================
// o = Input 1 = output
//
P2SEL = 0;
P1SEL = 0;
P1DIR = 0xB8;
P2DIR = 0xC0;
P1OUT = 0;
P2OUT = 0;
//disable the WDT + enable nmi
WDTCTL = WDTPW + WDTHOLD + WDTNMI + WDTNMIES;
// Select VLO as clock source for ACLK
BCSCTL3 |= LFXT1S_2;
// reference voltage work around
asm(" MOV.B # 0x61, & 0xbf");
// Initialize variables
// SampleValue = 0;
//ADCOffset = 000;
//SampleNum = 512;
//LastADCValue = 0;
//VoltageSettleCtr = 0;
ADCValue = 0;
//ReadTemperature = 1;
P2OUT &= ADC_ENABLE;
}
//================================================================================
//================================================================================
void delay (void)
//===========================================================================
{
volatile unsigned long int tmp_delay;
tmp_delay = DelayVal;
while (tmp_delay > 0) {
tmp_delay --;
;
}
}
=========================================================================================================================