English
Language : 

MC9S12HZ256_08 Datasheet, PDF (286/692 Pages) Freescale Semiconductor, Inc – Microcontrollers
Chapter 9 Motor Controller (MC10B8CV1)
9.7 Initialization/Application Information
This section provides an example of how the PWM motor controller can be initialized and used by
application software. The configuration parameters (e.g., timer settings, duty cycle values, etc.) are not
guaranteed to be adequate for any real application.
The example software is implemented in assembly language.
9.7.1 Code Example
One way to use the motor controller is:
1. Perform global initialization
a) Set the motor controller control registers MCCTL0 and MCCTL1 to appropriate values.
i) Prescaler disabled (MCPRE1 = 0, MCPRE0 = 0).
ii) Fast mode and dither disabled (FAST = 0, DITH = 0).
iii) Recirculation feature in dual full H-bridge mode disabled (RECIRC = 0).
All other bits in MCCTL0 and MCCTL1 are set to 0.
b) Configure the channel control registers for the desired mode.
i) Dual full H-bridge mode (MCOM[1:0] = 11).
ii) Left aligned PWM (MCAM[1:0] = 01).
iii) No channel delay (MCCD[1:0] = 00).
2. Perform the startup phase
a) Clear the duty cycle registers MCDC0 and MCDC1
b) Initialize the period register MCPER, which is equivalent to enabling the motor controller.
c) Enable the timer which generates the timebase for the updates of the duty cycle registers.
3. Main program
a) Check if pin PB0 is set to “1” and execute the sub program if a timer interrupt is pending.
b) Initiate the shutdown procedure if pin PB0 is set to “0”.
4. Sub program
a) Update the duty cycle registers
Load the duty cycle registers MCDC0 and MCDC1 with new values from the table and clear
the timer interrupt flag.
The sub program will initiate the shutdown procedure if pin PB0 is set to “0”.
b) Shutdown procedure
The timer is disabled and the duty cycle registers are cleared to drive an inactive value on the PWM output
as long as the motor controller is enabled. The period register is cleared after a certain time, which disables
the motor controller. The table address is restored and the timer interrupt flag is cleared.
MC9S12HZ256 Data Sheet, Rev. 2.05
286
Freescale Semiconductor