
NXP Semiconductors PMSMFRDMMCXN947
MCUXpresso SDK Field-Oriented Control (FOC) of 3-Phase PMSM and BLDC Motors
•The eFlexPWM submodule SM0 generates trigger 0 (ADC Trigger) when the counter counts to a value equal
to the VAL4 value. ADC Trigger is delayed of approximately Tdeatime/2. This delay ensures correct current
sampling at the duty cycles close to 100 %.
•When the ADC conversion is completed, the ADC_ISR (ADC interrupt) is entered. The FOC calculation is
done in this interrupt.
3.1.2 Peripheral settings
This section describes the peripherals used for the motor control. On MCXN94x, three submodules from the
enhanced FlexPWM (eFlexPWM) are used for 6-channel PWM generation and 12-bit ADC for the phase
currents and DC-bus voltage measurement. The eFlexPWM and ADC are synchronized via submodule 0 from
the eFlexPWM. The following settings are located in the mc_periph_init.c and peripherals.c files and
their header files.
3.1.2.1 PWM generation - FlexPWM1
•Six channels from three submodules are used for the 3-phase PWM generation. Submodule 0
generates the master reload at event every nth opportunity, depending on the user-defined macro
M1_FOC_FREQ_VS_PWM_FREQ.
•Submodules 1 and 2 get their clocks from submodule 0.
•The counters at submodules 1 and 2 are synchronized with the master reload signal from submodule 0.
•Submodule 0 is used for synchronization with ADC. The submodule generates the output trigger after the
PWM reload, when the counter counts to VAL4.
•Fault mode is enabled for channels A and B at submodules 0, 1, and 2 with automatic fault clearing.
Note: The PWM outputs are re-enabled at the first PWM reload after the fault input returns to zero.
•The PWM period (frequency) is determined by how long the counter takes to count from INIT to VAL1.
By default, INIT = -MODULO/2 and VAL1 = MODULO/2 -1 where MODULO = FastPeripheralClock /
M1_PWM_FREQ.
•Dead time insertion is enabled. Define the dead time length in the M1_PWM_DEADTIME macro.
3.1.2.2 Analog sensing - ADC0
ADC0 is used for the MC analog sensing of currents and DC-bus voltage.
•The ADC operate as 12-bit with the single-ended conversion and hardware trigger selected.
•ADC0 trigger source is the PWM submodule 0.
3.1.2.3 Peripheral interconnection for - XBAR
The crossbar is used to interconnect the trigger from the PWM to the ADC.
3.1.2.4 Slow-loop interrupt generation - CTIMER0
The Standard Counter or Timer CTIMER is used to generate the slow-loop interrupt.
•The slow loop is usually ten times slower than the fast loop. Therefore, the interrupt is generated after the
timer counter counts to MR[0] = kCLOCK_FroHf / M1_SLOW_LOOP_FREQ. The speed loop frequency is set in
the M1_SPEED_LOOP_FREQ macro and equals 1000 Hz.
•An interrupt (which serves the slow-loop period) is enabled and generated at the reload event.
3.1.2.5 Quadrature Decoder (ENC)
The QD module is used to sense the position and speed from the encoder sensor.
PMSMFRDMMCXN947 All information provided in this document is subject to legal disclaimers. © 2023 NXP B.V. All rights reserved.
User guide Rev. 0 — 5 December 2023
9 / 61