Hi i am trying to interface pga116 (slave) with msp430(master)
i used the following code
#include <msp430.h>
volatile
char
received_ch = 0;
int
main(
void
)
{
WDTCTL = WDTPW + WDTHOLD;
// Stop WDT
P1OUT |= BIT5;
P1DIR |= BIT5;
P1SEL = BIT1 | BIT2 | BIT4;
P1SEL2 = BIT1 | BIT2 | BIT4;
UCA0CTL1 = UCSWRST
UCA0CTL0 |= UCCKPH + UCMSB + UCMST + UCSYNC;
// 3-pin, 8-bit SPI master
UCA0CTL1 |= UCSSEL_2;
// SMCLK
UCA0BR0 |= 0x02;
// /2
UCA0BR1 = 0;
//
UCA0MCTL = 0;
// No modulation
UCA0CTL1 &= ~UCSWRST;
// **Initialize USCI state machine**
P1OUT &= (~BIT5);
// Select Device
while
(!(IFG2 & UCA0TXIFG));
// USCI_A0 TX buffer ready?
UCA0TXBUF = 0x11;
// gain 2 channel 1
while
(!(IFG2 & UCA0RXIFG));
// USCI_A0 RX Received?
received_ch = UCA0RXBUF;
// Store received data
P1OUT |= (BIT5);
// Unselect Device
}
i supply 2V to PGA channel 1 and with gain of 2 I should get 4V at the output pin but when observed on DSO I get a square wave of 50Hz with some other voltage value.
Please help me out as in how to interface pga116 with msp430g2553 using spi.