TI中文支持网
TI专业的中文技术问题搜集分享网站

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;
}

user151383853:

我想只要遵守通信协议, 不管用哪个 MCU 肯定能够实现

你要的是仔细捕捉波形来验证时序.

赞(0)
未经允许不得转载:TI中文支持网 » ADS7229配置读取
分享到: 更多 (0)