ݺߣ

ݺߣShare a Scribd company logo
Ch 4 – TK hệ VXL
Các thí dụ minh họa
LED Blinking
XTAL2
18
XTAL1
19
ALE
30
EA
31
PSEN
29
RST
9
P0.0/AD0
39
P0.1/AD1
38
P0.2/AD2
37
P0.3/AD3
36
P0.4/AD4
35
P0.5/AD5
34
P0.6/AD6
33
P0.7/AD7
32
P2.7/A15
28
P2.0/A8
21
P2.1/A9
22
P2.2/A10
23
P2.3/A11
24
P2.4/A12
25
P2.5/A13
26
P2.6/A14
27
P1.0
1
P1.1
2
P1.2
3
P1.3
4
P1.4
5
P1.5
6
P1.6
7
P1.7
8
P3.0/RXD
10
P3.1/TXD
11
P3.2/INT0
12
P3.3/INT1
13
P3.4/T0
14
P3.7/RD
17
P3.6/WR
16
P3.5/T1
15
U1
80C51
B1 S1
R01
10k
R00
10k
R30
330R
R31
330R
DB1 DS1
X1
16MHzCX1
33p
CX2
33p
CRST
10n
RRST
10k
B2
R32
330R
DB2
D1
LED-GREEN
D2
LED-GREEN
D3
LED-GREEN
D4
LED-GREEN
D5
LED-GREEN
D6
LED-GREEN
D7
LED-GREEN
R1
330R
R2
330R
R3
330R
R4
330R
R5
330R
R6
330R
R7
330R
R8
330R
D8
LED-GREEN
Blink01.asm (1/2)
xtal equ 12 ; Crystal frequency in MHz
Patternequ 0FEh
org 0
mov P0,#00000011b ; Dat cau hinh P0.1 va P0.0 la Input
mov P3,#10000000b ; Dat cau hinh P3.7 la Input
mov P1,#Pattern
back:
; copy port0 switch B1,S1 states to acc
mov a,P0
anl a,#00000011b ; P0.1 and P0.0 are selected
orl a,#10000000b ; prepare P3.7 for input
; Sao chep bit P3.7 vao bit P3.2
mov C, p3.7
mov acc.2, C
mov P3,a
Blink01.asm (2/2)
mov A, P1
jb P0.1, RoR
; Xoay trai P1
RL A
sjmp Next
RoR:
; Xoay phai P1
RR A
Next: mov P1, A
; delay for 25ms delay
mov A,#250
acall dly100u
sjmp back
dly100u:
; delay loop takes
;
mov r1,A
dlylp1: mov r0,#(xtal*62/10)
dlylp2: djnz r0,dlylp2
djnz r1,dlylp1
ret
end
Boole_Up BCD counter_7seg LED
XTAL2
18
XTAL1
19
ALE
30
EA
31
PSEN
29
RST
9
P0.0/AD0
39
P0.1/AD1
38
P0.2/AD2
37
P0.3/AD3
36
P0.4/AD4
35
P0.5/AD5
34
P0.6/AD6
33
P0.7/AD7
32
P2.7/A15
28
P2.0/A8
21
P2.1/A9
22
P2.2/A10
23
P2.3/A11
24
P2.4/A12
25
P2.5/A13
26
P2.6/A14
27
P1.0
1
P1.1
2
P1.2
3
P1.3
4
P1.4
5
P1.5
6
P1.6
7
P1.7
8
P3.0/RXD
10
P3.1/TXD
11
P3.2/INT0
12
P3.3/INT1
13
P3.4/T0
14
P3.7/RD
17
P3.6/WR
16
P3.5/T1
15
U1
80C51
X1
16MHzCX1
33p
CX2
33p
CRST
10n
RRST
10k
R1
270R
R2
270R
R3
270R
R4
270R
R5
270R
R6
270R
R7
270R
;TD: boole04.asm
; Minh hoa cac lenh nhay theo tri bien Boole: JC, JNC, JB, JNB, JBC
; Mo phong mach dem 10: ngo ra nhi phan o 4 bit thap P2, duoc noi voi mach hien
thi so
; xung nhip CK (kich canh xuong) duoc noi chan P3.7
CK EQU P3.7
MOV P3,#80H ; Dat cau hinh P3.7 INPUT
MOV R0,#0 ; So dem ban dau la 0
MOV P0,#0C0H; Dau tien so dem la 0
LOOP:
JNB CK,$ ; Doi CK o muc 1
JB CK,$ ; Doi CK o muc 0 ==> phat hien duoc canh xuong
INC R0
CJNE R0,#10,NEXT
MOV R0,#0
NEXT:
MOV A,R0
ACALL BCD2LED
SJMP LOOP
BCD2LED:
MOV DPTR,#LED_DATA
MOVC A,@A+DPTR
MOV P0,A
RET
LED_DATA:
DB 0C0H, 0F9H, 0A4H, 0B0H, 99H, 92H, 82H, 0F8H, 80H, 90H
RET
Boole_Up BCD counter_7seg LED
Using Timer 0
XTAL2
18
XTAL1
19
ALE
30
EA
31
PSEN
29
RST
9
P0.0/AD0
39
P0.1/AD1
38
P0.2/AD2
37
P0.3/AD3
36
P0.4/AD4
35
P0.5/AD5
34
P0.6/AD6
33
P0.7/AD7
32
P2.7/A15
28
P2.0/A8
21
P2.1/A9
22
P2.2/A10
23
P2.3/A11
24
P2.4/A12
25
P2.5/A13
26
P2.6/A14
27
P1.0
1
P1.1
2
P1.2
3
P1.3
4
P1.4
5
P1.5
6
P1.6
7
P1.7
8
P3.0/RXD
10
P3.1/TXD
11
P3.2/INT0
12
P3.3/INT1
13
P3.4/T0
14
P3.7/RD
17
P3.6/WR
16
P3.5/T1
15
U1
80C51
X1
12MHzCX1
33p
CX2
33p
CRST
10n
RRST
10k
R1
270R
R2
270R
R3
270R
R4
270R
R5
270R
R6
270R
R7
270R
;TD: counter01.asm
; Minh hoa su dung chuc nang counter cua 8051
; Su dung T0 che do 2 lam counter voi CLK la chan P3.4 (T0)
; counter nay co modulo 10, nghia là dem het 9 thi tran
COUNT EQU -10
SETB P3.4 ; dat cau hinh input cho P3.4
MOV TMOD,#6 ; Timer 0: counter mode 2
MOV TH0, #COUNT
MOV TL0, #COUNT
SETB TR0
LOOP:
MOV A,TL0
ADD A,#-COUNT
CALL BCD2LED
MOV P0,A
SJMP LOOP
BCD2LED:
MOV DPTR,#LED_DATA
MOVC A,@A+DPTR
MOV P0,A
RET
LED_DATA:
DB 0C0H, 0F9H, 0A4H, 0B0H, 99H, 92H, 82H, 0F8H, 80H, 90H
RET
END
Vxl ch 4 – tk he vxl cac td minh hoa
Vxl ch 4 – tk he vxl cac td minh hoa
Ad

