CD4094移位总线寄存器驱动程序
时间:11-29
来源:互联网
点击:
//CD4094 20120302 8路基准电压源使用测试
//程序... #include#include #define uint unsigned int #define uchar unsigned char sbit k6=P1^7;sbit k5=P1^6;sbit k4=P1^5;sbit k3=P1^4;sbit k2=P1^3;sbit k1=P1^2;sbit LED_ON=P1^1;sbit led=P3^7;sbit A_=P3^3;sbit B_=P3^4;sbit C_=P3^5;sbit DEL=P1^0;sbit STR = P3^2;//定义CD4094各端口; sbit DATA = P3^1; sbit CLK = P3^0;uchar tt,tt1,K=0;uchar KEY();uchar code table[]={0x03,0x9f,0x25,0x0d,0x99,0x49,0x41}; //code unsigned char C51BOX2[3] _at_ 0x43; void Out_4094(uchar data1);//CD4094写数据子函数; void Delay(uint a); //延时子函数; //主程序开始; void timer0(void) interrupt 1 using 0{TH0 =5000/256;TL0 =5000%256;if(K==0){tt++;if(K==0&&tt==7){{tt=0;LED_ON=~LED_ON;}}}Out_4094(table[K]);if(K!=0) LED_ON=0;tt1++;if(tt1==7){tt1=0;led=~led;}} void main() { uchar i,f,g; //无限循环;TMOD=0x01;TH0 =5000/256;TL0 =5000%256;EA=1;ET0=1;TR0=1;A_=0;B_=0;C_=0;DEL=0; while(1) { /*for(g=0;g<6;g++){Delay(30000);f=table[g];Out_4094(f); //调用显示子函数; Delay(30000); //延时; } */KEY();if(K==0){A_=0;B_=0; C_=0; DEL=0 ;}if(K==1){A_=0;B_=1; C_=1; DEL=0 ;}if(K==2){A_=1;B_=0; C_=1; DEL=0 ;}if(K==3){A_=0;B_=0; C_=1; DEL=0 ;}if(K==4){A_=1;B_=1; C_=0; DEL=0 ;}if(K==5){A_=0;B_=1; C_=0; DEL=1 ;}if(K==6){A_=1;B_=0; C_=0; DEL=1 ;}}} void Out_4094(uchar data1) //写CD4094子函数; { uchar i; //定义子函数; STR=0; //保持然来的状态不变; for(i=0;i<8;i++) //写八位数据进CD4094; { if(data1&0x01) //判断并发串行数据; { DATA=1; //发高电平; } else { DATA=0; //发低电平; } CLK=0; //形成上升延脉冲; _nop_(); _nop_(); //延时; _nop_(); CLK=1; data1>>=1; //数据移位,送下一位数据; } STR=1; //数据送完;更新显示; } void Delay(uint a) //延时子函数; { uint b; for(b=0;b
CD4094移位总线寄存器驱动程 相关文章:
- Windows CE 进程、线程和内存管理(11-09)
- RedHatLinux新手入门教程(5)(11-12)
- uClinux介绍(11-09)
- openwebmailV1.60安装教学(11-12)
- Linux嵌入式系统开发平台选型探讨(11-09)
- Windows CE 进程、线程和内存管理(二)(11-09)