BasicMicro - Forums

www.basicmicro.com
It is currently Mon May 21, 2012 8:35 pm

All times are UTC - 8 hours [ DST ]




Post new topic Reply to topic  [ 8 posts ] 
Author Message
 Post subject: timer interrupts on the BASIC ATOM PRO 64
PostPosted: Thu Mar 24, 2011 5:14 am 
Offline
New User

Joined: Thu Mar 03, 2011 11:32 am
Posts: 2
It's my first post here, so hello everyone!

I have a problem with timer interrupts on the BASIC ATOM PRO 64. I want to use a timer to increment a variable every time there's an overflow. I had a look at the example in the basic micro syntax manual and tried applying it to my project but no success - the microcontroller just gets stuck when I load the program into it. So my idea is that I'm doing something wrong when setting up the timer. I'd be very thankful if someone helped.Here is the code:

Code:
;------------------
;varable declarations and so on
;...
;-------------------

;-------------------
;the timer set up, based on what can be found in the basic micro syntax manual

;calculates the number of interrupts per 1/100th of a second
;as a floating point constant.
interval fcon MHZ/100/256/128
counter var float
counter = 0.0
milliseconds var long
milliseconds = 0
TCRV0 = 0x03 ;Sets Timer V to count once every 128 OSC clocks
'TCRV1 = 0x01
;Tells the processor where to jump to when the timer V
;overflow interrupt triggers.
ONINTERRUPT TIMERVINT_OVF,handler
ENABLE TIMERVINT_OVF ;enables the timer V overflow interrupt
ENABLE ;enables interrupts in general


handler
;this interrupt is executed once per 256*128 clock cycles
counter = counter + 1.0

if(counter>interval)then
counter=counter-interval
milliseconds = milliseconds + 10

;this is what it does in my program - increments xw everytime milliseconds equals pauza
;and sends some data to a screen
if menu = 1 then
   if milliseconds = pauza then
   milliseconds = 0
   xw = xw + 1
      if xw >220 then
      SEROUT p2, i9600, ["r", 0,21, 0,40, 0,220, 0,199, $00,$00]   
      GOSUB GetACK
      PAUSE 1

      xw = 20

      endif
   return
   endif
else
return
endif
   

endif


Thanks in advance.


Top
 Profile  
 
 Post subject: Re: timer interrupts on the BASIC ATOM PRO 64
PostPosted: Thu Mar 24, 2011 7:23 am 
Offline
Master

Joined: Tue Nov 21, 2006 9:34 am
Posts: 528
I have played around a lot with interrupts. More details up on the old thread: http://www.lynxmotion.net/viewtopic.php?f=4&t=3496

One thing I noticed. I think you used a return statement at the end of your interrupt handler. You should be using the resume statement.

Kurt


Top
 Profile  
 
 Post subject: Re: timer interrupts on the BASIC ATOM PRO 64
PostPosted: Fri Mar 25, 2011 9:03 am 
Offline
Site Admin
User avatar

Joined: Thu Mar 01, 2001 11:00 am
Posts: 903
Location: Temecula, CA
Kurt is correct. That return is definitely a problem. However there is another problem. Your code also tries to execute the handler routine as if it was regular code. You need to put something before your handler label so you main code doesn't try to exeucte the handler code except as an interrupt.

Code:
;------------------
;varable declarations and so on
;...
;-------------------

;-------------------
;the timer set up, based on what can be found in the basic micro syntax manual

;calculates the number of interrupts per 1/100th of a second
;as a floating point constant.
interval fcon MHZ/100/256/128
counter var float
counter = 0.0
milliseconds var long
milliseconds = 0
TCRV0 = 0x03 ;Sets Timer V to count once every 128 OSC clocks
'TCRV1 = 0x01
;Tells the processor where to jump to when the timer V
;overflow interrupt triggers.
ONINTERRUPT TIMERVINT_OVF,handler
ENABLE TIMERVINT_OVF ;enables the timer V overflow interrupt
ENABLE ;enables interrupts in general

main
   goto main

