Ramius
I don't see a "Return" at the end of the subroutines.
Norm
Ramius
I don't see a "Return" at the end of the subroutines.
Norm
norm, i agree, no return for the gosubs...
Hi Guys!
Thanks and to be honest I am not sure where a "return" or "returns" would or should go!Everything seems to run normally except for the program stopping and waiting for the "FromSensor" to go low so it can continue. The "FromSensor" does toggle from high to low to high to low consistently and the program runs completely for 3 minutes and then for some unknown reason at the D2 section "Wend" stops as "FromSensor" does not appear to go low!? Ed
Ramius
A GoSub is a routine which can be reused and should include a "Return" at its end which takes the code point back to the GoSub where it was originally called.
Norm
You could try changing this gosub to a goto ReadSensor.if calFlag = 0 then
goto CalSensor
else
gosub ReadSensor
endif
Hi,
Without looking at the PIC's datasheet I think that the problem might be with the following line
ADCON1 = 255 ' Make everything digital (no analog)
Don't you need to define PORTA.0 as analog?
Robert
"No one is completely worthless. They can always serve as a bad example."
Anonymous
Hi,
Just a thought and question:
Are you sure that it is the PIC that stops? I've never used the MCS Debugger but is it possible that IT is either stopping itself (so that you THINK the program has stopped) or perhaps IT is actually stopping the PIC? Have you tried running it without the ICD?
And, what others have said: ALL subroutines to which you jump with a GOSUB must, at some point, end with a RETURN or bad things will happen. I haven't looked that close at your code but perhaps you've just been "lucky" that it works and that after three minutes there's been exactly the amount of GOSUBS without RETURN to make the stack tip over. I don't know, just thinking out loud.
/Henrik.
Bookmarks