资源描述:
《5110液晶显示程序》由会员上传分享,免费在线阅读,更多相关内容在行业资料-天天文库。
1、5110液晶显示程序#include/*commondefinesandmacros*///#include"derivative.h"/*derivative-specificdefinitions*/#include#defineucharunsignedchar#defineuintunsignedint#defineulongunsignedlong/*********************************************///初始化voidinit(){/***********************
2、**********************///超频CLKSEL=0X00;//选定锁相环时钟PLLCTL_PLLON=1;//锁相环电路使能REFDV=0XC0
3、0X01;SYNR=0XC0
4、0X07;POSTDIV=0X00;_asm(nop);_asm(nop);_asm(nop);_asm(nop);_asm(nop);_asm(nop);//选用16MHZ的外部晶体振荡器,总线时钟为64Mwhile(!(CRGFLG_LOCK==1));//等待锁相环频率锁定CLKSEL_PLLSEL=1;//选定外部时钟/****************************
5、*****************///PWM设置PWME=0X00;//全部关闭PWMPRCLK=0X22;//22分频时钟A=32M时钟B=32M时钟A=总线频率/2PWMSCLA=0X01;//再分频时钟SA=16M时钟SB=16MSB=时钟A/(2*PWMSCLA)PWMSCLB=0X01;PWMCLK=0X00;//电机1、5选择时钟SAPWMPOL=0XFF;//输出为高电平PWMCAE=0X00;//输出的为左对齐PWMCTL=0XF8;//45级联23级联01级联冻结下禁止计数WAIT禁止输入时钟PWMCNT01=0X0000;PWMCNT23=0X0000;
6、PWMCNT45=0X0000;PWMCNT67=0X0000;PWME_PWME1=0;PWME_PWME3=0;PWME_PWME5=0;PWME_PWME7=0;/*********************************************///IO口设置输入DDRA=0;DDRB=0xff;DDRM=0x40;DDRS=0xff;DDRT=0xff;/*********************************************///AD初始化ATD0CTL1=0X00;ATD0CTL2=0X60;ATD0CTL3=0X80;ATD0CTL4
7、=0X01;ATD0CTL5=0X30;ATD0DIEN=0X00;}/*********************************************///延时voiddelay(intxms)//xms毫秒延时{intii,jj;for(ii=0;ii8、****************///LCD#defineCEPORTB_PB0#defineDCPORTB_PB2#defineSDIPORTB_PB4#defineSCKPORTB_PB6#defineRSTPORTB_PB1#defineDATA1//数据命令#defineCMD0//指令/************************字模********************************/unsignedcharasc2[][6]={{0x00,0x00,0x00,0x00,0x00,0x00},//sp{0x00,0x00,0x00,0x2f,0x0
9、0,0x00},//!{0x00,0x00,0x07,0x00,0x07,0x00},//"{0x00,0x14,0x7f,0x14,0x7f,0x14},//#{0x00,0x24,0x2a,0x7f,0x2a,0x12},//${0x00,0x62,0x64,0x08,0x13,0x23},//%{0x00,0x36,0x49,0x55,0x22,0x50},//&{0x00,0x00,0x05,0x03,0x00,0x00},//'{0x00,0x00,0x1c,0x22,0x41,0x00},/