The brake control routine is written around Line 192 in the MAIN.C main function as shown in "Figure
4-16 Brake control".
While SW3 is pressed, the outputs to all the semiconductor elements are set to off and the brake is applied
to the motor.
void main(void)
{
(omitted)
/* main loop */
while (1)
{
if (!gCanEnableFlag)
{
(omitted)
/* Set motor break */
if(gMtStatus == MTST_MOVE)
{
/* Set the Motor Start Flag */
if (PDR4_P41)
{
OCSH1_OTE0 = 1;
OCSH1_OTE1 = 1;
OCSH3_OTE0 = 1;
OCSH3_OTE1 = 1;
OCSH5_OTE0 = 1;
OCSH5_OTE1 = 1;
TCCSL0_STOP = 0;
}
else
{
OCSH1_OTE0 = 0;
OCSH1_OTE1 = 0;
OCSH3_OTE0 = 0;
OCSH3_OTE1 = 0;
OCSH5_OTE0 = 0;
OCSH5_OTE1 = 0;
PDR3 = 0x00;
TCCSL0_STOP = 1;
}
}
(omitted)
}
(omitted)
}
}
←Brake released
←Brake applied
Figure 4-16 Brake control
- 80 -
AN07-00180-3E