Quantcast
Channel: MSP430 Technical Forums
Viewing all articles
Browse latest Browse all 2077

ILI9341 Display on MSP432 with SPI

$
0
0

Hi,
 
I'm struggling to get the the ILI9341 display to work on a MSP432.
 
I've used it on an arduino with this display driver, so I figured that would be a good start for the porting.
 
This display is setup to use SPI (SCK,MISO,MOSI, CS,DC). I understand this is called 4 wire SPI?
 
The following is the code used to init the SPI is this correct?
 
 

    GPIO_setAsOutputPin(LCD_RESET_PORT,
                        LCD_RESET_PIN);

    GPIO_setOutputLowOnPin(LCD_RESET_PORT,
                           LCD_RESET_PIN);

    GPIO_setAsOutputPin(LCD_DC_PORT,
                        LCD_DC_PIN);

    GPIO_setOutputLowOnPin(LCD_DC_PORT,
                           LCD_DC_PIN);

    GPIO_setAsOutputPin(LCD_SPI_CS_PORT,
                        LCD_SPI_CS_PIN);

    GPIO_setOutputLowOnPin(LCD_SPI_CS_PORT,
                           LCD_SPI_CS_PIN);

    //
    // Configure SPI peripheral.
    //
	GPIO_setAsPeripheralModuleFunctionOutputPin(LCD_SPI_MOSI_PORT,
                                                LCD_SPI_MOSI_PIN,
                                                LCD_SPI_MOSI_PIN_FUNCTION);

	GPIO_setAsPeripheralModuleFunctionOutputPin(LCD_SPI_MISO_PORT,
                                                LCD_SPI_MISO_PIN,
                                                LCD_SPI_MISO_PIN_FUNCTION);

	GPIO_setAsPeripheralModuleFunctionOutputPin(LCD_SPI_CLK_PORT,
    											LCD_SPI_CLK_PIN,
                                                LCD_SPI_CLK_PIN_FUNCTION);

    eUSCI_SPI_MasterConfig spiMasterConfig =
    {
        EUSCI_B_SPI_CLOCKSOURCE_SMCLK,                      // SMCLK Clock Source
        CS_getSMCLK(),                                  // Get SMCLK frequency
        15000000,                                                // SPICLK = 15 MHz
        EUSCI_B_SPI_MSB_FIRST,                             // MSB First
        EUSCI_B_SPI_PHASE_DATA_CHANGED_ONFIRST_CAPTURED_ON_NEXT,         // Phase
        EUSCI_B_SPI_CLOCKPOLARITY_INACTIVITY_LOW,         // Low polarity
	EUSCI_B_SPI_4PIN_UCxSTE_ACTIVE_HIGH                                   // SPI Mode
    };

    //EUSCI_B_SPI_4PIN_UCxSTE_ACTIVE_HIGH
    //EUSCI_B_SPI_4PIN_UCxSTE_ACTIVE_LOW

    SPI_initMaster(LCD_EUSCI_MODULE, &spiMasterConfig);
    SPI_enableModule(LCD_EUSCI_MODULE);

    SPI_clearInterruptFlag(LCD_EUSCI_MODULE,  EUSCI_B_SPI_RECEIVE_INTERRUPT);

The code i'm unsure about is:

- GPIO_setAsPeripheralModuleFunctionOutputPin

Should SCK, MOSI, MISO all be set as output or input?

 

- EUSCI_B_SPI_CLOCKPOLARITY_INACTIVITY_LOW

Not really sure what this means is it correct?

 

- EUSCI_B_SPI_PHASE_DATA_CHANGED_ONFIRST_CAPTURED_ON_NEXT

Not really sure what this means is it correct?

 

-EUSCI_B_SPI_4PIN_UCxSTE_ACTIVE_HIGH

Not really sure what this means is it correct?

 

- SPI_clearInterruptFlag(LCD_EUSCI_MODULE, EUSCI_B_SPI_RECEIVE_INTERRUPT);

I'm not using interrupts should I remove this line?

 
Board: MSP432 Launchpad
 
Datasheet:
http://www.adafruit.com/datasheets/ILI9341.pdf


Viewing all articles
Browse latest Browse all 2077

Trending Articles