This thread has been locked.

If you have a related question, please click the "Ask a related question" button in the top right corner. The newly created question will be automatically linked to this question.

SPI Communication on MSP430f5529 Launchpad

Other Parts Discussed in Thread: MSP430F5529

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
}

  • I am also currently having trouble interfacing the MSP430F5529 with my ISD1760 audo module. The problem I am encountering is that I am no getting any data in MISO but I see data in MOSI and CS and CLK are working. Were you able to configure it?
  • Could you share the code you have for the LCD... It would be really nice

  • Hello Anatolii,

    I do not have the actual code for LCD but i will share with you the code for SPI interface .You can modify according to your requirements.

    void SPI_init()
    {
        UCB0CTL1 |= UCSWRST;
        UCB0CTL0  =  0x00+UCMST + UCSYNC + UCMODE_0 + UCMSB + UCCKPH;
        UCB0CTL1 |=  UCSSEL_3;                  //data rate:
        UCB0BR1   =  0x00;
        UCB0BR0   =  0x01;                     // division factor of clock source
          /* 3) Configure ports
           MISO -> P3.1
           MOSI -> P3.0
           SCLK -> P3.2
           CS_N -> manualy set. (XOUT P2.2)*/
          P3SEL = BIT0+ BIT1+BIT2;                               // Configures SPI
          P2OUT &= ~BIT2;                                        //select device
          P3OUT|=BIT1;
          P2OUT|= BIT2;
          P2DIR|=BIT2;                                            //CONFIGURE CS FOR OUTPUT
          P3DIR |= BIT0 + BIT2;                                    // Set as outputs
          P3DIR&=~BIT1;//
          UCB0CTL1 &= ~UCSWRST;                                    //enable module or module initialization
          P2OUT&=~BIT2;//Make CS Low
    }

    See whether it resolves your problem or not  .Because i think you MISO line behaving weirdely.

    Thanks and Regards,

    Pavan

**Attention** This is a public forum