Help!! FTM2_C0V does not update.

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

Help!! FTM2_C0V does not update.

1,923 次查看
josegardo
Contributor I

Hello,

I am using the FTM2 in Output Compare mode. This timers get the reference clock through external clock (100 KHz), so it overflows each 655.4ms. I am interested in using the Channel Match interrupt capabilities of this peripheral, but the content of FTM2_C0V is never updated. The reference manual said that this register is updated in the next count of FTM2 after FTM2_C0V was written (in my case, CLKS !=0 and FTMEN=0) but it always remains the same value. Check this simple code:

PE_ISR(FTM2_overflow)

{

  FTM2_C0SC &= (uint32_t)~0x80UL; //Clear flag

  sendUart(FTM2_C0V);                     //Print FTM2_C0V value

}

void setTimer(void)

{

  FTM2_C0V=0x7FFF;

  FTM2_C0SC &= (uint32_t)~0x80UL;    //Clear flag to clean previous channel matches

  FTM2_C0SC |= (uint32_t)0x40UL;        // Channel match interrupt enabled

}

When setTimer function is called, UART send the FTM2_C0V value each 655.4 ms, but this value is always 0x0000 (the default value) instead 0x7FFF.

Thank you

Jose

标记 (4)
0 项奖励
回复
12 回复数

1,643 次查看
josegardo
Contributor I

We have not found out the solution :smileysad:. Anyone can help me?

0 项奖励
回复

1,643 次查看
Wlodek_D_
Senior Contributor II

Dear Jose Garcia Doblado,

Thank you for your post, however please consider moving it to the right community place for better visibility.

For details please see general advice https://community.freescale.com/docs/DOC-99909

Thank you for using Freescale Community.

Regards,

Wlodek_D.

0 项奖励
回复

1,643 次查看
Robinwithu
Senior Contributor I

Hi,

can you tell me which controller you are using?

Thanks and Regards,

Robin

0 项奖励
回复

1,643 次查看
josegardo
Contributor I

I am using a Kinetis K30 microcontroller, the MK30DN512ZVLQ10.

Thanks,

Jose

0 项奖励
回复

1,643 次查看
Robinwithu
Senior Contributor I

Like

void setTimer(void)

{

FTM2_MOD=0xFFFF;

  FTM2_C0V=0x7FFF;

  FTM2_C0SC &= (uint32_t)~0x80UL;    //Clear flag to clean previous channel matches

  FTM2_C0SC |= (uint32_t)0x40UL;        // Channel match interrupt enabled

}

Thanks n Regards,

Robin

0 项奖励
回复

1,643 次查看
josegardo
Contributor I

I have tried it but It does not work.

I was able to update the FTM2_C0V value stopping the counter CLKS=00 and the restarting again. But this solution is not valid for me. FTM2 is the synchornization time in a CDMA system and it can not be stopped. This is the code:

{void setTimer(void)

  FTM2_SC &=(uint32_t)~0x18UL;

  FTM2_C0V=0x7FFF;

  FTM2_SC |=(uint32_t)0x18UL;

  FTM2_C0SC &= (uint32_t)~0x80UL;    //Clear flag to clean previous channel matches

  FTM2_C0SC |= (uint32_t)0x40UL;        // Channel match interrupt enabled

}

Any other solution?

Thanks,

Jose

0 项奖励
回复

1,643 次查看
Robinwithu
Senior Contributor I

Hi Jose,

give me sometime i will look into that.if you will get the solution please post it.

Thanks n Regards,

Robin

0 项奖励
回复

1,643 次查看
josegardo
Contributor I

Hi Robin,

I'll do that.

Thanks

Jose

0 项奖励
回复

1,643 次查看
Robinwithu
Senior Contributor I

Hi Jose,

so what was problem?

Thanks n Regards,

Robin

0 项奖励
回复

1,643 次查看
josegardo
Contributor I

Sorry, I mean that I'll post the solution if I resolve the problem.

Thanks

0 项奖励
回复

1,643 次查看
Robinwithu
Senior Contributor I

Hi Jose,

can you mail me your complete code so that i can simulate on my pc.?

my email           robinwithu@yahoo.co.in

Thanks n Regards,

Robin

0 项奖励
回复

1,643 次查看
Robinwithu
Senior Contributor I

Hi Jose,

can you initilize your FTM_MOD  to 0xFFFF , register in first case and see the result.

Regards,

Robin

0 项奖励
回复