Hi Everyone,
I am using MSP430F5510 SPI to control ADS1299, set it in RDATAC mode, read data and send through USB to PC.
After setup ADS1299 I can only test DRDY signal and I can not test sclk(0) and somi(DVdd). So I doubt that I made some mistake on setup part
Below I list part of my code for the ADS1299 setup.
Thank you for the help.
int TX_START[2] = {8,16}; // the order is: start->rdatac
int TX_WREG[28]= {17,65,24,212,192,228,0,7,7,7,7,7,7,7,7,0,0,0,0,0,0,0,15,0,0,0,0,0};
// 17 is opcode for SDATAC, 65 is the memory address for CONFIG1 (Starts writing registers at that point)
//and 24 is (n-1) number of registers to be written (so we are writing 25 registers, starting at CONFIG1)
//212(0xD4 for 1k sps, disable osc output and standart mode), 192(0xC0 for config2),
//228(0xE4) for conifg3 get externally biasref
//7(gain = 1 for all 8 chs), 15(0x0F for GPIO set)
void power_up(void)
{
uint8_t i;
// ADS1299 power up*************************************************************************//
GPIO_setOutputHighOnPin(GPIO_PORT_P6, GPIO_PIN0); // /RESET high
__delay_cycles(4000000);//1 second delay
// RESET pulse
GPIO_setOutputLowOnPin(GPIO_PORT_P6, GPIO_PIN0); // /RESET low
__delay_cycles(100);//at least two cycles delay
GPIO_setOutputHighOnPin(GPIO_PORT_P6, GPIO_PIN0); // /RESET high
//Wait for slave to initialize
__delay_cycles(100); // at least 18clk delay
// Finish power up **************************************************************************//
// Send opcode to program configration register
GPIO_setOutputLowOnPin(GPIO_PORT_P1, GPIO_PIN0);//ensable /CS0
for (i=0; i<28; i++)
{
//USCI_A1 TX buffer ready?
while(!USCI_A_SPI_getInterruptStatus(USCI_A1_BASE,
USCI_A_SPI_TRANSMIT_INTERRUPT));
//Transmit Data to slave
USCI_A_SPI_transmitData(USCI_A1_BASE, TX_WREG[i]);
__delay_cycles(32);//must wait for at least 4clk between two opcode
}
GPIO_setOutputHighOnPin(GPIO_PORT_P1, GPIO_PIN0); //disable /CS0
}
void send_spi_start(void)
// 1. This command sends RREG opcode to the ADS1299 to read register values
{
uint8_t i;
GPIO_setOutputLowOnPin(GPIO_PORT_P1, GPIO_PIN0);//ensable /CS0
for (i=0; i<2; i++)
{
//USCI_A1 TX buffer ready?
while(!USCI_A_SPI_getInterruptStatus(USCI_A1_BASE,
USCI_A_SPI_TRANSMIT_INTERRUPT));
//Transmit Data to slave
USCI_A_SPI_transmitData(USCI_A1_BASE, TX_START[i]);
__delay_cycles(32);//must wait for at least 4clk between two opcode
}
//GPIO_setOutputHighOnPin(GPIO_PORT_P1, GPIO_PIN0); //disable /CS0
}
void send_spi_rdatac (void)
{
uint8_t i;
// Initialize variables //
stop=0;
// Send start opcode
send_spi_start();
// Start RDATAC loop //
while(!stop)
{
// // step 1 - wait for DRDY0
while (!GPIO_getInputPinValue( GPIO_PORT_P1, GPIO_PIN1));
// // step 2 - Read from ADS0
GPIO_setOutputLowOnPin(GPIO_PORT_P1, GPIO_PIN0); //enable ADS1299_0
for(i=0; i<27; i++)
{
DOUT[i] = USCI_A_SPI_receiveData(USCI_A1_BASE);
//DOUT[i] = DOUT[i]+0x21;
}
//Send data
USBCDC_sendDataInBackground(DOUT,27,CDC0_INTFNUM,1);
}