If you do not believe in MAGIC, Consider how currency has value simply by printing it, and is then traded for real assets.
.
Gold is the money of kings, silver is the money of gentlemen, barter is the money of peasants - but debt is the money of slaves
.
There simply is no "Happy Spam" If you do it you will disappear from this forum.
Joe, thanks for the info!
Okay, related to interrupts, I've run into another problem. I go into my interrupt routine, detect a button on a port change and then tell the program to resume at a new routine based on which button was pressed. The first button works fine, but whenever I press the second button, it seems to ignore/skip the resume (colored below) and go on to the end of the interrupt routine. I added a toggle to an LED to indicate where the program was going. It works before the colored resume statement and after the end if statement, but not immediately after the resume statement. I also tried it at the beginning of the Score_player2 routine, which of course didn't work. I tried a quick search on the forum, but didn't come across anything similar, at least not yet. Any reason PBP would skip or ignore a resume statement? I've just included the interrupt routine - the rest is very similar to the code posted above.
I don't know if this is an indication of another problem, but I'm multiplexing two seven segment digits and whenever I press either button, one of the digits goes out, sometimes digit A and sometimes digit B regardless of the button pressed, and comes back on whenever I release the button.
'************************************************* ************************************************** ***
DISABLE ' do NOT place interrupt checking code below
Halt: ' Halt Routine
temp = PORTB
TOGGLE PORTE.1
IF temp.0 = 0 THEN
WHILE PORTB.0=0 ' wait for button release & end mismatch condition on portb
WEND
PAUSE 20 ' Debounce delay
INTCON.0 = 0 ' Clear the interrupt-on-change flag
RESUME SCORE_PLAYER1
ENDIF
IF temp.1 = 0 THEN
WHILE PORTB.1=0 ' wait for button release & end mismatch condition on portb
WEND
PAUSE 20 ' Debounce delay
INTCON.0 = 0 ' Clear the interrupt-on-change flag
RESUME SCORE_PLAYER2
ENDIF
INTCON.0 = 0 ' Clear the interrupt-on-change flag
RESUME Main ' Go to Main routine
ENABLE ' Enable all active interrupts
'************************************************* ************************************************** ***
Not a good idea to me to use label with RESUME as you never know where the program was before to jump in the ISR. You should jump (goto) at the end if your ISR, then your program will return where he was before.
Steve
It's not a bug, it's a random feature.
There's no problem, only learning opportunities.
Steve,
I'd be lying if I said I completely understood what you meant, but I noticed that I was forcing the program to resume at the start of the Main routine and allowed it to just resume at the end of the ISR. It works! Thank you for your advice. I still have one of the digits going off whenever I press a button, but I'll investigate that further. Likely a hardware issue.
'************************************************* ************************************************** ***
DISABLE ' do NOT place interrupt checking code below
Halt: ' Halt Routine
temp = PORTB
TOGGLE PORTE.1
IF temp.0 = 0 THEN
WHILE PORTB.0=0 ' wait for button release & end mismatch condition on portb
WEND
PAUSE 20 ' Debounce delay
INTCON.0 = 0 ' Clear the interrupt-on-change flag
RESUME SCORE_PLAYER1
ENDIF
IF temp.1 = 0 THEN
WHILE PORTB.1=0 ' wait for button release & end mismatch condition on portb
WEND
PAUSE 20 ' Debounce delay
INTCON.0 = 0 ' Clear the interrupt-on-change flag
RESUME SCORE_PLAYER2
ENDIF
INTCON.0 = 0 ' Clear the interrupt-on-change flag
RESUME ' Resume program running before interrupt occurred
ENABLE ' Enable all active interrupts
'************************************************* ************************************************** ***
Bookmarks