beautypg.com

Motorola M68HC08 User Manual

Page 87

background image

Software Design

Main Software Flowchart

DRM028 — Rev 0

Designer Reference Manual

MOTOROLA

Software Design

87

When the start is successfully completed, the Running () function is
called from main(). During the Running state, the commutation time
preset calculations are provided by the CmtPreset() function, and
commutation time set calculations are provided by the CmtSet()
function.

During the Running, Start or Alignment states, the DecideStop ()
function is called to check drive stop conditions and can set the Stop_F
flag. When the stop flag is set the MotorStop () function is called to stop
the motor, and running, start, or alignment state is left. The software
enters stand-by state.

Also, the commutation error (Cntr_Err>= MAX_ZC_ERR) and
over-current (OverCurrent flag = 1) fault are checked in ERRHndl () and
OVCurrent ()
functions during the Running, Start or Alignment states.
If any error is detected, the function MotorStop () function is called.
Then the software enters Fault state through the Fault() function. This
is only left when the failures are cleared (variable Failure = 0). This
decision is provided DecideCleSto () function, called from ErrorStop ().
In manual control, the failures are cleared by setting the Start/Stop
switch to Stop. In case of PC master software control, the failures are
cleared by the ClearFail flag from the software. When the failures are
cleared, the software enters Application Initialization.

Besides the main loop, there are three interrupts: timer 1, timer 2, and
PWM reload interrupts. They are described in

Figure 5-6

.

Interrupt Timer 1 is periodically called with period PER_CS_T1. The
interrupt function provides dc-bus current measurement and virtual timer
3 service, where timer 1 is providing the timer 3 time base. When
over-current is discovered, the OVC_F

flag is set. Finally, the ADC is set

according to the Nxt_Chnl variable to prepare speed potentiometer or
temperature sensing. This interrupt is provided by the TIMACh1_Int()
function.

Interrupt Timer 2 sets commutation actions. If commutation is enabled
(CmtE_F flag is set), the following actions are done:

PWM commutation step

Synchronization of timer 1, for current measurement with PWM

F

re

e

sc

a

le

S

e

m

ic

o

n

d

u

c

to

r,

I

Freescale Semiconductor, Inc.

For More Information On This Product,

Go to: www.freescale.com

n

c

.

..