3.1.2 RT1160/1170 - Peripheral settings
This section describes the peripherals used for the motor control. On i.MX RT1160/1070, there are three submodules from the
enhanced FlexPWM (eFlexPWM) 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.
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 n
th
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 (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 it takes the counter to count from INIT to VAL1. By default, INIT =
-MODULO/2 = -12000 and VAL1 = MODULO/2 -1 = 11999. The eFlexPWM clock is 240 MHz so it takes 0.0001 s (10 KHz).
• Dead-time insertion is enabled. Define the dead-time length in the M1_PWM_DEADTIME macro.
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.
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.
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.
Peripheral interconnection for - XBARA1
The crossbar is used to interconnect the trigger from the PWM to the ADC_ETC and to connect the encoder (connected to
GPIO) to the QD.
• The FLEXPWM2_PWM1_OUT_TRIG0_1 output trigger (generated by submodule 0) is connected to
ADC_ETC_XBAR0_TRIG0.
• The encoder signal Phase A and Phase B are configured in
pinmux.c
.
NXP Semiconductors
RT crossover processors features and peripheral settings
MCUXpresso SDK Field-Oriented Control (FOC) of 3-Phase PMSM and BLDC motors, Rev. 0, 01/2022
User Guide
12 / 50