Hello!
Can you help me with starting up my ads1240.
I have connected ads1240 and msp430g2553. but the problem that i have had zero response from ads,when i'm sending command RDATA. UCA0RXBUF=0x00.may be in the beginning i didn't finished all procedures to initialize ads device. I have sent commands RESET and SELFCAL through spi. Are there any errors in the code?
And there is one more problem,in response only one byte,i didn't have other two bytes
#include "msp430g2553.h"
void set_dco(void);
void init_spi(void);
#define RST 0xFE
#define SELFCAL 0xF0
#define RDATA 0x01
void main(void)
{
char c='0';
WDTCTL = WDTPW | WDTHOLD;
set_dco();
init_spi();
P1OUT &= ~BIT4; //CS low
while (!(IFG2&UCB0TXIFG));
UCB0TXBUF=RST;
__delay_cycles(1000);
while (!(IFG2&UCB0TXIFG));
UCB0TXBUF=SELFCAL;
__delay_cycles(1000);
P1OUT |= BIT4;
while(1)
{
P1OUT &= ~BIT4; //CS low
while (!(IFG2&UCB0TXIFG));
UCB0TXBUF=RDATA;
__delay_cycles(1000);
while (!(IFG2&UCB0RXIFG));
c=UCB0RXBUF;
P1OUT |= BIT4;
}
}
void set_dco()
{
BCSCTL1 = 0x86; // Set DCO 1 MHz
DCOCTL = 0xD1;
}
void init_spi()
{
P1SEL |= BIT6 + BIT7 + BIT5; //SPI pin
P1SEL2 |= BIT6 + BIT7 + BIT5;
P1DIR |= BIT4; // cs select
UCB0CTL0 |= UCMSB + UCMST + UCSYNC; //3 pin master mode sync
UCB0CTL1 |= UCSSEL_2; // SMCLK
UCB0BR0 |= 0x02; // bit rate?? /2
UCB0BR1 = 0; //
UCB0CTL1 &= ~UCSWRST; // **Initialize USCI state machine**
IE2 |= UCB0RXIE; // Enable USCI0 RX interrupt
P1OUT &= ~BIT4; // Now with SPI signals initialized,
P1OUT |= BIT4; // reset slave
__delay_cycles(75); //?? need delay to initialize slave
}