这是1293的时序图
这是我SPI读写程序,可以写入,示波器也能看见SCLK的的波形,但是
/****************写入命令和数据******************/
void ADS_Write(unsigned char ADS_COM,unsigned char ADS_DAT)
{
ADS_CS = 0; // SSN LOW
U0DBUF = ADS_COM; while (!(U0CSR&0x02)); U0CSR &= 0xFD;
U0DBUF = ADS_DAT; while (!(U0CSR&0x02)); U0CSR &= 0xFD;
unsigned char temp = U0DBUF;
ADS_CS = 1; // SSN high
}
/********************************
从SPI器件读出一个字节数据
********************************/
unsigned char ADS_read(unsigned char ADS_addr)
{
unsigned char ADS_DAT;
ADS_CS = 0; // SSN LOW
U0DBUF = 0x80+ADS_addr;
while (!(U0CSR&0x02)); U0CSR &= 0xFD;
ADS_DAT = U0DBUF;
ADS_CS=1;
return ADS_DAT;
}
//初始化
ADS_Write(0x01,0x11); //IN1连CH1- ,IN2连CH1+
Delay(1000);
ADS_Write(0x02,0x19); //IN1连CH2- ,IN3连CH2+
Delay(1000);
ADS_Write(0x03,0x2E);
Delay(1000);
ADS_Write(0x0A,0x07); // 共模检测IN1,IN2,IN3.
Delay(1000);
ADS_Write(0x0C,0x04); //通道IN4 为右腿驱动
Delay(1000);
ADS_Write(0x0D,0x01); //威尔逊参考输入IN1
Delay(1000);
ADS_Write(0x0E,0x02); //威尔逊参考输入IN2
Delay(1000);
ADS_Write(0x0F,0x03); //威尔逊参考输入IN3
Delay(1000);
ADS_Write(0x10,0x01); //威尔逊选择
Delay(1000);
ADS_Write(0x12,0x04); //使能时钟 注意:设置此位高后,才振荡器起振后或振荡器已关闭和外部时钟已经开始了。
Delay(1000);
ADS_Write(0x21,0x02); //抽取率?????
Delay(1000);
ADS_Write(0x22,0x02);
Delay(1000);
ADS_Write(0x23,0x02);
Delay(1000);
ADS_Write(0x24,0x02);
Delay(1000);
ADS_Write(0x27,0x08); //Data Ready Pin Source Driven by channel 1 ECG
Delay(1000);
ADS_Write(0x2F,0x70); // 配置通道的环回读模式
Delay(1000);
ADS_Write(0x01,0x01);
void main(void)
{
uchar count = 0;
uchar LDate,MDate,HDate;
uint ALLDate;
Init_T4_AND_LED();
INT_ADS1293();
//Set_Spi();
while(1)
{
LDate=ADS_read(TI_ADS1293_DATA_CH1_ECG_L_REG);
MDate=ADS_read(TI_ADS1293_DATA_CH1_ECG_M_REG);
HDate=ADS_read(TI_ADS1293_DATA_CH1_ECG_H_REG);
ALLDate=LDate+MDate*255+HDate*255*255;
};
总是不能返回数据,我用中断模式去读取数据,DRDYB也不会被拉低,就是说没有返回数据,请高手看下,哪里有错误,或者可能是哪里的错误?
一周热门 更多>