Forum - MCS Electronics

 

FAQFAQ SearchSearch RegisterRegister Log inLog in

Timer resets after interrupt?

 
This forum is locked: you cannot post, reply to, or edit topics.   This topic is locked: you cannot edit posts or make replies.    www.mcselec.com Forum Index -> BASCOM-AVR Archive
View previous topic :: View next topic  
Author Message
dewey

Bascom Member



Joined: 01 Mar 2012
Posts: 2
Location: Seattle, Washington

usa.gif
PostPosted: Sun Oct 05, 2014 12:53 am    Post subject: Timer resets after interrupt? Reply with quote

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
...
Enable Interrupts                                           'Turn on global interrupt ability
Enable TIMER1
On TIMER1 PL_tone_ISR
Waitms 1000   '<-- Trigger timer1 overflow and ISR

...
Do
Loop
End


PL_tone_ISR:
   TIMER1 = 19000

   If PLToneWavePosition = 3 Then                           '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 = 2 Then
      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
 


(BASCOM-AVR version : 2.0.7.7 )
Back to top
View user's profile
i.dobson

Bascom Expert



Joined: 05 Jan 2006
Posts: 1570
Location: Basel, Switzerland

switzerland.gif
PostPosted: Sun Oct 05, 2014 10:09 am    Post subject: Reply with quote

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.
Back to top
View user's profile
Evert :-)

Bascom Expert



Joined: 18 Feb 2005
Posts: 2156

netherlands.gif
PostPosted: Sun Oct 05, 2014 11:45 am    Post subject: Reply with quote

You need to give as some more info, clock speed, config timer, stack, cpu.
_________________
www.evertdekker.com Bascom code vault
Back to top
View user's profile Visit poster's website
Display posts from previous:   
This forum is locked: you cannot post, reply to, or edit topics.   This topic is locked: you cannot edit posts or make replies.    www.mcselec.com Forum Index -> BASCOM-AVR Archive All times are GMT + 1 Hour
Page 1 of 1

 
Jump to:  
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