julianjesuthasan
Newbie level 4
Problem:Timer1 PIC16f887 (ASSEMBLY)
Hi guys im using Timer1 to create a 0.5s delay to get one of the LEDs to blink however the the LED turns on but does not blink. Any suggestions?
#include <p16F887.inc>
__CONFIG _CONFIG1, _LVP_OFF & _FCMEN_OFF & _IESO_OFF & _BOR_OFF & _CPD_OFF & _CP_OFF & _MCLRE_OFF & _PWRTE_ON & _WDT_OFF & _INTRC_OSC_NOCLKOUT
__CONFIG _CONFIG2, _WRT_OFF & _BOR21V
cblock 0x20
Delay1 ; Define two file registers for the
Delay2 ; delay loop
endc
org 0
Start:
bsf STATUS,RP0 ; select Register Bank 1
bcf TRISD,0 ; make IO D PORT an output
MOVLW b'11110101'
bsf PIE1,TMR1IE
bsf INTCON,PEIE
bsf INTCON,GIE
bcf STATUS,RP0 ; back to Register Bank 0
MainLoop:
bsf PORTD,0 ; turn on LED RD0
Onloop:
btfss PIR1,TMR1IF ; wait here until Timer1 rolls over
goto Onloop
bcf PIR1,TMR1IF ;CLEAR FLAG
clrf TMR1H
clrf TMR1L
bcf PORTD,0
Offloop
btfss PIR1,TMR1IF ; wait here until Timer1 rolls over
goto Offloop
bcf PIR1,TMR1IF ;CLEARFLAG
clrf TMR1H
clrf TMR1L
goto MainLoop
end
Hi guys im using Timer1 to create a 0.5s delay to get one of the LEDs to blink however the the LED turns on but does not blink. Any suggestions?
#include <p16F887.inc>
__CONFIG _CONFIG1, _LVP_OFF & _FCMEN_OFF & _IESO_OFF & _BOR_OFF & _CPD_OFF & _CP_OFF & _MCLRE_OFF & _PWRTE_ON & _WDT_OFF & _INTRC_OSC_NOCLKOUT
__CONFIG _CONFIG2, _WRT_OFF & _BOR21V
cblock 0x20
Delay1 ; Define two file registers for the
Delay2 ; delay loop
endc
org 0
Start:
bsf STATUS,RP0 ; select Register Bank 1
bcf TRISD,0 ; make IO D PORT an output
MOVLW b'11110101'
bsf PIE1,TMR1IE
bsf INTCON,PEIE
bsf INTCON,GIE
bcf STATUS,RP0 ; back to Register Bank 0
MainLoop:
bsf PORTD,0 ; turn on LED RD0
Onloop:
btfss PIR1,TMR1IF ; wait here until Timer1 rolls over
goto Onloop
bcf PIR1,TMR1IF ;CLEAR FLAG
clrf TMR1H
clrf TMR1L
bcf PORTD,0
Offloop
btfss PIR1,TMR1IF ; wait here until Timer1 rolls over
goto Offloop
bcf PIR1,TMR1IF ;CLEARFLAG
clrf TMR1H
clrf TMR1L
goto MainLoop
end