这两天总有人问数码管与74HC573的事,现在将数码管与74HC573正确连接图发给大家,并附上代码。代码是阿迪用其他软件编写的,我用ICCV7稍改了一下.发这个代码的另一个意义是他这个代码写的很精练,有很好的启发作用.
单片机源码:
- #include <iom16v.h>
- #include <macros.h>
- #define uchar unsigned char
- #define uint unsigned int
- uchar du[]={0x3f,0x06,0x5b,0x4f,0x66,0x6d};
- void delay(uint S)
- {
- uint i,j;
- for( i=0;i<S;i++)
- for(j=0;j<240;j++);
- }
- int main()
- {
- uchar i;
-
- DDRA =0xff;
- PORTA |= BIT(3);
- DDRB = 0xff;
-
- while(1)
- {
-
- for(i=0;i<6;i++)
- {
- PORTB = 0xff; //暂时关DA码
-
- PORTB &=~ BIT(i) ; //送位码 精华! 不用数组,用PI口变量定义位
-
- PORTA |= BIT(4) ; //开573位 //相当于51 P1^4=1; P1也可是P2,P3
-
- PORTA &=~ BIT(4); //关573位 // 相当于51 P1^4=0;
-
-
- PORTA = BIT(3) ; //开573DA选
-
- PORTB=du[i]; //送DA码
-
- PORTA &=~ BIT(3); //关573DA选
-
- delay(1) ;
- }
- }
- }
复制代码 全部资料51hei下载地址:
一个IO口与74HC573及数码管显示应用电路图.zip
(37.08 KB, 下载次数: 41)
|