I'm working with the imxrt117x and 'm trying to run a simple PWM on output PWM(A,2) with this code:
pwm_config_t pwmConfig;
pwm_signal_param_t pwmSignal[1];
uint32_t pwmSourceClockHz = PWM_SRC_CLK_FREQ;
uint32_t pwmFreqHz = 10000; // 10 kHz frequency
// Default PWM configuration (init PWM for a submodule)
PWM_GetDefaultConfig(&pwmConfig);
// Adjust the configuration for our specific use case
pwmConfig.enableDebugMode = true;
pwmConfig.reloadLogic = kPWM_ReloadImmediate;
pwmConfig.pairOperation = kPWM_Independent;
pwmConfig.enableDebugMode = true;
pwmConfig.clockSource = kPWM_BusClock;
pwmConfig.prescale = kPWM_Prescale_Divide_4;
pwmConfig.initializationControl = kPWM_Initialize_LocalSync;
/* Initialize submodule 2 the same way as submodule 1 */
if (PWM_Init(BOARD_PWM_BASEADDR, kPWM_Module_2, &pwmConfig) == kStatus_Fail)
{
PRINTF("PWM initialization failed\n");
return 1;
}
// Configure the PWM signal for channel A and channel B
pwmSignal[0].pwmChannel = kPWM_PwmA;
pwmSignal[0].level = kPWM_HighTrue;
pwmSignal[0].dutyCyclePercent = 50; // 50% duty cycle
PWM_SetPwmLdok(BOARD_PWM_BASEADDR, kPWM_Control_Module_2, false);
// Set up PWM signals
PWM_SetupPwm(BOARD_PWM_BASEADDR, kPWM_Module_2, pwmSignal, 2,
kPWM_SignedCenterAligned, pwmFreqHz, pwmSourceClockHz);
// Load the configuration
PWM_SetPwmLdok(BOARD_PWM_BASEADDR, kPWM_Control_Module_2, true);
// Start the PWM
PWM_StartTimer(BOARD_PWM_BASEADDR, kPWM_Control_Module_2);
```
Still I don't get why it's not working.
I got also the pinmuxing:
```
IOMUXC_SetPinMux(
IOMUXC_GPIO_AD_28_FLEXPWM2_PWM2_A, /* GPIO_AD_28 is configured as FLEXPWM2_PWM2_A */
0U); /* Software Input On Field: Input Path is determined by functionality */
```
Is there anything else that I need to take into account?
Thx