Problems Setting Prescaler for PWM capture

取消
显示结果 
显示  仅  | 搜索替代 
您的意思是: 

Problems Setting Prescaler for PWM capture

1,234 次查看
mexp2
Contributor I

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 

0 项奖励
回复
3 回复数

1,166 次查看
mexp2
Contributor I

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

0 项奖励
回复

1,108 次查看
RaRo
NXP TechSupport
NXP TechSupport

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.

0 项奖励
回复

1,206 次查看
Sanket_Parekh
NXP TechSupport
NXP TechSupport

Hi @mexp2 ,

I hope you are doing well.

Please specify which i.MX Processor is used to debug further.

Thanks & Regards,
Sanket Parekh

0 项奖励
回复