Suppose we are using an external oscilaltor at 8 MHz and needed a voltage high for approximately 1 second at pin RA0. One instruction cycle takes 0.5 \$\mu s\$. I made a subroutine that takes 25 ms, with the prescaler set to \$\frac{1}{256}\$.
delay
clrf TMR0
L0
movf TMR0,w
xorlw d'195'
btfss STATUS, Z
goto L0
return
This subroutine( accounting for the call and return instructions that use up two cycles each) takes up 49924 cycles.
So, to create a one second delay, all I need to do is to call this routine 40 times.
counter equ 0x21
movlw d'40'
movwf counter
bsf LATA, 0
bcf BSR, BSR1
L1
call delay
decfsz counter
goto L1
bsf BSR, BSR1
bcf LATA, 0
However, in MPLAB's logic analyzer I get some strange results, the RA0 pin doesn't even go to HIGH! I am self teaching on this subject, and if you know any good online articles on this subject I would be very happy to read them. Also how can we do this using the INTCON register?
HERE is the datasheet of the pic I am using. The OPTION_ REG is on page 187, and the INTCON regsister is at page 90.