Hi All,
I am new to this forum and I could use some help. I have a TI Launchpad with an MSP430f5529 u-controller. I am having trouble getting the SPI on the controller to interface with an LCD breakout board that I have (ST7735R). I have spent a considerable amount of time going over the example code provided by TI for SPI and the datasheet for the LCD, but so far I have had no luck getting the two to talk to each other. Below is one of the TI CCS example projects that I have adapted for my uses. I have hooked the Launchpad up to an o-scope and I have been unable to see a clock signal, and I do not see the expected result when sending a command to the LCD. Can anyone see anything wrong with the code? Any help on the matter would be greatly appreciated. Thanks!
#include <msp430.h>
unsigned char MST_Data,SLV_Data;
unsigned char temp;
int main(void)
{
volatile unsigned int i;
WDTCTL = WDTPW+WDTHOLD; // Stop watchdog timer
P4DIR |= BIT1; //Set P4.1 (chip select) as output
P4OUT |= BIT1; //Set P4.1 (chip select) high
P8DIR |= BIT1; //Set P8.1 (Data/Command) as output
P8OUT |= BIT1; //Set P8.1 (Data/Command high
//The LCD SPI peripheral I am using
//Requires a Data/command bit to indicate
//whether the transmission is a command or data
P2DIR |= BIT0;
P2OUT |= BIT0; // Set P2.0 for slave reset
P1DIR |= 0x03; // Set P1.0-2 to output direction
P3SEL |= BIT3+BIT4; // P3.3,4 option select
P2SEL |= BIT7; // P2.7 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 &= ~BIT0; // Now with SPI signals initialized,
P2OUT |= BIT0; // reset slave
for(i=50;i>0;i--); // Wait for slave to initialize
P4OUT &= ~BIT1; //Set P4.1 (chip select) low to select LCD
P8OUT &= ~BIT1; //Set P8.1 (Data/Command) low to indicate command transmission
MST_Data = 0x21; // Initialize data 0x21 = color inversion command
// SLV_Data = 0x01; //
while (!(UCA0IFG&UCTXIFG)); // USCI_A0 TX buffer ready?
UCA0TXBUF = MST_Data; // Transmit first character
P4OUT |= 0x02; // Set CS back high
P8OUT |= BIT1; // Set D/C back high
// __bis_SR_register(LPM0_bits + GIE); // CPU off, enable interrupts
}