KE04 FTM0 C0V, C1V update problem

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

KE04 FTM0 C0V, C1V update problem

1,435件の閲覧回数
jaroslavbrazdil
Contributor I

Hi,

I have a problem with update (or set) the FTM0_C0V or FTM0_C1V register. I can use FTM2 with no problem.

I know that FTM0 is more simple than FTM2.

Here is my Init function:

void FTM0_Init(void){

/* ReSet the CLKS */
FTM0->SC = 0;
/* Set the PWM period */
FTM0->MOD = 0x0FFF0;

/* Set the channel values Output Capture Mode*/
FTM0->CONTROLS[0].CnSC = FTM_CnSC_ELSA_MASK | FTM_CnSC_CHIE_MASK;
FTM0->CONTROLS[1].CnSC = FTM_CnSC_ELSA_MASK | FTM_CnSC_CHIE_MASK;
/* Set the C0V and C1V */
FTM0->CONTROLS[0].CnV = 0x08F8;
FTM0->CONTROLS[1].CnV = 0x0800;
/* Set CLKS*/
FTM0->SC = FTM_SC_CLKS(1) | FTM_SC_PS(0);
}

The CnSC registers are updated OK, The counter is counting but I cant set the CnV registers.

The CLKS is 0:0, but CnV is not changed.

 

I tried to change CnV repeatedly in loop too. No change.

Can somebody help me please?

Thank You.

Jaroslav

0 件の賞賛
返信
2 返答(返信)

1,421件の閲覧回数
jaroslavbrazdil
Contributor I

Hi again,

I have found something new.

I can change FTM0_C0V or FTM_C1V when I set FTM0_SC = FTM_SC_CPWMS_MASK;

Then CnV is set, but the FTM0_C0SC bit CHF is not set when CNT is running. I cant get an interrupt.

TOF interrupt is working OK.

CNT value is changing.

 

I have no idea what is going here.

 

Thanks

 Jaroslav

 

 

 

 

 

0 件の賞賛
返信

1,400件の閲覧回数
diego_charles
NXP TechSupport
NXP TechSupport

Hi @jaroslavbrazdil 

I have not seen in your code if you already enabled the  FTM IRQ in the NVIC. Could you try to call the following function before the FTM starts to run?

 

 

NVIC_EnableIRQ( IRQn_Type interrupt );

 

 

 

Yet, the FRDM-KE04Z does not have examples for the  FTM. However for a reference you could check the FRDM-KE06Z SDK FTM examples.  Its examples use the FTM SDK drivers.

The FTM is common along Kinetis MCUs. There is an application note regarding the FTM with bare metal code examples. It may help you as an additional reference. 

Features of the FlexTimer Module

I hope this helps. 

Best regards,

Diego.

 

0 件の賞賛
返信