1 Attachment(s)
Strange happenings PBP and 12F683
I'm hollering "Uncle!" on this right now.
Attached are two segments from a larger program that, as of right now, works perfectly. It records keypresses (TRIGR) at 8 frames per second and plays them back. This is running on a 12F683 and uses Darrel's interrupts for timing.
What I've been trying is to add (somewhere) a test: If the key is stuck or still held down, I want further execution to stop until the key is released.
And that's where the trouble begins. Sounds silly, simple, and should be straightforward, right? But I've tried an amazing number of combinations of IF . . . ENDIF, WHILE . . . WEND, GOTOs, and GOSUBs. Nothing works quite right. Obviously, I'm not seeing something.
The most common result is that the test "sticks" on odd-numbered attempts and won't release back to the program when the key is released until the key is pressed again. (I've even used ALED as a blinky/status indicator.)
Did I fry one too many brain cells back in the 1960s?
You do not dream ... halas.
Hi, Russ
I remember having had similar issues some years ago whith a 16F628 ...
IF THEN tests didn't work at all ... whether the condition result.
Was for a R/C failsafe sequence ... rather annoying, indeed.
I just got out of that by re-organizing my subs ( that were called by goto's ...) a bit more "rationnaly" ...
May be posts are not fallen into Archives yet ... ( I'll dig somewhat ... )
Alain
PS: Got it ... but hurry up !!! I Won't be able to post a lot until it passes the limit ... lol
http://www.picbasic.co.uk/forum/showthread.php?t=1952
I think I solved it . . .
Thanks, Jerson and Alain. I'll keep both of those ideas in mind.
What I ended up doing that worked: Inspired by part of what Charles said, I check the condition of the switch in the interrupt handler and set a flag if the switch is closed. Then I check the flag during the MAIN loop. If it and another flag are both set, it kicks to a subroutine.
But nothing yet explains why I couldn't dependably perform simple conditionals on that input in the MAIN loop. It's a mystery.
1 Attachment(s)
Still an occasional problem
I've attached the most recent version.
Once in a while, for no apparent reason, or after a RECORD cycle, when TRIGR is activated (with MFLAG set to 0), the program appears to jump directly to NOTCLR.
How long does the interrupt service in TIMER take? I'm sure it's a matter of microseconds, but how many using DT_INTS-14?
Is it possible that, if TRIGR goes high during the very short time while the interrupt is being serviced, the routine is going to skip going to PLAY and instead will go to NOTCLR?
And, if so, what is the best solution?