<?xml version="1.0" encoding="UTF-8"?>
<rss xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#" xmlns:taxo="http://purl.org/rss/1.0/modules/taxonomy/" version="2.0">
  <channel>
    <title>topic Re: S32K144 FTM Interrupt in S32K</title>
    <link>https://community.nxp.com/t5/S32K/S32K144-FTM-Interrupt/m-p/994535#M5860</link>
    <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hello,&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;You can refer to the example ftm_periodic_interrupt within the SDK. This project does exactly what you are trying to achieve, you can use this as a base to see what you are missing on your project that is causing the error you are seeing.&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Have a great day,&lt;/P&gt;&lt;P&gt;Victor&lt;/P&gt;&lt;P&gt;-------------------------------------------------------------------------------&lt;BR /&gt;Note:&lt;BR /&gt;- If this post answers your question, please click the "Mark Correct" button. Thank you!&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;- We are following threads for 7 weeks after the last post, later replies are ignored&lt;BR /&gt; Please open a new thread and refer to the closed one, if you have a related question at a later point in time.&lt;BR /&gt;-------------------------------------------------------------------------------&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
    <pubDate>Fri, 22 Nov 2019 20:00:27 GMT</pubDate>
    <dc:creator>victorjimenez</dc:creator>
    <dc:date>2019-11-22T20:00:27Z</dc:date>
    <item>
      <title>S32K144 FTM Interrupt</title>
      <link>https://community.nxp.com/t5/S32K/S32K144-FTM-Interrupt/m-p/994534#M5859</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hello, please trouble you again, may I ask to finish the FTM interrupt, let the LED flash, I don't know what is wrong with my code, the phenomenon is that the LED light is always on, thank you&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;#include "S32K144.h" /* include peripheral declarations S32K144 */&lt;BR /&gt;#include "s32_core_cm4.h"&lt;/P&gt;&lt;P&gt;void WDOG_disable (void)&lt;BR /&gt;{&lt;BR /&gt; WDOG-&amp;gt;CNT=0xD928C520; //解锁看门狗&lt;BR /&gt; WDOG-&amp;gt;TOVAL=0x0000FFFF; //把时间配置为最大&lt;BR /&gt; WDOG-&amp;gt;CS = 0x00002100; //关闭看门狗&lt;BR /&gt;}&lt;/P&gt;&lt;P&gt;void SOSC_init_8MHz(void)&lt;BR /&gt;{&lt;BR /&gt; SCG-&amp;gt;SOSCDIV=0x00000101; //SOSCDIV1 &amp;amp; SOSCDIV2 =1: 分频/1&lt;BR /&gt; SCG-&amp;gt;SOSCCFG=0x00000024; //Range=2: 选择晶体振荡器的中频范围 (SOSC 1MHz-8MHz)&lt;BR /&gt; // HGO=0: 控制晶体振荡器的工作功率模式 --低功率模式&lt;BR /&gt; // EREFS=1: 外部参考选择OSC内部晶体振荡器&lt;BR /&gt; while(SCG-&amp;gt;SOSCCSR &amp;amp; SCG_SOSCCSR_LK_MASK); //等待SOSCCSR解锁 寄存器解锁后才可写入&lt;BR /&gt; SCG-&amp;gt;SOSCCSR=0x00000001; // LK=0: SOSCCSR可以写&lt;BR /&gt; // SOSCCM=0: 系统OSC时钟监视器被禁用&lt;BR /&gt; // SOSCEN=1: 启用系统OSC&lt;BR /&gt; while(!(SCG-&amp;gt;SOSCCSR &amp;amp; SCG_SOSCCSR_SOSCVLD_MASK)); //等待系统OSC成功启用，输出时钟有效&lt;BR /&gt;}&lt;/P&gt;&lt;P&gt;&lt;BR /&gt;void SPLL_init_160MHz(void)&lt;BR /&gt;{&lt;BR /&gt; while(SCG-&amp;gt;SPLLCSR &amp;amp; SCG_SPLLCSR_LK_MASK); //等待SPLLCSR寄存器解锁 寄存器解锁后才可写入&lt;BR /&gt; SCG-&amp;gt;SPLLCSR = 0x00000000; // LK=0: SPLLCSR可以写入&lt;BR /&gt; // SPLLEN=0: SPLL禁用&lt;BR /&gt; SCG-&amp;gt;SPLLDIV = 0x00000302; // SPLLDIV1 分频/2; SPLLDIV2 分频/4&lt;BR /&gt; SCG-&amp;gt;SPLLCFG = 0x00180000; // PREDIV=0: 锁相环参考时钟分频因子&lt;BR /&gt; // MULT=24: SPLL时钟频率的乘法因子&lt;BR /&gt; // SPLL_CLK = 8MHz / 1 * 40 / 2 = 160 MHz SPLL_CLK = (VCO_CLK)/2 VCO_CLK = SPLL_SOURCE/(PREDIV+1)*(MULT+16)&lt;BR /&gt; while(SCG-&amp;gt;SPLLCSR &amp;amp; SCG_SPLLCSR_LK_MASK); //等待SPLLCSR寄存器解锁 寄存器解锁后才可写入&lt;BR /&gt; SCG-&amp;gt;SPLLCSR = 0x00000001; // LK=0: SPLLCSR可以写入&lt;BR /&gt; // SPLLCM=0: SPLL时钟监视器被禁用&lt;BR /&gt; // SPLLEN=1: 开启SPLL&lt;BR /&gt; while(!(SCG-&amp;gt;SPLLCSR &amp;amp; SCG_SPLLCSR_SPLLVLD_MASK)); //等待SPLL成功启用，输出时钟有效&lt;BR /&gt;}&lt;/P&gt;&lt;P&gt;void NormalRUNmode_40MHz (void)&lt;BR /&gt;{&lt;BR /&gt; SCG-&amp;gt;RCCR=SCG_RCCR_SCS(6) // SPLL做为系统时钟源&lt;BR /&gt; |SCG_RCCR_DIVCORE(0b11) // DIVCORE=3, 分频/4: Core clock = 160/4 MHz = 40 MHz&lt;BR /&gt; |SCG_RCCR_DIVBUS(0b11) // DIVBUS=3, 分频/4: bus clock = 160/4 MHz = 40 MHz&lt;BR /&gt; |SCG_RCCR_DIVSLOW(0b111); // DIVSLOW=7, 分频/8: SCG slow, flash clock= 160/8 MHz = 20MHZ&lt;BR /&gt; while (((SCG-&amp;gt;CSR &amp;amp; SCG_CSR_SCS_MASK) &amp;gt;&amp;gt; SCG_CSR_SCS_SHIFT ) != 6) {}//等待系统时钟源成功选择SPLL&lt;BR /&gt;}&lt;/P&gt;&lt;P&gt;void FTM2_init_40MHZ(void)&lt;BR /&gt;{&lt;BR /&gt; PCC-&amp;gt;PCCn[PCC_FTM2_INDEX] &amp;amp;= ~PCC_PCCn_CGC_MASK; //禁止FTM2时钟&lt;BR /&gt; PCC-&amp;gt;PCCn[PCC_FTM2_INDEX] |= PCC_PCCn_PCS(0) | PCC_PCCn_CGC_MASK;//时钟关闭，可以启动外部时钟&lt;/P&gt;&lt;P&gt;FTM2-&amp;gt;MODE |= FTM_MODE_WPDIS_MASK; //写保护禁用&lt;BR /&gt; FTM2-&amp;gt;MODE |= FTM_MODE_FTMEN_MASK; //FTM使能 开始写寄存器&lt;BR /&gt; FTM2-&amp;gt;SC = 0;//清除状态寄存器&lt;BR /&gt; FTM2-&amp;gt;SC |= FTM_SC_TOIE_MASK | FTM_SC_PS(0);// 计数器溢出中断 分频因子选择 000b Divide by 1&lt;BR /&gt; FTM2-&amp;gt;SC &amp;amp;= ~FTM_SC_TOF_MASK;//清除计数器溢出标志&lt;/P&gt;&lt;P&gt;FTM2-&amp;gt;COMBINE = 0x00000000;//DECAPENx, MCOMBINEx, COMBINEx=0&lt;BR /&gt; FTM2-&amp;gt;POL = 0x00000000; //设置通道输出的极性&lt;BR /&gt; FTM2-&amp;gt;CNTIN = 0;&lt;BR /&gt; FTM2-&amp;gt;MOD = 2560 -1; //设置计数器终止值 配置中断时间 2560 *2ctr_clks* 0.025 = 128us&lt;BR /&gt; /* FTM3 Period = MOD-CNTIN+0x0001 ~= 2 ctr clks */&lt;BR /&gt; /* 40MHz / 1 = 40MHz 1/40MHZ = 0.025us */&lt;BR /&gt; FTM2-&amp;gt;SC |= FTM_SC_CLKS(62); //选择时钟源&lt;BR /&gt;}&lt;BR /&gt;void GPIO_Init(void)&lt;BR /&gt;{&lt;BR /&gt; /*******LED——RUN端口配置*******/&lt;BR /&gt; PCC-&amp;gt;PCCn[PCC_PORTD_INDEX] |= PCC_PCCn_CGC_MASK; //使能PTD端口时钟&lt;BR /&gt; PTD-&amp;gt;PDDR |= (1&amp;lt;&amp;lt;12); //配置PTD12为输出端口&lt;BR /&gt; PORTD-&amp;gt;PCR[12] = 0x00000100; //配置PTD12为GPIO，不使用其他复用功能&lt;BR /&gt; PTD-&amp;gt;PDOR &amp;amp;= ~(1&amp;lt;&amp;lt;12); //PTD12输出低电平&lt;/P&gt;&lt;P&gt;&lt;BR /&gt;}&lt;/P&gt;&lt;P&gt;void FTM2_NVIC_init_IRQs (void)&lt;BR /&gt;{&lt;BR /&gt; S32_NVIC-&amp;gt;ICPR[1] = 1 &amp;lt;&amp;lt; (116 % 32); /* IRQ122-FTM0 ch0: clr any pending IRQ*/&lt;BR /&gt; S32_NVIC-&amp;gt;ISER[(uint32_t)(FTM2_Ovf_Reload_IRQn) &amp;gt;&amp;gt; 5U] = (uint32_t)(1UL &amp;lt;&amp;lt; ((uint32_t)(FTM2_Ovf_Reload_IRQn) &amp;amp; (uint32_t)0x1FU));&lt;BR /&gt; S32_NVIC-&amp;gt;IP[116] = 0xb; /* IRQ122-FTM0 ch0: priority 10 of 0-15*/&lt;BR /&gt;}&lt;/P&gt;&lt;P&gt;int main(void)&lt;BR /&gt;{&lt;BR /&gt; WDOG_disable(); //关闭看门狗&lt;BR /&gt; SOSC_init_8MHz(); //配置系统振荡器为外部8MHZ&lt;BR /&gt; SPLL_init_160MHz(); //使用SOSC 8MHZ配置SPLL 为160 MHz&lt;BR /&gt; NormalRUNmode_40MHz(); //配置系列时钟40MHz, 40MHz总线时钟&lt;/P&gt;&lt;P&gt;FTM2_init_40MHZ(); //配置FTM2 定时中断 128us&lt;BR /&gt; FTM2_NVIC_init_IRQs(); //配置FTM3中断优先级&lt;BR /&gt; GPIO_Init();&lt;/P&gt;&lt;P&gt;//for(;;)&lt;BR /&gt; //PTD-&amp;gt;PDOR |= 1&amp;lt;&amp;lt;12;&lt;BR /&gt; if(FTM2-&amp;gt;SC &amp;amp;= ~FTM_SC_TOF_MASK)&lt;BR /&gt; {&lt;BR /&gt; PTD-&amp;gt;PDOR |= 1&amp;lt;&amp;lt;12;&lt;BR /&gt; }&lt;BR /&gt; if(FTM2-&amp;gt;SC |= FTM_SC_TOIE_MASK)&lt;BR /&gt; {&lt;BR /&gt; PTE-&amp;gt;PDOR &amp;amp;= ~(1&amp;lt;&amp;lt;12);&lt;BR /&gt; }&lt;/P&gt;&lt;P&gt;&lt;BR /&gt; return 0;&lt;BR /&gt;}&lt;BR /&gt;//void FTM2_Ovf_Reload_IRQHandler (void)&lt;BR /&gt;//{&lt;BR /&gt;// //产生FTM2中断&lt;BR /&gt;// FTM2-&amp;gt;SC &amp;amp;= ~FTM_SC_TOF_MASK; //清除中断标志&lt;BR /&gt;//}&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Fri, 15 Nov 2019 10:26:23 GMT</pubDate>
      <guid>https://community.nxp.com/t5/S32K/S32K144-FTM-Interrupt/m-p/994534#M5859</guid>
      <dc:creator>1416899748</dc:creator>
      <dc:date>2019-11-15T10:26:23Z</dc:date>
    </item>
    <item>
      <title>Re: S32K144 FTM Interrupt</title>
      <link>https://community.nxp.com/t5/S32K/S32K144-FTM-Interrupt/m-p/994535#M5860</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hello,&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;You can refer to the example ftm_periodic_interrupt within the SDK. This project does exactly what you are trying to achieve, you can use this as a base to see what you are missing on your project that is causing the error you are seeing.&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Have a great day,&lt;/P&gt;&lt;P&gt;Victor&lt;/P&gt;&lt;P&gt;-------------------------------------------------------------------------------&lt;BR /&gt;Note:&lt;BR /&gt;- If this post answers your question, please click the "Mark Correct" button. Thank you!&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;- We are following threads for 7 weeks after the last post, later replies are ignored&lt;BR /&gt; Please open a new thread and refer to the closed one, if you have a related question at a later point in time.&lt;BR /&gt;-------------------------------------------------------------------------------&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Fri, 22 Nov 2019 20:00:27 GMT</pubDate>
      <guid>https://community.nxp.com/t5/S32K/S32K144-FTM-Interrupt/m-p/994535#M5860</guid>
      <dc:creator>victorjimenez</dc:creator>
      <dc:date>2019-11-22T20:00:27Z</dc:date>
    </item>
  </channel>
</rss>

