chand-o
Newbie level 1
Hi, this is my first post so Hello all :grin:.
Ihave been working on an assignment to implement the timer0 function to be used as a delay subroutine rather than looping the program. I appear to be going around in circles! When I animate the program it continuously loops between the BTFSS INTCON,T0IF and GOTO Timerdel. From the view watch panel (MPLAB IDE) i can see the OPTION_REG never changes from 0xFF. Also when ever i write to the WREG and move it to somewhere else eg. PORTB the associate register stays s 0x00. I tried using the MOVF command instead of the MOVWF but the results were the same.
The pic is a 16F84. If someone an point my in the right direction that would be very helpful.
Ihave been working on an assignment to implement the timer0 function to be used as a delay subroutine rather than looping the program. I appear to be going around in circles! When I animate the program it continuously loops between the BTFSS INTCON,T0IF and GOTO Timerdel. From the view watch panel (MPLAB IDE) i can see the OPTION_REG never changes from 0xFF. Also when ever i write to the WREG and move it to somewhere else eg. PORTB the associate register stays s 0x00. I tried using the MOVF command instead of the MOVWF but the results were the same.
The pic is a 16F84. If someone an point my in the right direction that would be very helpful.
Code:
DELAY:
MOVLW 0X07 ; use 0000 0111 for timer0 prescaler
MOVWF OPTION_REG ; set prescaler to max 256
CLRF TMR0 ; clear timer register
Timerdel BTFSS INTCON,T0IF ; check timer flag, skip next instuction is set
GOTO Timerdel ; loops until timer flag is set T0IF
BCF INTCON,T0IF ; clear timer flag ready for next delay subroutine
RETURN ; will return to main program (line after the Delay was called from)
END ; end of program