This thread has been locked.

If you have a related question, please click the "Ask a related question" button in the top right corner. The newly created question will be automatically linked to this question.

ADS7229配置读取

Other Parts Discussed in Thread: ADS7229

能否询问下,SPI读取ADS7229的寄存器配置问题,ATMEGA128每次最多读取8位,无法读取到正确的配置,请问该怎么正确读取ADS7229的寄存器配置和数据?

FS = 1; //置高电平,置低电平时读不到值

spi_write(0x0E); //write CFR
spi_write(0x0D); //CFR D11-D8
spi_write(0x0F); //CFR D7-D4
spi_write(0x0D); //CFR D3-D0

//回读配置

CFR_DATA = spi_read(0x0C); //read CFR

uint16 spi_read(uint8 read_cmd)
{
uint16 temp = 0;
uint8 cmd_rec = 0;

cmd_rec = read_cmd;
SPSR = 0; //CLEAR ERROR AND FLAG

//send the command
SPDR = read_cmd;
while((SPSR & 0X80) != 0X80); //WAIT THE DATA BYTE SEND END
SPSR = 0;

//read the data
while((SPSR & 0X80) != 0X80); //WAIT THE DATA BYTE SEND END
temp = (SPDR << 8) & 0xFF00;
SPSR = 0;

SPDR = 0; //启动SCK
while((SPSR & 0X80) != 0X80); //WAIT THE DATA BYTE SEND END
temp |= SPDR & 0x00FF;
SPSR = 0;

return temp;
}