;Toggling PE2 to turn on and off the relay for Dragon12 Plus Trainer Board with D-Bug12 installed. ;PE2 of PORTE is connected to Relay on Dragon12+ board ;This program toggles PE2 to click on and off the relay (you hear the click sound opening and clsoing the relay) ;For relay discussion see Chapter 15 of Mazidi & Causey HCS12 book ;If you use this relay to control an external device such as horn and lamp use external power as shown in chapter 15. #include "C:\Reg9s12.H" ;----------------------USE $1000-$2FFF for Scratch Pad and Stack R1 EQU $1001 R2 EQU $1002 R3 EQU $1003 ;code section ORG $2000 ; LDS #$2000 ;Stack BSET DDRE,%00000100 ;PE2 as Output pin for Relay ;-------Turn on and off the Relay at PE2 BACK BSET PORTE,%00000100 ;PE2=1 to turn on relay JSR DELAY BCLR PORTE,%00000100 ;PE2=0 to turn off relay JSR DELAY BRA BACK ;Keep toggling Relay ;----------DELAY DELAY PSHA ;Save Reg A on Stack LDAA #100 ;Change this value to hear STAA R3 ;different relay clicking sound ;--1 msec delay. The D-Bug12 works at speed of 48MHz with XTAL=8MHz on Dragon12+ board ;Freq. for Instruction Clock Cycle is 24MHz (1/2 of 48Mhz). ;(1/24MHz) x 10 Clk x240x10=1 msec. Overheads are excluded in this calculation. L3 LDAA #10 STAA R2 L2 LDAA #240 STAA R1 L1 NOP ;1 Intruction Clk Cycle NOP ;1 NOP ;1 DEC R1 ;4 BNE L1 ;3 DEC R2 ;Total Instr.Clk=10 BNE L2 DEC R3 BNE L3 ;-------------- PULA ;Restore Reg A RTS ;-------------------