AnsweredAssumed Answered

Dutycycle Update in MK60 using Flex timers

Question asked by mss on Nov 19, 2012
Latest reply on Nov 22, 2012 by Pedro Augusto Panecatl Salas


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;

}

 

 






 

 

 

 

 

Outcomes