Hi
I have going to interface the MSP430f5438 with digital potentiometer MCP41010 by SPI communication.For that i have write the code as below.My spi had some problem because of that i am not able to write the value in the data registers.If you had any solution for me then please send me.
void spi_init(void)
{
//unsigned char spi_cmd,spi_data;
WDTCTL = WDTPW+WDTHOLD; // Stop watchdog timer
P10OUT |= 0x01; //Chip select
P10DIR |= 0x0B; // Set P10-0,3,1 to output direction
P10SEL |= 0xA; // P10.1,3 option select for the si and clk
UCB3CTL1 |= UCSWRST; // **Put state machine in reset**
UCB3CTL0 |= UCMST+UCSYNC+UCCKPL+UCMSB; // 3-pin, 8-bit SPI master
// Clock polarity high, MSB
UCB3CTL1 |= UCSSEL_2; // SMCLK
UCB3BR0 = 0x02; // /2
UCB3BR1 = 0; //
//UCA3MCTL = 0; // No modulation
UCB3CTL1 &= ~UCSWRST; // **Initialize USCI state machine**
// UCA0IE |= UCRXIE; // Enable USCI_A0 RX interrupt
P10OUT &= ~0x01; // Now with SPI signals initialized,
P10OUT |= 0x01; // reset slave
}
void spi_write(unsigned char data)
{
while (!(UCB3IFG&UCTXIFG)); // USCI_A0 TX buffer ready?
UCB3TXBUF = data;
}
void main (void)
{
spi_init();
P10OUT&=~0x01
delay(1000);
spi_write(17); //command set for the digital pot IC
spi_write(0); //values given to the data register
delay(1000);
P10OUT|=0x01
}