Hello!
I want to connect the ADS1255 to the MSP430F5438 via SPI. After the initialisation of the MSP I want to write to the registers of the ADS. Afterwards I want to read them again to check if the right values are stored.
I can see that the right commands and values were transmitted to the ADC using a logicanalyzer. But when I want to read the registers, the ADC just gives me back a lot of 0x00s or other random numbers but never the values I sent.
SCLK of the SPI is 2.9MHz, four - wire. The inactive state of the clock is low, data is changed on the first UCLK edge (rising) and captured on the following edge (falling).
Here is the code that i use to init the ADC:
P4OUT &= ~0x04; //CS low
UCB3TXBUF = 0x0F; //send command to stop sending data continously
while((UCB3STAT & UCBUSY)); //wait until byte is sent
P4OUT |= 0x04; //CS high
__delay_cycles(100);
while(P1IN & 0x04); //wait for DREADY of the ADC to get low
P4OUT &= ~0x04; //CS low
UCB3TXBUF = 0xFE; //RESET
while((UCB3STAT & UCBUSY)); //wait until byte is sent
P4OUT |= 0x04; //CS high
__delay_cycles(100);
P4OUT &= ~0x04; //CS low
UCB3TXBUF = 0x52; //write command + address of the register - write to 0x02 ADCON-register
while((UCB3STAT & UCBUSY)); //wait until byte is sent
UCB3TXBUF = 0x02; //(number of registers that will be written) -1
while((UCB3STAT & UCBUSY)); //wait until byte is sent
UCB3TXBUF = 0x00; //clock out on clk-pin of the ADC is OFF, PGA = 1,
while((UCB3STAT & UCBUSY)); //wait until byte is sent
UCB3TXBUF = 0xB0; //Samplerate = 2000 SPS
while((UCB3STAT & UCBUSY)); //wait until byte is sent
UCB3TXBUF = 0x00; //GPIO
while((UCB3STAT & UCBUSY)); //wait until byte is sent
P4OUT |= 0x04; //CS high
__delay_cycles(100);
P4OUT &= ~0x04; //CS low
UCB3TXBUF = 0xFC; //send sync-command
while((UCB3STAT & UCBUSY)); //wait until byte is sent
UCB3TXBUF = 0x00; //send wake-up command
while((UCB3STAT & UCBUSY)); //wait until byte is sent
P4OUT |= 0x04; //CS high
__delay_cycles(100);
P4OUT &= ~0x04; //CS low
UCB3TXBUF = 0xF0; //send command to stop send data continously
while((UCB3STAT & UCBUSY)); //wait until byte is sent
P4OUT |= 0x04; //CS high
while((!P1IN & 0x04)); //wait for DREADY to go low -> calibration completed
Afterwards I read the register continously:
P4OUT &= ~0x04; //CS low for adc
UCB3TXBUF = 0x11; //read command + address of the register
while((UCB3STAT & UCBUSY)); //wait until byte is sent
UCB3TXBUF = 0x02; //send number of registers to be read -1
while((UCB3STAT & UCBUSY)); //wait until byte is received
__delay_cycles(120); //wait until command is processed
UCB3TXBUF = DUMMY; //read content of register
while((UCB3STAT & UCBUSY));
UCB3TXBUF = DUMMY; //read content of register
while((UCB3STAT & UCBUSY));
UCB3TXBUF = DUMMY; //read content of register
while((UCB3STAT & UCBUSY));
P4OUT |= 0x04; //CS adc high
__delay_cycles(1000000);
Where is the mistake that I do? Thank you all!