Problem resetting FTM timers, what is the correct way to do it?

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

Problem resetting FTM timers, what is the correct way to do it?

ソリューションへジャンプ
1,256件の閲覧回数
zeal
Contributor II

I am using the ftm timer to measure rtos performance, I'm not using systick because it is reserved for the rtos.

 

The FTM timer is setup to use the core clock but the counter will overflow if performing multiple tests or doing stuff between tests. Therefore I want to reset it between tests.

 

If the clock overflows the counter stops, why doesn't it start over from 0?

If I try to reset the counter by using reset_ftm_timer() it stops.

If i run setup_ftm_timer twice, the counter stops.

 

What am I doing wrong?

 

 

 

#include "MK60N512MD100.h"

 

void setup_ftm_timer()
{

    SIM->SCGC6 |= SIM_SCGC6_FTM0_MASK;  
    FTM0->SC = 0x0;
    FTM0->MODE |= FTM_MODE_WPDIS_MASK;
    FTM0->MODE |= FTM_MODE_FTMEN_MASK;
    FTM0->CNT = 0x0;
    FTM0->CNTIN = 0;
    FTM0->SC = FTM_SC_CLKS(1);
}

 

void reset_ftm_timer() {
    FTM0->CNT = 0x0;
}

 

All input and feedback is appreciated

//Zeal

0 件の賞賛
返信
1 解決策
910件の閲覧回数
zeal
Contributor II

 FTM0->MOD has to be set, I wrongly assumed leaving it to 0 would behave as setting it to 0xFFFF letting the 16 bit registers overflow..

元の投稿で解決策を見る

0 件の賞賛
返信
1 返信
911件の閲覧回数
zeal
Contributor II

 FTM0->MOD has to be set, I wrongly assumed leaving it to 0 would behave as setting it to 0xFFFF letting the 16 bit registers overflow..

0 件の賞賛
返信