diff --git a/Documentation/platforms/arm/imxrt/index.rst b/Documentation/platforms/arm/imxrt/index.rst index e00823e85b4..7e9a60ec155 100644 --- a/Documentation/platforms/arm/imxrt/index.rst +++ b/Documentation/platforms/arm/imxrt/index.rst @@ -181,7 +181,7 @@ Output on pin B is currently supported only as a complementary option to pin A. The lower-half of this driver is initialize by calling :c:func:`imxrt_pwminitialize`. PWM module can be synchronized by an external signal. The external signal used for synchronization -is selected by IMXRT_FLEXPWMx_MODx_SYNC_SRC config option. The number in IMXRT_FLEXPWM4_MOD4_SYNC_SRC +is selected by IMXRT_FLEXPWMx_MODx_SYNC_SRC config option. The number in IMXRT_FLEXPWMx_MODx_SYNC_SRC corresponds with the XBAR number. Following numbers can be used for synchronization of PWMs with other PWM module when using iMXRT1020, iMXRT1050 or iMXRT1060. @@ -221,6 +221,9 @@ iMXRT1170 has different XBAR connections: - PWM4 Module 3 = 88 - PWM4 Module 4 = 89 +Option IMXRT_FLEXPWMx_MODx_TRIG allows the module to generate a trigger signal. The trigger is generated on +timer capture of either period or duty cycle value based on the configuration. + SAI --- diff --git a/arch/arm/src/imxrt/Kconfig b/arch/arm/src/imxrt/Kconfig index 8eb74656681..ead7d7919dd 100644 --- a/arch/arm/src/imxrt/Kconfig +++ b/arch/arm/src/imxrt/Kconfig @@ -601,6 +601,23 @@ config IMXRT_FLEXPWM1_MOD1_TRIG interrupt that can trigger ADC conversion or synchronize other PWMs for example. +choice + prompt "Trigger value source" + default IMXRT_FLEXPWM1_MOD1_TRIG_PER + depends on IMXRT_FLEXPWM1_MOD1_TRIG + ---help--- + PWM can use either duty cycle value or period value register + to generate the trigger. The trigger is generated when the timer + reaches the corresponding value. + +config IMXRT_FLEXPWM1_MOD1_TRIG_PER + bool "Period value" + +config IMXRT_FLEXPWM1_MOD1_TRIG_DUTY + bool "Duty cycle value" + +endchoice + config IMXRT_FLEXPWM1_MOD1_SYNC_SRC int "Synchronization source signal" default -1 @@ -634,6 +651,23 @@ config IMXRT_FLEXPWM1_MOD2_TRIG interrupt that can trigger ADC conversion or synchronize other PWMs for example. +choice + prompt "Trigger value source" + default IMXRT_FLEXPWM1_MOD2_TRIG_PER + depends on IMXRT_FLEXPWM1_MOD1_TRIG + ---help--- + PWM can use either duty cycle value or period value register + to generate the trigger. The trigger is generated when the timer + reaches the corresponding value. + +config IMXRT_FLEXPWM1_MOD2_TRIG_PER + bool "Period value" + +config IMXRT_FLEXPWM1_MOD2_TRIG_DUTY + bool "Duty cycle value" + +endchoice + config IMXRT_FLEXPWM1_MOD2_SYNC_SRC int "Synchronization source signal" default -1 @@ -667,6 +701,23 @@ config IMXRT_FLEXPWM1_MOD3_TRIG interrupt that can trigger ADC conversion or synchronize other PWMs for example. +choice + prompt "Trigger value source" + default IMXRT_FLEXPWM1_MOD3_TRIG_PER + depends on IMXRT_FLEXPWM1_MOD3_TRIG + ---help--- + PWM can use either duty cycle value or period value register + to generate the trigger. The trigger is generated when the timer + reaches the corresponding value. + +config IMXRT_FLEXPWM1_MOD3_TRIG_PER + bool "Period value" + +config IMXRT_FLEXPWM1_MOD3_TRIG_DUTY + bool "Duty cycle value" + +endchoice + config IMXRT_FLEXPWM1_MOD3_SYNC_SRC int "Synchronization source signal" default -1 @@ -700,6 +751,23 @@ config IMXRT_FLEXPWM1_MOD4_TRIG interrupt that can trigger ADC conversion or synchronize other PWMs for example. +choice + prompt "Trigger value source" + default IMXRT_FLEXPWM1_MOD4_TRIG_PER + depends on IMXRT_FLEXPWM1_MOD4_TRIG + ---help--- + PWM can use either duty cycle value or period value register + to generate the trigger. The trigger is generated when the timer + reaches the corresponding value. + +config IMXRT_FLEXPWM1_MOD4_TRIG_PER + bool "Period value" + +config IMXRT_FLEXPWM1_MOD4_TRIG_DUTY + bool "Duty cycle value" + +endchoice + config IMXRT_FLEXPWM1_MOD4_SYNC_SRC int "Synchronization source signal" default -1 @@ -738,6 +806,23 @@ config IMXRT_FLEXPWM2_MOD1_TRIG interrupt that can trigger ADC conversion or synchronize other PWMs for example. +choice + prompt "Trigger value source" + default IMXRT_FLEXPWM2_MOD1_TRIG_PER + depends on IMXRT_FLEXPWM2_MOD1_TRIG + ---help--- + PWM can use either duty cycle value or period value register + to generate the trigger. The trigger is generated when the timer + reaches the corresponding value. + +config IMXRT_FLEXPWM2_MOD1_TRIG_PER + bool "Period value" + +config IMXRT_FLEXPWM2_MOD1_TRIG_DUTY + bool "Duty cycle value" + +endchoice + config IMXRT_FLEXPWM2_MOD1_SYNC_SRC int "Synchronization source signal" default -1 @@ -771,6 +856,23 @@ config IMXRT_FLEXPWM2_MOD2_TRIG interrupt that can trigger ADC conversion or synchronize other PWMs for example. +choice + prompt "Trigger value source" + default IMXRT_FLEXPWM2_MOD2_TRIG_PER + depends on IMXRT_FLEXPWM2_MOD2_TRIG + ---help--- + PWM can use either duty cycle value or period value register + to generate the trigger. The trigger is generated when the timer + reaches the corresponding value. + +config IMXRT_FLEXPWM2_MOD2_TRIG_PER + bool "Period value" + +config IMXRT_FLEXPWM2_MOD2_TRIG_DUTY + bool "Duty cycle value" + +endchoice + config IMXRT_FLEXPWM2_MOD2_SYNC_SRC int "Synchronization source signal" default -1 @@ -804,6 +906,23 @@ config IMXRT_FLEXPWM2_MOD3_TRIG interrupt that can trigger ADC conversion or synchronize other PWMs for example. +choice + prompt "Trigger value source" + default IMXRT_FLEXPWM2_MOD3_TRIG_PER + depends on IMXRT_FLEXPWM2_MOD3_TRIG + ---help--- + PWM can use either duty cycle value or period value register + to generate the trigger. The trigger is generated when the timer + reaches the corresponding value. + +config IMXRT_FLEXPWM2_MOD3_TRIG_PER + bool "Period value" + +config IMXRT_FLEXPWM2_MOD3_TRIG_DUTY + bool "Duty cycle value" + +endchoice + config IMXRT_FLEXPWM2_MOD3_SYNC_SRC int "Synchronization source signal" default -1 @@ -837,6 +956,23 @@ config IMXRT_FLEXPWM2_MOD4_TRIG interrupt that can trigger ADC conversion or synchronize other PWMs for example. +choice + prompt "Trigger value source" + default IMXRT_FLEXPWM2_MOD4_TRIG_PER + depends on IMXRT_FLEXPWM2_MOD1_TRIG + ---help--- + PWM can use either duty cycle value or period value register + to generate the trigger. The trigger is generated when the timer + reaches the corresponding value. + +config IMXRT_FLEXPWM2_MOD4_TRIG_PER + bool "Period value" + +config IMXRT_FLEXPWM2_MOD4_TRIG_DUTY + bool "Duty cycle value" + +endchoice + config IMXRT_FLEXPWM2_MOD4_SYNC_SRC int "Synchronization source signal" default -1 @@ -875,6 +1011,23 @@ config IMXRT_FLEXPWM3_MOD1_TRIG interrupt that can trigger ADC conversion or synchronize other PWMs for example. +choice + prompt "Trigger value source" + default IMXRT_FLEXPWM3_MOD1_TRIG_PER + depends on IMXRT_FLEXPWM3_MOD1_TRIG + ---help--- + PWM can use either duty cycle value or period value register + to generate the trigger. The trigger is generated when the timer + reaches the corresponding value. + +config IMXRT_FLEXPWM3_MOD1_TRIG_PER + bool "Period value" + +config IMXRT_FLEXPWM3_MOD1_TRIG_DUTY + bool "Duty cycle value" + +endchoice + config IMXRT_FLEXPWM3_MOD1_SYNC_SRC int "Synchronization source signal" default -1 @@ -908,6 +1061,23 @@ config IMXRT_FLEXPWM3_MOD2_TRIG interrupt that can trigger ADC conversion or synchronize other PWMs for example. +choice + prompt "Trigger value source" + default IMXRT_FLEXPWM3_MOD2_TRIG_PER + depends on IMXRT_FLEXPWM3_MOD2_TRIG + ---help--- + PWM can use either duty cycle value or period value register + to generate the trigger. The trigger is generated when the timer + reaches the corresponding value. + +config IMXRT_FLEXPWM3_MOD2_TRIG_PER + bool "Period value" + +config IMXRT_FLEXPWM3_MOD2_TRIG_DUTY + bool "Duty cycle value" + +endchoice + config IMXRT_FLEXPWM3_MOD2_SYNC_SRC int "Synchronization source signal" default -1 @@ -941,6 +1111,23 @@ config IMXRT_FLEXPWM3_MOD3_TRIG interrupt that can trigger ADC conversion or synchronize other PWMs for example. +choice + prompt "Trigger value source" + default IMXRT_FLEXPWM3_MOD3_TRIG_PER + depends on IMXRT_FLEXPWM3_MOD3_TRIG + ---help--- + PWM can use either duty cycle value or period value register + to generate the trigger. The trigger is generated when the timer + reaches the corresponding value. + +config IMXRT_FLEXPWM3_MOD3_TRIG_PER + bool "Period value" + +config IMXRT_FLEXPWM3_MOD3_TRIG_DUTY + bool "Duty cycle value" + +endchoice + config IMXRT_FLEXPWM3_MOD3_SYNC_SRC int "Synchronization source signal" default -1 @@ -974,6 +1161,23 @@ config IMXRT_FLEXPWM3_MOD4_TRIG interrupt that can trigger ADC conversion or synchronize other PWMs for example. +choice + prompt "Trigger value source" + default IMXRT_FLEXPWM3_MOD4_TRIG_PER + depends on IMXRT_FLEXPWM3_MOD4_TRIG + ---help--- + PWM can use either duty cycle value or period value register + to generate the trigger. The trigger is generated when the timer + reaches the corresponding value. + +config IMXRT_FLEXPWM3_MOD4_TRIG_PER + bool "Period value" + +config IMXRT_FLEXPWM3_MOD4_TRIG_DUTY + bool "Duty cycle value" + +endchoice + config IMXRT_FLEXPWM3_MOD4_SYNC_SRC int "Synchronization source signal" default -1 @@ -1012,6 +1216,23 @@ config IMXRT_FLEXPWM4_MOD1_TRIG interrupt that can trigger ADC conversion or synchronize other PWMs for example. +choice + prompt "Trigger value source" + default IMXRT_FLEXPWM4_MOD1_TRIG_PER + depends on IMXRT_FLEXPWM4_MOD1_TRIG + ---help--- + PWM can use either duty cycle value or period value register + to generate the trigger. The trigger is generated when the timer + reaches the corresponding value. + +config IMXRT_FLEXPWM4_MOD1_TRIG_PER + bool "Period value" + +config IMXRT_FLEXPWM4_MOD1_TRIG_DUTY + bool "Duty cycle value" + +endchoice + config IMXRT_FLEXPWM4_MOD1_SYNC_SRC int "Synchronization source signal" default -1 @@ -1045,6 +1266,23 @@ config IMXRT_FLEXPWM4_MOD2_TRIG interrupt that can trigger ADC conversion or synchronize other PWMs for example. +choice + prompt "Trigger value source" + default IMXRT_FLEXPWM4_MOD2_TRIG_PER + depends on IMXRT_FLEXPWM4_MOD2_TRIG + ---help--- + PWM can use either duty cycle value or period value register + to generate the trigger. The trigger is generated when the timer + reaches the corresponding value. + +config IMXRT_FLEXPWM4_MOD2_TRIG_PER + bool "Period value" + +config IMXRT_FLEXPWM4_MOD2_TRIG_DUTY + bool "Duty cycle value" + +endchoice + config IMXRT_FLEXPWM4_MOD2_SYNC_SRC int "Synchronization source signal" default -1 @@ -1078,6 +1316,23 @@ config IMXRT_FLEXPWM4_MOD3_TRIG interrupt that can trigger ADC conversion or synchronize other PWMs for example. +choice + prompt "Trigger value source" + default IMXRT_FLEXPWM4_MOD3_TRIG_PER + depends on IMXRT_FLEXPWM4_MOD3_TRIG + ---help--- + PWM can use either duty cycle value or period value register + to generate the trigger. The trigger is generated when the timer + reaches the corresponding value. + +config IMXRT_FLEXPWM4_MOD3_TRIG_PER + bool "Period value" + +config IMXRT_FLEXPWM4_MOD3_TRIG_DUTY + bool "Duty cycle value" + +endchoice + config IMXRT_FLEXPWM4_MOD3_SYNC_SRC int "Synchronization source signal" default -1 @@ -1111,6 +1366,23 @@ config IMXRT_FLEXPWM4_MOD4_TRIG interrupt that can trigger ADC conversion or synchronize other PWMs for example. +choice + prompt "Trigger value source" + default IMXRT_FLEXPWM4_MOD4_TRIG_PER + depends on IMXRT_FLEXPWM4_MOD4_TRIG + ---help--- + PWM can use either duty cycle value or period value register + to generate the trigger. The trigger is generated when the timer + reaches the corresponding value. + +config IMXRT_FLEXPWM4_MOD4_TRIG_PER + bool "Period value" + +config IMXRT_FLEXPWM4_MOD4_TRIG_DUTY + bool "Duty cycle value" + +endchoice + config IMXRT_FLEXPWM4_MOD4_SYNC_SRC int "Synchronization source signal" default -1 diff --git a/arch/arm/src/imxrt/imxrt_flexpwm.c b/arch/arm/src/imxrt/imxrt_flexpwm.c index 1abbf7448fb..2d54926f460 100644 --- a/arch/arm/src/imxrt/imxrt_flexpwm.c +++ b/arch/arm/src/imxrt/imxrt_flexpwm.c @@ -79,7 +79,7 @@ struct imxrt_flexpwm_module_s { uint8_t module; /* Number of PWM module */ bool used; /* True if the module is used */ - bool trig_en; + uint8_t trig_val; /* 0: invalid, 1: period, 2: duty */ struct imxrt_flexpwm_out_s out_a; /* PWM output */ struct imxrt_flexpwm_out_s out_b; /* PWM output */ bool complementary; /* True if outputs are complementary */ @@ -139,9 +139,15 @@ static struct imxrt_flexpwm_module_s g_pwm1_modules[] = .module = 1, .used = true, #ifdef CONFIG_IMXRT_FLEXPWM1_MOD1_TRIG - .trig_en = true, +#ifdef CONFIG_IMXRT_FLEXPWM1_MOD1_TRIG_PER + .trig_val = 1, +#elif CONFIG_IMXRT_FLEXPWM1_MOD1_TRIG_DUTY + .trig_val = 2, #else - .trig_en = false, + .trig_val = 0, +#endif +#else + .trig_val = 0, #endif .out_a = { @@ -167,9 +173,15 @@ static struct imxrt_flexpwm_module_s g_pwm1_modules[] = .module = 2, .used = true, #ifdef CONFIG_IMXRT_FLEXPWM1_MOD2_TRIG - .trig_en = true, +#ifdef CONFIG_IMXRT_FLEXPWM1_MOD2_TRIG_PER + .trig_val = 1, +#elif CONFIG_IMXRT_FLEXPWM1_MOD2_TRIG_DUTY + .trig_val = 2, #else - .trig_en = false, + .trig_val = 0, +#endif +#else + .trig_val = 0, #endif .out_a = { @@ -195,9 +207,15 @@ static struct imxrt_flexpwm_module_s g_pwm1_modules[] = .module = 3, .used = true, #ifdef CONFIG_IMXRT_FLEXPWM1_MOD3_TRIG - .trig_en = true, +#ifdef CONFIG_IMXRT_FLEXPWM1_MOD3_TRIG_PER + .trig_val = 1, +#elif CONFIG_IMXRT_FLEXPWM1_MOD3_TRIG_DUTY + .trig_val = 2, #else - .trig_en = false, + .trig_val = 0, +#endif +#else + .trig_val = 0, #endif .out_a = { @@ -223,9 +241,15 @@ static struct imxrt_flexpwm_module_s g_pwm1_modules[] = .module = 4, .used = true, #ifdef CONFIG_IMXRT_FLEXPWM1_MOD4_TRIG - .trig_en = true, +#ifdef CONFIG_IMXRT_FLEXPWM1_MOD4_TRIG_PER + .trig_val = 1, +#elif CONFIG_IMXRT_FLEXPWM1_MOD4_TRIG_DUTY + .trig_val = 2, #else - .trig_en = false, + .trig_val = 0, +#endif +#else + .trig_val = 0, #endif .out_a = { @@ -269,9 +293,15 @@ static struct imxrt_flexpwm_module_s g_pwm2_modules[] = .module = 1, .used = true, #ifdef CONFIG_IMXRT_FLEXPWM2_MOD1_TRIG - .trig_en = true, +#ifdef CONFIG_IMXRT_FLEXPWM2_MOD1_TRIG_PER + .trig_val = 1, +#elif CONFIG_IMXRT_FLEXPWM2_MOD1_TRIG_DUTY + .trig_val = 2, #else - .trig_en = false, + .trig_val = 0, +#endif +#else + .trig_val = 0, #endif .out_a = { @@ -297,9 +327,15 @@ static struct imxrt_flexpwm_module_s g_pwm2_modules[] = .module = 2, .used = true, #ifdef CONFIG_IMXRT_FLEXPWM2_MOD2_TRIG - .trig_en = true, +#ifdef CONFIG_IMXRT_FLEXPWM2_MOD2_TRIG_PER + .trig_val = 1, +#elif CONFIG_IMXRT_FLEXPWM2_MOD2_TRIG_DUTY + .trig_val = 2, #else - .trig_en = false, + .trig_val = 0, +#endif +#else + .trig_val = 0, #endif .out_a = { @@ -325,9 +361,15 @@ static struct imxrt_flexpwm_module_s g_pwm2_modules[] = .module = 3, .used = true, #ifdef CONFIG_IMXRT_FLEXPWM2_MOD3_TRIG - .trig_en = true, +#ifdef CONFIG_IMXRT_FLEXPWM2_MOD3_TRIG_PER + .trig_val = 1, +#elif CONFIG_IMXRT_FLEXPWM2_MOD3_TRIG_DUTY + .trig_val = 2, #else - .trig_en = false, + .trig_val = 0, +#endif +#else + .trig_val = 0, #endif .out_a = { @@ -353,9 +395,15 @@ static struct imxrt_flexpwm_module_s g_pwm2_modules[] = .module = 4, .used = true, #ifdef CONFIG_IMXRT_FLEXPWM2_MOD4_TRIG - .trig_en = true, +#ifdef CONFIG_IMXRT_FLEXPWM2_MOD4_TRIG_PER + .trig_val = 1, +#elif CONFIG_IMXRT_FLEXPWM2_MOD4_TRIG_DUTY + .trig_val = 2, #else - .trig_en = false, + .trig_val = 0, +#endif +#else + .trig_val = 0, #endif .out_a = { @@ -399,9 +447,15 @@ static struct imxrt_flexpwm_module_s g_pwm3_modules[] = .module = 1, .used = true, #ifdef CONFIG_IMXRT_FLEXPWM3_MOD1_TRIG - .trig_en = true, +#ifdef CONFIG_IMXRT_FLEXPWM3_MOD1_TRIG_PER + .trig_val = 1, +#elif CONFIG_IMXRT_FLEXPWM3_MOD1_TRIG_DUTY + .trig_val = 2, #else - .trig_en = false, + .trig_val = 0, +#endif +#else + .trig_val = 0, #endif .out_a = { @@ -427,9 +481,15 @@ static struct imxrt_flexpwm_module_s g_pwm3_modules[] = .module = 2, .used = true, #ifdef CONFIG_IMXRT_FLEXPWM3_MOD2_TRIG - .trig_en = true, +#ifdef CONFIG_IMXRT_FLEXPWM3_MOD2_TRIG_PER + .trig_val = 1, +#elif CONFIG_IMXRT_FLEXPWM3_MOD2_TRIG_DUTY + .trig_val = 2, #else - .trig_en = false, + .trig_val = 0, +#endif +#else + .trig_val = 0, #endif .out_a = { @@ -455,9 +515,15 @@ static struct imxrt_flexpwm_module_s g_pwm3_modules[] = .module = 3, .used = true, #ifdef CONFIG_IMXRT_FLEXPWM3_MOD3_TRIG - .trig_en = true, +#ifdef CONFIG_IMXRT_FLEXPWM3_MOD3_TRIG_PER + .trig_val = 1, +#elif CONFIG_IMXRT_FLEXPWM3_MOD3_TRIG_DUTY + .trig_val = 2, #else - .trig_en = false, + .trig_val = 0, +#endif +#else + .trig_val = 0, #endif .out_a = { @@ -483,9 +549,15 @@ static struct imxrt_flexpwm_module_s g_pwm3_modules[] = .module = 4, .used = true, #ifdef CONFIG_IMXRT_FLEXPWM3_MOD4_TRIG - .trig_en = true, +#ifdef CONFIG_IMXRT_FLEXPWM3_MOD4_TRIG_PER + .trig_val = 1, +#elif CONFIG_IMXRT_FLEXPWM3_MOD4_TRIG_DUTY + .trig_val = 2, #else - .trig_en = false, + .trig_val = 0, +#endif +#else + .trig_val = 0, #endif .out_a = { @@ -529,9 +601,15 @@ static struct imxrt_flexpwm_module_s g_pwm4_modules[] = .module = 1, .used = true, #ifdef CONFIG_IMXRT_FLEXPWM4_MOD1_TRIG - .trig_en = true, +#ifdef CONFIG_IMXRT_FLEXPWM4_MOD1_TRIG_PER + .trig_val = 1, +#elif CONFIG_IMXRT_FLEXPWM4_MOD1_TRIG_DUTY + .trig_val = 2, #else - .trig_en = false, + .trig_val = 0, +#endif +#else + .trig_val = 0, #endif .out_a = { @@ -557,9 +635,15 @@ static struct imxrt_flexpwm_module_s g_pwm4_modules[] = .module = 2, .used = true, #ifdef CONFIG_IMXRT_FLEXPWM4_MOD2_TRIG - .trig_en = true, +#ifdef CONFIG_IMXRT_FLEXPWM4_MOD2_TRIG_PER + .trig_val = 1, +#elif CONFIG_IMXRT_FLEXPWM4_MOD2_TRIG_DUTY + .trig_val = 2, #else - .trig_en = false, + .trig_val = 0, +#endif +#else + .trig_val = 0, #endif .out_a = { @@ -585,9 +669,15 @@ static struct imxrt_flexpwm_module_s g_pwm4_modules[] = .module = 3, .used = true, #ifdef CONFIG_IMXRT_FLEXPWM4_MOD3_TRIG - .trig_en = true, +#ifdef CONFIG_IMXRT_FLEXPWM4_MOD3_TRIG_PER + .trig_val = 1, +#elif CONFIG_IMXRT_FLEXPWM4_MOD3_TRIG_DUTY + .trig_val = 2, #else - .trig_en = false, + .trig_val = 0, +#endif +#else + .trig_val = 0, #endif .out_a = { @@ -613,9 +703,15 @@ static struct imxrt_flexpwm_module_s g_pwm4_modules[] = .module = 4, .used = true, #ifdef CONFIG_IMXRT_FLEXPWM4_MOD4_TRIG - .trig_en = true, +#ifdef CONFIG_IMXRT_FLEXPWM4_MOD4_TRIG_PER + .trig_val = 1, +#elif CONFIG_IMXRT_FLEXPWM4_MOD4_TRIG_DUTY + .trig_val = 2, #else - .trig_en = false, + .trig_val = 0, +#endif +#else + .trig_val = 0, #endif .out_a = { @@ -957,13 +1053,24 @@ static int pwm_setup(struct pwm_lowerhalf_s *dev) } } - if (priv->modules[i].trig_en) + if (priv->modules[i].trig_val != 0) { - /* Use period register for trigger generation */ + /* Use either period or duty cycle register for + * trigger generation + */ regval = getreg16(priv->base + IMXRT_FLEXPWM_SM0TCTRL_OFFSET + MODULE_OFFSET * shift); - regval |= SMT_OUT_TRIG_EN_VAL1; + if (priv->modules[i].trig_val == 1) + { + regval |= SMT_OUT_TRIG_EN_VAL1; + } + + if (priv->modules[i].trig_val == 2) + { + regval |= SMT_OUT_TRIG_EN_VAL3; + } + putreg16(regval, priv->base + IMXRT_FLEXPWM_SM0TCTRL_OFFSET + MODULE_OFFSET * shift); }