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

cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 

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

Jump to solution
982 Views
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 Kudos
1 Solution
636 Views
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..

View solution in original post

0 Kudos
1 Reply
637 Views
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 Kudos