完善资料让更多小伙伴认识你,还能领取20积分哦, 立即完善>
本帖最后由 艾伊水郡 于 2013-5-21 22:23 编辑 大家可以练习练习 时钟程序(有闹钟,可设置时间): #include #include #include #define uchar unsigned char #define uint unsigned int uchar a; uchar XPOS,YPOS; ***it RS = P2^5; //Pin4 ***it RW = P2^6; //Pin5 ***it E = P2^7; //Pin6 ***it CLK=P3^6; //txd ***it DATA=P3^5; //RXD ***it SH_LD=P3^7; // ***it buz=P3^4; #define Data P0 //数据端口 uchar time,shi,fen,miao,shi11,shi12,fen11,fen12,miao11,miao12,miao1,fen1,shi1,yue1,r1,nian11,nian12,nian13,nian14,yue,yue11,yue12,r,r11,r12; uchar Time1[]={'0','1','2','3','4','5','6','7','8','9'}; uint nian,nian1; /******************************************************************/ /* 函数声明 */ /******************************************************************//***************************************************************/ void DelayUs(unsigned char us)//delay us { unsigned char uscnt; uscnt=us>>1;/* Crystal frequency in 12MHz*/ while(--uscnt); } /******************************************************************/ void DelayMs(unsigned char ms)//delay Ms { while(--ms) { DelayUs(250); DelayUs(250); DelayUs(250); DelayUs(250); } } void WriteCommand(unsigned char c) { DelayMs(5);//short delay before operation E=0; RS=0; RW=0; _nop_(); E=1; Data=c; E=0; } /****************************************************************/ void WriteData(unsigned char c) { DelayMs(5); //short delay before operation E=0; RS=1; RW=0; _nop_(); E=1; Data=c; E=0; RS=0; } /*********************************************************************/ void ShowChar(unsigned char pos,unsigned char c) { unsigned char p; //p=pos+0x80; //是第二行则命令代码高4位为0x8 p=pos; WriteCommand (p);//write command WriteData (c); //write data } void Writer_***c(uchar cspos,uchar*s) { WriteCommand (cspos); while(*s!=' |