S32k148 - FTM timer as clock divider

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

S32k148 - FTM timer as clock divider

1,243 Views
jakub_mielczare
Contributor III

Hello,

Could you please provide sample code how to configure FTM Timer 5 channel 7 as divider of clock coming on TCLK0?

Thank you,

Jakub

Tags (1)
0 Kudos
4 Replies

1,132 Views
Robin_Shen
NXP TechSupport
NXP TechSupport

Hi Jakub,

I am sorry there is no sample code for FTM5.
But you can try to test it just modify below registers:

SIM_FTMOPT0[FTMnCLKSEL]=0

PCC_FLEXTMRn[PCS]=0

FTMn_SC[CLKS]=0b11

External clock need to be connect to TCLK0.

Table 27-9. Peripheral module clocking FTM.png

I have test on S32K148_Project_FTM example.

The CLKOUT signal(PTE10) output clock to TCLK0(PTB1), then I can see the FTM0_CH0 output signal.

S32K148_Project_FTM.png

PCC->PCCn[PCC_PORTB_INDEX ]|=PCC_PCCn_CGC_MASK; /* Enable clock for PORTB */

PORTB->PCR[1]|=PORT_PCR_MUX(4); /* Port B1: MUX = ALT4, TCLK0 */
PORTE->PCR[10]|=PORT_PCR_MUX(2); /* Port E10: MUX = ALT2, CLKOUT */

SIM->CHIPCTL=SIM_CHIPCTL_CLKOUTEN_MASK|SIM_CHIPCTL_CLKOUTSEL(0x02); //CLKOUT output 0010b - SOSC DIV2 CLK

PCC->PCCn[PCC_FTM0_INDEX] &= ~PCC_PCCn_CGC_MASK; /* Ensure clk disabled for config */
PCC->PCCn[PCC_FTM0_INDEX] |= PCC_PCCn_PCS(0b00)//PCC_PCCn_PCS(0b010) /* Clock Src=1, 8 MHz SIRCDIV1_CLK */
| PCC_PCCn_CGC_MASK; /* Enable clock for FTM regs */

Best Regards,

Robin

 

-----------------------------------------------------------------------------------------------------------------------
Note: If this post answers your question, please click the Correct Answer button. Thank you!
-----------------------------------------------------------------------------------------------------------------------

0 Kudos

1,132 Views
jakub_mielczare
Contributor III

Hi Robin,

Can FTM5 CH7 work as clock divider with up-counting and toggle on output compare?

Best regards,

Jakub

0 Kudos

1,132 Views
Robin_Shen
NXP TechSupport
NXP TechSupport

yes

47.4.3.2 Status And Control (SC)

This register will divide clock source from TCLK0.

Best Regards,

Robin

0 Kudos

1,132 Views
jakub_mielczare
Contributor III

Could you share example FTM5 register settings for this function?

0 Kudos