PA3040
Advanced Member level 3
- Joined
- Aug 1, 2011
- Messages
- 883
- Helped
- 43
- Reputation
- 88
- Reaction score
- 43
- Trophy points
- 1,308
- Activity points
- 6,936
Dear All,
Today I am working with TIMR0 of PIC 16f877a
I configured TIMER0 to increment from external clock (T0CKI) and assigned Pres caller to TMR0 Rate . I check both my hardware and PIC IDE SIMULATOR
Prescaler set to 1 : 8
I incremented T0CKI in the PIC IDE SIMULATOR. in the first time after four times switch press, the TMR0 incremented. (wrong increment ) from second steps onwards TIMER0 incremented every eight switch press ( Correct increment) what is the reason in the first time it was incremented by four times switch press
Please advice
Today I am working with TIMR0 of PIC 16f877a
I configured TIMER0 to increment from external clock (T0CKI) and assigned Pres caller to TMR0 Rate . I check both my hardware and PIC IDE SIMULATOR
Prescaler set to 1 : 8
I incremented T0CKI in the PIC IDE SIMULATOR. in the first time after four times switch press, the TMR0 incremented. (wrong increment ) from second steps onwards TIMER0 incremented every eight switch press ( Correct increment) what is the reason in the first time it was incremented by four times switch press
Please advice
Code:
#include <p16f877a.inc>
__config 3f39
org 0x000
Start goto main
org 0x004
goto isr
main call sys_init
call led
led movf TMR0,W
movwf PORTC
goto led
isr btfss INTCON,TMR0IF ;Clear TMR0 Overflow Interrupt Flag bit
retfie
bcf INTCON,TMR0IF ;Clear TMR0 Overflow Interrupt Flag bit
clrf PORTC
rlf PORTD,F
retfie
sys_init clrf PORTC
clrf PORTD
banksel TRISC
clrf TRISC
clrf TRISD
movlw b'00100010'
movwf OPTION_REG
banksel PORTC
movf TMR0,w
clrf TMR0
bsf PORTD,0
bcf INTCON,TMR0IF ;Clear TMR0 Overflow Interrupt Flag bit
bsf INTCON,TMR0IE ;Enables the TMR0 interrupt
bsf INTCON,GIE ;Global Interrupt Enable bit
return
end
Last edited: