// // MSP430F5529 // ----------------- // /|\ | P2.0|-> Slave Chip Select (GPIO) // | | | // ---|RST P1.5|-> Slave Reset (GPIO) // | | // | P3.3|-> Data Out (UCA0SIMO) // | | // Button ->|P1.1 P3.4|<- Data In (UCA0SOMI) // | | // | P2.7|-> Serial Clock Out (UCA0CLK) #include #include "ADS1220.h" #include #include #define SLAVE_CS_OUT P2OUT #define SLAVE_CS_DIR P2DIR #define SLAVE_CS_PIN BIT0 /** * main.c */ unsigned char Result = 0; static volatile unsigned int ChA0results = 0x00; int main(void) { WDTCTL = WDTPW | WDTHOLD; // stop watchdog timer P1DIR |= BIT2; UCA0CTL1 |= UCSWRST; // **Put state machine in reset** UCA0CTL0 |= UCMST+UCSYNC +UCMSB; // 3-pin, 8-bit SPI master // Clock polarity high, MSB UCA0CTL1 |= UCSSEL_2; // SMCLK 16 mhz = SCLK of SPI UCA0BR0 = 0x02; // /2 UCA0BR1 = 0; // UCA0MCTL = 0; // No modulation UCA0CTL1 &= ~UCSWRST; // **Initialize USCI state machine** ADS1220Init(); ADS1220Config(); //ADS1220SendStartCommand; char input[] = {0x12}; char output[] = {0x00}; // write reg ADS1220WriteRegister(0x00, 1, input); //read back ADS1220ReadRegister(0, 1, output); //set_VREF(ADS1220_VREF_INT); //set_MUX(ADS1220_MUX_0_1); // set_GAIN(ADS1220_GAIN_128); ADS1220SetChannel(ADS1220_MUX_0_1); ADS1220SetChannel(ADS1220_MUX_2_3); ADS1220SetVoltageReference(ADS1220_VREF_INT); ADS1220WriteRegister(0x01, 0x01, 0xD4); ADS1220AssertCS(1); while(1) { UCA0RXBUF = ADS1220ReadData(); Result = UCA0RXBUF; //ser_output(Result); } }