We are using a PWM input to capture a external frequency of a tacho.
With the standard settings everything works fine but when i apply a prescaler during initialization
pwmConfig.prescale = kPWM_Prescale_Divide_64;
or by setting it via
void PWM_SetClockMode
the values of CVAL2 and CVAL3 are always 0x00 and the counter is not counting
My signal has a frequency of 200Hz
We use the imxRT1062 with the SDK v 2.13.0
/* Read the PWM default configuration */
PWM_GetDefaultConfig(&pwmConfig);
pwmConfig.reloadLogic = kPWM_ReloadImmediate;
pwmConfig.pairOperation = kPWM_Independent;
pwmConfig.enableDebugMode = true;
/* Init the pwm */
if( PWM_Init(TACHOPUMP_PERIPHERAL, TACHOPUMP_CHANNEL, &pwmConfig) == kStatus_Fail)
{
PRINTF("Can't initialize PWM\n");
return;
}
/* Configure the capture input of the PWM for one shot polling */
pwm_input_capture_param_t captureConfig;
captureConfig.captureInputSel = false;
captureConfig.edge0 = kPWM_RisingEdge;
captureConfig.edge1 = kPWM_RisingEdge;
captureConfig.enableOneShotCapture = true;
PWM_SetupInputCapture(TACHOPUMP_PERIPHERAL, TACHOPUMP_CHANNEL, TACHOPUMP_SIGNAL, &captureConfig);
PWM_SetPwmLdok(TACHOPUMP_PERIPHERAL, timerBitmask, true);
PWM_StartTimer(TACHOPUMP_PERIPHERAL, timerBitmask);
with this code everything works as expected, but if i add a prescaler in the configuration
pwmConfig.prescale = kPWM_Prescale_Divide_128;
the counter is not counting anymore
Hello @mexp2,
First of all, we apologize for the delay to answer you.
Just for double check, could you please tell us where are you placing the kPWM_Prescale_Divide_128? It might be good if you could write the pwmConfig.prescale=kPWM_Prescale_Divide_128; after pwmConfig.pairOperation=kPWM_Independent; and before PWM_Init(). Also, which clock source are you using?
Finally, could you please try to use other values of the prescaler below 64?
Best regards, Raul.