Recommended

Advanced motion controls b50a8
Advanced motion controls b50a8
Electromate
Advanced motion controls b50a20
Advanced motion controls b50a20
Electromate
Reload editor introductory manual
Reload editor introductory manual
Miguel Gil Beltrán
W cr 25_install_guide
W cr 25_install_guide
Miguel Gil Beltrán
Cyber bullying presentation
Cyber bullying presentation
gmtango
Rangkaian komputer
Rangkaian komputer
Nor Shahila Ishak
Ad idem
Ad idem
chandakhan007
Asiman9r2
Asiman9r2
asiman-sahlar
Venecia 8437
genesis159
Gentianasli 100721185953-phpapp01
Gentianasli 100721185953-phpapp01
Nor Shahila Ishak
Generator
Generator
BaRoez THesa
Kajian fabrik shilinku
Kajian fabrik shilinku
Nor Shahila Ishak
Kajian fabrik shilinku
Kajian fabrik shilinku
Nor Shahila Ishak
Bab5jahitan 091220024659-phpapp02
Bab5jahitan 091220024659-phpapp02
Nor Shahila Ishak
Hukum mendel
Hukum mendel
nurse_zsalam
Ekwa consult eng
Ekwa consult eng
EvelienVE01
Bullying powerpoint
Bullying powerpoint
gmtango
Curiosidades de la época de los avot
etics
Curiosidades de la época de los avot
etics
S4F03 Col11 Conversion of Accounting to SAP S/4HANA
S4F03 Col11 Conversion of Accounting to SAP S/4HANA
Libreria ERP
Tesia Dobrydnia - A Leader In Her Industry
Tesia Dobrydnia - A Leader In Her Industry
Tesia Dobrydnia
Power of the Many Masterclasses - 2nd draft .pptx
Power of the Many Masterclasses - 2nd draft .pptx
AlexBausch2
Glow Up Your Desk: The MOOJAY Monitor Stand Experience
Glow Up Your Desk: The MOOJAY Monitor Stand Experience
Topmate
What Drives Collectors in Sports and Beyond, and How Mantel is Bringing Them ...
What Drives Collectors in Sports and Beyond, and How Mantel is Bringing Them ...
Neil Horowitz
Integrating Customer Journey Insights into Your Business Process Management S...
Integrating Customer Journey Insights into Your Business Process Management S...
RUPAL AGARWAL
Salary_Wage_Computation_3Day_Lesson.pptx
Salary_Wage_Computation_3Day_Lesson.pptx
DaryllWhere
IEA_Press_Release_Tullow_Agreement-16-6-2025-1.pdf
IEA_Press_Release_Tullow_Agreement-16-6-2025-1.pdf
businessweekghana
Integration of Information Security Governance and Corporate Governance
Integration of Information Security Governance and Corporate Governance
Tokyo Security Community
Noah Loul Shares 5 Key Impacts of AI Agents on the Sales Industry
Noah Loul Shares 5 Key Impacts of AI Agents on the Sales Industry
Noah Loul
Marketing Assignment presentation of good marketing techniques how to impleme...
Marketing Assignment presentation of good marketing techniques how to impleme...
Priya Raj

