Joined: 01 Mar 2012 Posts: 2 Location: Seattle, Washington
Posted: Sun Oct 05, 2014 12:53 am Post subject: Timer resets after interrupt?
Hi
I'm experiencing unexpected behavior: When returning from an ISR, Timer1 resets to 0 and program flow jumps to the very top of the program, not back to where the ISR was triggered from. Then, the program executes one line of code (a Const ststement in my case, not nearly enough to overflow Timer1 again), then jumps right back to the ISR again! (As seen by the BASCOM simulator). Are both of these effects normal? I would have expected program flow to return to where it left and Timer1 to be what I set it at (plus a little) before it left the ISR (roughly 19050). Thanks for any help.
Here is my code:
Code:
'Main Program
...
EnableInterrupts'Turn on global interrupt ability EnableTIMER1 OnTIMER1 PL_tone_ISR
Waitms1000'<-- Trigger timer1 overflow and ISR
...
Do Loop End
PL_tone_ISR: TIMER1=19000
If PLToneWavePosition =3Then'Wave position varies from 0 to 3. At the top of the wave = 3
PLToneWaveDirection = Down '0 = a wave heading down, 1 = up
PLToneWavePosition =2
WalshBit1 =1
WalshBit2 =0 ElseIf PLToneWavePosition =2Then If PLToneWaveDirection = Down Then'Moving from wave position 2 to 1
PLToneWavePosition =1
WalshBit1 =0
WalshBit2 =1 Else'Moving from 2 to 3
PLToneWavePosition =3
WalshBit1 =1
WalshBit2 =1 End If End If Return'<-- Program execution returns from here to the very top of the file, processes 1 line, then jumps right back to the top of the ISR
Joined: 05 Jan 2006 Posts: 1570 Location: Basel, Switzerland
Posted: Sun Oct 05, 2014 10:09 am Post subject:
Hi,
What CPU are you using?
What are scaler are you using for timer1?
Do you see this on real Hardware or just the Simulator?
Is you Hardware/Software/Frame stack large enough?
Regards
Ian Dobson _________________ Walking on water and writing software to specification is easy if they're frozen.
You cannot post new topics in this forum You cannot reply to topics in this forum You cannot edit your posts in this forum You cannot delete your posts in this forum You cannot vote in polls in this forum You cannot attach files in this forum You cannot download files in this forum