#include <S12e128bits.h> #include <mc9s12e128.h> #include <stdio.h> #include "Pins.h" #include "ServoControl.h" void InitLaunchMotor(void){ // PWM - 0, U0 port // Enable PWME |= _S12_PWME0 ; // Pre-scaler PWMPRCLK = CLOCK_A_PRESCALER; // Scaler PWMSCLA = CLOCK_A_SCALER; // Polarity High PWMPOL |= _S12_PPOL0 ; // PWM Clock Select PWMCLK |= CLOCK_LAUNCHER; //SA clock // Set the period PWMPER0 = 100; // Initial duty = 00 PWMDTY0 = 0; printf("Init Launch Motor \n\r"); } void TurnOnLauncher(void) { //turn on motor LAUNCHER_DUTY = LAUNCH_ON_DUTY; puts("Shooting \n\r"); //release the gate GateServoToPosition(GATE_OPEN_POSITION); } void StartLauncherMotor(void){ LAUNCHER_DUTY = ((unsigned char)LAUNCH_ON_DUTY)*3/4; } void TurnOffLauncher(void) { //turn off motor LAUNCHER_DUTY= LAUNCH_OFF_DUTY; puts("Launcher Off \n\r"); //close the gate GateServoToPosition(GATE_CLOSED_POSITION); }