S32k144-Problem about PWM output of FTM

キャンセル
次の結果を表示 
表示  限定  | 次の代わりに検索 
もしかして: 

S32k144-Problem about PWM output of FTM

ソリューションへジャンプ
2,333件の閲覧回数
cqhcau
Contributor I

I want to output one PWM signal with 4000hz,50% duty cycle.

I modify on the official  demo "ftm_pwm" ,the SDK is RTM3.0.0.

I change the PE  configuration of PWM to "Edge-Aligned PWM" .

 When I run  FTM_DRV_UpdatePwmChannel(INST_FLEXTIMER_PWM1, 0U, FTM_PWM_UPDATE_IN_DUTY_CYCLE, dutyCycle, 0U, true); only once like below, the PWM signal can output normally.

volatile uint16_t dutyCycle =0x4000;

/* Infinite loop
* - increment or decrement duty cycle
* - Update channel duty cycle
* - Wait for a number of cycles to make
* the change visible
*/
FTM_DRV_UpdatePwmChannel(INST_FLEXTIMER_PWM1, 0U, FTM_PWM_UPDATE_IN_DUTY_CYCLE, dutyCycle, 0U, true);
while (1)
{
// if (increaseDutyCycle == false)
// {
// dutyCycle--;
// if (dutyCycle < 1U)
// increaseDutyCycle = true;
// }
// else
// {
// dutyCycle++;
// if (dutyCycle > 0xFFFU)
// increaseDutyCycle = false;
// }
// FTM_DRV_UpdatePwmChannel(INST_FLEXTIMER_PWM1, 0U, FTM_PWM_UPDATE_IN_DUTY_CYCLE, dutyCycle, 0U, true);
// delayCycles(0x2FFU);
}

But when I run  FTM_DRV_UpdatePwmChannel(INST_FLEXTIMER_PWM1, 0U, FTM_PWM_UPDATE_IN_DUTY_CYCLE, dutyCycle, 0U, true);in the while loop like below, the PWM signal can not output.So what's the problem?How to use FTM_DRV_UpdatePwmChannel funtion  correctly?

/* Infinite loop
* - increment or decrement duty cycle
* - Update channel duty cycle
* - Wait for a number of cycles to make
* the change visible
*/
// FTM_DRV_UpdatePwmChannel(INST_FLEXTIMER_PWM1, 0U, FTM_PWM_UPDATE_IN_DUTY_CYCLE, dutyCycle, 0U, true);
while (1)
{
// if (increaseDutyCycle == false)
// {
// dutyCycle--;
// if (dutyCycle < 1U)
// increaseDutyCycle = true;
// }
// else
// {
// dutyCycle++;
// if (dutyCycle > 0xFFFU)
// increaseDutyCycle = false;
// }
FTM_DRV_UpdatePwmChannel(INST_FLEXTIMER_PWM1, 0U, FTM_PWM_UPDATE_IN_DUTY_CYCLE, dutyCycle, 0U, true);
// delayCycles(0x2FFU);
}

ラベル(1)
タグ(1)
0 件の賞賛
返信
1 解決策
2,162件の閲覧回数
danielmartynek
NXP TechSupport
NXP TechSupport

Hello,

You are triggering the SW synchronization too fast in the infinite while loop.

Because the FTM driver initializes SYNCONF_SWRSTCNT = 1, the FTM_CNT is reset to 0 every time the SW synchronization is triggered in the FTM_DRV_UpdatePwmChannel() function.

Please use a delay loop between the calls of this function.

Thanks,

BR, Daniel

元の投稿で解決策を見る

0 件の賞賛
返信
1 返信
2,163件の閲覧回数
danielmartynek
NXP TechSupport
NXP TechSupport

Hello,

You are triggering the SW synchronization too fast in the infinite while loop.

Because the FTM driver initializes SYNCONF_SWRSTCNT = 1, the FTM_CNT is reset to 0 every time the SW synchronization is triggered in the FTM_DRV_UpdatePwmChannel() function.

Please use a delay loop between the calls of this function.

Thanks,

BR, Daniel

0 件の賞賛
返信