SET T_1 ON
GOSUB Chk_Rec
‘******************************************
Sub Chk_Rec
A_Cnt = 0
Loop1:
A_Cnt = A_Cnt + 1
If Rec_1 = 1 then
SET T_1 OFF
locate 1, 15
print A_Cnt
Goto Loop2
End If
Goto Loop1
Loop2:
End Sub
When I run this code, I get an A_Cnt of 1 meaning the IF statement immediately "saw" PORTA.0 (T_1) as a high.
When I connect an oscilloscope to PORTB.3 (T_1), I measure a pulse width of 1.4 milliseconds meaning it took 1.4 milliseconds for the PIC to go from the main program to the sub-routine.
1.4 milliseconds seems like a very long time for the PIC to perform this simple operation.
Am I doing something wrong?
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
Hi,
to call sub Chk_rec , you just type "Chk_rec" , not "gosub Chk_rec"
If you want use "gosub" then Ch_rec is a label you must type like that "Chk_rec:"
and it ends with the "return" keyword
Regards
GC
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
I have the following code that is part of a larger program:
;Chip Settings
#chip 16F876,20
#config LVP=OFF, PWRTE=ON, OSC=HS
#define T_1 PORTB.3
#define Rec_1 PORTA.0
;Variables
Dim A_Cnt As word
Dir T_1 OUT
Dir Rec_1 IN
SET T_1 ON
GOSUB Chk_Rec
‘******************************************
Sub Chk_Rec
A_Cnt = 0
Loop1:
A_Cnt = A_Cnt + 1
If Rec_1 = 1 then
SET T_1 OFF
locate 1, 15
print A_Cnt
Goto Loop2
End If
Goto Loop1
Loop2:
End Sub
When I run this code, I get an A_Cnt of 1 meaning the IF statement immediately "saw" PORTA.0 (T_1) as a high.
When I connect an oscilloscope to PORTB.3 (T_1), I measure a pulse width of 1.4 milliseconds meaning it took 1.4 milliseconds for the PIC to go from the main program to the sub-routine.
1.4 milliseconds seems like a very long time for the PIC to perform this simple operation.
Am I doing something wrong?
Hi,
to call sub Chk_rec , you just type "Chk_rec" , not "gosub Chk_rec"
If you want use "gosub" then Ch_rec is a label you must type like that "Chk_rec:"
and it ends with the "return" keyword
Regards
GC
I finally got to try your suggestion and it worked!
Thanks for your help