You are on page 1of 2

Q. toggle led of port A using TMR0 to provide 1ms delay.

Org

00h

Goto Main
Org

04h

Goto ISR
ISR:

//interrupt service routine


Movwfw_temp

//store w in temporary_reg

Movf status
Movwfstatus_temp
temporary_temp

//store status in

Movf pclath
Movwfpclath_temp
temporary_temp
Bcf

intcon,TMR0IF

//store pclath in
//clear TMR0IF flag

Comf portA

//complement of portA

Movf pclath_temp

//store pclath

Movwfpclath
Movf status_temp

//store status

Movwfstatus
Movf w_temp

//store W

Bcf

status,rp1

//select bank0

Bcf

status,rp0

Movlw 06h

//initialize TMR0=06h

MovwfTMR0
Bsf
Retfie
Main:

intcon,GIE

//enable GIE
//return from interrupt
//main program start

Bcf

status,rp1

Bcf

status,rp0

Clrf

portA

//select bank0

//clear portA

Movlw 06h
Movwftmr0

//TMR0=06h

Bcf

status,rp1

//select bank1

Bsf

status,rp0

Clrf

trisA

//clear trisA

Movlw 41h

//set timer0 prescalar 1:4,psa assigned

to TMR0
Movwfoption
Movlw A0h

//enable T0IE,GIE

Movwfintcon
Bcf

status,rp1

Bcf

status,rp0

//select bank0

Movlw 00h
MovwfportA
Mloop:
end

goto

//set portA=00h
mloop

//loop

You might also like