Thanks Daylor.
I`ll try to insert your program into my.
Hello Darrel,
now the interrupt works fine, but after interrupt the pic hangs. I need to reset it. Can you tell me where is the failure ?
code:
ADCON1 = %111
define OSC 4
TRISA = %00111000 ' RA0-2 OUT, RA3-5 INPUT
TRISB = %11000000 ' OUTPUT
TRISC = %00000000 ' OUTPUT
col1 var PORTA.0
col2 var PORTA.1
col3 var PORTA.2
row1 var PORTA.3
row2 var PORTA.4
row3 var PORTA.5
id1 var PORTB.7 ' Input1 Rotary
id2 var PORTB.6 ' Input2 Rotary
click var PORTB.5
tp var PORTB.4
tm var PORTB.3
vm var PORTC.0
vp var PORTC.1
unt var PORTC.2
srcl var PORTC.3
srcr var PORTC.4
dp4 var PORTC.5
dp3 var PORTC.6
dp2 var PORTC.7
dpo1 var PORTB.2 ' Simulation OUT 1
dpo2 var PORTB.1 ' Simulation OUT 2
summer var PORTB.0 ' Beep active
lp var word
drehpos var byte
savepos var byte
cnt var byte
ums var bit
delay var word
startclk var word
RBCPins var Byte
LastPins var Byte
Lastpins = PORTB
INTCON.0 = 0
INTCON.3 = 1
on interrupt goto myint
main:
...
GOTO main
switchd:
dpo2 = 0
for lp = 0 to 20
pause 1 ' Time for Simulation 20ms
next lp
dpo1 = 0
for lp = 0 to 40
pause 1 ' 40ms Pause
next lp
dpo2 = 1 : dpo1 = 1
return
switchh:
dpo1 = 0
for lp = 0 to 20
pause 1 ' Time for Simulation 20ms
next lp
dpo2 = 0
for lp = 0 to 40
pause 1 ' 40ms Pause
next lp
dpo1 = 1 : dpo2 = 1
return
DISABLE
myint:
RBCpins = PORTB
INTCON.0 = 0
if RBCpins.7 <> Lastpins.7 then
Lastpins.7 = rbcpins.7
gosub switchh
endif
if RBCpins.6 <> Lastpins.6 then
lastpins.6 = rbcpins.6
gosub switchd
resume
endif
enable
Last edited by Robson; - 27th June 2007 at 11:16.
Somehow, the RESUME got moved inside the IF statement.
The only way it will resume is if PORTB.6 changes.
Otherwise it falls off into never never land.
<br>
DT
Ok Darrel i´ve found the error.
I changed the program like this and it´s working perfect.
DISABLE
myint:
RBCpins = PORTB
INTCON.0 = 0
if rbcpins.7 <> Lastpins.7 then
dpo1 = 0
for lp = 0 to 20
pause 1
next lp
dpo2 = 0
for lp = 0 to 40
pause 1
next lp
dpo1 = 1
dpo2 = dpo1
endif
if rbcpins.6 <> lastpins.6 then
dpo2 = 0
for lp = 0 to 20
pause 1
next lp
dpo1 = 0
for lp = 0 to 40
pause 1
next lp
dpo2 = 1
dpo1 = dpo2
endif
RESUME
ENABLE
Maybe the error comes from the subroutine. I include the subroutine directly and it works fine.
Thanks a lot Darrel
PS: How you insert a code in a window like you posted it before ?
Using [code][/code] tags puts it in a window.
At the bottom of the page, there's a box that says "Posting Rules". Inside that there's a link to vB code. Check it out. You can do all kinds of formatting.
hth,
DT
Darrel and ON INTERRUPT in the same thread ???
![]()
![]()
Steve
It's not a bug, it's a random feature.
There's no problem, only learning opportunities.
Well, I figure you can't appreciate "Instant Interrupts" until you've had to deal with ON INTERRUPT a few times.
Got to get them started.
<br>
DT
Bookmarks