#include"pic.h" #include"pic1687x.h" unsigned char data; unsigned char k; unsigned char s0,s1,s2,s3; unsigned char s[4]; //table[3] 不是变量,它才识变量,显示LED上.
const table[10]={0xc0,0xf9,0xa4,0xb0,0x99,0x92,0x82,0XD8,0x80,0x90}; //不带小数点的显示段码表 const table0[10]={0X40,0X79,0X24,0X30,0X19,0X12,0X02,0X78,0X00,0X10}; //带小数点的显示段码表
void FZinitial() { s0=s1=s2=s3=0; s[0]=s0; s[1]=s1; s[2]=s2; s[3]=s3; }
void SPIinitial() { SSPCON=0X30; SSPSTAT=0XC0; //SPI主控制通讯模式,1为下降沿实现通讯,发送数据.
TRISC3=0; TRISC5=0; TRISA5=0;
PIR1=0; //SSPIF=0 }
void SPILED(data) { SSPBUF=data; do { ; }while(SSPIF=0); SSPIF=0; }
void display() { RA5=0; for(k=3;k>=0;k--) { //data=table[k]; data=s[k]; if(k==2) data=table0[data]; else data=table[data]; SPILED(data); }
RA5=1;
}
|