Hi,
I have ADS1258EVM with me. I have connected DIN,DOUT,SCLK,Reset,CS,ST of EVM to my MSP430.
Connections are as follows.
P3.1(SIMO)----------> DIN
P3.2(MOSI)---------->DOUT
P3.3(SCLK)--------->SCK
P2.0-------------------->LED
P2.1-------------------->Reset
P2.2-------------------->CS
P2.3-------------------->ST
I am reading register by sending 0x49 on DIN but i am receiving null in receive register.
Code is as follows.
#include <msp430x54x.h>
unsigned char MST_Data,SLV_Data;
void main(void)
{
volatile unsigned int i;
WDTCTL = WDTPW+WDTHOLD; // Stop watchdog timer
P2OUT |= 0x02; // Set P2.0 for LED
// Set P2.1 for slave reset
P2DIR |= 0x0F; // Set P2.0-3 to output direction
P3SEL |= 0x31; // P3.5,4,0 option select
UCA0CTL1 |= UCSWRST; // **Put state machine in reset**
UCA0CTL0 |= UCMST+UCSYNC+UCCKPL+UCMSB; // 3-pin, 8-bit SPI master
// Clock polarity high, MSB
UCA0CTL1 |= UCSSEL_2; // SMCLK
UCA0BR0 = 0x02; // /2
UCA0BR1 = 0; //
UCA0MCTL = 0; // No modulation
UCA0CTL1 &= ~UCSWRST; // **Initialize USCI state machine**
UCA0IE |= UCRXIE; // Enable USCI_A0 RX interrupt
P2OUT |= 0x06;
__delay_cycles(4096);
P2OUT |= 0x04;
//P2OUT &= ~0x08;
P2OUT &= ~0x02;
P2OUT |= 0x02; // reset slave
for(i=50;i>0;i--); // Wait for slave to initialize
MST_Data = 0x49; // Initialize data values
SLV_Data = 0x8B; //
while (!(UCA0IFG&UCTXIFG)); // USCI_A0 TX buffer ready?
UCA0TXBUF = MST_Data; // Transmit first character
for(i=500;i>0;i--);
__bis_SR_register(LPM0_bits + GIE); // CPU off, enable interrupts
}
#pragma vector=USCI_A0_VECTOR
__interrupt void USCIA0_ISR (void)
{
volatile unsigned int i;
if (UCA0RXBUF==SLV_Data) // Test for correct character RX'd
P2OUT |= 0x01; // If correct, light LED
else
P2OUT &= ~0x01; // If incorrect, clear LED
for(i=30;i>0;i--); // Add time between transmissions to
} // make sure slave can keep up