Problem with signal multiplexing FTM0 CH2

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

Problem with signal multiplexing FTM0 CH2

跳至解决方案
1,139 次查看
rev
Contributor III

I'm having trouble with the pin signal multiplexing for FTM0 CH2 on a MK22FX512AVLL device. My board uses a lot of FTM channels for PWM functions and I'm able to successfully route all other FTM signals to pins.  For some reason FTM0 CH2 is problematic.  Regardless of the PORT settings, the output pin remains floating (undriven) by the FTM channel.

A simple test case is below.  This code works for other FTM channels, but not for FTM0 CH2.  I've tried routing to PTA5, PTC3 and PTC5 with similar results.

// Set up Timer 0 for simple edge-aligned PWM

// Enable the Clock to the FTM0 Module

SIM->SCGC6 |= SIM_SCGC6_FTM0_MASK;

// Route FTM0_CH2 to PTA5,

PORTA->PCR[5] = PORT_PCR_MUX(3);

// Disable FTM write protection

FTM0->MODE |= FTM_MODE_WPDIS_MASK;

//FTM Counter Value - reset counter to zero

FTM0->CNT = 0x0;

// Set modulo count

FTM0->MOD = sysclk / (8 * FTM0_PWM_FREQUENCY);

//Set the Counter Initial Value to 0

FTM0->CNTIN = 0;

// Configure for edge aligned PWM

FTM0->CONTROLS[1].CnSC = (FTM_CnSC_ELSB_MASK | FTM_CnSC_MSB_MASK);

// Set PWM to ~50%

FTM0->CONTROLS[1].CnV = 500;

// Set clock prescaler to SYSCLK divided by 2

FTM0->SC =  FTM_SC_CLKS(1) | FTM_SC_PS(1);

while (1);

0 项奖励
回复
1 解答
1,040 次查看
rev
Contributor III

I have a solution but not an explanation. 

If I set the FTMEN bit in the MODE register, then all FTM channels are available as PWM signals. Since I was not using any advanced FTM functions, I assumed TPM compatibility (FTMEN=0) would be OK. 

Incidentally, without FTMEN set there are strange effects on certain other FTM channels.  For example, FTM0 CH0 has glitches in the PWM output.  These go away when FTMEN=1.

I've been using TPM legacy mode on other Kinetis devices for more than 1 year with this same motor control code.  I wonder if something changed in the latest silicon revision for this part?  It sure looks like silicon issue.  Moving on with my work-around.

在原帖中查看解决方案

0 项奖励
回复
1 回复
1,041 次查看
rev
Contributor III

I have a solution but not an explanation. 

If I set the FTMEN bit in the MODE register, then all FTM channels are available as PWM signals. Since I was not using any advanced FTM functions, I assumed TPM compatibility (FTMEN=0) would be OK. 

Incidentally, without FTMEN set there are strange effects on certain other FTM channels.  For example, FTM0 CH0 has glitches in the PWM output.  These go away when FTMEN=1.

I've been using TPM legacy mode on other Kinetis devices for more than 1 year with this same motor control code.  I wonder if something changed in the latest silicon revision for this part?  It sure looks like silicon issue.  Moving on with my work-around.

0 项奖励
回复