Ok.. now I have tested with another PIC,a PIC16F887 and then it works, the "bug" is gone.
So why does it hang with a PIC18F2550, PIC184550, and 18F4520?
Does it have something with the config fuses to do? what have I missed?
Ok.. now I have tested with another PIC,a PIC16F887 and then it works, the "bug" is gone.
So why does it hang with a PIC18F2550, PIC184550, and 18F4520?
Does it have something with the config fuses to do? what have I missed?
Hi Fredrick,
In the Check_Buttons subroutine, there's 2 Goto Main statements.
You should use RETURN to exit a subroutine.
Using GOTO will cause the stack to overflow.
With 18F's a stack overflow can cause a Reset.
But with 16F's the stack just wraps around and seems to work, although it's probably not working 100%.
DT
Ohh so simple!
When I notified the problem fist time I was saying to myself that this time I will try to solve the problem without help from anybody, so I have spent a lot off hours on trying to find the problem, but then I give up and started a thread here again.
Thank you Darrel.
But itīs OK to use Gotoīs within the subroutine as long as I call a label that is in the subroutine and only leave the subroutine by doing a Return
Last edited by Fredrick; - 23rd August 2009 at 19:43.
How is it with variables?
If I overflow a byte sized counter it will turn to 0 after passing 255, but is it OK to let a variable overflow? or should I take care of the overflow like this
Code:IF Counter > 254 Then Counter = 0 Endif
Last edited by Fredrick; - 24th August 2009 at 12:15.
For BYTE sized variables, when the value goes over 255 the upper bits are lost, which makes it automatically wrap around to 0.
You don't need to do it manually.
For words, it wraps when over 65535.
<br>
DT
Bookmarks