lpc1114 driver 1602_0802 program

Publisher:姑苏清风泉源客Latest update time:2016-12-09 Source: eefocusKeywords:lpc1114 Reading articles on mobile phones Scan QR code
Read articles on your mobile phone anytime, anywhere

LPC1114-1602

Figure 1. LPC1114 driving LCD1602

LPC1114-0802

Figure 2. LPC1114 driving LCD0802

The program used for LCD1602 and LCD0802 is the same.

In the lcd.h file, the code is as follows:

#ifndef __LCD0802_H__
#define __LCD0802_H__
#include "lpc11xx.h"

#define OUT_DATA(value)     LPC_GPIO2->DATA =(value<<4)
#define RS_LOW  LPC_GPIO3->DATA&=~(1<<0)
#define RS_HIGH  LPC_GPIO3->DATA|=(1<<0)
#define WR_LOW  LPC_GPIO3->DATA&=~(1<<1)
#define WR_HIGH  LPC_GPIO3->DATA|=(1<<1)
#define EN_LOW  LPC_GPIO3->DATA&=~(1<<2)
#define EN_HIGH  LPC_GPIO3->DATA|=(1<<2)

extern void delay_0802(uint16_t us);
extern void write_com(uint16_t com);
extern void write_date(uint16_t dat);
extern void init_0802(void);
extern void lcd_show(void);

#endif

In the lcd.c file, the code is as follows:

#include "lcd.h"
#include "lpc11xx.h"

void delay_0802(uint16_t us)
{
    uint16_t i,j;

    for(i=0;i<100;i++)
        for(j=0;jDIR|=0xFF0; // Set the high 8-bit pins of P2 port to output, used as LCD 8-bit parallel data
    LPC_GPIO2->DATA |= 0XFF0; // Set the high 8-bit pin of port P2 to high
    LPC_GPIO3->DIR|=0x007; // P3 port P3.0 to P3.3 are output pins, used as LCD control pins
    LPC_GPIO3->DATA |= 0x007; // P3 port P3.0 to P3.3 set high
    delay_0802(300);
    write_com(0x38);
    delay_0802(100);
    write_com(0x38);
    delay_0802(100);
    write_com(0x38);
    delay_0802(100);
    write_com(0x0c);
    delay_0802(100);
    write_com(0x06);
    delay_0802(100);
    write_com(0x01);
    delay_0802(100);
}

In the main.c file, the code is as follows:

/**************************************************
 * Name: LPC1114 drives LCD0802 1602
 * Main frequency: 50Mhz (externally connected to 10MHz crystal oscillator, multiplied by 5 times)
 * Author: Ration (CEO of Ruisheng Electronics Network)
 * Date: December 5, 2013 (edited)
 * Copyright: Copyright belongs to , please keep integrity when disseminating
 *
 * For more programs, please visit: http://www.rationmcu.com
 *************************************************/
#include "lpc11xx.h"
#include "lcd.h"

uint8_t table1[8]=" Hello  ";
uint8_t table2[8]=" World  ";

void delay_ms(uint16_t ms)
{
    uint16_t i,j;

    for(i=0;i<5000;i++)
        for(j=0;j


Keywords:lpc1114 Reference address:lpc1114 driver 1602_0802 program

Previous article:lpc1114 set pin function
Next article:LPC1114 Deep power-down mode Deep power-down mode

Latest Microcontroller Articles
  • Download from the Internet--ARM Getting Started Notes
    A brief introduction: From today on, the ARM notebook of the rookie is open, and it can be regarded as a place to store these notes. Why publish it? Maybe you are interested in it. In fact, the reason for these notes is ...
  • Learn ARM development(22)
    Turning off and on interrupts Interrupts are an efficient dialogue mechanism, but sometimes you don't want to interrupt the program while it is running. For example, when you are printing something, the program suddenly interrupts and another ...
  • Learn ARM development(21)
    First, declare the task pointer, because it will be used later. Task pointer volatile TASK_TCB* volatile g_pCurrentTask = NULL;volatile TASK_TCB* vol ...
  • Learn ARM development(20)
    With the previous Tick interrupt, the basic task switching conditions are ready. However, this "easterly" is also difficult to understand. Only through continuous practice can we understand it. ...
  • Learn ARM development(19)
    After many days of hard work, I finally got the interrupt working. But in order to allow RTOS to use timer interrupts, what kind of interrupts can be implemented in S3C44B0? There are two methods in S3C44B0. ...
  • Learn ARM development(14)
  • Learn ARM development(15)
  • Learn ARM development(16)
  • Learn ARM development(17)
Change More Related Popular Components

EEWorld
subscription
account

EEWorld
service
account

Automotive
development
circle

About Us Customer Service Contact Information Datasheet Sitemap LatestNews


Room 1530, 15th Floor, Building B, No.18 Zhongguancun Street, Haidian District, Beijing, Postal Code: 100190 China Telephone: 008610 8235 0740

Copyright © 2005-2024 EEWORLD.com.cn, Inc. All rights reserved 京ICP证060456号 京ICP备10001474号-1 电信业务审批[2006]字第258号函 京公网安备 11010802033920号