Hi all.
I'm trying to use the ADS1243-HT in my senior design project and I have a few questions about how we have the device currently set up. Right now I'm sending it the SELFCAL command via SPI from an MSP430F2619S-HT microcontroller, and DRDY is not being pulled low by the ADC, which should indicate that the calibration has completed. Here's how we setup our hardware.
The DRDY and *CS pins are connected to GPIO pins (interrupt capable for DRDY), and the SPI lines are tied to the outputs of a USCI module in SPI mode. The ADC is being run at 4.9152MHz (MCLK) to achieve the maximum 30Hz conversion rate, and the serial communications are being clocked at 1.0488MHz (MCLK/4).
We are only sampling the voltage of two RTD sensors with an output range of 0V to +3.3V. The reference voltage is +1.65V and any differential pair will be sampled with the negative channel tied to +1.65V to give a fullscale reading at +3.3V and a negative fullscale reading at 0V.
Below is a shot of the output from our MSP430.
I'll also share some of my code.
void main()
{
/***********************************************
* ADC TEST *
***********************************************/
ADC_Calibrate();
while(!conversion_ready); // Wait for calibration to complete
conversion_ready = false; // Clear DRDY flag
ADC_Write_Reg(ACR, 0x00, 0x00);
SamplePair = Select_Fullscale;
ADC_Set_Mux(SamplePair);
while(!conversion_ready); // Wait for calibration to complete
SamplePair = Select_Ground;
ADC_Set_Mux(SamplePair);
test = ADC_Read_Conversion();
while(!conversion_ready); // Wait for calibration to complete
SamplePair = Select_Midscale;
ADC_Set_Mux(SamplePair);
test = ADC_Read_Conversion();
while(!conversion_ready)
test = ADC_Read_Conversion();
}
uint8_t spiSendByte(uint8_t data)
{
while (!(SPI_IFG & SPI_TXIFG)); // USCI_B1 TX buffer empty?
SPI_TXBUF = data; // write
while (!(SPI_IFG & SPI_RXIFG)); // wait for transfer to complete
return(SPI_RXBUF);
}
void ADC_Calibrate()
{
ADC_CommandByte command = SelfCal;
P4OUT = 0x40; // Set ADC Chip Select Low
spiSendByte(command);
P4OUT |= ADC_CS; // Set ADC Chip Select High
}
void ADC_Set_Mux(ADC_SelectMux SelectLine)
{
uint8_t NumRegs = 0;
switch(SelectLine)
{
case Select_IntTemp_Sensor: //Select Internal Temperature Sensor
ADC_Write_Reg(MUX, NumRegs, 0x12); // Debug Voltage Pair
break;
case Select_ExtTemp_Sensor: //Select External Temperature Sensor
ADC_Write_Reg(MUX, NumRegs, 0x60);
break;
case Select_ExtPress_Sensor: //Select External Pressure Sensor
ADC_Write_Reg(MUX, NumRegs, 0x80);
break;
case Select_OffsetCal_Pair: //Select External Pressure Sensor
ADC_Write_Reg(MUX, NumRegs, 0x72);
break;
case Select_GainCal_Pair: //Select External Pressure Sensor
ADC_Write_Reg(MUX, NumRegs, 0x32);
break;
case Select_Fullscale:
ADC_Write_Reg(MUX, NumRegs, 0x01);
break;
case Select_Midscale:
ADC_Write_Reg(MUX, NumRegs, 0x10);
break;
case Select_Ground:
ADC_Write_Reg(MUX, NumRegs, 0x00);
break;
default:
//ERROR CASE
break;
}
}
void ADC_Write_Reg(ADC_CommandByte address, uint8_t NumRegs, uint8_t data)
{
int x;
uint8_t com_and_address;
ADC_CommandByte command = WriteReg;
com_and_address = command + address; // combine register address and command
P4OUT = 0x40;
spiSendByte(com_and_address);
spiSendByte(NumRegs);
for(x = 0; x <= NumRegs; x++)
spiSendByte(data & 0xFF); // masking all but lower 8 bits
P4OUT |= ADC_CS;
}
uint32_t ADC_Read_Conversion()
{
extern bool conversion_ready;
ADC_CommandByte command = ReadData;
uint8_t in_data[3];
uint32_t out_data;
uint8_t x;
P4OUT = 0x40;
spiSendByte(command);
spiReadFrame(in_data, 3);
for(x = 0; x < 2; x++)
out_data |= in_data[x] << (8 * x);
P4OUT |= ADC_CS;
conversion_ready = false; //reset conversion ready flag
return out_data;
}