handler
;this interrupt is executed once per 256*128 clock cycles
counter = counter + 1.0

if(counter>interval)then
counter=counter-interval
milliseconds = milliseconds + 10

;this is what it does in my program - increments xw everytime milliseconds equals pauza
;and sends some data to a screen
if menu = 1 then
   if milliseconds = pauza then
     milliseconds = 0
     xw = xw + 1
      if xw >220 then
      SEROUT p2, i9600, ["r", 0,21, 0,40, 0,220, 0,199, $00,$00]   
      GOSUB GetACK
      PAUSE 1

      xw = 20

      endif
   endif
endif
resume


Also this code:

Code:
      SEROUT p2, i9600, ["r", 0,21, 0,40, 0,220, 0,199, $00,$00]   
      GOSUB GetACK
      PAUSE 1


should not be in your interrupt handler. Never do anything in an interrupt handler that takes a significant amount of time. You should set a flag and then process that code in your main loop instead.

_________________
Tech Support
Basic Micro - Robotic Technology Evolved


Top
 Profile  
 
 Post subject: Re: timer interrupts on the BASIC ATOM PRO 64
PostPosted: Fri Mar 25, 2011 9:26 am 
Offline
Master

Joined: Tue Nov 21, 2006 9:34 am
Posts: 528
I forgot to ask: What is a Basic Atom Pro 64?


Top
 Profile  
 
 Post subject: Re: timer interrupts on the BASIC ATOM PRO 64
PostPosted: Fri Mar 25, 2011 3:40 pm 
Offline
New User

Joined: Thu Mar 03, 2011 11:32 am
Posts: 2
thanks very much for the replies, I'll have another go at making it work


@KurtEck
this is a BasicAtom Pro 64: http://www.basicmicro.com/BasicATOM-Pro ... _p_93.html


Top
 Profile  
 
 Post subject: Re: timer interrupts on the BASIC ATOM PRO 64
PostPosted: Fri Mar 25, 2011 9:50 pm 
Offline
Master

Joined: Sun Aug 17, 2008 5:26 pm
Posts: 798
Location: CA bay Area
KurtEck wrote:
I forgot to ask: What is a Basic Atom Pro 64?

Remember the Emperor's New Module?
http://forums.basicmicro.net/atompro-f486/the-emperor-s-new-module-t8585.html?hilit=emperor's%20board
Probably the same thing. BMicro sells it now, whereas I had to special order it and have them program it after I paid an assembly house to have it soldered to an adapter board.

_________________
kenjj
http://blog.basicmicro.com/
http://kjennejohn.wordpress.com/


Top
 Profile  
 
 Post subject: Re: timer interrupts on the BASIC ATOM PRO 64
PostPosted: Sat Mar 26, 2011 6:59 am 
Offline
Master

Joined: Tue Nov 21, 2006 9:34 am
Posts: 528
kenjj wrote:
Remember the Emperor's New Module?
http://forums.basicmicro.net/atompro-f486/the-emperor-s-new-module-t8585.html?hilit=emperor's%20board
Probably the same thing. BMicro sells it now, whereas I had to special order it and have them program it after I paid an assembly house to have it soldered to an adapter board.

Yep, I remember now. It might be fun to have a board with all of those IOs exposed. But soldering them by hand may be a pain...


Top
 Profile  
 
 Post subject: Re: timer interrupts on the BASIC ATOM PRO 64
PostPosted: Sun Apr 17, 2011 10:22 am 
Offline
Master

Joined: Sun Oct 05, 2008 9:40 am
Posts: 111
First video is a tqfp64 to dip built from this:
http://www.proto-advantage.com/store/pr ... id=2210114



and another tqfp project



Top
 Profile  
 
Display posts from previous:  Sort by  
Post new topic Reply to topic  [ 8 posts ] 

All times are UTC - 8 hours [ DST ]


Who is online

Users browsing this forum: No registered users and 1 guest


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 post attachments in this forum

Jump to:  
cron
Powered by phpBB © 2000, 2002, 2005, 2007 phpBB Group

phpBB SEO