I have a LTC2400 and am having trouble interpreting the serial data. The SDO data format seems fairly straight forward, however I am getting mixed results and am not sure if it is the way I am reading the serial data or the way I am converting the serial data to an actual analog voltage is creating the problem.
The adc is connected through a SI8651 digital isolator and a TI EK-TM4C1294XL development kit.
Figure 1: LTC2400 and DAC8411 on the Isolated SPI Bus
Figure 2: Digital Isolator
The SPI signals at the LTC2400 are shown below. The microcontroller on the development kit I am using has a 16 bit limit on SPI data read in. I am reading in the SPI data in four 8 bit chunks and manually controlling the CS line.
Figure 3: CH1: SDO CH2: ADC CS CH3: DAC CS CH4: SCLK
Below is the function I am using to read in the SPI data from the ADC.
float read_adc() {
#define NUM_SSI_DATA_ADC 4
uint32_t pui32DataTx[NUM_SSI_DATA_ADC];
uint32_t pui32DataRx[NUM_SSI_DATA_ADC];
uint32_t ui32Index;
//Set the Chip Select Pin of the ADC Low. (Active Low)
ROM_SysCtlDelay(5.44e6);
ROM_GPIOPinWrite(GPIO_PORTC_BASE, GPIO_PIN_7, 0x0);
for(ui32Index = 0; ui32Index < NUM_SSI_DATA_ADC; ui32Index++)
{
//a. Send Nothing (Get the bus going).
ROM_SSIDataPut(SSI0_BASE, 0);
while(ROM_SSIBusy(SSI0_BASE))
{
}
//b. Read ADC
//
// Receive the data using the "blocking" Get function. This function
// will wait until there is data in the receive FIFO before returning.
//
ROM_SSIDataGet(SSI0_BASE, &pui32DataRx[ui32Index]);
}
//Set the Chip Select Pin of the ADC High. (Active Low)
ROM_GPIOPinWrite(GPIO_PORTC_BASE, GPIO_PIN_7, GPIO_PIN_7);
adc_data = (pui32DataRx[0] << 24) | pui32DataRx[1] << 16 | pui32DataRx[2] << 8 | pui32DataRx[3];
EOC = 0x80 & pui32DataRx[0];
DMY = 0x40 & pui32DataRx[0];
SIG = 0x20 & pui32DataRx[0];
EXR = 0x10 & pui32DataRx[0];
adc_voltage = ((0xFFFFFF0 & adc_data) >> 4)/16777216.0;
//if (SIG == 0) adc_voltage = -1.0*adc_voltage;
UARTprintf("[0]= %u,[1]= %u, [2]= %u, [3]= %d => %u\n",
pui32DataRx[0], pui32DataRx[1], pui32DataRx[2], pui32DataRx[3], ((0xFFFFFF0 & adc_data) >> 4));
return adc_voltage;
}
The data from the microcontroller is [0]= 73,[1]= 80, [2]= 9, [3]= 38 => 9765010.
Assuming the way I am converting the result the analog voltage is correct 9765010 / 2^24 = 0.582039952, but the voltage on the ADC input is 1.3V.
The data from the microcontroller and the scope screenshot are from the same SPI reading. I am not sure why the SPI data is different between the scope and microcontroller or which one is correct.
The microcontroller is programmed in SPI_MODE0 and a data width of 8 bits.
Thanks,
Allan