URGENT HELP WITH WH1602B LCD DISPLAY INITIALIZATION

cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 

URGENT HELP WITH WH1602B LCD DISPLAY INITIALIZATION

1,034 Views
lpcware
NXP Employee
NXP Employee
Content originally posted in LPCWare by pindonga123 on Tue Nov 12 19:03:47 MST 2013
Hello I need to help with the lcd wh1602b initialization. I did the code but it doesnt work. I send the datasheet of lcd display and my circuit of connections.Im using LPC1769 and 8 bits interface. Does anybody help me please?

#include "LPC17xx.h"
#include "lpc17xx_gpio.h"
#include "LPC17xx_systick.h"

#define FUNCTION_SET 1<<5 | 1<<6 | 1<<7
#define ON_OFF_CONTROL 1<<2 | 1<<3 | 1<<4 | 1<<5
#define DISPLAY_CLEAR 1<<2
#define ENTRY_MODE_SET 1<<2 | 1<<3 | 1<<4
#define ENABLE 1<<1
#define CLEAR 1<<0 | 1<<1 | 1<<2 | 1<<3 | 1<<4 | 1<<5 | 1<<6 | 1<<7 | 1<<8 | 1<<10

volatile unsigned long SysTickCnt;

void set_display (void);
void set_pines (void);
void Set_SysTick (void);
void Systick_Handler (void);
void Delay (uint32_t tick);
void set_enable_pin (void);

int main (void)
{
set_pines ();
set_display ();
while (1)
{
}
return 0;
}

void set_pines (void)
{
GPIO_SetDir (2, 1<<0, 1);
GPIO_SetDir (2, 1<<1, 1);
GPIO_SetDir (2, 1<<2, 1);
GPIO_SetDir (2, 1<<3, 1);
GPIO_SetDir (2, 1<<4, 1);
GPIO_SetDir (2, 1<<5, 1);
GPIO_SetDir (2, 1<<6, 1);
GPIO_SetDir (2, 1<<7, 1);
GPIO_SetDir (2, 1<<8, 1);
GPIO_SetDir (2, 1<<10, 1);
}

void set_display (void)
{
Delay (50);
GPIO_ClearValue (2, CLEAR);         //Clear all pins
GPIO_SetValue (2, FUNCTION_SET);    //Write FUNCTION_SET Command 0011100
set_enable_pin ();                  //Prepare pin ENABLE to write next command
Delay (1);                          //Delay 1msec
GPIO_SetValue (2, FUNCTION_SET);    //Write FUNCTION_SET 0011100
set_enable_pin ();                  //Prepare pin ENABLE to write next command
Delay (1);                          //Delay 1msec
GPIO_SetValue (2, ON_OFF_CONTROL);  //Write ON_OFF_CONTROL Command 00001111
set_enable_pin ();
Delay (1);
GPIO_SetValue (2, DISPLAY_CLEAR);   //Write DISPLAY_CLEAR Command 00000001
set_enable_pin ();
Delay(2);
GPIO_SetValue (2, ENTRY_MODE_SET);  //Write ENTRY_MODE_SET Command 00000111
set_enable_pin ();
}

void Set_SysTick (void)
{
SYSTICK_InternalInit (1);
SYSTICK_Cmd (ENABLE);
SYSTICK_IntCmd (ENABLE);
}

void SysTick_Handler (void)
{
SysTickCnt++;
}

void Delay (uint32_t tick)
{
unsigned long systickcnt;
systickcnt = SysTickCnt;
while ((SysTickCnt - systickcnt) < tick);
}

void set_enable_pin (void)
{
GPIO_ClearValue (2, CLEAR);  //Clear all pins
Delay (1);                   //Delay 1msec
GPIO_SetValue (2,ENABLE);    //Put 1 in Enable pin
Delay (1);                   //Delay 1msec
GPIO_ClearValue (2, CLEAR);  //Clear all pins
Delay (1);                   //Delay 1msec
}
Labels (1)
0 Kudos
Reply
0 Replies