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.

Tiva C LaunchPad + Nokia5110 PCD8544 + SPI + TivaWare = Not working

Other Parts Discussed in Thread: TM4C123GH6PM, ENERGIA

It seems to be everything correct with the code. The wiring is fine, I'm sure.

Can anyone see what is wrong?

The sequence of commands were taken from the PCD8544 datasheet.

Microcontroller = TM4C123GH6PM.

IDE = CCS v6

Compiler = TI ARM Compiler 5.1.8

Peripheral Library = TivaWare 2.1

/*
* main.c
*/

#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)
         {

         }
}

  • Hello Issac

    After configuring the GPIO Pins for RST, DnC, SCE, etc can you make the respective pin's high before toggling them. In default value they would remain 0 and as I have seen in the past SSI slave device use this information of H->L, for shift and transfers

    Regards

    Amit

  • Hi,

    There is a library for Energia for that LCD. Look around the source code. If i remember correctly the library just uses Energia functions so you need to also see Energia source code for those:

    Energia download:

    http://forum.43oh.com/topic/5839-new-energia-release-0101e0013-09052014/

    Nokia 5110 library:

    http://forum.stellarisiti.com/topic/386-energia-library-nokia-5110-lcd-library/

  • For writing onto the LCD screen by TM4C123GH6PM microcontroller, is it important to use the Peripheral Devices API's for GPIO, SSI and Clock or can I just  configure the GPIO, clock and SSI and write the values to the SSIDR and the values would be sent automatically to the DDRAM of Nokia5110 LCD?