Other Parts Discussed in Thread: MSP430G2553
Hello Everybody,
I'm new here and i would like to use SPI on my MSP430G2553. I want "ride" my DAC (MAX548) with the MK but I have a problem . I don't know why it isn't work. I truly will be happy for the help by anyone! :) This is the code:
WDTCTL = WDTPW + WDTHOLD + WDTNMI + WDTNMIES; // WDT off
P1OUT &= ~BIT0; // clear BIT0
P1DIR = BIT0 + BIT4 ; // P1.0 i P1.4 output, else input
P1OUT = BIT0; // P1.0 pullup to hi
P1SEL = BIT2 + BIT4; // P1.2 ->TX, P1.4 -> SMCLK
P1SEL2 = BIT2;
UCA0CTL0 |= UCCKPH + UCMSB + UCMST; //Clock phase,MSB first,Master mode
UCA0CTL1 |= UCSSEL_2; // SMCLK
UCA0CTL1 &= ~UCSWRST; //USCI reset released for operation.
UCA0BR0 = 0; //Bit clock prescaler
UCA0BR1 = 0; //(UCA0BR0 + UCA0BR1 × 256)
IE2 = UCA0TXIE;
while (1)
{
P1OUT &= ~BIT0; // enable CS (to Low)
UCA0TXBUF =0x09; // Send command
while (!(IFG2 & UCA0TXIFG)); // wait for TX buffer ready
__delay_cycles(75);
UCA0TXBUF = chA; // Send wiper level
while (!(IFG2 & UCA0TXIFG)); // wait for TX buffer ready
while (UCA0STAT & UCBUSY); // wait for the tx to complete
P1OUT |= BIT0; // disable Slave (CS to High)
}
}