s32K14X FTM0 compare output mode,set C0V failed

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

s32K14X FTM0 compare output mode,set C0V failed

Jump to solution
751 Views
John_zhou2
Contributor I

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:

20231205-164714.jpg

      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    

0 Kudos
Reply
1 Solution
714 Views
danielmartynek
NXP TechSupport
NXP TechSupport

Can you strictly follow the FTM Initialization Procedure (RM, Section 47.8)?

 

Thank you

 

 

View solution in original post

0 Kudos
Reply
4 Replies
727 Views
danielmartynek
NXP TechSupport
NXP TechSupport

Hi @John_zhou2,

danielmartynek_0-1701773923562.png

Can you place

set c0v value:C0V[0:15] = 0xFFFF;

After

set c0sc value:C0SC[0:15] = 0x50;         // output compare mode

 

Thanks,

 

Regadrs,

Daniel

0 Kudos
Reply
723 Views
John_zhou2
Contributor I

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

0 Kudos
Reply
715 Views
danielmartynek
NXP TechSupport
NXP TechSupport

Can you strictly follow the FTM Initialization Procedure (RM, Section 47.8)?

 

Thank you

 

 

0 Kudos
Reply
676 Views
John_zhou2
Contributor I

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

0 Kudos
Reply