Download DRM020 Reference Manual
Transcript
Freescale Semiconductor, Inc. Software Design Software Implementation PMOD = 0x00e6; DEADTM=15; Freescale Semiconductor, Inc... DISMAP=0xff; PCTL2 = 0x80; PCTL1 |= 0xc0; PWMOUT = 0x00; PCTL1 |= 0x02; FCR |= 0x08; /* set up PWM modulus => PWM frequency */ /* for 7.3728MHz Bus Frequency PWM_MODULUS = 0x00e6 gives 16kHz PWM */ /* 2usec deadtime = #15 (for Bus freq. = 7.3728MHz) */ /* when PWM disabled, disable PWM1-6 */ /* PWM interrupt every 4th. PWM loads */ /* disable MCPWM */ /* output port control is PWM gen. */ /* set LDOK bit */ /* Flt2 enabled in manual mode */ PVAL1 = PWM_MODULUS/2; /* set phase A pwm to 50% */ PVAL3 = PWM_MODULUS/2; /* set phase B pwm to 50% */ PVAL5 = PWM_MODULUS/2; /* set phase C pwm to 50% */ When all modules of the microcontroller are initialised, enable the PWM module: PCTL1 |= 0x20; PCTL1 |= 0x01; /* enables PWM interrupts */ /* enables PWM */ 4.4.2 Software Timer The software timer routine provides the timing sequence for required subroutines. The software timer is performed instead of an Output Capture interrupt handler because of lack of interrupt priority in the HC08 MCU. The main program has several time-demanding interrupt routines and more interrupt requirements can cause a software fault. The software timer routine has two timed outputs • in READ_CONST timeout, there is a routine that scans inputs, calculates speed command, handles fault routines and the LED driver DRM020 — Rev 0 MOTOROLA Designer Reference Manual Software Design For More Information On This Product, Go to: www.freescale.com 43