#include "LPC23XX.h"
#include "CONFIG.H"
//set IO
void FIO_Set(unsigned char port ,unsigned int pin)
{
switch(port)
{
case 0:
FIO0SET = pin;
break;
case 1:
FIO1SET = pin;
break;
case 2:
FIO2SET = pin;
break;
case 3:
FIO3SET = pin;
break;
case 4:
FIO4SET = pin;
break;
default:
break;
}
}
//clear IO
void FIO_Clr(unsigned char port, unsigned int pin)
{
switch(port)
{
case 0:
FIO0CLR = pin;
break;
case 1:
FIO1CLR = pin;
break;
case 2:
FIO2CLR = pin;
break;
case 3:
FIO3CLR = pin;
break;
case 4:
FIO4CLR = pin;
break;
default:
break;
}
}
void config_IO(void)
{
SCS |= 1; //允许P0、P1的高速GPIO功能
PINSEL10 = 0; //禁止EMC
//LCD
PINSEL4 &= 0xfffc0000; //P2.0~P2.8用于I/O口
FIO0DIR |=LCD_CS|LCD_RS|LCD_WR|LCD_RST;
FIO2DIRL |= 0x01ff; //P2.0~P2.8输出方向
}
/*Write Data to P2*/
void WR_BUS(euint8 data)
{
euint8 i = 0;
i = data;
FIO2SET0 = i;
i= (~i);
FIO2CLR0 = i;
}
/*Delay*/
void LCD_Delay(euint32 time)
{
euint32 i,j;
for(i=0;i<time;i++)
for(j=0;j<20;j++)
;
}
/*Write Regist Cmd to LCD*/
void CmdWrite(euint8 cmdreg,euint8 cmddata)
{
WR_BUS( cmdreg ); //Write Regist Address
FIO_Clr( PORT0, LCD_CS );
FIO_Clr( PORT0, LCD_RS );
FIO_Clr( PORT0, LCD_WR );
LCD_Delay( 1 );
FIO_Set( PORT0, LCD_WR );
LCD_Delay( 1 );
FIO_Set( PORT0, LCD_RS );
FIO_Set( PORT0, LCD_CS );
WR_BUS( cmddata ); //Write Data
FIO_Clr( PORT0, LCD_CS );
FIO_Clr( PORT0, LCD_RS );
FIO_Clr( PORT0, LCD_WR );
LCD_Delay( 1 );
FIO_Set( PORT0, LCD_WR );
LCD_Delay( 1 );
FIO_Set( PORT0, LCD_RS );
FIO_Set( PORT0, LCD_CS );
}
/*Write Data to LCD*/
void DataWrite(euint8 wrdata)
{
FIO_Set( PORT0, LCD_WR );
FIO_Set( PORT0, LCD_RS );
WR_BUS(wrdata);
FIO_Clr( PORT0, LCD_CS );
FIO_Clr( PORT0, LCD_WR );
LCD_Delay( 1 );
FIO_Set( PORT0, LCD_WR);
LCD_Delay( 1 );
FIO_Clr( PORT0, LCD_RS);
FIO_Set( PORT0, LCD_CS);
}
//Set Cursor
void Set_Cursor(euint8 x,euint8 y)
{
CmdWrite( 0x60, x );
CmdWrite( 0x70, y );
}
void Printstr(euint8 x,euint8 y,euint8 *str)
{
Set_Cursor(x,y);
while(*str!=0)
{
DataWrite(*str);
str++;
LCD_Delay(1);
}
}
/*LCD Reset and Initial*/
void LCD_Initial(void)
{
FIO_Set( PORT0, LCD_WR );
FIO_Set( PORT0, LCD_RS );
FIO_Set( PORT0, LCD_CS );
WR_BUS( 0XFF );
FIO_Clr( PORT0, LCD_RST );
LCD_Delay( 1 );
FIO_Set( PORT0, LCD_RST );
LCD_Delay( 4000 );
CmdWrite(0x00,0xcd); //正常模式;文本模式;显示关开:开;屏幕闪烁:否;显示类型:正向
CmdWrite(0x90,0x0d); //移位时钟
CmdWrite(0x11,0x00); //光标高度:1;行距:0
CmdWrite(0x03,0x80); //高低位反转:否;垂直移动:禁止;水平移动:禁止;平移模式:垂直移动
CmdWrite(0x10,0x6b); //读数据时,光标自动移位:否;中英文对齐:是;正反相存储:正相;字体设置:正常;
//写数据时,光标自动移位:是;光标显示:关;光标闪烁:是;光标宽度:8或16
// CmdWrite(0x12,0x91); //图形
CmdWrite(0x20,0x17); //工作视窗右边位置
CmdWrite(0x30,0x7f); //工作视窗底部位置
CmdWrite(0x40,0x00); //工作视窗左边位置
CmdWrite(0x50,0x00); //工作视窗顶部位置
CmdWrite(0x21,0x17); //显示视窗右边位置
CmdWrite(0x31,0x80); //显示视窗底部位置
CmdWrite(0x41,0x00); //显示视窗左边位置
CmdWrite(0x51,0x00); //显示视窗顶部位置
CmdWrite(0x60,0x00); //设定X坐标
CmdWrite(0x70,0x00); //设定Y坐标
// CmdWrite(0xe0,0x00); //图形
CmdWrite(0xf0,0xa0); //简体字型
CmdWrite(0xf1,0x0f); //字型大小
CmdWrite(0xe0,0x00); //清屏
CmdWrite(0xf0,0xa8);
LCD_Delay( 300 ); //2ms
Printstr(0x05,0x38,"LPC2378开发板");
}
int main()
{
config_IO();
LCD_Initial();
while(1){ }
}
lcd.rar_arm显示lcd
版权申诉
94 浏览量
2022-09-21
07:32:46
上传
评论
收藏 104KB RAR 举报
林当时
- 粉丝: 100
- 资源: 1万+
最新资源
- 基于matlab实现字符识别的参考程序,用所用的字体识别率挺高,部分手写的也能识别,但是还不能识别扭曲和倾斜的字符 .rar
- 基于matlab实现指纹识别系统 包括数据库导入、图像选择识别、帮助功能、识别图像可视、gabor滤波可视,实现界面操作.rar
- 基于matlab实现指纹识别,利用gabor滤波器,提取指纹特征,只能呢读取bmp图像.rar
- 基于matlab实现于数字图像相关方法中散斑质量评价
- 基于matlab实现遗传算法和佳点集遗传算法的基本思想和不同点,用遗传算法测试一标准函数 佳点集算法测试一标准函数
- tensorflow-gpu-2.5.1-cp38-cp38-manylinux2010-x86-64.whl
- tensorflow-gpu-2.5.0-cp39-cp39-manylinux2010-x86-64.whl
- tensorflow-gpu-2.5.2-cp39-cp39-manylinux2010-x86-64.whl
- 内含方正小标宋简体、仿宋-Gb2312、黑体、楷体、宋体,五个公文常用字体
- 记忆卡牌游戏源码及可运行文件
资源上传下载、课程学习等过程中有任何疑问或建议,欢迎提出宝贵意见哦~我们会及时处理!
点击此处反馈