I am using a 16x2 LCD.. (1602ZFA)
I have used Port B of the Tiva C Launchpad as the data bus for the 8-bit LCD..
The connections are as follows :-
Board Pins = PB0 PB1 PB2 PB3 PB4 PB5 PB6 PB7 PA6 PA7
LCD Pins = D0 D1 D2 D3 D4 D5 D6 D7 RS EN
The RW pin has been connected to the ground.. I have turned ON the LCD's backlight and have used a POT on Vo pin.. Also, I am using the board at 40MHz system frequency.. The code is as follows :-
#include <stdint.h>
#include <stdbool.h>
#include "inc/hw_types.h"
#include "inc/hw_memmap.h"
#include "driverlib/sysctl.h"
#include "driverlib/gpio.h"
int main(void)
{
uint8_t ui8Value[]={0x38, 0x0e, 0x01, 0x06, 0x80};
uint8_t value;
//------------------- Tiva C Launchpad System Initilization------------------//
SysCtlClockSet(SYSCTL_SYSDIV_5 | SYSCTL_USE_PLL| SYSCTL_XTAL_16MHZ|
SYSCTL_OSC_MAIN);
SysCtlPeripheralEnable(SYSCTL_PERIPH_GPIOA);
SysCtlPeripheralEnable(SYSCTL_PERIPH_GPIOB);
GPIOPinTypeGPIOOutput(GPIO_PORTA_BASE, GPIO_PIN_6 | GPIO_PIN_7);
GPIOPinTypeGPIOOutput(GPIO_PORTB_BASE, GPIO_PIN_0 | GPIO_PIN_1| GPIO_PIN_2 | GPIO_PIN_3|GPIO_PIN_4 | GPIO_PIN_5| GPIO_PIN_6 | GPIO_PIN_7);
//------------------End of Tiva C Launchpad System Initilization------------//
SysCtlDelay(13333);
GPIOPinWrite(GPIO_PORTA_BASE, GPIO_PIN_6 | GPIO_PIN_7, 0x00);
for(value=0;value<=4;value++)
{
//-------------------------------LCD Command----------------------------//
//Put on the Data Pins 0x38 to get 2 Lines 5x7 Matrix (D0-D7, 8Bit)//
GPIOPinWrite(GPIO_PORTB_BASE, GPIO_PIN_0 | GPIO_PIN_1| GPIO_PIN_2 | GPIO_PIN_3
|GPIO_PIN_4 | GPIO_PIN_5| GPIO_PIN_6 | GPIO_PIN_7, ui8Value[value]);
//Register Select(RS) = 0, Enable(E) = 1//
GPIOPinWrite(GPIO_PORTA_BASE, GPIO_PIN_6 | GPIO_PIN_7, 0x80);
//Enable Pulse Width (High Level) 1 millisecond//
SysCtlDelay(13);
//Register Select(RS) = 0, Enable(E) = 0//
GPIOPinWrite(GPIO_PORTA_BASE, GPIO_PIN_6 | GPIO_PIN_7, 0x00);
//---------------------------End of LCD Command------------------------//
SysCtlDelay(13333);
}
//---------------------------LCD Data Write--------------------------//
GPIOPinWrite(GPIO_PORTB_BASE, GPIO_PIN_0 | GPIO_PIN_1| GPIO_PIN_2 | GPIO_PIN_3
|GPIO_PIN_4 | GPIO_PIN_5| GPIO_PIN_6 | GPIO_PIN_7, 0x42);
//Register Select(RS) = 1, Enable(E) = 1//
GPIOPinWrite(GPIO_PORTA_BASE, GPIO_PIN_6 | GPIO_PIN_7, 0xC0);
//Enable Pulse Width (High Level) 1 millisecond//
SysCtlDelay(13);
//Register Select(RS) = 1, Enable(E) = 0//
GPIOPinWrite(GPIO_PORTA_BASE, GPIO_PIN_6 | GPIO_PIN_7, 0x40);
SysCtlDelay(8333);
//--------------------------- End of LCD Data Write-------------------------//
while(1)
{
}
}
The problem is that as soon as I run the code, all the matrices of the first and second row become dotted and nothing else happens.. How should I modify the code so that it runs perfectly..
(For the enable signal, I am using a 1 millisecond high pulse)