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

ads1299 DRDY信號異常 SPI的SCLK、DIN、DOUT信號異常

Other Parts Discussed in Thread:ADS1299

DRDY理論上應該跟數據表第58頁的步驟三一樣,應該是2.048MHz / 8192 = 250Hz,但是我的只有150Hz,並且我的SPI的CLK為LOW,DIN、DOUT則為High,而不是方波,請指教感謝!

#include "ti/devices/msp432p4xx/inc/msp.h"
#include <stdint.h>

static uint8_t RXData[100];
static uint8_t TXData;
static char i;
#define HZ  3000000UL//3MHZ MCLK
int RXtest ;

int main(void)
{
////////////////////////////////////////////////////SPI////////////////////////////////////////////////////////////////////////WDT_A->CTL = WDT_A_CTL_PW |// Stop watchdog timerWDT_A_CTL_HOLD;P1->SEL0 |= BIT5 | BIT6 | BIT7;// Set P1.5, P1.6, and P1.7 as// SPI pins functionality//P3->DIR |= BIT0;// P3.0 set as outputCSEUSCI_B0->CTLW0 |= EUSCI_B_CTLW0_SWRST; // Put eUSCI state machine in resetEUSCI_B0->CTLW0 = EUSCI_B_CTLW0_SWRST | // Remain eUSCI state machine in resetEUSCI_B_CTLW0_MST |// Set as SPI masterEUSCI_B_CTLW0_SYNC |// Set as synchronous modeEUSCI_B_CTLW0_CKPL_OFS |// Set clock polarity lowEUSCI_B_CTLW0_CKPH |//Phase highEUSCI_B_CTLW0_MSB;// MSB firstEUSCI_B0->CTLW0 |= EUSCI_B_CTLW0_SSEL__ACLK; // ACLKEUSCI_B0->BRW = 0x01;// /2,fBitClock = fBRCLK/(UCBRx+1).EUSCI_B0->CTLW0 &= ~EUSCI_B_CTLW0_SWRST;// Initialize USCI state machine
///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////CS_Low();__delay_cycles(HZ);P5->DIR |= BIT1;P5->OUT =  BIT1;//PWDN High__delay_cycles(HZ);P2->DIR |= BIT7;P2->OUT ^= BIT7;//RESET Low__delay_cycles((4*HZ)/1000);P2->DIR |= BIT7;P2->OUT = BIT7;//RESET High__delay_cycles(HZ);P2->DIR |= BIT6;P2->OUT |= BIT6;//Set Start High__delay_cycles(HZ/1000);P3->DIR |= BIT5;P3->OUT =  BIT5;//CLKSEL High__delay_cycles(HZ/1000);__delay_cycles(HZ/1000);WREG(0x00 + 0x40,0x10); //channel1 Normal electrode input  0x60WREG(0x01 + 0x40,0x96);//Config192=>4K 採樣率WREG(0x02 + 0x40,0xD0);//Config20xC0WREG(0x03 + 0x40,0xE0);//Config3WREG(0x04 + 0x40,0x00); //LOFFWREG(0x05 + 0x40,0x65); //channel1 Normal electrode input  0x60WREG(0x06 + 0x40,0x65); //channel2WREG(0x07 + 0x40,0x65); //channel3WREG(0x08 + 0x40,0x65); //channel4WREG(0x09 + 0x40,0x65); //channel5WREG(0x0A + 0x40,0x65); //channel6WREG(0x0B + 0x40,0x65); //channel7WREG(0x0C + 0x40,0x00); //channel8WREG(0x0D + 0x40,0x00); //BIASSENSPWREG(0x0E + 0x40,0x00); //BIASSENSNWREG(0x0F + 0x40,0x00); //LOFF_SENSPWREG(0x10 + 0x40,0x00); //LOFF_SENSNWREG(0x11 + 0x40,0x00); //LOFF_FLIPWREG(0x12 + 0x40,0x00); //LOFF_STATPWREG(0x13 + 0x40,0x00); //LOFF_STATNWREG(0x14 + 0x40,0x00); //GPIOWREG(0x15 + 0x40,0x00); //MISC1WREG(0x16 + 0x40,0x00); //MISC2//P2->DIR |= BIT6;//P2->OUT = BIT6;//Set Start High//__delay_cycles(HZ);RDATAC();RXData[i] = EUSCI_B0->RXBUF;


}

