hey! chào ban . minh cũng đang nghiên cứu điều xung !
post bài này cho ban nghiên cứu chút
;xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx xx
;chuong trinh led roi 8bit
;thanhbangdesign suu tam
;xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx xxxxxxx
PWM EQU R6
B_GIAY EQU R7
ORG 0000H
JMP MAIN
ORG 00BH
JMP NGAT_T0
MAIN:
mov 10h,#1
mov 11h,#1
mov 12h,#1
mov 13h,#1
mov 14h,#1
mov 15h,#1
mov 16h,#1
mov 17h,#1
mov 18h,#1
mov 19h,#1
mov 20h,#1
mov 21h,#1
mov 22h,#1
mov 23h,#1
mov 24h,#1
mov 25h,#1
mov 26h,#1
mov 27h,#1
mov 28h,#1
mov 29h,#1
mov 30h,#1
mov 31h,#1
mov 32h,#1
mov 33h,#1
mov 34h,#1
mov 35h,#1
mov 36h,#1
mov 37h,#1
mov 38h,#1
mov 39h,#1
mov 40h,#1
mov 41h,#1
MOV TMOD,#01H
MOV TH0,#0FFH
MOV TL0,#0F2H
CLR TF0
SETB TR0
MOV IE,#82H
MAIN1:
MOV P0,#00000011b
MOV P1,#00000000b
MOV P2,#00000000b
MOV P3,#00000000b
MOV B_GIAY,#1
LCALL DELAY
MOV P0,#00000100b
MOV P1,#00000000b
MOV P2,#00000000b
MOV P3,#00000000b
MOV 10H,#80
MOV 11H,#80
MOV B_GIAY,#1
LCALL DELAY1
MOV 10H,#1
MOV 11H,#1
MOV P0,#00001000b
MOV P1,#00000000b
MOV P2,#00000000b
MOV P3,#00000000b
MOV 10H,#60
MOV 11H,#60
MOV 12H,#80
MOV B_GIAY,#1
LCALL DELAY1
MOV 10H,#1
MOV 11H,#1
MOV 12H,#1
MOV P0,#00010000b
MOV P1,#00000000b
MOV P2,#00000000b
MOV P3,#00000000b
MOV 10H,#40
MOV 11H,#40
MOV 12H,#60
MOV 13H,#80
MOV B_GIAY,#1
LCALL DELAY1
MOV 10H,#1
MOV 11H,#1
MOV 12H,#1
MOV 13H,#1
MOV P0,#00100000b
MOV P1,#00000000b
MOV P2,#00000000b
MOV P3,#00000000b
MOV 10H,#20
MOV 11H,#20
MOV 12H,#40
MOV 13H,#60
MOV 14H,#80
MOV B_GIAY,#1
LCALL DELAY1
MOV 10H,#1
MOV 11H,#1
MOV 12H,#1
MOV 13H,#1
MOV 14H,#1
MOV P0,#01000000b
MOV P1,#00000000b
MOV P2,#00000000b
MOV P3,#00000000b
MOV 10H,#10
MOV 12H,#20
MOV 13H,#40
MOV 14H,#60
MOV 15H,#80
MOV B_GIAY,#1
LCALL DELAY1
MOV 10H,#1
MOV 12H,#1
MOV 13H,#1
MOV 14H,#1
MOV 15H,#1
MOV P0,#10000000b
MOV P1,#00000000b
MOV P2,#00000000b
MOV P3,#00000000b
MOV 13H,#20
MOV 14H,#40
MOV 15H,#60
MOV 16H,#80
MOV B_GIAY,#1
LCALL DELAY1
MOV 13H,#1
MOV 14H,#1
MOV 15H,#1
MOV 16H,#1
MOV P0,#00000000b
MOV P1,#00000000b
MOV P2,#00000000b
MOV P3,#00000000b
MOV 15H,#40
MOV 16H,#60
MOV 17H,#80
MOV B_GIAY,#1
LCALL DELAY1
MOV 15H,#1
MOV 16H,#1
MOV 17H,#1
MOV P0,#00000000b
MOV P1,#00000000b
MOV P2,#00000000b
MOV P3,#00000000b
MOV 17H,#60
MOV B_GIAY,#1
LCALL DELAY1
MOV 17H,#1
JMP MAIN1
DELAY:
D: MOV R5,#8
DD:
MOV PWM,#0
DDD: CJNE PWM,#100,DDD
DJNZ R5,DD
DJNZ B_GIAY,D
RET
DELAY1:
D1: MOV R5,#8
DD1:
MOV PWM,#0
mov 45h,10h
mov 46h,11h
mov 47h,12h
mov 48h,13h
mov 49h,14h
mov 50h,15h
mov 51h,16h
mov 52h,17h
mov 53h,18h
mov 54h,19h
mov 55h,20h
mov 56h,21h
mov 57h,22h
mov 58h,23h
mov 59h,24h
mov 60h,25h
mov 61h,26h
mov 62h,27h
mov 63h,28h
mov 64h,29h
mov 65h,30h
mov 66h,31h
mov 67h,32h
mov 68h,33h
mov 69h,34h
mov 70h,35h
mov 71h,36h
mov 72h,37h
mov 73h,38h
mov 74h,39h
mov 75h,40h
mov 76h,41h
x0: mov a,10h
cjne a,#1,s0
jmp x1
s0: djnz 45h,z0
mov 45h,#1
clr P0.0
jmp x1
z0: setb P0.0
x1: mov a,11h
cjne a,#1,s1
jmp x2
s1: djnz 46h,z1
mov 46h,#1
clr P0.1
jmp x2
z1: setb P0.1
x2: mov a,12h
cjne a,#1,s2
jmp x3
s2: djnz 47h,z2
mov 47h,#1
clr P0.2
jmp x3
z2: setb P0.2
x3: mov a,13h
cjne a,#1,s3
jmp x4
s3: djnz 48h,z3
mov 48h,#1
clr P0.3
jmp x4
z3: setb P0.3
x4: mov a,14h
cjne a,#1,s4
jmp x5
s4: djnz 49h,z4
mov 49h,#1
clr P0.4
jmp x5
z4: setb P0.4
x5: mov a,15h
cjne a,#1,s5
jmp x6
s5: djnz 50h,z5
mov 50h,#1
clr P0.5
jmp x6
z5: setb P0.5
x6: mov a,16h
cjne a,#1,s6
jmp x7
s6: djnz 51h,z6
mov 51h,#1
clr P0.6
jmp x7
z6: setb P0.6
x7: mov a,17h
cjne a,#1,s7
jmp x8
s7: djnz 52h,z7
mov 52h,#1
clr P0.7
jmp x8
z7: setb P0.7
x8: mov a,18h
cjne a,#1,s8
jmp x9
s8: djnz 53h,z8
mov 53h,#1
clr P1.0
jmp x9
z8: setb P1.0
x9: mov a,19h
cjne a,#1,s9
jmp x10
s9: djnz 54h,z9
mov 54h,#1
clr P1.1
jmp x10
z9: setb P1.1
x10: mov a,20h
cjne a,#1,s10
jmp x11
s10: djnz 55h,z10
mov 55h,#1
clr P1.2
jmp x11
z10: setb P1.2
x11: mov a,21h
cjne a,#1,s11
jmp x12
s11: djnz 56h,z11
mov 56h,#1
clr P1.3
jmp x12
z11: setb P1.3
x12: mov a,22h
cjne a,#1,s12
jmp x13
s12: djnz 57h,z12
mov 57h,#1
clr P1.4
jmp x13
z12: setb P1.4
x13: mov a,23h
cjne a,#1,s13
jmp x14
s13: djnz 58h,z13
mov 58h,#1
clr P1.5
jmp x14
z13: setb P1.5
x14: mov a,24h
cjne a,#1,s14
jmp x15
s14: djnz 59h,z14
mov 59h,#1
clr P1.6
jmp x15
z14: setb P1.6
x15: mov a,25h
cjne a,#1,s15
jmp x16
s15: djnz 60h,z15
mov 60h,#1
clr P1.7
jmp x16
z15: setb P1.7
x16: mov a,26h
cjne a,#1,s16
jmp x17
s16: djnz 61h,z16
mov 61h,#1
clr P2.0
jmp x17
z16: setb P2.0
x17: mov a,27h
cjne a,#1,s17
jmp x18
s17: djnz 62h,z17
mov 62h,#1
clr P2.1
jmp x18
z17: setb P2.1
x18: mov a,28h
cjne a,#1,s18
jmp x19
s18: djnz 63h,z18
mov 63h,#1
clr P2.2
jmp x19
z18: setb P2.2
x19: mov a,29h
cjne a,#1,s19
jmp x20
s19: djnz 64h,z19
mov 64h,#1
clr P2.3
jmp x20
z19: setb P2.3
x20: mov a,30h
cjne a,#1,s20
jmp x21
s20: djnz 65h,z20
mov 65h,#1
clr P2.4
jmp x21
z20: setb P2.4
x21: mov a,31h
cjne a,#1,s21
jmp x22
s21: djnz 66h,z21
mov 66h,#1
clr P2.5
jmp x22
z21: setb P2.5
x22: mov a,32h
cjne a,#1,s22
jmp x23
s22: djnz 67h,z22
mov 67h,#1
clr P2.6
jmp x23
z22: setb P2.6
x23: mov a,33h
cjne a,#1,s23
jmp x24
s23: djnz 68h,z23
mov 68h,#1
clr P2.7
jmp x24
z23: setb P2.7
x24: mov a,34h
cjne a,#1,s24
jmp x25
s24: djnz 69h,z24
mov 69h,#1
clr P3.0
jmp x25
z24: setb P3.0
x25: mov a,35h
cjne a,#1,s25
jmp x26
s25: djnz 70h,z25
mov 70h,#1
clr P3.1
jmp x26
z25: setb P3.1
x26: mov a,36h
cjne a,#1,s26
jmp x27
s26: djnz 71h,z26
mov 71h,#1
clr P3.2
jmp x27
z26: setb P3.2
x27: mov a,37h
cjne a,#1,s27
jmp x28
s27: djnz 72h,z27
mov 72h,#1
clr P3.3
jmp x28
z27: setb P3.3
x28: mov a,38h
cjne a,#1,s28
jmp x29
s28: djnz 73h,z28
mov 73h,#1
clr P3.4
jmp x29
z28: setb P3.4
x29: mov a,39h
cjne a,#1,s29
jmp x30
s29: djnz 74h,z29
mov 74h,#1
clr P3.5
jmp x30
z29: setb P3.5
x30: mov a,40h
cjne a,#1,s30
jmp x31
s30: djnz 75h,z30
mov 75h,#1
clr P3.6
jmp x31
z30: setb P3.6
x31: mov a,41h
cjne a,#1,s31
jmp x32
s31: djnz 76h,z31
mov 76h,#1
clr P3.7
jmp x32
z31: setb P3.7
x32:
INC PWM
CJNE PWM,#100,x00
DJNZ R5,DD11
DJNZ B_GIAY,D11
ret
x00: jmp x0
dd11: jmp dd1
d11: jmp d1
RET
NGAT_T0:
MOV TH0,#0FFH
MOV TL0,#0F2H
INC PWM
RETI
END
;xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx xxx
post bài này cho ban nghiên cứu chút
;xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx xx
;chuong trinh led roi 8bit
;thanhbangdesign suu tam
;xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx xxxxxxx
PWM EQU R6
B_GIAY EQU R7
ORG 0000H
JMP MAIN
ORG 00BH
JMP NGAT_T0
MAIN:
mov 10h,#1
mov 11h,#1
mov 12h,#1
mov 13h,#1
mov 14h,#1
mov 15h,#1
mov 16h,#1
mov 17h,#1
mov 18h,#1
mov 19h,#1
mov 20h,#1
mov 21h,#1
mov 22h,#1
mov 23h,#1
mov 24h,#1
mov 25h,#1
mov 26h,#1
mov 27h,#1
mov 28h,#1
mov 29h,#1
mov 30h,#1
mov 31h,#1
mov 32h,#1
mov 33h,#1
mov 34h,#1
mov 35h,#1
mov 36h,#1
mov 37h,#1
mov 38h,#1
mov 39h,#1
mov 40h,#1
mov 41h,#1
MOV TMOD,#01H
MOV TH0,#0FFH
MOV TL0,#0F2H
CLR TF0
SETB TR0
MOV IE,#82H
MAIN1:
MOV P0,#00000011b
MOV P1,#00000000b
MOV P2,#00000000b
MOV P3,#00000000b
MOV B_GIAY,#1
LCALL DELAY
MOV P0,#00000100b
MOV P1,#00000000b
MOV P2,#00000000b
MOV P3,#00000000b
MOV 10H,#80
MOV 11H,#80
MOV B_GIAY,#1
LCALL DELAY1
MOV 10H,#1
MOV 11H,#1
MOV P0,#00001000b
MOV P1,#00000000b
MOV P2,#00000000b
MOV P3,#00000000b
MOV 10H,#60
MOV 11H,#60
MOV 12H,#80
MOV B_GIAY,#1
LCALL DELAY1
MOV 10H,#1
MOV 11H,#1
MOV 12H,#1
MOV P0,#00010000b
MOV P1,#00000000b
MOV P2,#00000000b
MOV P3,#00000000b
MOV 10H,#40
MOV 11H,#40
MOV 12H,#60
MOV 13H,#80
MOV B_GIAY,#1
LCALL DELAY1
MOV 10H,#1
MOV 11H,#1
MOV 12H,#1
MOV 13H,#1
MOV P0,#00100000b
MOV P1,#00000000b
MOV P2,#00000000b
MOV P3,#00000000b
MOV 10H,#20
MOV 11H,#20
MOV 12H,#40
MOV 13H,#60
MOV 14H,#80
MOV B_GIAY,#1
LCALL DELAY1
MOV 10H,#1
MOV 11H,#1
MOV 12H,#1
MOV 13H,#1
MOV 14H,#1
MOV P0,#01000000b
MOV P1,#00000000b
MOV P2,#00000000b
MOV P3,#00000000b
MOV 10H,#10
MOV 12H,#20
MOV 13H,#40
MOV 14H,#60
MOV 15H,#80
MOV B_GIAY,#1
LCALL DELAY1
MOV 10H,#1
MOV 12H,#1
MOV 13H,#1
MOV 14H,#1
MOV 15H,#1
MOV P0,#10000000b
MOV P1,#00000000b
MOV P2,#00000000b
MOV P3,#00000000b
MOV 13H,#20
MOV 14H,#40
MOV 15H,#60
MOV 16H,#80
MOV B_GIAY,#1
LCALL DELAY1
MOV 13H,#1
MOV 14H,#1
MOV 15H,#1
MOV 16H,#1
MOV P0,#00000000b
MOV P1,#00000000b
MOV P2,#00000000b
MOV P3,#00000000b
MOV 15H,#40
MOV 16H,#60
MOV 17H,#80
MOV B_GIAY,#1
LCALL DELAY1
MOV 15H,#1
MOV 16H,#1
MOV 17H,#1
MOV P0,#00000000b
MOV P1,#00000000b
MOV P2,#00000000b
MOV P3,#00000000b
MOV 17H,#60
MOV B_GIAY,#1
LCALL DELAY1
MOV 17H,#1
JMP MAIN1
DELAY:
D: MOV R5,#8
DD:
MOV PWM,#0
DDD: CJNE PWM,#100,DDD
DJNZ R5,DD
DJNZ B_GIAY,D
RET
DELAY1:
D1: MOV R5,#8
DD1:
MOV PWM,#0
mov 45h,10h
mov 46h,11h
mov 47h,12h
mov 48h,13h
mov 49h,14h
mov 50h,15h
mov 51h,16h
mov 52h,17h
mov 53h,18h
mov 54h,19h
mov 55h,20h
mov 56h,21h
mov 57h,22h
mov 58h,23h
mov 59h,24h
mov 60h,25h
mov 61h,26h
mov 62h,27h
mov 63h,28h
mov 64h,29h
mov 65h,30h
mov 66h,31h
mov 67h,32h
mov 68h,33h
mov 69h,34h
mov 70h,35h
mov 71h,36h
mov 72h,37h
mov 73h,38h
mov 74h,39h
mov 75h,40h
mov 76h,41h
x0: mov a,10h
cjne a,#1,s0
jmp x1
s0: djnz 45h,z0
mov 45h,#1
clr P0.0
jmp x1
z0: setb P0.0
x1: mov a,11h
cjne a,#1,s1
jmp x2
s1: djnz 46h,z1
mov 46h,#1
clr P0.1
jmp x2
z1: setb P0.1
x2: mov a,12h
cjne a,#1,s2
jmp x3
s2: djnz 47h,z2
mov 47h,#1
clr P0.2
jmp x3
z2: setb P0.2
x3: mov a,13h
cjne a,#1,s3
jmp x4
s3: djnz 48h,z3
mov 48h,#1
clr P0.3
jmp x4
z3: setb P0.3
x4: mov a,14h
cjne a,#1,s4
jmp x5
s4: djnz 49h,z4
mov 49h,#1
clr P0.4
jmp x5
z4: setb P0.4
x5: mov a,15h
cjne a,#1,s5
jmp x6
s5: djnz 50h,z5
mov 50h,#1
clr P0.5
jmp x6
z5: setb P0.5
x6: mov a,16h
cjne a,#1,s6
jmp x7
s6: djnz 51h,z6
mov 51h,#1
clr P0.6
jmp x7
z6: setb P0.6
x7: mov a,17h
cjne a,#1,s7
jmp x8
s7: djnz 52h,z7
mov 52h,#1
clr P0.7
jmp x8
z7: setb P0.7
x8: mov a,18h
cjne a,#1,s8
jmp x9
s8: djnz 53h,z8
mov 53h,#1
clr P1.0
jmp x9
z8: setb P1.0
x9: mov a,19h
cjne a,#1,s9
jmp x10
s9: djnz 54h,z9
mov 54h,#1
clr P1.1
jmp x10
z9: setb P1.1
x10: mov a,20h
cjne a,#1,s10
jmp x11
s10: djnz 55h,z10
mov 55h,#1
clr P1.2
jmp x11
z10: setb P1.2
x11: mov a,21h
cjne a,#1,s11
jmp x12
s11: djnz 56h,z11
mov 56h,#1
clr P1.3
jmp x12
z11: setb P1.3
x12: mov a,22h
cjne a,#1,s12
jmp x13
s12: djnz 57h,z12
mov 57h,#1
clr P1.4
jmp x13
z12: setb P1.4
x13: mov a,23h
cjne a,#1,s13
jmp x14
s13: djnz 58h,z13
mov 58h,#1
clr P1.5
jmp x14
z13: setb P1.5
x14: mov a,24h
cjne a,#1,s14
jmp x15
s14: djnz 59h,z14
mov 59h,#1
clr P1.6
jmp x15
z14: setb P1.6
x15: mov a,25h
cjne a,#1,s15
jmp x16
s15: djnz 60h,z15
mov 60h,#1
clr P1.7
jmp x16
z15: setb P1.7
x16: mov a,26h
cjne a,#1,s16
jmp x17
s16: djnz 61h,z16
mov 61h,#1
clr P2.0
jmp x17
z16: setb P2.0
x17: mov a,27h
cjne a,#1,s17
jmp x18
s17: djnz 62h,z17
mov 62h,#1
clr P2.1
jmp x18
z17: setb P2.1
x18: mov a,28h
cjne a,#1,s18
jmp x19
s18: djnz 63h,z18
mov 63h,#1
clr P2.2
jmp x19
z18: setb P2.2
x19: mov a,29h
cjne a,#1,s19
jmp x20
s19: djnz 64h,z19
mov 64h,#1
clr P2.3
jmp x20
z19: setb P2.3
x20: mov a,30h
cjne a,#1,s20
jmp x21
s20: djnz 65h,z20
mov 65h,#1
clr P2.4
jmp x21
z20: setb P2.4
x21: mov a,31h
cjne a,#1,s21
jmp x22
s21: djnz 66h,z21
mov 66h,#1
clr P2.5
jmp x22
z21: setb P2.5
x22: mov a,32h
cjne a,#1,s22
jmp x23
s22: djnz 67h,z22
mov 67h,#1
clr P2.6
jmp x23
z22: setb P2.6
x23: mov a,33h
cjne a,#1,s23
jmp x24
s23: djnz 68h,z23
mov 68h,#1
clr P2.7
jmp x24
z23: setb P2.7
x24: mov a,34h
cjne a,#1,s24
jmp x25
s24: djnz 69h,z24
mov 69h,#1
clr P3.0
jmp x25
z24: setb P3.0
x25: mov a,35h
cjne a,#1,s25
jmp x26
s25: djnz 70h,z25
mov 70h,#1
clr P3.1
jmp x26
z25: setb P3.1
x26: mov a,36h
cjne a,#1,s26
jmp x27
s26: djnz 71h,z26
mov 71h,#1
clr P3.2
jmp x27
z26: setb P3.2
x27: mov a,37h
cjne a,#1,s27
jmp x28
s27: djnz 72h,z27
mov 72h,#1
clr P3.3
jmp x28
z27: setb P3.3
x28: mov a,38h
cjne a,#1,s28
jmp x29
s28: djnz 73h,z28
mov 73h,#1
clr P3.4
jmp x29
z28: setb P3.4
x29: mov a,39h
cjne a,#1,s29
jmp x30
s29: djnz 74h,z29
mov 74h,#1
clr P3.5
jmp x30
z29: setb P3.5
x30: mov a,40h
cjne a,#1,s30
jmp x31
s30: djnz 75h,z30
mov 75h,#1
clr P3.6
jmp x31
z30: setb P3.6
x31: mov a,41h
cjne a,#1,s31
jmp x32
s31: djnz 76h,z31
mov 76h,#1
clr P3.7
jmp x32
z31: setb P3.7
x32:
INC PWM
CJNE PWM,#100,x00
DJNZ R5,DD11
DJNZ B_GIAY,D11
ret
x00: jmp x0
dd11: jmp dd1
d11: jmp d1
RET
NGAT_T0:
MOV TH0,#0FFH
MOV TL0,#0F2H
INC PWM
RETI
END
;xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx xxx
Comment