AN1931D Freescale Semiconductor / Motorola, AN1931D Datasheet - Page 50

no-image

AN1931D

Manufacturer Part Number
AN1931D
Description
3-Phase PM Synchronous Motor Vector Control
Manufacturer
Freescale Semiconductor / Motorola
Datasheet
Implementation Notes
7.4 Run/Stop Switch and Button Control
50
The functionality will be explained in following example:
The “trigger” function Process1StateTrig() is called from process1. The transient functions of
process2, process3,etc., which must be triggered by Process1State, are put inside the
Process1StateTrig().
In the DSP56F805EVM and the DSP56F807EVM, the Run/Stop switch is connected to a GPIO pin.
The state of the Run/Stop switch can be read directly from the GPIO Data Register. In the
DSP56F803EVM, there are fewer free GPIO pins, so the switch is connected to ADC input AN7 and
the switch status is obtained with the AD Converter. The switch logical status is obtained by
comparing the measured value with the threshold value.
Also, the buttons are usually connected to GPIO pins. But in this application, the buttons are connected
to IQRA and IRQB interrupts to allow the ability to run the same code on the DSP56F803,
DSP56F805, and DSP56F807 EVMs. Since the DSP56F803 has no free GPIO pins for user buttons,
the application uses buttons connected to IRQA/B pins. The EVM boards do not resolve the button
contact bouncing, which may occur while pushing and releasing the button, so this issue must be
resolved by software.
The IRQA and IRQB interrupts are maskable interrupts connected directly to the DSP’s core. The
IRQA and IRQB lines are internally synchronized with the processor’s internal clock and can be
programmed as level-sensitive or edge-sensitive. The IRQA and IRQB interrupts have no interrupt
flag, so this flag is replaced by a software flag. The following algorithm is used to check the state of
the IRQ line and is described for one interrupt.
The IRQ interrupt is set to be negative-level-sensitive. When the button is pressed, the logical level 0 is
applied on the IRQ line and the interrupt occurs; see
contact bounces, the ISR disables the IRQ interrupt, sets the debounce counter to a predefined value
and sets the variable buttonStatus to 1. The variable buttonStatus represents the interrupt flag. Using
the DSP56F80x’s software timer, the ButtonProcessing function is periodically called, as shown in
Figure
the IRQ interrupt is again enabled. The button press is checked by the ButtonEdge function; see
Figure
buttonStatus. When the variable buttonStatus is not set, the ButtonEdge function returns “0”.
According to the ButtonProcessing calling period, the value of the debounce counter should be set
close to 180ms. This value is sufficient to prevent multiple IRQ ISR calls due to contact bounces.
7-1. The function ButtonProcessing decrements the debounce counter and if the counter is 0,
7-2. When the variable buttonStatus is set, the ButtonEdge function returns “1” and clears
Freescale Semiconductor, Inc.
3-Phase PM Synchronous Motor Vector Control
For More Information On This Product,
Go to: www.freescale.com
Figure
7-1. To avoid multiple calls of ISR due to
MOTOROLA

Related parts for AN1931D