void spiTx (uint8_t byte)
{while(EUSCI_B0->IFG & EUSCI_B_IFG_TXIFG){EUSCI_B0->TXBUF = byte;// Transmit characters}
}
void spiRx (void)
{if (EUSCI_B0->IFG & EUSCI_B_IFG_RXIFG){// USCI_B0 TX buffer ready?RXtest = 1;// Echo received data}RXData[0] = EUSCI_B0->RXBUF;
}
void CS_High (void)
{P3->DIR |= BIT0; //Set P3.0腳位P3->OUT = BIT0;  //CS_High
}
void CS_Low (void)
{P3->DIR |= BIT0;P3->OUT ^= BIT0; //CS_Low
}
void RESET(void)
{spiTx(0x06);__delay_cycles((12*HZ)/1000000);
}
void SDATAC(void)
{spiTx(0x11);__delay_cycles((4*HZ)/10000);
}
void WREG(uint8_t _address, uint8_t value)
{uint8_t opcode1 = _address + 0x40;spiTx(opcode1);spiTx(0x00);spiTx(value);
}
uint8_t RREG(uint8_t _address)//在RDATAC模式下,RREG指令會被忽略(datasheet P35)
{uint8_t opcode1 = _address + 0x20;spiTx(opcode1);spiTx(0x00);
}
void RDATAC(void)
{spiTx(0x10);__delay_cycles((3*HZ)/1000);
}
void START(void)
{spiTx(0x08);
}

void Testsignal(void)
{void SDATAC();__delay_cycles(HZ);WREG(0x02 + 0x40,0xD0);WREG(0x05 + 0x40,0x05);void RDATAC();
}

Amy Luo:

您好,

通讯波形不是方波,是什么样子的呢,是存在干扰还是受寄生电容影响存在失真,可以附上示波器测量波形吗
“数据表第58页的步骤三”是指的哪个文件?我在数据表中看到的是寄存器GPIO说明:
www.ti.com/…/ads1299.pdf

,

user5121970:

數據表弟58頁上電流程

目前我有做一些程式碼小更改,我想要讀取ADS1299的ID號,附圖為各腳位訊號,我用RDATAC指令,DRDY應該會是連續的方波,並且SCLK以及DOUT也應該為方波,DIN則為LOW,但結果顯示我的DRDY只會產生一次方波,並且SCLK以及DOUT沒有方波。

SCLK示波圖

DIN圖

DOUT圖

暫存器結果圖

#include "ti/devices/msp432p4xx/inc/msp.h"
#include <stdint.h>static uint8_t RXData[50];
static uint8_t TXData;
static int i = 0;
#define HZ3000000UL//3MHZ MCLK
int RXtest ;int main(void)
{
////////////////////////////////////////////////////SPI////////////////////////////////////////////////////////////////////////WDT_A->CTL = WDT_A_CTL_PW |// Stop watchdog timerWDT_A_CTL_HOLD;P1->SEL0 |= BIT5 | BIT6 | BIT7;// Set P1.5, P1.6, and P1.7 as// SPI pins functionality//P3->DIR |= BIT0;// P3.0 set as outputCSEUSCI_B0->CTLW0 |= EUSCI_B_CTLW0_SWRST; // Put eUSCI state machine in resetEUSCI_B0->CTLW0 = EUSCI_B_CTLW0_SWRST | // Remain eUSCI state machine in resetEUSCI_B_CTLW0_MST |// Set as SPI masterEUSCI_B_CTLW0_SYNC |// Set as synchronous mode//EUSCI_B_CTLW0_CKPL |// Set clock polarity lowEUSCI_B_CTLW0_CKPH |//Phase highEUSCI_B_CTLW0_MSB;// MSB firstEUSCI_B0->CTLW0 |= EUSCI_B_CTLW0_SSEL__ACLK; // ACLKEUSCI_B0->BRW = 0x01;// /2,fBitClock = fBRCLK/(UCBRx+1).EUSCI_B0->CTLW0 &= ~EUSCI_B_CTLW0_SWRST;// Initialize USCI state machine
////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////*TXData = 0x01;// Initialize TX data to 0x01while(1){TXData++;spiTx(TXData);spiRx ();}*/CS_Low();__delay_cycles(HZ);P3->DIR |= BIT5;P3->OUT =BIT5;//CLKSEL High__delay_cycles(HZ/1000);P5->DIR |= BIT1;P5->OUT =BIT1;//PWDN High__delay_cycles(HZ);P2->DIR |= BIT7;P2->OUT ^= BIT7;//RESET Low__delay_cycles((4*HZ)/1000);P2->DIR |= BIT7;P2->OUT = BIT7;//RESET High__delay_cycles(HZ);SDATAC();__delay_cycles(HZ/1000);P2->DIR |= BIT6;P2->OUT |= BIT6;//Set Start High__delay_cycles(HZ/1000);WREG(0x00 + 0x40,0x10); //channel1 Normal electrode input0x60//void RDATA();RREG(0x00);RXData[0] = EUSCI_B0->RXBUF;/*WREG(0x01 + 0x40,0x96);//Config192=>4K 採樣率WREG(0x02 + 0x40,0xD0);//Config20xC0WREG(0x03 + 0x40,0xE0);//Config3WREG(0x04 + 0x40,0x00); //LOFFWREG(0x05 + 0x40,0x65); //channel1 Normal electrode input0x60WREG(0x06 + 0x40,0x65); //channel2WREG(0x07 + 0x40,0x65); //channel3WREG(0x08 + 0x40,0x65); //channel4WREG(0x09 + 0x40,0x65); //channel5WREG(0x0A + 0x40,0x65); //channel6WREG(0x0B + 0x40,0x65); //channel7WREG(0x0C + 0x40,0x00); //channel8WREG(0x0D + 0x40,0x00); //BIASSENSPWREG(0x0E + 0x40,0x00); //BIASSENSNWREG(0x0F + 0x40,0x00); //LOFF_SENSPWREG(0x10 + 0x40,0x00); //LOFF_SENSNWREG(0x11 + 0x40,0x00); //LOFF_FLIPWREG(0x12 + 0x40,0x00); //LOFF_STATPWREG(0x13 + 0x40,0x00); //LOFF_STATNWREG(0x14 + 0x40,0x00); //GPIOWREG(0x15 + 0x40,0x00); //MISC1WREG(0x16 + 0x40,0x00); //MISC2/*P2->DIR |= BIT6;P2->OUT = BIT6;//Set Start High__delay_cycles(HZ/1000);*//*RDATAC();__delay_cycles(HZ);Testsignal();for(i = 0;i<500;i++){RXData[i] = EUSCI_B0->RXBUF;__delay_cycles(HZ/250);}*/
}void spiTx (uint8_t byte)
{while(EUSCI_B0->IFG & EUSCI_B_IFG_TXIFG){EUSCI_B0->TXBUF = byte;// Transmit characters}
}
void spiRx (void)
{if (EUSCI_B0->IFG & EUSCI_B_IFG_RXIFG){// USCI_B0 TX buffer ready?RXtest = 1;// Echo received data}RXData[0] = EUSCI_B0->RXBUF;
}
void CS_High (void)
{P3->DIR |= BIT0; //Set P3.0腳位P3->OUT = BIT0;//CS_High
}
void CS_Low (void)
{P3->DIR |= BIT0;P3->OUT ^= BIT0; //CS_Low
}
void RESET(void)
{spiTx(0x06);__delay_cycles((12*HZ)/1000000);
}
void SDATAC(void)
{spiTx(0x11);__delay_cycles((4*HZ)/10000);
}
void WREG(uint8_t _address, uint8_t value)
{uint8_t opcode1 = _address + 0x40;spiTx(opcode1);spiTx(0x00);spiTx(value);
}
uint8_t RREG(uint8_t _address)//在RDATAC模式下,RREG指令會被忽略(datasheet P35)
{uint8_t opcode1 = _address + 0x20;spiTx(opcode1);spiTx(0x00);
}
void RDATAC(void)
{spiTx(0x10);__delay_cycles((3*HZ)/1000);
}
void RDATA(void)
{spiTx(0x12);__delay_cycles((3*HZ)/1000);
}
void START(void)
{spiTx(0x08);
}void Testsignal(void)
{//void SDATAC();__delay_cycles(HZ);WREG(0x00 + 0x40,0x10); //channel1 Normal electrode input0x60/*void RDATAC();RXData[i] = EUSCI_B0->RXBUF;*/WREG(0x01 + 0x40,0x96);//Config192=>4K 採樣率WREG(0x02 + 0x40,0xD0);//Config20xC0WREG(0x03 + 0x40,0xE0);//Config3WREG(0x04 + 0x40,0x00); //LOFFWREG(0x05 + 0x40,0x65); //channel1 Normal electrode input0x60WREG(0x06 + 0x40,0x65); //channel2WREG(0x07 + 0x40,0x65); //channel3WREG(0x08 + 0x40,0x65); //channel4WREG(0x09 + 0x40,0x65); //channel5WREG(0x0A + 0x40,0x65); //channel6WREG(0x0B + 0x40,0x65); //channel7WREG(0x0C + 0x40,0x00); //channel8WREG(0x0D + 0x40,0x00); //BIASSENSPWREG(0x0E + 0x40,0x00); //BIASSENSNWREG(0x0F + 0x40,0x00); //LOFF_SENSPWREG(0x10 + 0x40,0x00); //LOFF_SENSNWREG(0x11 + 0x40,0x00); //LOFF_FLIPWREG(0x12 + 0x40,0x00); //LOFF_STATPWREG(0x13 + 0x40,0x00); //LOFF_STATNWREG(0x14 + 0x40,0x00); //GPIOWREG(0x15 + 0x40,0x00); //MISC1WREG(0x16 + 0x40,0x00); //MISC2RDATAC();
}

,

Amy Luo:

读取ADS1299的ID号应该用寄存器读取命令RREG。
您使用的数据表不是最新的数据表,请下载使用最新的数据表:
www.ti.com/…/ads1299.pdf

,

user5121970:

我設定一個TXData暫存器去儲存RREG出來的值,請注意看我的void RREG()函式,以及main裡面的最後一行TXData=RREG(0x00);,我不知道我這樣的配置對不對,我讀出來的TXData為0xE0,跟預期的0x3E不一樣,請多多指教感謝。

#include "ti/devices/msp432p4xx/inc/msp.h"
#include <stdint.h>static uint8_t RXData[500];
static uint8_t TXData;
static int i = 0;
#define HZ3000000UL//3MHZ MCLK
int RXtest ;int main(void)
{
////////////////////////////////////////////////////SPI////////////////////////////////////////////////////////////////////////WDT_A->CTL = WDT_A_CTL_PW |// Stop watchdog timerWDT_A_CTL_HOLD;P1->SEL0 |= BIT5 | BIT6 | BIT7;// Set P1.5, P1.6, and P1.7 as// SPI pins functionality//P3->DIR |= BIT0;// P3.0 set as outputCSEUSCI_B0->CTLW0 |= EUSCI_B_CTLW0_SWRST; // Put eUSCI state machine in resetEUSCI_B0->CTLW0 = EUSCI_B_CTLW0_SWRST | // Remain eUSCI state machine in resetEUSCI_B_CTLW0_MST |// Set as SPI masterEUSCI_B_CTLW0_SYNC |// Set as synchronous mode//EUSCI_B_CTLW0_CKPL |// Set clock polarity lowEUSCI_B_CTLW0_CKPH |//Phase highEUSCI_B_CTLW0_MSB;// MSB firstEUSCI_B0->CTLW0 |= EUSCI_B_CTLW0_SSEL__ACLK; // ACLKEUSCI_B0->BRW = 0x01;// /2,fBitClock = fBRCLK/(UCBRx+1).EUSCI_B0->CTLW0 &= ~EUSCI_B_CTLW0_SWRST;// Initialize USCI state machine
////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////*TXData = 0x01;// Initialize TX data to 0x01while(1){TXData++;spiTx(TXData);spiRx ();}*/CS_Low();__delay_cycles(HZ);P3->DIR |= BIT5;P3->OUT =BIT5;//CLKSEL High__delay_cycles(HZ/1000);P5->DIR |= BIT1;P5->OUT =BIT1;//PWDN High__delay_cycles(HZ);P2->DIR |= BIT7;P2->OUT = BIT7;//RESET High__delay_cycles(HZ);spiTx(0x06);__delay_cycles(HZ);SDATAC();WREG(0x03,0xE0);//Config3WREG(0x01,0x96);//Config192=>4K 採樣率WREG(0x02,0xC0);//Config20xC0WREG(0x05,0x01); //channel1 Normal electrode input0x60WREG(0x06,0x01); //channel2WREG(0x07,0x01); //channel3WREG(0x08,0x01); //channel4WREG(0x09,0x01); //channel5WREG(0x0A,0x01); //channel6WREG(0x0B,0x01); //channel7WREG(0x0C,0x01); //channel8P2->DIR |= BIT6;P2->OUT |= BIT6;//Set Start High__delay_cycles(HZ/1000);RDATAC();SDATAC();WREG(0x02,0xD0);//Config2WREG(0x05,0x05); //channel1 Normal electrode input0x60WREG(0x06,0x05); //channel2WREG(0x07,0x05); //channel3WREG(0x08,0x05); //channel4WREG(0x09,0x05); //channel5WREG(0x0A,0x05); //channel6WREG(0x0B,0x05); //channel7WREG(0x0C,0x05); //channel8RDATAC();/*for(i = 0;i<500;i++){RXData[i] = EUSCI_B0->RXBUF;__delay_cycles(HZ/250);}*/SDATAC();TXData = RREG(0x00);}void spiTx (uint8_t byte)
{while(EUSCI_B0->IFG & EUSCI_B_IFG_TXIFG){EUSCI_B0->TXBUF = byte;// Transmit characters}
}
void spiRx (void)
{if (EUSCI_B0->IFG & EUSCI_B_IFG_RXIFG){// USCI_B0 TX buffer ready?RXtest = 1;// Echo received data}RXData[i] = EUSCI_B0->RXBUF;
}
void CS_Low (void)
{P3->DIR |= BIT0;P3->OUT ^= BIT0; //CS_Low
}
void RESET(void)
{spiTx(0x06);__delay_cycles((12*HZ)/1000000);
}
void SDATAC(void)
{spiTx(0x11);__delay_cycles((4*HZ)/1000);
}
void WREG(uint8_t _address, uint8_t value)
{uint8_t opcode1 = _address + 0x40;spiTx(opcode1);__delay_cycles(HZ/1000);spiTx(0x00);__delay_cycles(HZ/1000);spiTx(value);__delay_cycles(HZ/1000);
}
uint8_t RREG(uint8_t _address)//在RDATAC模式下,RREG指令會被忽略(datasheet P35)
{uint8_t opcode1 = _address + 0x20;spiTx(opcode1);spiTx(0x00);EUSCI_B0->RXBUF;
}
void RDATAC(void)
{spiTx(0x10);__delay_cycles((3*HZ)/1000);
}
void RDATA(void)
{spiTx(0x12);__delay_cycles((3*HZ)/1000);
}
void START(void)
{spiTx(0x08);
}

,

Amy Luo:

您可以用示波器测量下RREG读取寄存器ID的波形图吗

,

user5121970:

我目前更改後的代碼為下面這樣,MSP432P401R收到ADS1299回傳的ID值為0xE0,與預期的0x3E不同,我不知道問題出在哪?

如有發現問題,請指教,感謝!

示波器圖如下:

DRDY

DOUT

DIN

CLK

CS

#include "ti/devices/msp432p4xx/inc/msp.h"
#include <stdint.h>static uint8_t RXData;
static uint8_t TXData;
static uint8_t abc = 0;
static uint8_t cba = 0;
static int i ;
#define HZ3000000UL//3MHZ MCLK
int RXtest ;int main(void)
{
////////////////////////////////////////////////////SPI////////////////////////////////////////////////////////////////////////WDT_A->CTL = WDT_A_CTL_PW |// Stop watchdog timerWDT_A_CTL_HOLD;P1->SEL0 |= BIT5 | BIT6 | BIT7;// Set P1.5, P1.6, and P1.7 as// SPI pins functionalityEUSCI_B0->CTLW0 |= EUSCI_B_CTLW0_SWRST; // Put eUSCI state machine in resetEUSCI_B0->CTLW0 = EUSCI_B_CTLW0_SWRST | // Remain eUSCI state machine in resetEUSCI_B_CTLW0_MST |// Set as SPI masterEUSCI_B_CTLW0_SYNC |// Set as synchronous mode//EUSCI_B_CTLW0_CKPL |// Set clock polarity lowEUSCI_B_CTLW0_CKPH |//Phase highEUSCI_B_CTLW0_MSB;// MSB firstEUSCI_B0->CTLW0 |= EUSCI_B_CTLW0_SSEL__ACLK; // ACLKEUSCI_B0->BRW = 0x01;// /2,fBitClock = fBRCLK/(UCBRx+1).EUSCI_B0->CTLW0 &= ~EUSCI_B_CTLW0_SWRST;// Initialize USCI state machine/////////////////////////////////////////////////SPI INTERRUPT/////////////////////////////////////////////////////////////////////////////////__enable_irq();// Enable eUSCI_B0 interrupt in NVIC moduleNVIC->ISER[0] = 1 << ((EUSCIB0_IRQn) & 31);// Wake up on exit from ISRSCB->SCR &= ~SCB_SCR_SLEEPONEXIT_Msk;// Ensures SLEEPONEXIT takes effect immediately__DSB();///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
//初始化ADS1299//CS_Low();P3->DIR |= BIT0;P3->OUT ^= BIT0; //CS_Low__delay_cycles(HZ);P3->DIR |= BIT5;P3->OUT =BIT5;//CLKSEL High__delay_cycles(HZ/1000);P5->DIR |= BIT1;P5->OUT =BIT1;//PWDN High__delay_cycles(HZ);P2->DIR |= BIT7;P2->OUT = BIT7;//RESET High__delay_cycles(HZ);P2->DIR |= BIT7;P2->OUT = BIT7;//RESET High__delay_cycles(HZ);
///////////////////////////////////////////////P2->DIR |= BIT6;P2->OUT |= BIT6;//Set Start High__delay_cycles(HZ/1000);//進入TX中斷傳送指令EUSCI_B0->IFG |= EUSCI_B_IFG_TXIFG;// Clear TXIFG flagEUSCI_B0->IE |= EUSCI_B_IE_TXIE;// Enable TX interrupt
//進入RX中斷接收回傳數據EUSCI_B0->IFG |= EUSCI_B_IFG_RXIFG;// Clear TXIFG flagEUSCI_B0->IE |= EUSCI_B_IE_RXIE;// Enable TX interrupt
}void EUSCIB0_IRQHandler(void)
{if (EUSCI_B0->IFG & EUSCI_B_IFG_TXIFG){EUSCI_B0->TXBUF = 0x11;// Transmit characters__delay_cycles(HZ/100000);EUSCI_B0->TXBUF = 0x20;// Transmit characters__delay_cycles(HZ/100000);EUSCI_B0->TXBUF = 0x00;// Transmit characters__delay_cycles(HZ/100000);EUSCI_B0->IE &= ~EUSCI_B__TXIE;}else if (EUSCI_B0->IFG & EUSCI_B_IFG_RXIFG){//abc = 1;// USCI_B0 TX buffer ready?//while (!(EUSCI_B0->IFG & EUSCI_B_IFG_TXIFG));// Echo received dataRXData = EUSCI_B0->RXBUF;EUSCI_B0->IE &= ~EUSCI_B__RXIE;}
}

,

user5121970:

我還有一個疑問是,如果只初始化ADS1299,而無對既存記進行配置的話,可以讀取ID寄存器嗎?
我看到這篇文章的最後一個回復,但是沒有答案
e2echina.ti.com/…/373084

,

105080827 105080827:

大佬您好,我现在也是遇到了同样的问题读取ID值為0xE0,请教以下,问题解决了没有,解决了,是怎么解决的

赞(0)
未经允许不得转载:TI中文支持网 » ads1299 DRDY信號異常 SPI的SCLK、DIN、DOUT信號異常
分享到: 更多 (0)