点阵式液晶显示屏的显示程序设计.doc
《点阵式液晶显示屏的显示程序设计.doc》由会员分享,可在线阅读,更多相关《点阵式液晶显示屏的显示程序设计.doc(26页珍藏版)》请在沃文网上搜索。
1、点阵式液晶显示屏的显示程序设计一、设计目的1熟练掌握C51系统仿真开发系统的应用。2加强单片机的综合运用能力、提高单片机的软件编程和调试能力,为以后的学习和开发工作打下良好基础。3掌握的液晶的工作原理以及应用设计。4掌握小系统开发设计的流程以及设计思路。二、设计要求 1)字符方式:从下到上滚动显示:“江苏大学计算机学院”然后交替显示:“年单片机课程设计”“液晶点阵显示屏程序设计”“作者姓名、班级、学号” 2) 图片方式:显示相应图片(有左、右移,上下卷等多种动态方式 ) 3) 模拟量采样值显示(温度、压力、电位) 4)其它功能不限,可自由发挥(时钟、秒表、计算器、菜单等),拓展要求三、设计思路
2、:由于实验指导书中做过液晶显示和模数转换得实验,根据两个实验的功能实现和流程原理进行设计将程序分成三个模块:主函数模块main.c模数转换模块ADC.c液晶显示模块KS0108.c其中让主函数模块做一些初始化和函数调用工作,模数转换模块主要是将温度,压力,点位的值转化为数字量供液晶显示用,液晶显示模块得到模数转换模块传递过来的数字量显示到液晶面板上。程序流程图:1系统主流程图如下开始主函数模块显示模块模数转换模块2主函数流程图开始使能比较器1开中断初始化系统时钟钟初始化定时器0初始化IO端口初始化SPI0使能片内参考电压使能DAC3 显示模块流程图开始初始化LCD滚屏显示江苏大学计算机学院读取
3、数字量并显示调用模数转换得到值显示课程设计题目、班级、姓名健值是否1.2.34 模数转换模块流程图开始读取No和模拟量返回温度返回点位结束返回压力No=2?No=3?No=1? 主要的源程序及注释四、主函数:#include c8051f020.h #include void Delay1us(unsigned char us) while (us) _nop_(); _nop_(); _nop_(); _nop_(); _nop_(); -us; /初始化系统时钟,使用22.1184MHZ晶体作为时钟源void SYSCLK_Init (void) int i; OSCXCN = 0x67;
4、 Wait for osc. to start up while (!(OSCXCN&0x80) ; OSCICN = 0x88; OSCICN = 0x07; /interal 16MHZ #define PRT0CF P0MDOUT #define PRT1CF P1MDOUT #define PRT2CF P2MDOUT void PORT_Init (void) XBR0=0x07; XBR1=0x00; XBR2=0x44; EMI0CF=0x27; EMI0TC=0x21; P74OUT=0xFF; P0MDOUT=0x15; P1MDOUT|=0x3C; /P1.2-P1.5推挽
5、输出 P&=0xc3; /P1.2-P1.5=0 void SPI0_Init(void) SPI0CFG=0x07; SPI0CFG|=0xC0; /CKPOL =1; SPI0CN=0x03; SPI0CKR=SYSCLK/2/8000000-1; unsigned char Count1ms; void Timer0_Init (void) CKCON|=0x8; TMOD|=0x1; Count1ms=10; TR0=0; TH0=(-SYSCLK/1000) 8; TL0=-SYSCLK/1000; TR0=1; IE|=0x2; void Timer0_ISR(void)inter
6、rupt 1 TH0=(-SYSCLK/1000)8; TL0=-SYSCLK/1000; if (Count1ms) Count1ms-; void Delay1ms(unsigned char T) Count1ms=T; while (Count1ms); void Delay1s(unsigned char T) while (T) Delay1ms(200); Delay1ms(200); Delay1ms(200); Delay1ms(200); Delay1ms(200); T-; char GetKeyValue(void); void init_adc(void); unsi
7、gned int GetADCValue(char No); void TestLCD(void); void DispLED(char *buf);void TestI2C (void);void DispLCD(char *DispBuf,char num); void InitLCD(void);/初始化LCD void ShowWenDu(void); void ShowDianYa(void); void ShowYaLi(void); void showniu(); void showfu(); void showdsheshidu(); void Test7279(bit Loo
8、pFlag);void LCD_WriteHZ(char x,char y,char *Dot);void LCD_DispChar(char x,char y,char ch); void Delay1ms(unsigned char T);void main (void) unsigned int w; char No,i,buf5; No=1; WDTCN = 0xde; WDTCN = 0xad; /关看门狗 SYSCLK_Init (); /初始化时钟 Timer0_Init(); /初始化定时器 PORT_Init (); /初始化IO口 SPI0_Init (); /初始化SPI
9、0 init_adc(); CPT1CN|=0x80; /使能比较器1 REF0CN = 0x07; /使能片内参考电压 DAC0CN |= 0x80; /使能DAC0 DAC0H=0; DAC0L=0; EA=1; /开中断 /Test7279(0); No=0; /w = GetADCValue(1); for (;) i=GetKeyValue(); if(i=0)&(i=5) No=i; switch(No) case 0: caidan();break; case 1: ShowWenDu();break; case 2: ShowDianYa();break; case 3: Sh
10、owYaLi();break; case 4: TestI2C();break; case 5: TestLCD() ;break; w = GetADCValue(No); Delay1ms(30); switch(No) case 1: buf0=(w%10000)/1000; buf1=(w%1000)/100; buf2= ; buf3=(w%100)/10; buf4=(w%10); DispLCD(buf,1); showsheshidu(); break; case 2: /ShowDianYa(); buf0=(w%10000)/1000; buf1= ; buf2=(w%10
11、00)/100; buf3=(w%100)/10; buf4=(w%10); DispLCD(buf,2); showfu(); break; case 3: /ShowYaLi(); buf0=(w%10000)/1000; buf1=(w%1000)/100; buf2=(w%100)/10; buf3= ; buf4=(w%10); DispLCD(buf,3); showniu(); break; default: break; KS0108模块:#include c8051F020.h #include #define LCD_DATA P2 #define LCD_RS P30 #
12、define LCD_RW P31 #define LCD_E P32 #define LCD_CS1 P34 #define LCD_CS2 P33 #define LCD_RST P35 void Delay1ms(unsigned char); char code screen=0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x
13、00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x
14、00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x
15、00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x
16、00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x
17、00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x
18、00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x
19、00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x12,0xA4,0x70,0x04,0x04,0x04,0xFC,0x04,0x04,0x04,0x00,0x00,0x04,0x24,0xA4,0x2E,0x24,0xF4,0x24,0x2E,0xE4,0x84,0x04,0x00,0x10,0x10,0x10,0x10,0x90,0x7E,0x90,0x10,0x10,0x18,0x10,0x00,0x38,0x
20、08,0x2A,0x2C,0x2A,0xAC,0x68,0x28,0x0E,0x28,0x18,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x
21、00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x20,0x40,0x00,0x00,0x00,0x02,0xEF,0x08,0x08,0x08,0x08,0x0F,0xC8,0x68,0xC8,0x48,0x80,0x40,0x69,0xC8,0x44,0x43,0x08,0x88,0x8C,0xE3,0x80,0x83,0xC0,0x48,0x48,0xE4,0x42,0x01,0x
- 1.请仔细阅读文档,确保文档完整性,对于不预览、不比对内容而直接下载带来的问题本站不予受理。
- 2.下载的文档,不会出现我们的网址水印。
- 3、该文档所得收入(下载+内容+预览)归上传者、原创作者;如果您是本文档原作者,请点此认领!既往收益都归您。
下载文档到电脑,查找使用更方便
20 积分
下载 | 加入VIP,下载更划算! |
- 配套讲稿:
如PPT文件的首页显示word图标,表示该PPT已包含配套word讲稿。双击word图标可打开word文档。
- 特殊限制:
部分文档作品中含有的国旗、国徽等图片,仅作为作品整体效果示例展示,禁止商用。设计者仅对作品中独创性部分享有著作权。
- 关 键 词:
- 阵式 液晶显示屏 显示 程序设计