谢谢你的回复,下面是我的程序,麻烦多费心看看。(ST单片机C程序) PC6 WR,PA6 DATA,PB4 /CS #include "io72324.h" /* 寄存器定义文件 */ #include "lib.h" #include "linsci.h" /* COSMIC 编译器需要用的头文件 */ #include "st72324.h" #define BIAS 0x29 #define SYSDIS 0x00 #define SYSEN 0x01 #define LCDOFF 0x02 #define LCDON 0x03 const u8 DisNumber[10][7]={{0x06,0xaf,0xaf,0xaf,0xaf,0xaf,0xaf},{0x00,0x03,0x04,0x05,0x06,0xaf,0xaf}, {0x02,0x05,0xaf,0xaf,0xaf,0xaf,0xaf},{0x04,0x05,0xaf,0xaf,0xaf,0xaf,0xaf}, {0x00,0x03,0x04,0xaf,0xaf,0xaf,0xaf},{0x01,0x04,0xaf,0xaf,0xaf,0xaf,0xaf},{0x01,0xaf,0xaf,0xaf,0xaf,0xaf,0xaf}, {0x03,0x04,0x05,0x6,0xaf,0xaf,0xaf},{0xaf,0xaf,0xaf,0xaf,0xaf,0xaf,0xaf},{0x04,0xaf,0xaf,0xaf,0xaf,0xaf,0xaf} };
void t_clk(void) { #asm nop nop nop nop nop nop nop nop nop nop nop nop nop nop nop nop nop nop nop nop #endasm } /************************************************/ /*函数调用方式:SendBit(uchar Dat,uchar BitNum);*/ /*将Dat数据从高位开始发送共BitNum位 */ /************************************************/ void SendBit(u8 Dat,u8 BitNum) { u8 i; for(i=0;i<BitNum;i++) { /*置时钟线为低通知被控器开始接收*/ ClrBit(PCDR,6); t_clk(); if(( Dat & 0x80 ) == 0) { ClrBit(PADR,6); } else { SetBit(PADR,6);/* Q3=6DATA*/ /*发送数据由高位到低位传送 */ } SetBit(PCDR,6); //SetBit(PADR,Q4); /*保持住总线准备下一个数据位 */ t_clk(); Dat=Dat<<1; /*发送数据左移一位 */ }
}
void SendDataBit_1621(u8 Dat,u8 BitNum) {u8 i; for(i=0;i<BitNum;i++) { ClrBit(PCDR,6); t_clk(); if((Dat&0x01)==0) { ClrBit(PADR,6); } else { SetBit(PADR,6); } SetBit(PCDR,6); //SetBit(PADR,Q4); /*保持住总线准备下一个数据位 */ t_clk(); Dat=Dat>>1; } } /************************************************/ /*函数调用方式:SendCmd(uchar Dat); */ /*将Dat命令字发给接收端 */ /************************************************/ void SendCmd(u8 Dat) { ClrBit(PBDR,4); /*Q6=4*/ SendBit(0x80,3); SendBit(Dat,9); #asm nop #endasm SetBit(PBDR,4); #asm nop nop #endasm }
void Write_1621(u8 addr,u8 data) { DisableInterrupts(); ClrBit(PBDR,4); SendBit(0xa0,3); SendBit(addr<<2,6); SendDataBit_1621(data,4); #asm nop #endasm SetBit(PBDR,4); #asm nop nop #endasm EnableInterrupts(); }
void lcdinit(void) { u8 i,j; SetBit(PADDR,6); //data SetBit(PAOR,6); SetBit(PADR,6); SetBit(PBDDR,4); //不选中1621 SetBit(PBOR,4); SetBit(PBDR,4); SetBit(PCDDR,6); //WR SetBit(PCOR,6); ClrBit(PCDR,6); for(i=0;i<200;i++) for(j=0;j<65;j++) ; SendCmd(0x0e3); //NORMAL*/ SendCmd(0x18); //RC256K SendCmd(BIAS); SendCmd(SYSEN); SendCmd(LCDON); } void main(void) {u8 m,Temp,Adr; u8 n; u8 baiwei,shiwei,gewei; lcdinit(); TACSR=0; WDGCR=0; EnableInterrupts(); while(1) { for(m=0;m<7;m++) Write_1621(DisNumber[1][m],0x08); for(m=0;m<7;m++) Write_1621(DisNumber[6][m]+0x08,0x08); for(m=0;m<7;m++) Write_1621(DisNumber[4][m]+0x10,0x08); for(m=0;m<7;m++) Write_1621(DisNumber[9][m]+0x18,0x08); for(m=0;m<200;m++) for(n=0;n<65;n++) ; for(m=0;m<7;m++) Write_1621(DisNumber[2][m],0x08); for(m=0;m<7;m++) Write_1621(DisNumber[0][m]+0x08,0x08); for(m=0;m<7;m++) Write_1621(DisNumber[5][m]+0x10,0x08); for(m=0;m<7;m++) Write_1621(DisNumber[3][m]+0x18,0x08); for(m=0;m<200;m++) for(n=0;n<65;n++) ; } }
|