我也是这样接的,用的面包板,亮倒是亮,隔一会胡乱亮一下,就是不显示我想要得结果,这是我的程序,用protues仿真都可以
ORG 0000H
LJMP MAIN
ORG 001BH
LJMP SHI
ORG 0100H
MAIN: MOV SP,#60H ;设置堆栈指针
SETB PT1 ;设置定时器1中断为高级中断
MOV DPTR,#0300H
MOV R4,#14H
;MAX7219初始化
MOV A,#0BH ;置显示数位寄存器地址
MOV B,#07H ;选择8位显示方式
LCALL SHU ;写入MAX7219
MOV A,#0AH ;置亮度寄存器地址
MOV B,#08H ;选择占空比
LCALL SHU ;写入MAX7219
MOV A,#09H ;置译码方式寄存器地址
MOV B,#0FFH ;选择BCD译码方式
LCALL SHU ;写入MAX7219
MOV A,#0CH ;置关闭显示寄存器地址
MOV B,#01H ;选择进入正常工作方式
LCALL SHU ;写入MAX7219
;定时器0初始化,定时250us
MOV TMOD,#12H
MOV TH0,#06H
MOV TL0,#06H
SETB EA
;启动定时器1,每隔1S响应一次
MOV TH1,#3CH
MOV TL1,#0B0H
SETB EA
SETB ET1
SETB TR1
LCALL YAN05S
START: LCALL YAN05S
;东西左转弯绿灯亮15S
MOV P0,#9BH
MOV P2,#07H
MOV R0,#03H ;延时15S
L1: LCALL YAN5S
DJNZ R0,L1
;东西左转弯黄灯闪烁3S
SETB P0.2
CLR P0.1
MOV R0,#06H
L2: LCALL YAN05S
CPL P0.1
DJNZ R0,L2
;东西绿灯亮45S
MOV P0,#0B6H
MOV P2,#07H
MOV R0,#09H ;延时45S
L3: LCALL YAN5S
DJNZ R0,L3
;东西黄灯闪烁3S
SETB P0.3
CLR P0.4
MOV R0,#06H
L4: LCALL YAN05S
CPL P0.4
DJNZ R0,L4
;南北左转弯绿灯亮10S
MOV P0,#0DEH
MOV P2,#06H
MOV R0,#02H ;延时10S
L5: LCALL YAN5S
DJNZ R0,L5
;南北左转弯黄灯闪烁3S
SETB P2.0
CLR P0.7
MOV R0,#06H
L6: LCALL YAN05S
CPL P0.7
DJNZ R0,L6
;南北绿灯亮30S
MOV P0,#9EH
MOV P2,#0DH
MOV R0,#06H ;延时30S
L7: LCALL YAN5S
DJNZ R0,L7
;南北黄灯闪烁3S
SETB P2.1
CLR P2.2
MOV R0,#06H
L8: LCALL YAN05S
CPL P2.2
DJNZ R0,L8
MOV DPTR,#0300H
LJMP START
;延时5S子程序
YAN5S: MOV R6,#0C8H
MOV R7,#64H
SETB TR0
LL1: JNB TF0,LL1
CLR TF0
DJNZ R6,LL1
MOV R6,#0C8H
DJNZ R7,LL1
CLR TR0
RET
;延时0.5S子程序
YAN05S: MOV R6,#0C8H
MOV R7,#0AH
SETB TR0
LL2: JNB TF0,LL2
CLR TF0
DJNZ R6,LL2
MOV R6,#0C8H
DJNZ R7,LL2
CLR TR0
RET
;写入MAX7219子程序
SHU: CLR P1.1 ;将LOAD信号拉低
LCALL ONE ;一字节地址写入MAX7219
MOV A,B
LCALL ONE ;一字节地址写入MAX7219
NOP
SETB P1.1 ;产生LOAD上升沿信号,锁存数据
RET
ONE: MOV R1,#08H ;置串行移位计数器
LL3: CLR P1.2 ;将CLK信号拉低
RLC A ;A中的值左移入C中
MOV P1.0,C ;逐位送入DIN
NOP
SETB P1.2 ;产生CLK上升沿信号,移入数据
DJNZ R1,LL3 ;循环8次
RET
;时钟显示中断子程序
SHI: MOV TH1,#3CH ;重载初始值
MOV TL1,#0B0H
DJNZ R4,LLEND
MOV 70H,A ;保护A,B中的数据
MOV 71H,B
MOV R2,#01H ;指向第0位LED
MOV R3,#08H ;置显示器个数
LOOP: CLR A
MOVC A,@A+DPTR ;取显示缓冲区数据
MOV B,A ;数据送入B
MOV A,R2 ;LED显示的位地址送A
LCALL SHU ;写入MAX7219
INC DPTR ;指向下一个显示数据
INC R2 ;指向下一位LED
DJNZ R3,LOOP ;循环
MOV A,70H ;恢复中断前A,B的值
MOV B,71H
CLR TF1 ;标志位清零
MOV R4,#14H
LLEND: RETI
ORG 0300H
DB 01H,05H,01H,08H,06H,06H,06H,06H
DB 01H,04H,01H,07H,06H,05H,06H,05H
DB 01H,03H,01H,06H,06H,04H,06H,04H
DB 01H,02H,01H,05H,06H,03H,06H,03H
DB 01H,01H,01H,04H,06H,02H,06H,02H
DB 01H,00H,01H,03H,06H,01H,06H,01H
DB 00H,09H,01H,02H,06H,00H,06H,00H
DB 00H,08H,01H,01H,05H,09H,05H,09H
DB 00H,07H,01H,00H,05H,08H,05H,08H
DB 00H,06H,00H,09H,05H,07H,05H,07H
DB 00H,05H,00H,08H,05H,06H,05H,06H
DB 00H,04H,00H,07H,05H,05H,05H,05H
DB 00H,03H,00H,06H,05H,04H,05H,04H
DB 00H,02H,00H,05H,05H,03H,05H,03H
DB 00H,01H,00H,04H,05H,02H,05H,02H
DB 00H,03H,00H,03H,05H,01H,05H,01H
DB 00H,02H,00H,02H,05H,00H,05H,00H
DB 00H,01H,00H,01H,04H,09H,04H,09H
DB 04H,08H,04H,05H,04H,08H,04H,08H
DB 04H,07H,04H,04H,04H,07H,04H,07H
DB 04H,06H,04H,03H,04H,06H,04H,06H
DB 04H,05H,04H,02H,04H,05H,04H,05H
DB 04H,04H,04H,01H,04H,04H,04H,04H
DB 04H,03H,04H,00H,04H,03H,04H,03H
DB 04H,02H,03H,09H,04H,02H,04H,02H
DB 04H,01H,03H,08H,04H,01H,04H,01H
DB 04H,00H,03H,07H,04H,00H,04H,00H
DB 03H,09H,03H,06H,03H,09H,03H,09H
DB 03H,08H,03H,05H,03H,08H,03H,08H
DB 03H,07H,03H,04H,03H,07H,03H,07H
DB 03H,06H,03H,03H,03H,06H,03H,06H
DB 03H,05H,03H,02H,03H,05H,03H,05H
DB 03H,04H,03H,01H,03H,04H,03H,04H
DB 03H,03H,03H,00H,03H,03H,03H,03H
DB 03H,02H,02H,09H,03H,02H,03H,02H
DB 03H,01H,02H,08H,03H,01H,03H,01H
DB 03H,00H,02H,07H,03H,00H,03H,00H
DB 02H,09H,02H,06H,02H,09H,02H,09H
DB 02H,08H,02H,05H,02H,08H,02H,08H
DB 02H,07H,02H,04H,02H,07H,02H,07H
DB 02H,06H,02H,03H,02H,06H,02H,06H
DB 02H,05H,02H,02H,02H,05H,02H,05H
DB 02H,04H,02H,01H,02H,04H,02H,04H
DB 02H,03H,02H,00H,02H,03H,02H,03H
DB 02H,02H,01H,09H,02H,02H,02H,02H
DB 02H,01H,01H,08H,02H,01H,02H,01H
DB 02H,00H,01H,07H,02H,00H,02H,00H
DB 01H,09H,01H,06H,01H,09H,01H,09H
DB 01H,08H,01H,05H,01H,08H,01H,08H
DB 01H,07H,01H,04H,01H,07H,01H,07H
DB 01H,06H,01H,03H,01H,06H,01H,06H
DB 01H,05H,01H,02H,01H,05H,01H,05H
DB 01H,04H,01H,01H,01H,04H,01H,04H
DB 01H,03H,01H,00H,01H,03H,01H,03H
DB 01H,02H,00H,09H,01H,02H,01H,02H
DB 01H,01H,00H,08H,01H,01H,01H,01H
DB 01H,00H,00H,07H,01H,00H,01H,00H
DB 00H,09H,00H,06H,00H,09H,00H,09H
DB 00H,08H,00H,05H,00H,08H,00H,08H
DB 00H,07H,00H,04H,00H,07H,00H,07H
DB 00H,06H,00H,03H,00H,06H,00H,06H
DB 00H,05H,00H,02H,00H,05H,00H,05H
DB 00H,04H,00H,01H,00H,04H,00H,04H
DB 00H,03H,00H,03H,00H,03H,00H,03H
DB 00H,02H,00H,02H,00H,02H,00H,02H
DB 00H,01H,00H,01H,00H,01H,00H,01H
DB 04H,06H,04H,06H,01H,00H,01H,03H
DB 04H,05H,04H,05H,00H,09H,01H,02H
DB 04H,04H,04H,04H,00H,08H,01H,01H
DB 04H,03H,04H,03H,00H,07H,01H,00H
DB 04H,02H,04H,02H,00H,06H,00H,09H
DB 04H,01H,04H,01H,00H,05H,00H,08H
DB 04H,00H,04H,00H,00H,04H,00H,07H
DB 03H,09H,03H,09H,00H,03H,00H,06H
DB 03H,08H,03H,08H,00H,02H,00H,05H
DB 03H,07H,03H,07H,00H,01H,00H,04H
DB 03H,06H,03H,06H,00H,03H,00H,03H
DB 03H,05H,03H,05H,00H,02H,00H,02H
DB 03H,04H,03H,04H,00H,01H,00H,01H
DB 03H,03H,03H,03H,03H,03H,03H,00H
DB 03H,02H,03H,02H,03H,02H,02H,09H
DB 03H,01H,03H,01H,03H,01H,02H,08H
DB 03H,00H,03H,00H,03H,00H,02H,07H
DB 02H,09H,02H,09H,02H,09H,02H,06H
DB 02H,08H,02H,08H,02H,08H,02H,05H
DB 02H,07H,02H,07H,02H,07H,02H,04H
DB 02H,06H,02H,06H,02H,06H,02H,03H
DB 02H,05H,02H,05H,02H,05H,02H,02H
DB 02H,04H,02H,04H,02H,04H,02H,01H
DB 02H,03H,02H,03H,02H,03H,02H,00H
DB 02H,02H,02H,02H,02H,02H,01H,09H
DB 02H,01H,02H,01H,02H,01H,01H,08H
DB 02H,00H,02H,00H,02H,00H,01H,07H
DB 01H,09H,01H,09H,01H,09H,01H,06H
DB 01H,08H,01H,08H,01H,08H,01H,05H
DB 01H,07H,01H,07H,01H,07H,01H,04H
DB 01H,06H,01H,06H,01H,06H,01H,03H
DB 01H,05H,01H,05H,01H,05H,01H,02H
DB 01H,04H,01H,04H,01H,04H,01H,01H
DB 01H,03H,01H,03H,01H,03H,01H,00H
DB 01H,02H,01H,02H,01H,02H,00H,09H
DB 01H,01H,01H,01H,01H,01H,00H,08H
DB 01H,00H,01H,00H,01H,00H,00H,07H
DB 00H,09H,00H,09H,00H,09H,00H,06H
DB 00H,08H,00H,08H,00H,08H,00H,05H
DB 00H,07H,00H,07H,00H,07H,00H,04H
DB 00H,06H,00H,06H,00H,06H,00H,03H
DB 00H,05H,00H,05H,00H,05H,00H,02H
DB 00H,04H,00H,04H,00H,04H,00H,01H
DB 00H,03H,00H,03H,00H,03H,00H,03H
DB 00H,02H,00H,02H,00H,02H,00H,02H
DB 00H,01H,00H,01H,00H,01H,00H,01H
END
不说了,我的还是比你那个好一点喔, 现在远行没问题了啊,
ORG 0000H
LJMP MAIN
ORG 001BH
LJMP SHI
ORG 0100H
MAIN: MOV SP,#60H ;设置堆栈指针
SETB PT1 ;设置定时器1中断为高级中断
MOV DPTR,#0300H
MOV R4,#14H
;MAX7219初始化
MOV A,#0BH ;置显示数位寄存器地址
MOV B,#07H ;选择8位显示方式
LCALL SHU ;写入MAX7219
MOV A,#0AH ;置亮度寄存器地址
MOV B,#08H ;选择占空比
LCALL SHU ;写入MAX7219
MOV A,#09H ;置译码方式寄存器地址
MOV B,#0FFH ;选择BCD译码方式
LCALL SHU ;写入MAX7219
MOV A,#0CH ;置关闭显示寄存器地址
MOV B,#01H ;选择进入正常工作方式
LCALL SHU ;写入MAX7219
;定时器0初始化,定时250us
MOV TMOD,#12H
MOV TH0,#06H
MOV TL0,#06H
SETB EA
;启动定时器1,每隔1S响应一次
MOV TH1,#3CH
MOV TL1,#0B0H
SETB EA
SETB ET1
SETB TR1
LCALL YAN05S
START: LCALL YAN05S
;东西左转弯绿灯亮15S
MOV P0,#9BH
MOV P2,#07H
MOV R0,#03H ;延时15S
L1: LCALL YAN5S
DJNZ R0,L1
;东西左转弯黄灯闪烁3S
SETB P0.2
CLR P0.1
MOV R0,#06H
L2: LCALL YAN05S
CPL P0.1
DJNZ R0,L2
;东西绿灯亮45S
MOV P0,#0B6H
MOV P2,#07H
MOV R0,#09H ;延时45S
L3: LCALL YAN5S
DJNZ R0,L3
;东西黄灯闪烁3S
SETB P0.3
CLR P0.4
MOV R0,#06H
L4: LCALL YAN05S
CPL P0.4
DJNZ R0,L4
;南北左转弯绿灯亮10S
MOV P0,#0DEH
MOV P2,#06H
MOV R0,#02H ;延时10S
L5: LCALL YAN5S
DJNZ R0,L5
;南北左转弯黄灯闪烁3S
SETB P2.0
CLR P0.7
MOV R0,#06H
L6: LCALL YAN05S
CPL P0.7
DJNZ R0,L6
;南北绿灯亮30S
MOV P0,#9EH
MOV P2,#0DH
MOV R0,#06H ;延时30S
L7: LCALL YAN5S
DJNZ R0,L7
;南北黄灯闪烁3S
SETB P2.1
CLR P2.2
MOV R0,#06H
L8: LCALL YAN05S
CPL P2.2
DJNZ R0,L8
MOV DPTR,#0300H
LJMP START
;延时5S子程序
YAN5S: MOV R6,#0C8H
MOV R7,#64H
SETB TR0
LL1: JNB TF0,LL1
CLR TF0
DJNZ R6,LL1
MOV R6,#0C8H
DJNZ R7,LL1
CLR TR0
RET
;延时0.5S子程序
YAN05S: MOV R6,#0C8H
MOV R7,#0AH
SETB TR0
LL2: JNB TF0,LL2
CLR TF0
DJNZ R6,LL2
MOV R6,#0C8H
DJNZ R7,LL2
CLR TR0
RET
;写入MAX7219子程序
SHU: CLR P1.1 ;将LOAD信号拉低
LCALL ONE ;一字节地址写入MAX7219
MOV A,B
LCALL ONE ;一字节地址写入MAX7219
NOP
SETB P1.1 ;产生LOAD上升沿信号,锁存数据
RET
ONE: MOV R1,#08H ;置串行移位计数器
LL3: CLR P1.2 ;将CLK信号拉低
RLC A ;A中的值左移入C中
MOV P1.0,C ;逐位送入DIN
NOP
SETB P1.2 ;产生CLK上升沿信号,移入数据
DJNZ R1,LL3 ;循环8次
RET
;时钟显示中断子程序
SHI: MOV TH1,#3CH ;重载初始值
MOV TL1,#0B0H
DJNZ R4,LLEND
MOV 70H,A ;保护A,B中的数据
MOV 71H,B
MOV R2,#01H ;指向第0位LED
MOV R3,#08H ;置显示器个数
LOOP: CLR A
MOVC A,@A+DPTR ;取显示缓冲区数据
MOV B,A ;数据送入B
MOV A,R2 ;LED显示的位地址送A
LCALL SHU ;写入MAX7219
INC DPTR ;指向下一个显示数据
INC R2 ;指向下一位LED
DJNZ R3,LOOP ;循环
MOV A,70H ;恢复中断前A,B的值
MOV B,71H
CLR TF1 ;标志位清零
MOV R4,#14H
LLEND: RETI
ORG 0300H
DB 01H,05H,01H,08H,06H,06H,06H,06H
DB 01H,04H,01H,07H,06H,05H,06H,05H
DB 01H,03H,01H,06H,06H,04H,06H,04H
DB 01H,02H,01H,05H,06H,03H,06H,03H
DB 01H,01H,01H,04H,06H,02H,06H,02H
DB 01H,00H,01H,03H,06H,01H,06H,01H
DB 00H,09H,01H,02H,06H,00H,06H,00H
DB 00H,08H,01H,01H,05H,09H,05H,09H
DB 00H,07H,01H,00H,05H,08H,05H,08H
DB 00H,06H,00H,09H,05H,07H,05H,07H
DB 00H,05H,00H,08H,05H,06H,05H,06H
DB 00H,04H,00H,07H,05H,05H,05H,05H
DB 00H,03H,00H,06H,05H,04H,05H,04H
DB 00H,02H,00H,05H,05H,03H,05H,03H
DB 00H,01H,00H,04H,05H,02H,05H,02H
DB 00H,03H,00H,03H,05H,01H,05H,01H
DB 00H,02H,00H,02H,05H,00H,05H,00H
DB 00H,01H,00H,01H,04H,09H,04H,09H
DB 04H,08H,04H,05H,04H,08H,04H,08H
DB 04H,07H,04H,04H,04H,07H,04H,07H
DB 04H,06H,04H,03H,04H,06H,04H,06H
DB 04H,05H,04H,02H,04H,05H,04H,05H
DB 04H,04H,04H,01H,04H,04H,04H,04H
DB 04H,03H,04H,00H,04H,03H,04H,03H
DB 04H,02H,03H,09H,04H,02H,04H,02H
DB 04H,01H,03H,08H,04H,01H,04H,01H
DB 04H,00H,03H,07H,04H,00H,04H,00H
DB 03H,09H,03H,06H,03H,09H,03H,09H
DB 03H,08H,03H,05H,03H,08H,03H,08H
DB 03H,07H,03H,04H,03H,07H,03H,07H
DB 03H,06H,03H,03H,03H,06H,03H,06H
DB 03H,05H,03H,02H,03H,05H,03H,05H
DB 03H,04H,03H,01H,03H,04H,03H,04H
DB 03H,03H,03H,00H,03H,03H,03H,03H
DB 03H,02H,02H,09H,03H,02H,03H,02H
DB 03H,01H,02H,08H,03H,01H,03H,01H
DB 03H,00H,02H,07H,03H,00H,03H,00H
DB 02H,09H,02H,06H,02H,09H,02H,09H
DB 02H,08H,02H,05H,02H,08H,02H,08H
DB 02H,07H,02H,04H,02H,07H,02H,07H
DB 02H,06H,02H,03H,02H,06H,02H,06H
DB 02H,05H,02H,02H,02H,05H,02H,05H
DB 02H,04H,02H,01H,02H,04H,02H,04H
DB 02H,03H,02H,00H,02H,03H,02H,03H
DB 02H,02H,01H,09H,02H,02H,02H,02H
DB 02H,01H,01H,08H,02H,01H,02H,01H
DB 02H,00H,01H,07H,02H,00H,02H,00H
DB 01H,09H,01H,06H,01H,09H,01H,09H
DB 01H,08H,01H,05H,01H,08H,01H,08H
DB 01H,07H,01H,04H,01H,07H,01H,07H
DB 01H,06H,01H,03H,01H,06H,01H,06H
DB 01H,05H,01H,02H,01H,05H,01H,05H
DB 01H,04H,01H,01H,01H,04H,01H,04H
DB 01H,03H,01H,00H,01H,03H,01H,03H
DB 01H,02H,00H,09H,01H,02H,01H,02H
DB 01H,01H,00H,08H,01H,01H,01H,01H
DB 01H,00H,00H,07H,01H,00H,01H,00H
DB 00H,09H,00H,06H,00H,09H,00H,09H
DB 00H,08H,00H,05H,00H,08H,00H,08H
DB 00H,07H,00H,04H,00H,07H,00H,07H
DB 00H,06H,00H,03H,00H,06H,00H,06H
DB 00H,05H,00H,02H,00H,05H,00H,05H
DB 00H,04H,00H,01H,00H,04H,00H,04H
DB 00H,03H,00H,03H,00H,03H,00H,03H
DB 00H,02H,00H,02H,00H,02H,00H,02H
DB 00H,01H,00H,01H,00H,01H,00H,01H
DB 04H,06H,04H,06H,01H,00H,01H,03H
DB 04H,05H,04H,05H,00H,09H,01H,02H
DB 04H,04H,04H,04H,00H,08H,01H,01H
DB 04H,03H,04H,03H,00H,07H,01H,00H
DB 04H,02H,04H,02H,00H,06H,00H,09H
DB 04H,01H,04H,01H,00H,05H,00H,08H
DB 04H,00H,04H,00H,00H,04H,00H,07H
DB 03H,09H,03H,09H,00H,03H,00H,06H
DB 03H,08H,03H,08H,00H,02H,00H,05H
DB 03H,07H,03H,07H,00H,01H,00H,04H
DB 03H,06H,03H,06H,00H,03H,00H,03H
DB 03H,05H,03H,05H,00H,02H,00H,02H
DB 03H,04H,03H,04H,00H,01H,00H,01H
DB 03H,03H,03H,03H,03H,03H,03H,00H
DB 03H,02H,03H,02H,03H,02H,02H,09H
DB 03H,01H,03H,01H,03H,01H,02H,08H
DB 03H,00H,03H,00H,03H,00H,02H,07H
DB 02H,09H,02H,09H,02H,09H,02H,06H
DB 02H,08H,02H,08H,02H,08H,02H,05H
DB 02H,07H,02H,07H,02H,07H,02H,04H
DB 02H,06H,02H,06H,02H,06H,02H,03H
DB 02H,05H,02H,05H,02H,05H,02H,02H
DB 02H,04H,02H,04H,02H,04H,02H,01H
DB 02H,03H,02H,03H,02H,03H,02H,00H
DB 02H,02H,02H,02H,02H,02H,01H,09H
DB 02H,01H,02H,01H,02H,01H,01H,08H
DB 02H,00H,02H,00H,02H,00H,01H,07H
DB 01H,09H,01H,09H,01H,09H,01H,06H
DB 01H,08H,01H,08H,01H,08H,01H,05H
DB 01H,07H,01H,07H,01H,07H,01H,04H
DB 01H,06H,01H,06H,01H,06H,01H,03H
DB 01H,05H,01H,05H,01H,05H,01H,02H
DB 01H,04H,01H,04H,01H,04H,01H,01H
DB 01H,03H,01H,03H,01H,03H,01H,00H
DB 01H,02H,01H,02H,01H,02H,00H,09H
DB 01H,01H,01H,01H,01H,01H,00H,08H
DB 01H,00H,01H,00H,01H,00H,00H,07H
DB 00H,09H,00H,09H,00H,09H,00H,06H
DB 00H,08H,00H,08H,00H,08H,00H,05H
DB 00H,07H,00H,07H,00H,07H,00H,04H
DB 00H,06H,00H,06H,00H,06H,00H,03H
DB 00H,05H,00H,05H,00H,05H,00H,02H
DB 00H,04H,00H,04H,00H,04H,00H,01H
DB 00H,03H,00H,03H,00H,03H,00H,03H
DB 00H,02H,00H,02H,00H,02H,00H,02H
DB 00H,01H,00H,01H,00H,01H,00H,01H
END
一周热门 更多>