ex 38514e
DESCRIPTION
gghTRANSCRIPT
![Page 1: Ex 38514e](https://reader036.vdocuments.net/reader036/viewer/2022082822/5695cfdb1a28ab9b028fd215/html5/thumbnails/1.jpg)
EEE 447 MICROPROCESSOR LABORATORY
EXPERIMENTAL WORK 3
PIC I/O PORT PROGRAMMING
Objective: In this experiment, I/O Port programming of PIC18F25K22 is represented.Setting the ports of PIC18F25K22 as input and output is emphasized.
Ex.1: Write the following Assembly Language Program, compile and download the resulted “HEX” file to PIC18F25K22. Observe PORTB, PORTC and PORTD individually.
LIST P=18f45k22INCLUDE "P18f45k22.INC"
MYREG EQU 0X09R1 EQU 0X07R2 EQU 0X08
ORG 0 ; Starting pointMOVLW 0X00MOVWF TRISB ;PORTB is outputMOVWF TRISC ;PORTC is outputMOVWF TRISD ;PORTD is output
L1 MOVLW 0X55MOVWF PORTB ;PORTB =0x55CALL DELAYMOVLW 0X50MOVWF PORTC ;PORTC =0x50CALL DELAYMOVLW 0X45MOVWF PORTD ;PORTD =0x45
; Delay Routine, 0.25s DelayORG 200H ; Starting point
of delay routineDELAY MOVLW D'200'
MOVWF R1D1 MOVLW D'250'
MOVWF R2D2 NOP
NOPDECF R2,FBNZ D2DECF R1,FBNZ D1RETURNEND
Ex.2: Write the following Assembly Language Program, compile and download the resulted “HEX” file to PIC18F25K22. Observe PORTB, PORTC and PORTD pins individually.
LIST P=18f45k22INCLUDE "P18f45k22.INC"R1 EQU 0X07R2 EQU 0X08
ORG 0 ; Starting pointCLRF TRISB ;PORTB is outputCLRF TRISC ;PORTC is outputCLRF TRISD ;PORTD is output
BSF PORTB,0CALL DELAYBSF PORTC,1CALL DELAYBSF PORTD,2CALL DELAYBSF PORTB,3CALL DELAYBSF PORTC,4CALL DELAY
BSF PORTD,5GOTO FINISH
; Delay Routine, 0.25s DelayORG 200H ; Starting point
of delay routineDELAY MOVLW D'200'
MOVWF R1D1 MOVLW D'250'
MOVWF R2D2 NOP
NOPDECF R2,FBNZ D2DECF R1,FBNZ D1RETURN
FINISH NOPEND
![Page 2: Ex 38514e](https://reader036.vdocuments.net/reader036/viewer/2022082822/5695cfdb1a28ab9b028fd215/html5/thumbnails/2.jpg)
Ex.3: Repeat the procedures in the previous Assembly Language program for the following one. The program:
Checks the state of RC3 pin
If it is 0, does nothing
If it is 1, sends 63H to PORTB and sets RD3 0.25s later.
LIST P=18f45k22INCLUDE "P18f45k22.INC"R1 EQU 0X07R2 EQU 0X08
BSF TRISC,3 ;RC3 is inputCLRF TRISB ;PORTB is outputBCF TRISD,4 ;RD4 is output
MOVLW 0X63REPEAT BTFSS PORTC,3
BRA REPEATCALL DELAYMOVWF PORTBBSF PORTD,3GOTO FINISH
; Delay RoutineDELAY MOVLW D'200'
MOVWF R1D1 MOVLW D'250'
MOVWF R2D2 NOP
NOPDECF R2,FBNZ D2DECF R1,FBNZ D1RETURN
FINISH NOPEND