Dutycycle Update in MK60 using Flex timers

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

Dutycycle Update in MK60 using Flex timers

跳至解决方案
1,094 次查看
mss
Contributor I


Hi,

I am using MK60 Flex times for pwm generation. I have the pwm going in the complemetary mode where the dutycycle is controlling the speed as well as the direction of dc motor. The motor runs fine but as soon as I update the dutycycle the motor stops. I can see that the registers C0V and C1V update with the new dutycycle values but at that point the motor stops. I am not sure why this is happening. Did anybody run across this issue or have any idea why this might be happening? Thanks much for the help.

SIM_SCGC6 |= SIM_SCGC6_FTM0_MASK;

SIM_SCGC5 = SIM_SCGC5_PORTA_MASK | SIM_SCGC5_PORTB_MASK | SIM_SCGC5_PORTC_MASK | SIM_SCGC5_PORTD_MASK | SIM_SCGC5_PORTE_MASK;

PORTC_PCR1 = 0x400;

PORTC_PCR2 = 0x400;

GPIOA_PDDR |= (1 << 24);            

GPIOA_PDOR |= (1 << 24);

FTM0_MODE |= FTM_MODE_FTMEN_MASK;

FTM0_COMBINE = 0x32;

FTM0_DEADTIME = 0x46;

FTM0_MOD = 0x000012A;     /* PWM period */

FTM0_C0SC = 0x28;

FTM0_C0V =0x0ff;

FTM0_C1SC = 0x28;

FTM0_C1V =0x0ff;

FTM0_PWMLOAD = FTM_PWMLOAD_LDOK_MASK;

FTM0_SC = 0x08;

FTM0_SYNCONF = 0x00001FB4;

FTM0_SYNC = 0x80;

if (counter>2 & counter<=8){           // I have defined an infinite counter in the main loop.

FTM0_C0V =0x0EE;                                    <--------------Motor stops running here.

FTM0_C1V =0x0EE;                                    <--------------Motor stops running here.

FTM0_OUTMASK = 0xFF;

FTM0_SYNC = 0x88;  

FTM0_SWOCTRL = 0x3F3F;

FTM0_PWMLOAD = FTM_PWMLOAD_LDOK_MASK;

}






标签 (1)
0 项奖励
回复
1 解答
675 次查看
apanecatl
Senior Contributor II

You need to check when is the register being updated, depending on the mode the FTM is working, you can check it here in the CnV register update table (reference manual chapter 40.4.10.3):

2868_2868.png

在原帖中查看解决方案

0 项奖励
回复
1 回复
676 次查看
apanecatl
Senior Contributor II

You need to check when is the register being updated, depending on the mode the FTM is working, you can check it here in the CnV register update table (reference manual chapter 40.4.10.3):

2868_2868.png

0 项奖励
回复