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
解決済! 解決策の投稿を見る。
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..
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..