Download as txt, pdf, or txt
Download as txt, pdf, or txt
You are on page 1of 2

#include

#include
#include
#include
#include
#include
#include
#include
#include
#include
#include
#include

<stdint.h>
<stdbool.h>
"inc/hw_memmap.h"
"inc/hw_types.h"
"driverlib/gpio.h"
"driverlib/pin_map.h"
"driverlib/rom.h"
"driverlib/sysctl.h"
"driverlib/uart.h"
"utils/uartstdio.h"
"inc/tm4c123gh6pm.h"
"lcd5110.h"

volatile unsigned long ulLoop;


void setup()
{
//clock setup
SysCtlClockSet(SYSCTL_SYSDIV_8|SYSCTL_USE_PLL|SYSCTL_XTAL_16MHZ|SYSCTL_OSC_MAIN)
;
SYSCTL_RCGC2_R |= SYSCTL_RCGC2_GPIOD;
SYSCTL_RCGC2_R |= SYSCTL_RCGC2_GPIOE;
//lcd connections init
ulLoop = SYSCTL_RCGC2_R;
GPIO_PORTD_DIR_R = 0xff;
GPIO_PORTD_DEN_R = 0xff;
GPIO_PORTE_DIR_R = 0xff;
GPIO_PORTE_DEN_R = 0xff;
}
#define
#define
#define
#define
#define
#define

RS PE1
EN PE2
LCD_STROBE do{EN=BIT2;EN=!BIT2;}while(0)
databits GPIO_PORTD_DATA_R // P1.7 - D7, ....., P1.4 - D4
LINE1 cmd(0x80)
LINE2 cmd(0xc0)

void data(unsigned char c)


{
RS=BIT1;
SysCtlDelay(400);
databits = c >>4;
LCD_STROBE;
databits = c;
LCD_STROBE;
}
void cmd(unsigned char c)
{
RS=!BIT1;
SysCtlDelay(400);
databits = c >>4;
LCD_STROBE;
databits = c;
LCD_STROBE;
}
void pseudo_8bit_cmd(unsigned char c)
{
RS=!BIT1;

SysCtlDelay(15000);
databits = (c);
LCD_STROBE;
}
void clear(void)
{
cmd(0x01);
SysCtlDelay(30000);
}
void lcd_init()
{
pseudo_8bit_cmd(0x30); //this command is like 8 bit mode command
pseudo_8bit_cmd(0x30); //lcd expect 8bit mode commands at first
pseudo_8bit_cmd(0x30); //for more details, check any 16x2 lcd spec
pseudo_8bit_cmd(0x20);
cmd(0x28); //4 bit mode command started, set two line
cmd(0x0c); // Make cursorinvisible
clear(); // Clear screen
cmd(0x6); // Set entry Mode(auto increment of cursor)
}
void string(char *p)
{
while(*p) data(*p++);
}
int main()
{
while(1) {
setup();
lcd_init();
LINE1;
string("Stellaris |====>");
LINE2;
string("|====> Launchpad");
SysCtlDelay(50000);
RS=!BIT1;
while(1);
}
}

You might also like