/*********GZ0601C0 IST3040 COG+FPC serial **********/ #include // C51頭文件 #include //#include // 延時子程序 #define Uchar unsigned char #define Uint unsigned int sbit SDA=P1^3; // 主機第14PIN sbit SCK=P1^2; // 主機第13PIN sbit CS =P1^1; // 主機第5PIN sbit INH=P1^0; // 主機第6PIN Uchar code Num1[]={0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00}; Uchar code Num2[]={0x00,0x00,0x7d,0xfa,0xc1,0xd5,0x75,0x7a,0xc9,0x91,0x17,0xaf,0x5f,0xff,0x7d,0x00,0x00,0x00,0x00,0x00}; Uchar code Num3[]={0x00,0x00,0x35,0x61,0xf1,0xa3,0x30,0x65,0x14,0x6a,0x4b,0xa7,0x6d,0x9b,0xb5,0x00,0x00,0x00,0x00,0x00}; Uchar code Num4[]={0x00,0x00,0x7a,0x9e,0xc0,0x7d,0x07,0x75,0xc1,0x43,0x17,0x4f,0xbe,0x7c,0xfa,0x00,0x00,0x00,0x00,0x00}; Uchar code Num5[]={0x00,0x00,0x4f,0x6f,0x21,0x9e,0x37,0x0a,0x1c,0xb8,0x4d,0xe9,0xd3,0xe7,0x4f,0x00,0x00,0x00,0x00,0x00}; Uchar code Num6[]={0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff}; // 以上數組第3組起到第15組止為有效 unsigned char dd[] ={5,8,156,154,152,150}; unsigned char dd1[] ={17,20,144,142,140,138,5,8,156,154,152,150}; void Disp258(unsigned char *pdat); void initial(void); void Datwrite(unsigned char dat); void allon(void); void alloff(void); void delay(unsigned int i) { unsigned char j; while(i) { i--; for(j=0;j>16;j++) { ; } } } void write(unsigned char dat) { unsigned char i; for (i = 0; i <8; i++) //每組數據送8次(位) { SCK=0; SDA=(bit)(dat&0x80); _nop_(); _nop_(); _nop_(); _nop_(); _nop_(); _nop_(); _nop_(); _nop_(); SCK=1; dat=dat<<1; _nop_(); _nop_(); _nop_(); _nop_(); _nop_(); _nop_(); _nop_(); _nop_(); _nop_(); } } void start(void) { CS=0; _nop_(); _nop_(); _nop_(); CS=1; _nop_(); _nop_(); _nop_(); INH=1; //INH=0; _nop_(); _nop_(); _nop_(); _nop_(); _nop_(); _nop_(); CS=1; _nop_(); _nop_(); _nop_(); _nop_(); _nop_(); _nop_(); } void end(void) { CS=0; _nop_(); _nop_(); _nop_(); _nop_(); _nop_(); _nop_(); _nop_(); INH=0; // INH=1; _nop_(); _nop_(); _nop_(); _nop_(); _nop_(); _nop_(); _nop_(); } void Datwrite(unsigned char dat) { unsigned char count; CS =0; INH=1; delay(10); CS =1; for (count = 0; count <8; count++) //每組數據送8次(位) { SCK=0; SDA=(bit)(dat&0x80); SCK=1; dat=dat<<1; delay(0); } INH=0; delay(0); } void writebit(unsigned char b) { SCK=0; if(b) SDA=1; else SDA=0; SCK=1; // dat=dat<<1; delay(0); } void clr() { int i; for(i=0;i<20;i++) //4*40/8=20 送20組數據 { Datwrite(0x00); } delay(10000); } void dsp(unsigned char *buf, int l) { int i; int j; unsigned char flag=0; CS =0; INH=1; delay(10); CS =1; for(i=0;i<160;i++) //4*40/8=20 送20組數據 { flag=0 ; /* if(i+1==8) writebit(1); else writebit(0); */ for(j=0;j