Tool/software: TI C/C++ Compiler
Hi,
I am trying to interface a 16X2 LCD with Tiva,Here I am trying to send strings on the Lcd,I have used lcd in 4 bit mode.In my hardware only 4 bit provisions are there,so I am unable to use 8 bit mode. Please help me to solve this 4 bit mode issue. I am getting the dots in LCD screen but not displaying any cursor/string.I was using systick interrupt to provide proper time delay.I was checked the Enable pin triggering with oscilloscope and it is triggering correctly. I red many forum regarding the LCD display and still I am unable to solve the issues. I am new to tiva ,I am hoping someone in this forum can help me.
VSS is connected to ground
VDD is connected to a pot
VEE is connected to +5V
RS is connected to portG pin 4
RW is grounded...
Enable pin is connected to portG pin 5
D0 to D4 are connected to portG pin0 to pin 4 respectively
Back light pins are also connected to +5V and ground...
Given below is my code I was used for interfacing
#include <stdbool.h>
#include <stdint.h>
#include "inc/hw_i2c.h"
#include "inc/hw_memmap.h"
#include "inc/hw_types.h"
#include "driverlib/gpio.h"
#include "driverlib/i2c.h"
#include "driverlib/pin_map.h"
#include "driverlib/sysctl.h"
#include "driverlib/uart.h"
#include "driverlib/systick.h"
#include "inc/hw_nvic.h"
#include "inc/hw_types.h"
#include "driverlib/pin_map.h"
#include "driverlib/interrupt.h"
volatile uint32_t msTicks = 0;
/*****************************************************************************************************************
LCD is in 4-bit mode so it send data in 2 strocks in first First the higher four nibbles of a character
*******************************************************************************************************************/
/******************************************************************************************************************
Systick interrupt function
******************************************************************************************************************/
void SysTick_Handler(void)
{
//
// Update the Systick interrupt counter.
//
/* Increment counter necessary in Delay()*/
msTicks++;
}
void Delay(uint32_t dlyTicks)
{
uint32_t curTicks;
curTicks = msTicks;
while ((msTicks - curTicks )< dlyTicks) ;
}
/*****************************************************************************************************************************
End of systick interrupt
******************************************************************************************************************************/
void Lcd_command(unsigned char cmd)
{
GPIOPinWrite(GPIO_PORTG_BASE, GPIO_PIN_0|GPIO_PIN_1|GPIO_PIN_2|GPIO_PIN_3, cmd);//LCD data
Delay(1000);
//GPIOPinWrite(GPIO_PORTD_BASE, GPIO_PIN_0,com);//LCD mode
GPIOPinWrite(GPIO_PORTG_BASE, GPIO_PIN_4|GPIO_PIN_5,0x00);//Make RS=0GPIO pin-4,E=0 GPIO pin 5
Delay(1000);
GPIOPinWrite(GPIO_PORTG_BASE, GPIO_PIN_4|GPIO_PIN_5,0x20);//make RS=0,E=1 enabling lcd by high to low pulse
Delay(1000);
GPIOPinWrite(GPIO_PORTG_BASE, GPIO_PIN_4|GPIO_PIN_5,0x00);//Make RS=0,E=0
Delay(1000);
}
void Lcd_data(unsigned char data)
{
GPIOPinWrite(GPIO_PORTG_BASE, GPIO_PIN_0|GPIO_PIN_1|GPIO_PIN_2|GPIO_PIN_3, data);//LCD data
Delay(1000);
//GPIOPinWrite(GPIO_PORTD_BASE, GPIO_PIN_0,com);//LCD mode
GPIOPinWrite(GPIO_PORTG_BASE, GPIO_PIN_4|GPIO_PIN_5,0x10);//Make RS=1GPIO pin-4,E=0 GPIO pin 5
Delay(1000);
GPIOPinWrite(GPIO_PORTG_BASE, GPIO_PIN_4|GPIO_PIN_5,0x30);//make RS=1,E=1 enabling lcd by high to low pulse
Delay(1000);
GPIOPinWrite(GPIO_PORTG_BASE, GPIO_PIN_4|GPIO_PIN_5,0x10);//Make RS=1,E=0
Delay(1000);
}
void Lcd_Init()
{
Lcd_command(0x28); //4-bit mode lcd having 2 lines and character shape between 5x7 matrix.
Delay(500); //provide 500ms delay
Lcd_command(0x06); //Display ON, cursor OFF / entry mode it tells the lcd that we are going to use.
Delay(500); //provide 500ms delay
Lcd_command(0x0E); //displays cursor on and dispaly on.
Delay(500); //provide 500ms delay
Lcd_command(0x0F); //displays cursor on and dispaly on.
Delay(500); //provide 500ms delay
Lcd_command(0x01); //Clear screen
Delay(500); //provide 500ms delay
}
void Lcd_String_Display(unsigned char *str)
{
while(*str!='\0')
{
Lcd_data(*str);
str++;
}
}
/*******************************************************************************************************************************************
Main starts here
*******************************************************************************************************************************************/
int main(void)
{
SysCtlClockSet(SYSCTL_SYSDIV_1|SYSCTL_USE_OSC |SYSCTL_XTAL_8MHZ|SYSCTL_OSC_MAIN);//8MHz crystall oscilator
SysCtlPeripheralEnable(SYSCTL_PERIPH_GPIOG);
while(!SysCtlPeripheralReady(SYSCTL_PERIPH_GPIOG));
GPIOPinTypeGPIOOutput(GPIO_PORTG_BASE, GPIO_PIN_0|GPIO_PIN_1|GPIO_PIN_2|GPIO_PIN_3|GPIO_PIN_4|GPIO_PIN_5);
IntMasterEnable();// Enable interrupts to the processor.
SysTickPeriodSet(7997); // Set up the period for the SysTick timer of 1ms.
SysTickIntEnable(); // Enable the SysTick Interrupt.
SysTickEnable();// Enable SysTick. SysTickEnable();// Enable SysTick.
//GPIOPinTypeLCD(GPIO_PORTG_BASE, GPIO_PIN_0|GPIO_PIN_1|GPIO_PIN_2|GPIO_PIN_3|GPIO_PIN_4|GPIO_PIN_5);
Lcd_Init();
while (1)
{
Lcd_String_Display("Welcome....");
}
}
/*************************************************************************************************************************************************
End of main
*************************************************************************************************************************************************/
Looking forward for a quick replay...
Regards,
Alphy