EASy68K  
It is currently Sat Jan 25, 2020 6:42 pm

All times are UTC




Post new topic Reply to topic  [ 3 posts ] 
Author Message
 Post subject: switch interupt
PostPosted: Wed Jan 20, 2010 6:22 am 
Offline

Joined: Mon Jan 18, 2010 3:57 am
Posts: 6
Location: malaysia
hello..
somebody can tell me if easy69k program can program the devise to produce an output like a text message by control a switch...

for example..
a PID/push button switch is switch on then the output 'message 1' will appear

and how to go to the next message if there are have 4 message..

i have try this but not one is working..
i hope somebody can tell or give me some example for this situation..


Top
 Profile  
 
 Post subject:
PostPosted: Fri Jan 22, 2010 3:45 pm 
Offline
User avatar

Joined: Thu Dec 16, 2004 6:42 pm
Posts: 1115
Here is an example program that displays the state of toggle switches 0 and 1.

Code:
*-----------------------------------------------------------
* Program    : switchInput.x68
* Written by : Chuck Kelly
* Date       : Jan 22, 2010
* Description: Demonstrate use of toggle switches for user input.
*
* Displays the current state of toggle switches 0 and 1.
*-----------------------------------------------------------
        ORG $1000
START:                      ; first instruction of program

* Display hardware window
        MOVE.B  #32,D0
        MOVE.B  #00,D1
        TRAP    #15

* Use trap task to get address of toggle switches in D1.L
        MOVE.B  #32,D0      ; trap task 32 Hardware/Simulator
        MOVE.B  #3,D1       ; D1.B = 03, Return address of toggle swithces in D1.L
        TRAP    #15         ; perform task
        MOVE.L  D1,A0       ; A0 is pointer to toggle switches

* Read starting state of toggle switches into D2
        MOVE.B  (A0),D2
        BSR     DISPLAY     ; display switch states

    WHILE <T> DO.S          ; ***** INFINITE LOOP *****
        REPEAT
            MOVE.B  #23,D0
            MOVE.L  #1,D1       ; delay 1/100 second
            TRAP    #15
            MOVE.B  (A0),D1     ; read switches
        UNTIL.B D1 <NE> D2 DO   ; loop until switch change
        MOVE.B  D1,D2       ; switch data
        BSR     DISPLAY
    ENDW   

* Keep here in case infinite loop is removed.
        MOVE.B  #9,D0
        TRAP    #15             ; halt simulator

*------------------------------------------------
* Display switch states
* Pre: D2.B contains switch data
* Post: Displays switch states
*       D2 unchanged
DISPLAY MOVEM.L D0/D1/A1,-(SP)  ; save registers
        MOVE.B  #11,D0      ; clear screen
        MOVE.W  #$FF00,D1
        TRAP    #15
       
        LEA     SWITCH0,A1  ; message pointer
        MOVE.B  #14,D0
        TRAP    #15         ; display message
        BTST    #0,D2       ; test switch 0 state
        BEQ     S0_OFF      ; if off
        LEA     ON,A1       ; 'ON' message
        BRA     S0DISP
S0_OFF  LEA     OFF,A1      ; 'OFF' message
S0DISP  MOVE.B  #14,D0
        TRAP    #15         ; display 'ON' or 'OFF'

        LEA     SWITCH1,A1  ; same for switch1
        MOVE.B  #14,D0
        TRAP    #15
        BTST    #1,D2
        BEQ     S1_OFF
        LEA     ON,A1
        BRA     S1DISP
S1_OFF  LEA     OFF,A1
S1DISP  MOVE.B  #14,D0
        TRAP    #15
       
        MOVEM.L (SP)+,D0/D1/A1  ; restore registers
        RTS

*------------------------------------------------
* Variables and Strings
SWITCH0 DC.B    'SWITCH 0 ',0
SWITCH1 DC.B    'SWITCH 1 ',0
ON      DC.B    'ON',$D,$A,0
OFF     DC.B    'OFF',$D,$A,0

        END       START   ; last line of source



_________________
Prof. Kelly


Top
 Profile  
 
 Post subject: thanks you prof
PostPosted: Mon Jan 25, 2010 2:14 am 
Offline

Joined: Mon Jan 18, 2010 3:57 am
Posts: 6
Location: malaysia
now i understand how to make it..but by referring into your code i'm want to know how to give some led output because you not state the address of switch..

switch 0 on=led 0 on
switch 0 off=led 0 off

switch1 on=led 1 on
switch1 off =led1 off

that true if i just give the output address for led

movea.l #$100001,A2 *set value to output LED
move.b #$00,(A2) *all LED will OFF

or something like this

LED EQU $100001 *set led output address

tq


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

All times are UTC


Who is online

Users browsing this forum: No registered users and 6 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