Dear sir,
Board: S32k146
I used S32K146 Board test FTM function, my init FTM like this:
void init_ftm0(void)
{
disabled write protect.MODE[2] = 0b1;
stop FTM0 clock, SC[3:4] = 0b00;
set modulo value, MOD[0:15] = 0xFFFF;
set citin value: CNTIN[0:15] = 0x0;
set c0v value:C0V[0:15] = 0xFFFF; (1)
set c0sc value:C0SC[0:15] = 0x50; // output compare mode
start FTM0, SC[3:4] = 0b10;
}
When I used step mode debug the code, run (1) code, it can be set the C0V reg 0xFFFF, but when I set a breakpoint after this function, and full speed to breakpoint, the C0V reg can't set.
I'm only want used ftm0 in out compare mode, and trigger an interrupt when the comparison value is reached.
I see the RM 47.5.12.3:
Before set C0V, the FTM0 clock is disable, so it may be not limited by the markings in the basket.
Question 1: How can the register values be set correctly when the timer clock is off.
Question 2: If the CLKS[0:1] not equal 0:0, when the FTM0 clk select RTC_CLK, it only 32K freq, FTM counter change 1 need 0.0325ms, it is very slow to upfate C0V.Is there any way to set the C0V value immediately.
Thanks.
BR, John.zhou
Solved! Go to Solution.
Can you strictly follow the FTM Initialization Procedure (RM, Section 47.8)?
Thank you
Hi @John_zhou2,
Can you place
set c0v value:C0V[0:15] = 0xFFFF;
After
set c0sc value:C0SC[0:15] = 0x50; // output compare mode
Thanks,
Regadrs,
Daniel
Hi Daniel,
I place
set c0v value:C0V[0:15] = 0xFFFF;
after
set c0sc value:C0SC[0:15] = 0x50; // output compare mode
The C0V can't set correct also.
Is there other way to set the C0V.
BR.
John
Can you strictly follow the FTM Initialization Procedure (RM, Section 47.8)?
Thank you
Hi Daniel,
After many attempts at this, the C0V register can be set correctly.
I did exactly the steps recommended in the manual, although
there were a lot of registers I didn't use. Thank you.
And this issue can be close.
BR.
John