資源簡介
LCD1602程序 for MSP430F449,本人編寫的詳細源代碼,供學習和工作參考使用。值得下載和收藏。

代碼片段和文件信息
/*******************************************************************************
*??描述:???????????????????????????????????????????????????????????????????????*
*?????????1602字符型LCD顯示演示程序????????????????????????????????????????????*
*?????????在第一行顯示??welcome????????????????????????????????????????????????*
*?????????在第二行顯示??www.ycit.cn?????????????????????????????????????????*
*??????????????????????????????????????????????????????????????????????????????*
********************************************************************************/
#ifndef?uchar
#define?uchar?unsigned?char
#endif
#ifndef?uint?
#define?uint?unsigned?int
#endif
#define?nop?_NOP()
//RS--P5.6??RW--P5.5??E--P5.4
//sbit?RS =?P2^6; //
//sbit?RW?=?P2^5;
//sbit?E?=?P2^7;
#define?RS_1?P5OUT?|=?BIT6
#define?RS_0?P5OUT?&=?~BIT6
#define?RW_1?P5OUT?|=?BIT5
#define?RW_0?P5OUT?&=?~BIT5??////
#define?E_1??P5OUT?|=?BIT4
#define?E_0??P5OUT?&=?~BIT4
uchar??dis1[]?=?{“welcome!“};
uchar??dis2[]?=?{“www.ycit.cn“};
/*
void?RS(char?s)
{
if(s==1)?P5OUT?|=?BIT6;
else??P5OUT?&=?~BIT6;
}
void?RW(char?s)
{
if(s==1)?P5OUT?|=?BIT5;
else??P5OUT?&=?~BIT5;
}
void?E(char?s)
{
if(s==1)?P5OUT?|=?BIT4;
else??P5OUT?&=?~BIT4;
}??*/
/**********LCD1602.c?函數聲明***************/
void?delay(uchar?ms);??????//延時3*ms毫秒
uchar?lcd_bz();??????????????//測試LCD忙碌狀態
void?write_cmd1(uchar?cmd1);??//寫入指令數據到LCD
void?write_cmd(uchar?cmd);??//寫入指令數據到LCD
void?lcd_pos(uchar?pos);???//設定顯示位置
void?write_data(uchar?dat);?//寫入字符顯示數據到LCD
void?LCD_Init();???????????//LCD初始化設定
void?delay(uchar?ms)
{ //?延時子程序
??uchar?i;
??while(ms--)
??{
???for(i?=?0;?i250;?i++)
???{
nop;
nop;
nop;
nop;
???}
??}
}
void?delay_ms(int?ms)
{ //?延時子程序
??uchar?i;
??while(ms--?>0)
??{
???for(i?=?0;?i250;?i++)
???{
nop;
nop;
nop;
nop;
???}
??}
}
/*
uchar?lcd_bz()
{ //?測試LCD忙碌狀態bit7
uchar?result=0x80;
????????P3DIR?=0x00;///
RS_0;
RW_1;
E_1;
? //nop;
//nop;
//nop;
nop;
result?=?(uchar)(P3IN?&?0x80);
????????if(result?==?0)
??????????nop;
E_0;
return?(result);
}
void?write_cmd(uchar?cmd)
{ //?寫入指令數據到LCD
//while(lcd_bz()?&?0x80);
???E_0;
???P3DIR?=?0xff;?///
???RS_0;
???RW_0;
//nop;
//nop;
???P3OUT?=?cmd;
//nop;
//nop;
//nop;
//nop;
???E_1;
???nop;
//nop;
//nop;
//nop;
???E_0;
}
void?lcd_pos(uchar?pos)
{ //設定顯示位置
??//while(lcd_bz()?&?0x80);
??writecmd(pos?|?0x80);
}
void?write_data(uchar?dat)
{ //寫入字符顯示數據到LCD
??//while(lcd_bz()?&?0x80);
??P3DIR?=??0x00;?????????????//?置位輸入模式
??RW_1;
??RS_0;
??E_1;
??//while((P3IN?&?0x80)==0x80);//檢測LCD是否忙
??E_0;
??P3DIR?=?0xff;?///
??RS_0;
??RW_0;
??RS_1;?//
//E_0;
??P3OUT?=?dat;
//nop;
//nop;
//nop;
//nop;
??E_1;
//nop;
//nop;
//nop;
??nop;
??E_0;
}
*/
void?delay_us(uchar?de)
{??while(de--?>0)
??????nop;
}
//((((((((((((((((((((((((((((((
void?busy_check()
{
??P3DIR?=?0;
??E_0;?//
?屬性????????????大小?????日期????時間???名稱
-----------?---------??----------?-----??----
?????文件??????19242??2011-03-04?16:09??LCD1602\Debug\Exe\LCD1602.d43
?????文件????????133??2011-03-04?16:09??LCD1602\Debug\Obj\LCD1602.pbd
?????文件??????21482??2011-03-04?16:09??LCD1602\Debug\Obj\main.r43
?????文件???????5208??2011-03-04?16:03??LCD1602\LCD1602.c
?????文件???????2121??2011-03-04?16:23??LCD1602\LCD1602.dep
?????文件??????17879??2011-03-03?21:50??LCD1602\LCD1602.ewd
?????文件??????47478??2011-03-03?21:50??LCD1602\LCD1602.ewp
?????文件????????161??2011-03-03?21:50??LCD1602\LCD1602.eww
?????文件????????901??2011-03-04?16:09??LCD1602\main.c
?????文件???????2729??2011-03-04?16:10??LCD1602\settings\LCD1602.cspy.bat
?????文件???????5545??2011-03-04?16:23??LCD1602\settings\LCD1602.dbgdt
?????文件???????1188??2011-03-04?16:23??LCD1602\settings\LCD1602.dni
?????文件???????3404??2011-03-04?16:23??LCD1602\settings\LCD1602.wsdt
?????目錄??????????0??2011-03-04?15:12??LCD1602\Debug\Exe
?????目錄??????????0??2011-03-03?21:42??LCD1602\Debug\List
?????目錄??????????0??2011-03-04?16:23??LCD1602\Debug\Obj
?????目錄??????????0??2011-03-03?21:42??LCD1602\Debug
?????目錄??????????0??2011-03-03?22:29??LCD1602\settings
?????目錄??????????0??2011-03-04?16:09??LCD1602
-----------?---------??----------?-----??----
???????????????127471????????????????????19
- 上一篇:基于FPGA的舵機控制程序
- 下一篇:基于VTK的人頭骨3D圖像
評論
共有 條評論