View previous topic :: View next topic |
Author |
Message |
hast66
Joined: 18 Aug 2005 Posts: 28
|
Posted: Fri Aug 26, 2005 3:27 pm Post subject: interrupt problem |
|
|
Hi
On PIND.3 of a 90S2313 I connect a pushbutton and I use this as an interrupt
Every time I push short the prg should wait 1500sec. When I push longer(>1sec) it should go to the ISR "RESETTEN"
Code: |
Config Portd = Input
Reset Portd
Config Int0 = Falling
Config Int1 = Rising
Enable Interrupts
Enable Int0
Enable Int1
On Int0 Resetten , Nosave
On Int1 Uitstel , Nosave
'main program
Do
‘something with some wait instructions in between
Loop
'ISR 1 rising uitstel
Uitstel:
Wait 1
Enable Interrupts
Enable Int1
If Pind.3 = 0 Then
Wait 1500
Goto Resetten
End If
Bitwait Pind.3 , Reset
Goto Resetten
Return
'ISR 0 falling resetten
Resetten:
jmp 0 ' soft reset
Return
End 'end program
|
when I push short the prg goes to the wait 1500 instruction (I think) and I can interrupt this with an INT0 signal but not with a longer(>1sec) INT1 signal
What am I doing wrong???
[/code] |
|
Back to top |
|
|
Duval JP
Joined: 22 Jun 2004 Posts: 1161 Location: France
|
Posted: Sat Aug 27, 2005 2:08 pm Post subject: |
|
|
hello,
for a keyboard, I carried out a similar program without used interruption.
the idea was as follows: in the main loop I question the keyboard perpetually.
if I do not have an answer I return to the loop
if I have an answer corresponding to the pushed key, I makes leave another loop where I control the time where the key is pushed with
waitms and exit do
You can make the same thing by controlling the reserved pin
bon courage
JP _________________ pleasure to learn, to teach, to create |
|
Back to top |
|
|
naicheben
Joined: 18 Nov 2004 Posts: 47 Location: Leck
|
Posted: Tue Sep 06, 2005 8:18 am Post subject: |
|
|
how about:
Config Portd = Input
Reset Portd
Config Int0 = Falling
Config Int1 = Rising
Enable Interrupts
Enable Int0
Enable Int1
On Int0 Resetten , Nosave
On Int1 Uitstel , Nosave
'main program
Do
‘something with some wait instructions in between
Loop
'ISR 1 rising uitstel
Uitstel:
waitms 1500 'since 1500sec= 25 min ... you didn't wait, did you?
If Pind.3 = 0 Then 'so if its still pressed ... reset
Goto Resetten
End If
'Do what so ever ....
Return
'ISR 0 falling resetten
Resetten:
jmp 0 ' soft reset
Return
End 'end program |
|
Back to top |
|
|
hast66
Joined: 18 Aug 2005 Posts: 28
|
Posted: Tue Sep 06, 2005 11:12 am Post subject: |
|
|
I found the solution.
Due to contactvibrations(I don't know the right word), the flags in the GIFR ar set unintentionelly, so you get another interrupt as soon as you enable interrupts again.
A way to prefent this :
(= setting(discarding) the pending INT0 en INT1.) just before enableing interrupts. Of course you can play with the number 192 to choose the right INT
Another silly thing I've searched for: with external interrupts and sleep mode: you can only wake up with a LEVEL interrupt |
|
Back to top |
|
|
hast66
Joined: 18 Aug 2005 Posts: 28
|
Posted: Tue Sep 06, 2005 11:20 am Post subject: |
|
|
oh yes Naicheben
It was the intention to interrupt the wait 25minutes with a longer push on the button or to re-begin the 25minutes loop with a shorter push.
I make this small project to automatically close my garage after 5 minutes with some postpone options.
thanks anyway |
|
Back to top |
|
|
|