If anyone has an idea please guide me on this
I defined three timers TMR0(10 ms), TMR1(0.5 sec) AND TMR2(50 ms) in the main part of the assembly program.
Now in the Interrupt service routine I used the following code
ISR:
movwf W_TEMP ; copy W to TEMP register
swapf STATUS,W ; swap status to be saved into W
movwf STATUS_TEMP ; save status
btfsc INTCON,2 ; TMR0 interrupt (10ms)
goto TMR0_int
btfsc PIR1,0 ; TMR1 interrupt (.5sec)
goto TMR1_int
btfsc PIR1,1 ; TMR2 interrupt (50 ms)
goto TMR2_int
goto ISR_End
ISR_End:
swapf STATUS_TEMP,W ; swap STATUS_TEMP register into W
movwf STATUS ; restore STATUS
swapf W_TEMP,F ; swap W_TEMP
swapf W_TEMP,W ; swap W_TEMP into W
retfie
TMR0_int:
bcf INTCON,2 ; clear TMR0L int flag
movlw b'00100000'
xorwf PORTC
movlw 0xD9
movwf TMR0L
goto ISR_End
TMR1_int:
bcf PIR1,0
goto ISR_End
TMR2_int:
bcf PIR1,1
goto ISR_End
The issue is that PORTC, pin 5 toggles every 10 ms that is I get 50Hz frequency but not all the time
Sometimes the frequency changes to 33 Hz
I want to get a stable frequency all the time from that timer
I couldn't figure out the problem
Thanks
I defined three timers TMR0(10 ms), TMR1(0.5 sec) AND TMR2(50 ms) in the main part of the assembly program.
Now in the Interrupt service routine I used the following code
ISR:
movwf W_TEMP ; copy W to TEMP register
swapf STATUS,W ; swap status to be saved into W
movwf STATUS_TEMP ; save status
btfsc INTCON,2 ; TMR0 interrupt (10ms)
goto TMR0_int
btfsc PIR1,0 ; TMR1 interrupt (.5sec)
goto TMR1_int
btfsc PIR1,1 ; TMR2 interrupt (50 ms)
goto TMR2_int
goto ISR_End
ISR_End:
swapf STATUS_TEMP,W ; swap STATUS_TEMP register into W
movwf STATUS ; restore STATUS
swapf W_TEMP,F ; swap W_TEMP
swapf W_TEMP,W ; swap W_TEMP into W
retfie
TMR0_int:
bcf INTCON,2 ; clear TMR0L int flag
movlw b'00100000'
xorwf PORTC
movlw 0xD9
movwf TMR0L
goto ISR_End
TMR1_int:
bcf PIR1,0
goto ISR_End
TMR2_int:
bcf PIR1,1
goto ISR_End
The issue is that PORTC, pin 5 toggles every 10 ms that is I get 50Hz frequency but not all the time
Sometimes the frequency changes to 33 Hz
I want to get a stable frequency all the time from that timer
I couldn't figure out the problem
Thanks