Tool/software: Code Composer Studio
I am trying to interface nokia5110 with tiva USING SPI .
Its not working below is the code .
Help me in this...........any changes
#include <stdint.h>
#include <stdbool.h>
#include <inc/hw_memmap.h>
#include <inc/hw_types.h>
#include <driverlib/gpio.h>
#include <driverlib/sysctl.h>
#include <driverlib/pin_map.h>
#include <driverlib/ssi.h>
#define LCD_PIN_CLK GPIO_PIN_2 //used by the SSI module
#define LCD_PIN_RST GPIO_PIN_3
#define LCD_PIN_DnC GPIO_PIN_4
#define LCD_PIN_DIN GPIO_PIN_5 //used by the SSI module
//#define LCD_PIN_BL GPIO_PIN_6
#define LCD_PIN_SCE GPIO_PIN_7
#define LCD_PIN_HIGH 0xff
#define LCD_PIN_LOW 0x00
void LCDWriteCmd(uint8_t u8Cmd)
{
GPIOPinWrite(GPIO_PORTA_BASE, LCD_PIN_DnC, LCD_PIN_LOW);
GPIOPinWrite(GPIO_PORTA_BASE, LCD_PIN_SCE, LCD_PIN_LOW);
SSIDataPut(SSI0_BASE, ((uint32_t) u8Cmd));
GPIOPinWrite(GPIO_PORTA_BASE, LCD_PIN_SCE, LCD_PIN_HIGH);
}
void LCDWriteDat(uint8_t u8Data)
{
GPIOPinWrite(GPIO_PORTA_BASE, LCD_PIN_DnC, LCD_PIN_HIGH);
GPIOPinWrite(GPIO_PORTA_BASE, LCD_PIN_SCE, LCD_PIN_LOW);
SSIDataPut(SSI0_BASE, ((uint32_t) u8Data));
GPIOPinWrite(GPIO_PORTA_BASE, LCD_PIN_SCE, LCD_PIN_HIGH);
}
int main(void)
{
//Clock configuration
SysCtlClockSet(SYSCTL_OSC_MAIN | SYSCTL_USE_PLL | SYSCTL_SYSDIV_4 | SYSCTL_XTAL_16MHZ);
//Enable GPIOA and SSI eripheral
SysCtlPeripheralEnable(SYSCTL_PERIPH_SSI0);
SysCtlPeripheralEnable(SYSCTL_PERIPH_GPIOA);
//Configure GPIO pins (RST, DnC, BL, SCE) as output
GPIOPinTypeGPIOOutput(GPIO_PORTA_BASE, GPIO_PIN_3 | GPIO_PIN_4 | GPIO_PIN_6 | GPIO_PIN_7);
//Enable pin PA2 for SSI0 SSI0CLK
GPIOPinConfigure(GPIO_PA2_SSI0CLK);
GPIOPinTypeSSI(GPIO_PORTA_BASE, GPIO_PIN_2);
//Enable pin PA5 for SSI0 SSI0TX
GPIOPinConfigure(GPIO_PA5_SSI0TX);
GPIOPinTypeSSI(GPIO_PORTA_BASE, GPIO_PIN_5);
//COnfigures SSI module
SSIConfigSetExpClk(SSI0_BASE, SysCtlClockGet(), SSI_FRF_MOTO_MODE_0 , SSI_MODE_MASTER,1000000, 8);
SSIEnable(SSI0_BASE);
//Applies reset signal
GPIOPinWrite(GPIO_PORTA_BASE, LCD_PIN_RST, LCD_PIN_HIGH);
SysCtlDelay(100000);
GPIOPinWrite(GPIO_PORTA_BASE, LCD_PIN_RST, LCD_PIN_LOW);
SysCtlDelay(100000);
GPIOPinWrite(GPIO_PORTA_BASE, LCD_PIN_RST, LCD_PIN_HIGH);
//SCE line goes low
GPIOPinWrite(GPIO_PORTA_BASE, LCD_PIN_SCE, LCD_PIN_LOW);
//Selects command mode
GPIOPinWrite(GPIO_PORTA_BASE, LCD_PIN_DnC, LCD_PIN_LOW);
//Selects extended instruction set
SSIDataPut(SSI0_BASE, ((uint32_t) 0x21));
//Set Vop
SSIDataPut(SSI0_BASE, ((uint32_t) 0x90));
//Selects normal instruction set
SSIDataPut(SSI0_BASE, ((uint32_t) 0x20));
//Puts display on normal mode
SSIDataPut(SSI0_BASE, ((uint32_t) 0x0c));
//Selectes data mode
GPIOPinWrite(GPIO_PORTA_BASE, LCD_PIN_DnC, LCD_PIN_HIGH);
//Write some data (uppercase letters P and H)
SSIDataPut(SSI0_BASE, ((uint32_t) 0x1f));
SSIDataPut(SSI0_BASE, ((uint32_t) 0x05));
SSIDataPut(SSI0_BASE, ((uint32_t) 0x07));
SSIDataPut(SSI0_BASE, ((uint32_t) 0x00));
SSIDataPut(SSI0_BASE, ((uint32_t) 0x1f));
SSIDataPut(SSI0_BASE, ((uint32_t) 0x04));
SSIDataPut(SSI0_BASE, ((uint32_t) 0x1f));
//Selects command mode
GPIOPinWrite(GPIO_PORTA_BASE, LCD_PIN_DnC, LCD_PIN_LOW);
//Sets inverse video mode
SSIDataPut(SSI0_BASE, ((uint32_t) 0x0d));
//Set X address to 0000000
SSIDataPut(SSI0_BASE, ((uint32_t) 0x80));
//Data write
SSIDataPut(SSI0_BASE, ((uint32_t) 0x00));
while(1)
{
}
}