|
求助!!430F169做主机,接一个24位的AD1246采集芯片实现一个数据采集功能。
[复制链接]
最近在用430f169做主机,控制ADS1246实现24位的AD采集,但是调试的结果都不对,现在不知道是哪里有问题,不清楚430发送的数据AD芯片有没有接收到,读到的数都是0xff,每次用仿真器调试初始化后接收寄存器的值是0x7f,读寄存器的值也读到的全是0xff,快过年了,做不出来,导师不让回家,求各位大神帮帮忙!
void ADS1298_SPI_Init(void)
{
//U0CTL=CHAR + SYNC + MM + SWRST;
P3SEL |= 0x0E; // P3.1,2,3选为SPI通信端口
U0CTL|=SWRST;
U0CTL |= CHAR + SYNC + MM ; // 8-bit传送, SPI模式, 主机,允许中断
U0TCTL |= CKPH + SSEL1 + STC;//CKPL + 时钟信号高电平无效,数据在下降沿发出,输入数据在上升沿被锁存,时钟信号为SMCLK, 3线模式
U0BR0 = 0x00; // SPICLK = SMCLK/4
U0BR1 = 0x00;
U0MCTL =0x00;
ME1 |= UTXE0+URXE0; //USPIE0; // 模块使能
U0CTL &= ~SWRST; // SPI使能
//IE1 |= URXIE0; // Enable USART0 TX interrupt
//U0RCTL=0x00;
}
void ADS1298_Init(void)
{
unsigned char d[8];
P4DIR |= 0x0F;
ADS1298_START1;
ADS1298_CS0;
delay_us(10);
ADS1298_RST0;
delay_ms(5);
ADS1298_RST1;
delay_ms(5);
ADS1298_SPI_Init();
delay_ms(10);
ADS1298_CS0;
ADS1298_Send_CMD_One(RESET);
delay_ms(10);
ADS1298_Send_CMD_One(WAKEUP);
delay_ms(10);
d[0]=0x00;
ADS1298_Send_CMD_Muti(Addr_IDsend,1,d);//定义DRDY为标志数据完成和发送
delay_us(10);
//ADS1298_Send_CMD_Read(Addr_VBIASreceive,1);
//wait_ready();
d[0]=0x01; //烧坏电流源关闭
ADS1298_Send_CMD_Muti(Addr_BCSsend,1,d);
delay_us(10);
d[0]=0x00; //向模拟输入端口输入偏执电压关闭
ADS1298_Send_CMD_Muti(Addr_VBIASsend,1,d);
delay_us(10);
d[0]=0x80; //定义为外部时钟,工作于正常模式
ADS1298_Send_CMD_Muti(Addr_MUXsend,1,d);
delay_us(10);
d[0]=0x08; //增益为1,采集速率为1000sps
ADS1298_Send_CMD_Muti(Addr_SYS0send,1,d);
delay_us(10);
//ADS1298_Send_CMD_Read(Addr_IDreceive,1);
//wait_ready();
ADS1298_Send_CMD_One(RDATA);
}
uchar spi_receive(void)
{
while(UTXIFG0 & IFG1==0);
U0TXBUF = 0xff;
while(UTXIFG0 & IFG1==0);
return U0RXBUF;
}
uchar wait_ready (void)
{
ADS1298_CS0;
uchar res;
delay_us(10);
//Timer2 = 250;
//spi_receive();
do
res = spi_receive();
while (res == 0xFF); //&& Timer2);
ADS1298_CS1;
return res;
}
这是部分程序,求用过的大神解答!
|
|