Hello, I try to use ADS1218 with MSP430. I want to do conversation of voltage on Ain2 input channel. Without executing SELFCALL cmd, value is not accurate (~0.2 V deviation).
So I tried make SELFCALL, and I understood some terrible thing: every time when i make SELFCALL again (when restart MC) OCR register has different values in range 100 - 4000. First time on DRDY interrupt FSR and ACR registers has 0 values.
So what I have: F_osc on ADC = 4.9152 MHz, MCLK of MSP430 = 16 MHz, SPI CLK = 32 kHz. I used unipolar mode, max decimation.
This is code. Initialization:
ads1218_init(); //initialize pins and SPI module
__delay_cycles(500000);
ads1218_send_SELFCAL_command(); //self autocalibrate OFFSET and GAIN
uint8_t data = BIT3; //SPEED=0 - F_mod=F_osc/128, REF EN = 1, REF HI = 0 - Vref = 1.25, BUF EN = 0
ads1218_write_register(ADS1218_SETUP_REGISTER, 0x01, &data);
data = 0x7 + BIT4 + BIT5 + BIT6; // Decimation high 3 bits and sinc3 filtering mode
ads1218_write_register(ADS1218_MDEC1_REGISTER, 0x01, &data);
data = 0xFF ; // Decimation low 8 bits FF
ads1218_write_register(ADS1218_DEC0_REGISTER, 0x01, &data);
ads1218_set_channel(ADS1218_MUXP_AIN2 + ADS1218_MUXN_AINCOM); //select ADS positive and negative channels
/* F_mod=F_osc/128 = 4.9152 MHz / 128 = 38400 Hz
Data Reit = F_mod / dec = 38400 Hz / 2047 = 18.7 Hz; */
P2IE |= BIT7; // P2.7 interrupt enable
SET_BIT(ADC_NOT_DSYNC); //start conversation
And DRDY interrupt:
#pragma vector=PORT2_VECTOR
__interrupt void Port_2(void)
{
ocr_val = ads1218_read_OCR();
fsr_val = ads1218_read_FSR(); //when we read here first time ocr_val = 0, and fsr_val =0.
if (++drdy_div == 4) { // In sinc3 filtering we must skip 3 data convertions
ads1218_rdata_cmd();
temp_data = ads1218_read_data();
uint8_t voltage = temp_data * 1.25 * 100 / 0xFFFFFF; // voltage scalled for 100
drdy_div = 0;
}
P2IFG &= ~BIT7; // clear IFG
}
I attached detailed sources with all used function :
SPI works perfectly - I tried to read default values of registers, and tried to write/read - all right.
My questions:
1) what is reason of problem with OCR?
2) where can I find some code examples with using ADS1218 or similar ADC? Please give me some links. I tried searching for it, but I can't find anything on official ADS1218 page.
3)where can I find all time specifications ? ( for example time of the ADC initialization - I am using 500000 ticks of the MCLK, whitout it SPI did not work, In datasheet (SBAS187C) I can't find it, i see there only SPI time specifications.)
Please help.