More Related Content

Viewers also liked (11)

Venecia 8437
genesis159
Gentianasli 100721185953-phpapp01
Gentianasli 100721185953-phpapp01
Nor Shahila Ishak
Generator
Generator
BaRoez THesa
Kajian fabrik shilinku
Kajian fabrik shilinku
Nor Shahila Ishak
Kajian fabrik shilinku
Kajian fabrik shilinku
Nor Shahila Ishak
Bab5jahitan 091220024659-phpapp02
Bab5jahitan 091220024659-phpapp02
Nor Shahila Ishak
Hukum mendel
Hukum mendel
nurse_zsalam
Ekwa consult eng
Ekwa consult eng
EvelienVE01
Bullying powerpoint
Bullying powerpoint
gmtango
Curiosidades de la época de los avot
etics
Curiosidades de la época de los avot
etics
Venecia 8437
genesis159
Bullying powerpoint
Bullying powerpoint
gmtango
Curiosidades de la época de los avot
etics
Curiosidades de la época de los avot
etics

Recently uploaded (20)

S4F03 Col11 Conversion of Accounting to SAP S/4HANA
S4F03 Col11 Conversion of Accounting to SAP S/4HANA
Libreria ERP
Tesia Dobrydnia - A Leader In Her Industry
Tesia Dobrydnia - A Leader In Her Industry
Tesia Dobrydnia
Power of the Many Masterclasses - 2nd draft .pptx
Power of the Many Masterclasses - 2nd draft .pptx
AlexBausch2
Glow Up Your Desk: The MOOJAY Monitor Stand Experience
Glow Up Your Desk: The MOOJAY Monitor Stand Experience
Topmate
What Drives Collectors in Sports and Beyond, and How Mantel is Bringing Them ...
What Drives Collectors in Sports and Beyond, and How Mantel is Bringing Them ...
Neil Horowitz
Integrating Customer Journey Insights into Your Business Process Management S...
Integrating Customer Journey Insights into Your Business Process Management S...
RUPAL AGARWAL
Salary_Wage_Computation_3Day_Lesson.pptx
Salary_Wage_Computation_3Day_Lesson.pptx
DaryllWhere
IEA_Press_Release_Tullow_Agreement-16-6-2025-1.pdf
IEA_Press_Release_Tullow_Agreement-16-6-2025-1.pdf
businessweekghana
Integration of Information Security Governance and Corporate Governance
Integration of Information Security Governance and Corporate Governance
Tokyo Security Community
Noah Loul Shares 5 Key Impacts of AI Agents on the Sales Industry
Noah Loul Shares 5 Key Impacts of AI Agents on the Sales Industry
Noah Loul
Marketing Assignment presentation of good marketing techniques how to impleme...
Marketing Assignment presentation of good marketing techniques how to impleme...
Priya Raj
placement-brochure Great lakes Gurgaon. 2025
placement-brochure Great lakes Gurgaon. 2025
charankumarboom
The Future State Of Work - Actionable Summary for Startup Founders
The Future State Of Work - Actionable Summary for Startup Founders
vikram sood
PTJ Contracted Manufacturer's Repsentative V.1.pdf
PTJ Contracted Manufacturer's Repsentative V.1.pdf
victoryuipworks
Vaden Consultancy: Transforming Businesses with Integrated HR, IT, and Cloud ...
Vaden Consultancy: Transforming Businesses with Integrated HR, IT, and Cloud ...
Vaden Consultancy
5 Smart Ways to Build a Highly Productive Team
5 Smart Ways to Build a Highly Productive Team
RUPAL AGARWAL
Improving Sales Forecasting in Volatile B2B Capital Equipment Markets - Dave ...
Improving Sales Forecasting in Volatile B2B Capital Equipment Markets - Dave ...
Dave Litwiller
Power of the Many: Digital Energy Masterclass
Power of the Many: Digital Energy Masterclass
mariana491193
The APCO Geopolitical Radar Q3 2025 Edition
The APCO Geopolitical Radar Q3 2025 Edition
APCO
MOOJAY Wireless Keyboard & Mouse Ergonomic Combo – Comfort, Silence, and Styl...
MOOJAY Wireless Keyboard & Mouse Ergonomic Combo – Comfort, Silence, and Styl...
Topmate
S4F03 Col11 Conversion of Accounting to SAP S/4HANA
S4F03 Col11 Conversion of Accounting to SAP S/4HANA
Libreria ERP
Tesia Dobrydnia - A Leader In Her Industry
Tesia Dobrydnia - A Leader In Her Industry
Tesia Dobrydnia
Power of the Many Masterclasses - 2nd draft .pptx
Power of the Many Masterclasses - 2nd draft .pptx
AlexBausch2
Glow Up Your Desk: The MOOJAY Monitor Stand Experience
Glow Up Your Desk: The MOOJAY Monitor Stand Experience
Topmate
What Drives Collectors in Sports and Beyond, and How Mantel is Bringing Them ...
What Drives Collectors in Sports and Beyond, and How Mantel is Bringing Them ...
Neil Horowitz
Integrating Customer Journey Insights into Your Business Process Management S...
Integrating Customer Journey Insights into Your Business Process Management S...
RUPAL AGARWAL
Salary_Wage_Computation_3Day_Lesson.pptx
Salary_Wage_Computation_3Day_Lesson.pptx
DaryllWhere
IEA_Press_Release_Tullow_Agreement-16-6-2025-1.pdf
IEA_Press_Release_Tullow_Agreement-16-6-2025-1.pdf
businessweekghana
Integration of Information Security Governance and Corporate Governance
Integration of Information Security Governance and Corporate Governance
Tokyo Security Community
Noah Loul Shares 5 Key Impacts of AI Agents on the Sales Industry
Noah Loul Shares 5 Key Impacts of AI Agents on the Sales Industry
Noah Loul
Marketing Assignment presentation of good marketing techniques how to impleme...
Marketing Assignment presentation of good marketing techniques how to impleme...
Priya Raj
placement-brochure Great lakes Gurgaon. 2025
placement-brochure Great lakes Gurgaon. 2025
charankumarboom
The Future State Of Work - Actionable Summary for Startup Founders
The Future State Of Work - Actionable Summary for Startup Founders
vikram sood
PTJ Contracted Manufacturer's Repsentative V.1.pdf
PTJ Contracted Manufacturer's Repsentative V.1.pdf
victoryuipworks
Vaden Consultancy: Transforming Businesses with Integrated HR, IT, and Cloud ...
Vaden Consultancy: Transforming Businesses with Integrated HR, IT, and Cloud ...
Vaden Consultancy
5 Smart Ways to Build a Highly Productive Team
5 Smart Ways to Build a Highly Productive Team
RUPAL AGARWAL
Improving Sales Forecasting in Volatile B2B Capital Equipment Markets - Dave ...
Improving Sales Forecasting in Volatile B2B Capital Equipment Markets - Dave ...
Dave Litwiller
Power of the Many: Digital Energy Masterclass
Power of the Many: Digital Energy Masterclass
mariana491193
The APCO Geopolitical Radar Q3 2025 Edition
The APCO Geopolitical Radar Q3 2025 Edition
APCO
MOOJAY Wireless Keyboard & Mouse Ergonomic Combo – Comfort, Silence, and Styl...
MOOJAY Wireless Keyboard & Mouse Ergonomic Combo – Comfort, Silence, and Styl...
Topmate
Ad

