Am I correct that this can be used to cancel a GOSUB? Thank you.
start:
gosub blink
do more stuff here
blink:
if porta.1 = 1 then sound
high porta.0
pause 50
low porta.0
return
sound:
@ POP
make sound on a pin
goto start
Am I correct that this can be used to cancel a GOSUB? Thank you.
start:
gosub blink
do more stuff here
blink:
if porta.1 = 1 then sound
high porta.0
pause 50
low porta.0
return
sound:
@ POP
make sound on a pin
goto start
I believe this is correct. I ran into this problem when I switched from a 16F877 to the 18F452. Took a little bit to track it down. The 16F masked my bad coding practice quite well, lol.
Peter, yes I would say that is correct (or at least one way to do it). I suppose there are no hard and fast rules per se, but any Programming 101 professor would surely beat us with a stick for exiting a GOSUB with a GOTO rather than RETURN with a flag set or some other method.
CCK, Same here, I spent MANY hours headscratching over that one. Until I discovered that the processor always reset after exactly the same number of calls to a certain subroutine. Lots of time spent reading the datasheets/forums too. All resulting from poor (untrained) programming practices/bad habits. But learned a LOT in the process. 18F definitely has a few "gotchas" when migrating.
Thank you for the fast replies guys. Are you also saying that if you don't cancel a gosub with a return on the 16F parts, it doesn't matter? I am not in the habit of doing this but, as a quick fix to a program, it would be handy to know. I was told it will eventually cause a stack overflow on any PIC. Thank you. - Peter
You could test to disable the Stack reset in the configuration bits, that should prevent the MCU from doing a reset when doing a stack under- or overflow. Simple and easy but be aware that a return later in the code can make stange things. Page 253 in the manual if you want to look CONFIG4L register.
Power supply: 3.6V current peaks of up to 2° and a maxximum voltage drop of 300mV durino transmission burst. Local power source feeds the Q2501 module and the PIC 18f2620.
Connection MCLRE pin – Diode –R 11Kohm – Vcc. I use one breadboard.
Hour we come to the good news: inserted condenser from 0,1 uf. They are some hours that software turn without restart. The strange characters between the PIC and the PC are passings also. Thanks. Perhaps resolved problem
Bookmarks