完善资料让更多小伙伴认识你,还能领取20积分哦, 立即完善>
扫一扫,分享给好友
#include "msp430x14x.h" #define uchar unsigned char #define rs_h P1OUT|=BIT5 #define rs_l P1OUT&=~BIT5 #define rw_h P1OUT|=BIT6 #define rw_l P1OUT&=~BIT6 #define e_h P1OUT|=BIT7 #define e_l P1OUT&=~BIT7 #define lcd P4OUT void delay(long int i) { while(i--); } //写命令函数 void wcom(unsigned char com) { P1DIR|=0XF0; P2DIR|=0XFF; e_l; rs_l; rw_l; e_h; delay(1); lcd|=com; delay(1); e_l; } void wdata(unsigned char dat) { P1DIR|=0XF0; P2DIR|=0XFF; e_l; rs_h; rw_l; e_h; delay(50); lcd|=dat; delay(50); e_l; } //初始化函数 void init() { delay(50000); wcom(0x30); //写基本指令集 delay(1000); wcom(0x30); delay(1000); wcom(0x0c); //显示开 delay(1500); wcom(0x01); //清屏指令 delay(2000); wcom(0x06); //游标右移 delay(1000); } //清屏函数 void lcdclear(void) { wcom(0x01); //清屏指令 delay(10); } //显示汉字 void dishanzi(uchar addr,uchar *hz) { int i; wcom(addr); for(i=0;hz[i]!=' |