;Toggling PE3 to activate the optoisolator for Dragon12 Plus Trainer Board ;PE3 of PORTE actiavtes the Base of Optoisolator (CNY75GB) on Dragon12+ board ;This program toggles PE3 to turn on and off the optoisolator. ;The collector (COL) and emittter (EMT) pins of the Optoisolator are available to user (see bottom of the Dragon12 board). ;For Optoisolator See Chapter 15 of HCS12 book by Mazidi & Causey ;The Optoisolator used in the Dragon12 is CNY75GB. Google it to get the data sheet ;Connect +5V pin on Dragon12 to positive side of an LED (long leg) ;Connect the negative side of the LED (short leg) to COL pin of Opto on Dragon12+ board ;Connect the EMT pin of Opto (on Dragon12) to GND pin. Now, by running this program the lED goes on and off. ;If you use this optoisolator 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,%00001000 ;PE3 as Output pin for optoisolator ;-------Turn on and off the optoisolator at PE3 BACK BSET PORTE,%00001000 ;PE3=1 to turn on optoisolator JSR DELAY BCLR PORTE,%00001000 ;PE3=0 to turn off optoisolator JSR DELAY BRA BACK ;Keep doing it ;----------DELAY DELAY PSHA ;Save Reg A on Stack LDAA #100 ;100 msec delay STAA R3 ;--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 ;-------------------