//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 /* common defines and macros */ #include "derivative.h" /* derivative-specific definitions */ void MSDelay(unsigned int); void main(void) { /* put your own code here */ DDRE = DDRE | 0b00001000; // PE3 as output for (;;) { PORTE = PORTE | 0b00001000; //make PE3=1 to turn on Optoislator MSDelay(500); //change the delay size to see what happens PORTE = PORTE & 0b11110111; //Make PE3=0 to turn off Optoisolator MSDelay(500); //change delay size. } } void MSDelay(unsigned int itime) //msec delay { unsigned int i; unsigned int j; for(i=0;i