
NXP Semiconductors PMSMRT1170B
MCUXpresso SDK Field-Oriented Control (FOC) of 3-Phase PMSM and BLDC Motors
3.1.2 RT1170 - Peripheral settings
This section describes the peripherals used for the motor control. On i.MX RT1170, three submodules from the
enhanced FlexPWM (eFlexPWM) are used for 6-channel PWM generation and two 12-bit ADCs 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 - PWM1
•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_ETC. 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 = -15000 and VAL1 = MODULO/2 -1 = 14999. The eFlexPWM clock is 240 MHz,
so it takes 0.0000625 s (16 kHz).
•Dead time insertion is enabled. Define the dead time length in the M1_PWM_DEADTIME macro.
3.1.2.2 ADC external trigger control - ADC_ETC
The ADC_ETC module enables multiple users to share the ADC modules in the Time Division Multiplexing
(TDM) way. The external triggers can be brought from the Cross BAR (XBAR) or other sources. The ADC scan
is started via ADC_ETC.
•Both ADCs have set their own trigger chains.
•The trigger chain length is set to 2. The back-to-back ADC trigger mode is enabled.
•The SyncMode is on. In the SyncMode, ADC1 and ADC2 are controlled by the same trigger source. The
trigger source is the PWM submodule 0.
•After both ADCs conversion is completed, ADC_ETC interrupt is enabled and serves the FOC fast-loop
algorithm.
3.1.2.3 Analog sensing - ADC1 and ADC2
ADC1 and ADC2 are used for the MC analog sensing of currents and DC-bus voltage.
•The ADCs operate as 12-bit with the single-ended conversion and hardware trigger selected. The ADCs are
triggered from ADC_ETC by the trigger generated by the eFlexPWM.
3.1.2.4 Quadrature Decoder (QD) module
The QD module is used to sense the position and speed from the encoder sensor.
•The direction of counting is set in the M1_POSPE_ENC_DIRECTION macro.
•The modulo counting and the modulus counting roll-over/under to increment/decrement revolution counter are
enabled.
PMSMRT1170B All information provided in this document is subject to legal disclaimers. © 2023 NXP B.V. All rights reserved.
User guide Rev. 1 — 20 April 2023
10 / 63