Hello,
I use a MCU which communicates with two ADS8332's (daisy-chain) over SPI, whereby the MCU is the master and both ADC's are slaves. The function below shows the configuration of the CFR register. Both input parameters (ADS833x_CFR_Reg1 and ADS833x_CFR_Reg2) correspond to the bits which I want to write in the register:
void ADS833x_init(uint16_t ADS833x_CFR_Reg1, uint16_t ADS833x_CFR_Reg2) // Initialize ADS833x
{
uint16_t Reg_Word1;
uint16_t Reg_Word2;
uint16_t ADS833x_Write_Com = 0xE000;
uint16_t ADS833x_Read_Com = 0xC000;
uint16_t ADS833x_Buf[BUF_SIZE];
for (int i =0; i<BUF_SIZE;i++){
ADS833x_Buf[i]=0;
}
Reg_Word1 = ADS833x_Write_Com + ADS833x_CFR_Reg1;
Reg_Word2 = ADS833x_Write_Com + ADS833x_CFR_Reg2;
// clear CS1
GPIO_PinOutClear(gpioPortB,6);
USART_TxDouble(USART2,Reg_Word1);
// wait until transmission is over
while (!(USART2->STATUS & USART_STATUS_TXC));
GPIO_PinOutSet(gpioPortB,6);
while(GPIO_PinOutGet(gpioPortB,6) != 1);
// the same procedure for CS2
GPIO_PinOutClear(gpioPortB,0);
USART_TxDouble(USART2,Reg_Word2);
while (!(USART2->STATUS & USART_STATUS_TXC));
GPIO_PinOutSet(gpioPortB,0);
while(GPIO_PinOutGet(gpioPortB,0) != 1);
// Read out CFR register
GPIO_PinOutClear(gpioPortB,6),GPIO_PinOutClear(gpioPortB,0);
USART_TxDouble(USART2,ADS833x_Read_Com);
while (!(USART2->STATUS & USART_STATUS_TXC));
ADS833x_Buf[0] = (uint16_t)USART2->RXDOUBLE;
USART_TxDouble(USART2,ADS833x_Read_Com);
while (!(USART2->STATUS & USART_STATUS_TXC));
ADS833x_Buf[1] = (uint16_t)USART2->RXDOUBLE;
GPIO_PinOutSet(gpioPortB,0),GPIO_PinOutSet(gpioPortB,6);
ADS833x_Buf[2] = ADS833x_Buf[0] & 0x0FFF;
ADS833x_Buf[3] = ADS833x_Buf[1] & 0x0FFF;
if ((ADS833x_CFR_Reg1 != ADS833x_Buf[2])||(ADS833x_CFR_Reg2 != ADS833x_Buf[3])){
error( );
}
}
Currently, the readout values of both CFR registers do not correspond to ADS833x_CFR_Reg1 and ADS833x_CFR_Reg2 which is why my programm ends in the error loop. Therefore, I assume that writing in the CFR register was not succesfully. Are there any solutions for my problem? Thank you!!
Kind regards,
Sebastian