0% found this document useful (0 votes)
17 views2 pages

Listing Program Mdul 3

The document discusses three programming examples using a microcontroller: 1. I/O using Port 1 for output and input, setting and clearing various port pins. 2. Using an external interrupt on INT0 along with interrupt enables to trigger an interrupt service routine when the pin is pressed. 3. Using Timer/Counter 0 in timer mode 0/1 to increment a register value in a timer ISR and turn on an output pin periodically. Initialization of registers and ports is also described for each example.

Uploaded by

Kipeh Angin
Copyright
© Attribution Non-Commercial (BY-NC)
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
17 views2 pages

Listing Program Mdul 3

The document discusses three programming examples using a microcontroller: 1. I/O using Port 1 for output and input, setting and clearing various port pins. 2. Using an external interrupt on INT0 along with interrupt enables to trigger an interrupt service routine when the pin is pressed. 3. Using Timer/Counter 0 in timer mode 0/1 to increment a register value in a timer ISR and turn on an output pin periodically. Initialization of registers and ports is also described for each example.

Uploaded by

Kipeh Angin
Copyright
© Attribution Non-Commercial (BY-NC)
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
You are on page 1/ 2

Listing Program 1. I/O dengan Port 1 a.

Port 1 sebagai Output


$mod51 CSEG ORG 4000H LJMP START ORG 4100H START: MOV SP,#30H CLR P1.0 CLR P1.1 SETB P1.2 CLR P1.3 SETB P1.4 SETB P1.5 SETB P1.6 SETB P1.7 SJMP $ END

b. Port 1 sebagai Input


$mod51 CSEG ORG 4000H LJMP START ORG 4100H START: MOV SP, #30H INIT: MOV DPTR, #2003H MOV A, #80H MOVX @DPTR, A MOV A, P1 MOV DPTR, #2002H MOVX @DPTR, A SJMP LABEL1 END

LABEL1: DISPLAY:

2. Interrupt Penggunaan INT0 dengan interrupt Enable


$mod51 CSEG ORG 4000H LJMP START ORG 4003H

RL A MOV P1, A MOV R5, #0FFH DJNZ R5, $ RETI ORG 4200H ;INISIALISASI START: MOV SP, #30H MOV TCON, #01H MOV A, #01H MOV P1, #01H MOV IE, #81H SJMP $ END

;DELAY

3. Timer/Counter Penggunaan Timer/Counter 0 sebagai Timer mode 0/1


$mod51 Cseg org LJMP ORG COUNT: CJNE SETB MOV LUP:

4000h START 400BH INC R0 R0,#10H, OUT1 P1.5 R7, #0FFH

MOV R6,#0FFh DJNZ R6,$ DJNZ R7,LUP MOV R7,#0FFH DJNZ R7, $ MOV R4,#0FFh DJNZ R4,$ CLR P1.5 MOV R0,#00H OUT1: MOV TH0,#0FFH MOV TL0,#00H RETI ORG 4200H

;INISIALISASI START: MOV SP,#30H MOV R0,#00H MOV TMOD,#01H MOV TH0,#0FFH MOV TL0,#00H MOV TCON,#10H MOV P1,#00H MOV IE,#82H SJMP $ END

You might also like