完善资料让更多小伙伴认识你,还能领取20积分哦, 立即完善>
#include #include #define uint unsigned int #define uchar unsigned char ***it sck=P1^0; ***it misi=P1^1; ***it miso=P1^2; ***it ss=P1^3; ***it lcden=P2^0; ***it lcdrw=P2^1; ***it lcdrs=P2^2; uchar code table[]={'0','1','2','3','4','5','6','7','8','9', 'a','b','c','d','e','f','g','h','i','j', 'k','l','m','n','o','p','q','r','s','t', 'u','v','w','x','y','z','A','B','C','D', 'E','F','G','H','I','J','K','L','M','N', 'O','P','Q','R','S','T','U','V','W','X', 'Y','Z',',','.',':',';','"','?','!','+', '-','*','/'}; void lcd_com(uchar com); void delay(uint t) { uint i; while(t--) for(i=500;i>0;i--); } uchar receive() { uchar i,date=0,temp; bit bt; ss=0; for(i=0;i<8;i++) { sck=1; _nop_(); _nop_(); _nop_(); bt=misi; if(bt) temp=0x01; else temp=0x00; date<<=1; date=(date|temp); sck=0; _nop_(); _nop_(); _nop_(); } for(i=0;i<74;i++) if(date==table[i]) return date; } void lcd_com(uchar com) { lcdrs=0; lcdrw=0; lcden=0; delay(5); P0=com; delay(5); lcden=1; delay(5); lcden=0; } void lcd_data(uchar dat) { lcdrs=1; lcdrw=0; lcden=0; delay(5); P0=dat; delay(5); lcden=1; delay(5); lcden=0; } void init() { lcden=0; lcdrs=0; lcd_com(0x38); lcd_com(0x0f); lcd_com(0x06); lcd_com(0x01); } /*void string(uchar x,uchar y, uchar *str) { uchar address; if(y==0) address=0x00+x; else address=0x40+x; lcd_com(address|0x80); while(*str!=' |