//Stepper Motor control using the H-Bridge on Dragon12 //Dragon12 board comes with TI's 754410 H-bridge driver which can be used to drive stepper motor and DC motor(Google for data sheet and study it) //On Dragon12 , PORTB and PORTP are used to control BOTH 754410 chip and 7-seg LEDs //WE CANNOT USE BOTH 7-SEG LEDs and 754410 AT THE SAME TIME. //J24 (on left side of CPU) is used to provide power to 7-seg LEDs driver //and J18 (at the bottom left side of the board by the buzzer) is used to provide power to H-bridge driver. //ONLY ONE OF THEM SHOULD HAVE A JUMPER //The Dragon12 is shipped with J24 (7-Seg LEDs) power enabled and nothing on J18. //If you want to use H-Bridge you MUST move the jumper from J24 to J18. ONLY ONE OF THEM SHOULD HAVE A JUMPER //Examine the outputs of the H-bridge at T4 Terminal block next to Reset button. They are M1,M2,M3 and M4 //On Dragon12 the PP0 is connected to EN12 input pin of 754410. //PB0 is connected to 1A and PB1 to 2A input pins of the 754410. That means M1 (1Y) and M2 (2Y) outputs are controlled by PB0,PB1 and PP0. //Also the PP1 is connected to EN34 pin of 754410. //PB2 is connected to 3A and PB3 to 4A input pins of the 754410. That means M3 (3Y) and M4 (4Y) outputs are controlled by PB2,PB3 and PP1. //Steps to connect and run this program to control stepper motor //1)move jumper from J24 to J18 to power the 754410 chip //2)Connect an external 5V-9V DC power to the COM leads of the stepper motor //3)Connect Mx (M1,M2,M3, and M4 on T4 Terminal block) to the stepper motor leads as follow: // M1 to blue, M2 to white, M3 to yellow, and M3 to red lead //Now, power your Dragon12 board and //Compile (F7), Download (F5) and run(F5), //This program will rotate the stepper motor counter clockwise(CCW) continuosly, //Written and tested by M. Mazidi. //for stepper motor control see chapter 15 of HCS12 book by Mazidi & Causey. #include /* common defines and macros */ #include "derivative.h" /* derivative-specific definitions */ void MSDelay(unsigned int); void main(void) { /* put your own code here */ DDRB = 0x0F; //PORTB0-PORTB3 as output DDRP = 0x03; //PORTP0 and PORTP1 as output for 12EN=1 and 34EN=1 ```````````````````````````````````````````````````````````````````````````````````````````````````````````````````````````````````````````````````````````````````````````````````````````````````````````````````````````````````````````````````````````````````````````````````````````````````````````````````````````````````````````````````````````````````````````````````````````````````````````````````````````````````````````````````````````````````````````````````````````````````````````````````````````````````````````````````````````````````````````````````````````````````````````````````````````````````````````````````````````` PORTB=0b00000000; // start with all off PTP=0b00000011; //Turn on both 12EN and 34EN Enables for 754410 chip for(;;) { PORTB=0b00000011; MSDelay(50); PORTB=0b00000110; MSDelay(50); PORTB=0b00001100; MSDelay(50); PORTB=0b00001001; MSDelay(50); } } //millisecond delay for XTAL=8MHz, PLL=48MHz //The HCS12 Serial Monitor is used to download and the program. //Serial Monitor uses PLL=48MHz void MSDelay(unsigned int itime) { unsigned int i; unsigned int j; for(i=0;i