program to blink LED’s connected to a PORT of PIC18
Write a program
to blink LED’s connected to a PORT of PIC18, also simulate it on Mplab-IDE
simulator & “Proteous”.
#include
LIST P=18F452, F=INHX32, MM=OFF
CONFIG OSC=XT
CONFIG WDT=OFF
MAIN:
COUNT1 EQU D'254'
COUNT2 EQU D'255'
R1 EQU 0x10
R2 EQU 0x30
R3 EQU 0x40
SAVE EQU 0x50
C1 EQU D'100'
C2 EQU D'1000'
C3 EQU D'10'
ORG 00H
ORG 20H
BSF TRISC,2
CLRF TRISB
CLRF PORTB
MOVLW 0
AGAIN1
BSF TRISC,2
BTFSS PORTC,2
GOTO AGAIN1
BCF TRISC,2
BCF PORTC,2
INCF WREG,W
CALL DELAY
MOVWF PORTB
DECF COUNT2 ,F
BNZ AGAIN1
MOVLW 0
MOVWF PORTB
CLRF PORTC
GOTO AGAIN1
ORG 0x2000
DELAY
MOVWF SAVE
MOVLW C3
MOVWF R3
L3 MOVLW C2
MOVWF R2
L2 MOVLW C1
MOVWF R1
L1 DECF R1,F
BNZ L1
DECF R2,F
BNZ L2
DECF R3,F
BNZ L3
MOVF SAVE,WREG
RETURN
END
0 comments:
Confused? Feel Free To Ask
Your feedback is always appreciated. We will try to reply to your queries as soon as time allows.