发布网友 发布时间:2024-10-24 09:35
共3个回答
热心网友 时间:2024-11-07 03:45
ORG 00H
AJMP MAIN
ORG 30H
MAIN:
MOV 20H,#2
MOV 21H,#0
MOV 22H,#1
MOV 23H,#1
MOV 24H,#1
MOV 25H,#2
MOV 26H,#1
MOV 27H,#2
ACALL DISP
AJMP $-2 ;转上一条反复执行DISP子程序
DISP:
MOV A,20H ;送最高位到A
ACALL SEG7 ;取码指针子程序
MOV P0,A ;段码送P0口
CLR P2.0 ;位选
ACALL D1MS ;延时1MS,即显示1MS
SETB P2.0
MOV A,21H ;下一位
ACALL SEG7
MOV P0,A
CLR P2.1
ACALL D1MS
SETB P2.1
MOV A,22H
ACALL SEG7
MOV P0,A
CLR P2.2
ACALL D1MS
SETB P2.2
MOV A,23H
ACALL SEG7
MOV P0,A
CLR P2.3
ACALL D1MS
SETB P2.3
MOV A,24H
ACALL SEG7
MOV P0,A
CLR P2.4
ACALL D1MS
SETB P2.4
MOV A,25H
ACALL SEG7
MOV P0,A
CLR P2.5
ACALL D1MS
SETB P2.5
MOV A,26H
ACALL SEG7
MOV P0,A
CLR P2.6
ACALL D1MS
SETB P2.6
MOV A,27H
ACALL SEG7
MOV P0,A
CLR P2.7
ACALL D1MS
SETB P2.7
RET
D1MS:
MOV R7,#10 ;延时1MS子程序。
MOV R6,#50
DJNZ R6,$
DJNZ R7,$-4
RET
SEG7:
INC A
MOVC A,@A+PC
RET
DB 3FH ;0 共阴管段码
DB 06H ;1
DB 5BH ;2
DB 4FH ;3
DB 66H ;4
DB 6DH ;5
DB 7DH ;6
DB 07H ;7
DB 7FH ;8
DB 6FH ;9
END
鼠标点小图,按确定成大图。再按住鼠标左键将大图拉到另一个浏览器窗口,就可看到原图。
热心网友 时间:2024-11-07 03:43
用MAX7221驱动8位显示的
#include<reg52.h>
#include<INTRINS.h>
#define uchar unsigned char
#define uint unsigned int
sbit CK = P1^2;
sbit IO = P1^3;
sbit CS = P1^4;
uchar data Disp[8];
void write_7221( uint idat )
{
uchar i;
CS = 0;
for(i = 0; i < 16; i++)
{
CK = 0; idat <<= 1; DI = CY;
CK = 1; _nop_(); _nop_();
CK = 0;
}
CS = 1;
}
void Show( void )
{
uchar s;
for(s = 0; s < 8; s++) write_7221( ((s + 1) * 256) + Disp[s] );
}
void main( )
{
write_7221( 0x09FF );
write_7221( 0x0A0C );
write_7221( 0x0B07 );
write_7221( 0x0C01 );
Disp[0] = 2;
Disp[1] = 0;
Disp[2] = 1;
Disp[3] = 1;
Disp[4] = 1;
Disp[5] = 2;
Disp[6] = 1;
Disp[7] = 2;
Show();
}
热心网友 时间:2024-11-07 03:44
数码管是共阴极还是共阳极?位地址、段地址是多少?没有这些东西没法编写的