I believe the "BTFSS INTCON, T0IF " should monitor the Timer 0 Interrupt bit and SKIP the next instruction (Goto Pt2) and perform the "Goto BitClk" command as long as Timer 0 has not overflowed.
If Timer0 overflows then "BTFSS INTCON, T0IF " should equal1 and the "Goto Pt2" command should be performed.
I'm feeding a frequency into the RA4/T0CKI pin but the Lcnt never increments. I've tried frequencies between 10 Hz and 10 MHz but Lcnt always equals 1. I've even grounded this pin.
Anyone know why this happens?
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
I think what is happening there is that once the timer overflows, the T0IF bit goes high and stays high. This will mean that the PIC sits in an infinite loop, doing nothing other than incrementing Lcnt. This means that once the timer overflows, the PIC will never escape the loop and get to the Print statement. Try putting in a Set (or bcf) command to clear T0IF before the Goto BitClk command.
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
I'm using a 16F627 and wrote this code:
BitClk:
Lcnt = Lcnt + 1
BTFSS INTCON, T0IF ;Check if T0IF=1
Goto Pt2
Goto BitClk
Pt2:
Print Lcnt
I believe the "BTFSS INTCON, T0IF " should monitor the Timer 0 Interrupt bit and SKIP the next instruction (Goto Pt2) and perform the "Goto BitClk" command as long as Timer 0 has not overflowed.
If Timer0 overflows then "BTFSS INTCON, T0IF " should equal1 and the "Goto Pt2" command should be performed.
I'm feeding a frequency into the RA4/T0CKI pin but the Lcnt never increments. I've tried frequencies between 10 Hz and 10 MHz but Lcnt always equals 1. I've even grounded this pin.
Anyone know why this happens?
I think what is happening there is that once the timer overflows, the T0IF bit goes high and stays high. This will mean that the PIC sits in an infinite loop, doing nothing other than incrementing Lcnt. This means that once the timer overflows, the PIC will never escape the loop and get to the Print statement. Try putting in a Set (or bcf) command to clear T0IF before the Goto BitClk command.
Thanks for your response.
The PIC is escaping the loop. It does generate the Print statement but it always gives a value of 1 for Lcnt.
Shouldn't it be "BTFSC INTCON, T0IF " so that it skips the goto Pt2 while T0IF is clear then when its set it executes the goto Pt2.
Alternatively you could replace the bit of assembly with a basic control structure like -
Thanks! Your BTFSC instead of BTFSS comment makes sense.