EASy68K  
It is currently Sun Dec 16, 2018 12:02 pm

All times are UTC




Post new topic Reply to topic  [ 10 posts ] 
Author Message
 Post subject: interrupt
PostPosted: Thu Aug 19, 2010 7:17 pm 
Offline
User avatar

Joined: Mon Aug 16, 2010 3:16 pm
Posts: 22
hello, is it possible to have interrupt in a loop? for example, before interrupt 1 is pressed, the code will keep on looping until interrupt 1 is pressed and it will go to next step. here is my code:
Code:
IDLE   BSR   DA_MSG      ; IDLE PHASE
   BSR   DELAY_2
   BRA    INTERRUPT   ; IRQ1 TO ARM, IRQ2 TO DISARM
   
CHECK   CLR.B   D0
   BSR   CHECK_MSG
   BSR   DELAY_2
   CLR.B   D0
   MOVE.B   SWITCH,D0
   NOT.B   D0
   MOVE.B   D0,LED
   MOVE.B   #7,D2
   BRA    INTERRUPT

before interrupt 1 is pressed, the code will keep on looping in CHECK. only after interrupt 1 is pressed, it will continue to next step. do we have something like BTST for interrupt?

thanks.


Top
 Profile  
 
 Post subject:
PostPosted: Thu Aug 19, 2010 9:18 pm 
Offline
User avatar

Joined: Thu Dec 16, 2004 6:42 pm
Posts: 1087
Change the state of a variable in the interrupt handler. Use that variable to control program execution.

Code:
    REPEAT
       
        ;loop here until interrupt
       
    UNTIL.B CONTINUE <EQ> #1 DO.S

    STOP    #$2700      ; end program
   
* Interrupt handler
INT
    MOVE.B  #1,CONTINUE
    RTE

   
* variables
CONTINUE  DC.B    0

_________________
Prof. Kelly


Top
 Profile  
 
 Post subject:
PostPosted: Thu Aug 19, 2010 9:22 pm 
Offline

Joined: Mon Jul 26, 2010 11:43 pm
Posts: 198
Location: Aurora, IL
You would be better to allow your foreground code (main loop) to execute in a loop, and have your background code (interrupts) just respond and exit.

The interrupt code would set or clear some flags, then the main loop could then identify and respond accordingly. Interrupts are designed to act on some immediate event, and leave quickly. If you do too much in the interrupt, or wait on some other dependency you are likely to create a dead-lock situation.


Top
 Profile  
 
 Post subject:
PostPosted: Mon Aug 23, 2010 6:57 pm 
Offline
User avatar

Joined: Mon Aug 16, 2010 3:16 pm
Posts: 22
profkelly wrote:
Change the state of a variable in the interrupt handler. Use that variable to control program execution.

Code:
    REPEAT
       
        ;loop here until interrupt
       
    UNTIL.B CONTINUE <EQ> #1 DO.S

    STOP    #$2700      ; end program
   
* Interrupt handler
INT
    MOVE.B  #1,CONTINUE
    RTE

   
* variables
CONTINUE  DC.B    0


PROF, i dont really understand the line: UNTIL.B CONTINUE <EQ> #1 DO.S

thanks


Top
 Profile  
 
 Post subject:
PostPosted: Mon Aug 23, 2010 7:54 pm 
Offline
User avatar

Joined: Thu Dec 16, 2004 6:42 pm
Posts: 1087
The program is looping until the variable CONTINUE contains the number 1 at which point it will exit the loop. It could also have been written as

UNTIL.B CONTINUE <NE> #0 DO.S

Which loops until the variable CONTINUE does not equal the number 0. In this case either will do the same thing. The interrupt handler code writes the value 1 to variable CONTINUE.

_________________
Prof. Kelly


Top
 Profile  
 
 Post subject:
PostPosted: Thu Aug 26, 2010 1:38 pm 
Offline
User avatar

Joined: Mon Aug 16, 2010 3:16 pm
Posts: 22
hello. i tried the method above but i got the error msg, 'Address or Bus error during exception processing. Execution halted'

my code is as followed (for testing purpose only):
Code:
INT2   EQU   $0068
LED   EQU   $E00010
SWITCH   EQU   $E00012

   
   ORG   $1000
START:   MOVE.B   SWITCH,D3
   MOVE.B   IRQ2,INT2
   CMP   #1,CONTINUE
   BEQ   END
   NOT.B   D3
   MOVE.B   D3,LED   
   BTST   #0,D3
   BNE   T
   BRA   START      


T   CLR.B   LED
   BRA   START
   
IRQ2   MOVE.B   #1,CONTINUE
   RTE
   
END   MOVE.B   #9,D0
   TRAP   #15      
CONTINUE   
   DC.B   0
   END   START

please assist me. thank you!


Top
 Profile  
 
 Post subject:
PostPosted: Fri Aug 27, 2010 3:59 am 
Offline

Joined: Mon Dec 27, 2004 11:40 pm
Posts: 318
The line ..
Code:
      MOVE.B      IRQ2,INT2

.. will try to copy the byte sized contents of IRQ2 into INT2. What I think you wanted to do was save the long sized immediate value IRQ2 into INT2.

Lee.


Top
 Profile  
 
 Post subject:
PostPosted: Sat Aug 28, 2010 3:12 am 
Offline
User avatar

Joined: Mon Aug 16, 2010 3:16 pm
Posts: 22
still cannot, same error message: 'Address or Bus error during exception processing. Execution halted'


Top
 Profile  
 
 Post subject:
PostPosted: Sat Aug 28, 2010 3:27 am 
Offline
User avatar

Joined: Thu Dec 16, 2004 6:42 pm
Posts: 1087
The instruction to set INT2 exception vector and the following compare should be:
Code:
    MOVE.L  #IRQ2,INT2
    CMP.B   #1,CONTINUE

_________________
Prof. Kelly


Top
 Profile  
 
 Post subject:
PostPosted: Sat Aug 28, 2010 5:41 am 
Offline
User avatar

Joined: Mon Aug 16, 2010 3:16 pm
Posts: 22
thanks


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

All times are UTC


Who is online

Users browsing this forum: No registered users and 3 guests


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

Search for:
Jump to:  
cron
Powered by phpBB® Forum Software © phpBB Group