Hello,
I have two ADS8332 in daisy-chain configuration. Writing and Reading my CFR register works with following configuration:
CFR1 = 0b111011111101
CFR2 = 0b111011011101
Currently, I try to read out all 16 channels, whereby on channel 1 and 9 a sinus signal (70 Hz, sampling frequency 2000 Hz) is connected. SCLK works with 41.67 ns (corresponds to (12 MHz)). The plots in Matlab show that the sinus signal can not be reproduced.
Code:
void startADC(int16_t ADS833x_Result[number_channels][SIZE], int cycle){
uint16_t LoopCount; // Count times through idle loop
uint16_t Channel_Number = 8;
for(LoopCount=0;LoopCount<Channel_Number;LoopCount++)
{
int16_t tempBuffer[2];
for (int i =0; i<2;i++){
tempBuffer[i]=0;
}
TIMER_Enable(TIMER1,false);
TIMER_CounterSet(TIMER1,0);
TIMER_Enable(TIMER1,true);
GPIO_PinOutClear(gpioPortB,1);
// Timing of minimum 40 ns
while(TIMER1->CNT<3){
;
}
TIMER_Enable(TIMER1,false);
GPIO_PinOutSet(gpioPortB,1);
while(GPIO_PinOutGet(gpioPortB,1) != 1){
;
}
ADS833x_ReadRegister(&tempBuffer[0],0xD000);
ADS833x_Result[LoopCount][cycle] = tempBuffer[0];
ADS833x_Result[LoopCount+8][cycle] = tempBuffer[1];
}
}
void ADS833x_ReadRegister(int16_t dataBuffer[2], uint16_t command)
{
uint16_t ReadData_MSB = command >> 8;
uint16_t ReadData_LSB = command & 0xFF;
uint16_t adc1_MSB;
uint16_t adc1_LSB;
uint16_t adc2_MSB;
uint16_t adc2_LSB;
GPIO_PinOutClear(gpioPortB,6),GPIO_PinOutClear(gpioPortB,0);
adc2_MSB = USART_SpiTransfer(USART2,ReadData_MSB);
adc2_LSB = USART_SpiTransfer(USART2,ReadData_LSB);
adc1_MSB = USART_SpiTransfer(USART2,0);
adc1_LSB = USART_SpiTransfer(USART2,0);
GPIO_PinOutSet(gpioPortB,6), GPIO_PinOutSet(gpioPortB,0);
dataBuffer[0] = (((adc1_MSB<<8)|0x00FF)&((adc1_LSB)|0xFF00));
dataBuffer[1] = (((adc2_MSB<<8)|0x00FF)&((adc2_LSB)|0xFF00));
}
I am surprised about the bad reconstruction of the signal in CH1 and CH9 (in spite of a sampling frequency of 2000 Hz) as well as about the curves at CH2 and CH10.
However, I have checked all code lines, the SPI (between ADC and MCU) and UART (between MCU and PC) connection repeatedly, the error must be found in converting. Also changing clock polarity and phase do not have an positive effect on the results. Further on attached is a timing diagramm:
(Reading all 16 channels --> one cycle)
(zooming in --> reading two channels)
Thank you and Kind Regards,
Sebastian