Vxl ch 4 – tk he vxl cac td minh hoa

  • 1. Ch 4 – TK hệ VXL Các thí dụ minh họa
  • 3. Blink01.asm (1/2) xtal equ 12 ; Crystal frequency in MHz Patternequ 0FEh org 0 mov P0,#00000011b ; Dat cau hinh P0.1 va P0.0 la Input mov P3,#10000000b ; Dat cau hinh P3.7 la Input mov P1,#Pattern back: ; copy port0 switch B1,S1 states to acc mov a,P0 anl a,#00000011b ; P0.1 and P0.0 are selected orl a,#10000000b ; prepare P3.7 for input ; Sao chep bit P3.7 vao bit P3.2 mov C, p3.7 mov acc.2, C mov P3,a
  • 4. Blink01.asm (2/2) mov A, P1 jb P0.1, RoR ; Xoay trai P1 RL A sjmp Next RoR: ; Xoay phai P1 RR A Next: mov P1, A ; delay for 25ms delay mov A,#250 acall dly100u sjmp back dly100u: ; delay loop takes ; mov r1,A dlylp1: mov r0,#(xtal*62/10) dlylp2: djnz r0,dlylp2 djnz r1,dlylp1 ret end
  • 5. Boole_Up BCD counter_7seg LED XTAL2 18 XTAL1 19 ALE 30 EA 31 PSEN 29 RST 9 P0.0/AD0 39 P0.1/AD1 38 P0.2/AD2 37 P0.3/AD3 36 P0.4/AD4 35 P0.5/AD5 34 P0.6/AD6 33 P0.7/AD7 32 P2.7/A15 28 P2.0/A8 21 P2.1/A9 22 P2.2/A10 23 P2.3/A11 24 P2.4/A12 25 P2.5/A13 26 P2.6/A14 27 P1.0 1 P1.1 2 P1.2 3 P1.3 4 P1.4 5 P1.5 6 P1.6 7 P1.7 8 P3.0/RXD 10 P3.1/TXD 11 P3.2/INT0 12 P3.3/INT1 13 P3.4/T0 14 P3.7/RD 17 P3.6/WR 16 P3.5/T1 15 U1 80C51 X1 16MHzCX1 33p CX2 33p CRST 10n RRST 10k R1 270R R2 270R R3 270R R4 270R R5 270R R6 270R R7 270R
  • 6. ;TD: boole04.asm ; Minh hoa cac lenh nhay theo tri bien Boole: JC, JNC, JB, JNB, JBC ; Mo phong mach dem 10: ngo ra nhi phan o 4 bit thap P2, duoc noi voi mach hien thi so ; xung nhip CK (kich canh xuong) duoc noi chan P3.7 CK EQU P3.7 MOV P3,#80H ; Dat cau hinh P3.7 INPUT MOV R0,#0 ; So dem ban dau la 0 MOV P0,#0C0H; Dau tien so dem la 0 LOOP: JNB CK,$ ; Doi CK o muc 1 JB CK,$ ; Doi CK o muc 0 ==> phat hien duoc canh xuong INC R0 CJNE R0,#10,NEXT MOV R0,#0 NEXT: MOV A,R0 ACALL BCD2LED SJMP LOOP BCD2LED: MOV DPTR,#LED_DATA MOVC A,@A+DPTR MOV P0,A RET LED_DATA: DB 0C0H, 0F9H, 0A4H, 0B0H, 99H, 92H, 82H, 0F8H, 80H, 90H RET
  • 7. Boole_Up BCD counter_7seg LED Using Timer 0 XTAL2 18 XTAL1 19 ALE 30 EA 31 PSEN 29 RST 9 P0.0/AD0 39 P0.1/AD1 38 P0.2/AD2 37 P0.3/AD3 36 P0.4/AD4 35 P0.5/AD5 34 P0.6/AD6 33 P0.7/AD7 32 P2.7/A15 28 P2.0/A8 21 P2.1/A9 22 P2.2/A10 23 P2.3/A11 24 P2.4/A12 25 P2.5/A13 26 P2.6/A14 27 P1.0 1 P1.1 2 P1.2 3 P1.3 4 P1.4 5 P1.5 6 P1.6 7 P1.7 8 P3.0/RXD 10 P3.1/TXD 11 P3.2/INT0 12 P3.3/INT1 13 P3.4/T0 14 P3.7/RD 17 P3.6/WR 16 P3.5/T1 15 U1 80C51 X1 12MHzCX1 33p CX2 33p CRST 10n RRST 10k R1 270R R2 270R R3 270R R4 270R R5 270R R6 270R R7 270R
  • 8. ;TD: counter01.asm ; Minh hoa su dung chuc nang counter cua 8051 ; Su dung T0 che do 2 lam counter voi CLK la chan P3.4 (T0) ; counter nay co modulo 10, nghia là dem het 9 thi tran COUNT EQU -10 SETB P3.4 ; dat cau hinh input cho P3.4 MOV TMOD,#6 ; Timer 0: counter mode 2 MOV TH0, #COUNT MOV TL0, #COUNT SETB TR0 LOOP: MOV A,TL0 ADD A,#-COUNT CALL BCD2LED MOV P0,A SJMP LOOP BCD2LED: MOV DPTR,#LED_DATA MOVC A,@A+DPTR MOV P0,A RET LED_DATA: DB 0C0H, 0F9H, 0A4H, 0B0H, 99H, 92H, 82H, 0F8H, 80H, 90H RET END