<?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: Unexpected PWM Behavior on S32K142 Using FTM3 – Duty Cycle Not Updating in S32K</title>
    <link>https://community.nxp.com/t5/S32K/Unexpected-PWM-Behavior-on-S32K142-Using-FTM3-Duty-Cycle-Not/m-p/2187256#M53608</link>
    <description>&lt;P&gt;Hi&amp;nbsp;&lt;A href="https://community.nxp.com/t5/user/viewprofilepage/user-id/199320" target="_self"&gt;&lt;SPAN class=""&gt;_Leo_&lt;/SPAN&gt;&lt;/A&gt;,&lt;/P&gt;&lt;P&gt;thanks for your answer.&amp;nbsp;&lt;/P&gt;&lt;P&gt;To be honest it was not helpful for me because it was not related to my question. I asked in detail if the FTM3 configuration for a certain PWM duty cycle update is correct or if it is necessary to stop the counter each time which I don't believe and which is contradictionary to the reference manual. Maybe I'm interpreting something wrong here.&lt;/P&gt;&lt;P&gt;I have to stick to my development environment for other reasons (BTW I didn't mention which version I am using currently) and wanted to clarify this problem without using any additional driver code but from register level and basic understanding of the reference manual.&lt;/P&gt;&lt;P&gt;Kind regards&lt;BR /&gt;Armin&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
    <pubDate>Thu, 16 Oct 2025 07:17:54 GMT</pubDate>
    <dc:creator>ArminD</dc:creator>
    <dc:date>2025-10-16T07:17:54Z</dc:date>
    <item>
      <title>Unexpected PWM Behavior on S32K142 Using FTM3 – Duty Cycle Not Updating</title>
      <link>https://community.nxp.com/t5/S32K/Unexpected-PWM-Behavior-on-S32K142-Using-FTM3-Duty-Cycle-Not/m-p/2186721#M53582</link>
      <description>&lt;P&gt;Dear NXP Support Team,&lt;BR /&gt;&lt;BR /&gt;I am currently working with the S32K142 microcontroller and using six PWM channels via the FTM3 module. The system clock is configured to 80 MHz. My application reads an ADC value from a potentiometer (ranging from 0 to approximately 1900 LSBs) and maps it to the PWM duty cycle.&lt;/P&gt;&lt;P&gt;&lt;BR /&gt;However, I am experiencing an issue where the duty cycle does not update during runtime, even though the ADC values are changing correctly. As a temporary workaround, I stop the FTM3 timer before writing to the CnV registers and restart it afterwards. This approach works, but it is not ideal for a real-time application.&lt;/P&gt;&lt;P&gt;It seems that the synchronization mechanism is not working as expected. I would like to understand the root cause of this behavior and whether there is a recommended way to update the duty cycle during runtime without stopping the timer.&lt;/P&gt;&lt;P&gt;&lt;BR /&gt;To support this, I am preparing a minimal example demonstrating the issue. I would appreciate any insights or suggestions you can provide regarding proper PWM synchronization with FTM3 on the S32K142.&lt;/P&gt;&lt;P&gt;Initialisation:&lt;/P&gt;&lt;LI-CODE lang="markup"&gt;void FTM3_PWM_Init_Basic(void)
{
    // Clock aktivieren
    PCC-&amp;gt;PCCn[PCC_FTM3_INDEX] |= PCC_PCCn_CGC_MASK;
    PCC-&amp;gt;PCCn[PCC_PORTD_INDEX] |= PCC_PCCn_CGC_MASK;

    // PTD3 als FTM3_CH5 konfigurieren (ALT2)
    PORTD-&amp;gt;PCR[3] = PORT_PCR_MUX(2);

    // FTM-Modus aktivieren
    FTM3-&amp;gt;MODE |= FTM_MODE_WPDIS_MASK | FTM_MODE_FTMEN_MASK;

    // Timer konfigurieren (noch nicht starten!)
    FTM3-&amp;gt;SC = 0; // Timer gestoppt
    FTM3-&amp;gt;MOD = PWM_PERIOD_TICKS;

    // Kanal 5 konfigurieren
    FTM3-&amp;gt;CONTROLS[5].CnSC = FTM_CnSC_MSB_MASK | FTM_CnSC_ELSB_MASK;
    FTM3-&amp;gt;CONTROLS[5].CnV = PWM_PERIOD_TICKS / 2; // 50% Duty

    // PWM-Ausgabe aktivieren
    FTM3-&amp;gt;SC |= FTM_SC_PWMEN5_MASK;

    // Jetzt Timer starten
    FTM3-&amp;gt;SC |= FTM_SC_CLKS(1) | FTM_SC_PS(0); // System Clock, Prescaler = 1
}&lt;/LI-CODE&gt;&lt;P&gt;Duty-Update that does not work:&lt;/P&gt;&lt;LI-CODE lang="markup"&gt;void FTM3_PWM_Update(uint16_t adcValue)
{
    uint16_t dutyTicks = (adcValue * PWM_PERIOD_TICKS) / MAX_ADC_VALUE;

    // 1. PWM-Ausgabe kurz maskieren, um Glitches zu vermeiden
    FTM3-&amp;gt;OUTMASK = 0x20; // Maske für CH5 (Bit 5)

    // 2. Duty-Cycle in gepuffertes Register schreiben
    FTM3-&amp;gt;CONTROLS[5].CnV = dutyTicks;

    // 3. Synchronisation auslösen → übernimmt CnV und OUTMASK
    FTM3-&amp;gt;SYNC |= FTM_SYNC_SWSYNC_MASK;

    // 4. PWM-Ausgabe wieder aktivieren
    FTM3-&amp;gt;OUTMASK = 0x00;
    FTM3-&amp;gt;SYNC |= FTM_SYNC_SWSYNC_MASK;
}&lt;/LI-CODE&gt;&lt;P&gt;Duty-Update that works:&lt;/P&gt;&lt;LI-CODE lang="markup"&gt;void FTM3_PWM_Update(uint16_t adcValue)
{
    uint16_t dutyTicks = (adcValue * PWM_PERIOD_TICKS) / MAX_ADC_VALUE;

    // Timer stoppen
    FTM3-&amp;gt;SC &amp;amp;= ~FTM_SC_CLKS_MASK;

    // CnV schreiben
    FTM3-&amp;gt;CONTROLS[5].CnV = dutyTicks;

    // Timer wieder starten
    FTM3-&amp;gt;SC |= FTM_SC_CLKS(1) | FTM_SC_PS(0);
}&lt;/LI-CODE&gt;&lt;P&gt;&lt;BR /&gt;Thanks and kind regards,&lt;BR /&gt;Armin&lt;/P&gt;</description>
      <pubDate>Wed, 15 Oct 2025 14:23:43 GMT</pubDate>
      <guid>https://community.nxp.com/t5/S32K/Unexpected-PWM-Behavior-on-S32K142-Using-FTM3-Duty-Cycle-Not/m-p/2186721#M53582</guid>
      <dc:creator>ArminD</dc:creator>
      <dc:date>2025-10-15T14:23:43Z</dc:date>
    </item>
    <item>
      <title>Re: Unexpected PWM Behavior on S32K142 Using FTM3 – Duty Cycle Not Updating</title>
      <link>https://community.nxp.com/t5/S32K/Unexpected-PWM-Behavior-on-S32K142-Using-FTM3-Duty-Cycle-Not/m-p/2186893#M53590</link>
      <description>&lt;P&gt;Thank you for your interest in our products and for contributing to our community.&lt;/P&gt;
&lt;P&gt;For development with S32K142 (or any other S32K1 derivative) we recommend to use the latest S32DS and RTD versions:&lt;/P&gt;
&lt;P&gt;&lt;EM&gt;• S32 Design Studio 3.6.4 – Windows/Linux&lt;/EM&gt;&lt;BR /&gt;&lt;EM&gt;• S32K1_S32M24X Real Time Drivers AUTOSAR R21-11 Version 3.0.0&lt;/EM&gt;&lt;/P&gt;
&lt;P&gt;To download IDE, go to &lt;A href="https://www.nxp.com/design/design-center/software/automotive-software-and-tools/s32-design-studio-ide/s32-design-studio-for-s32-platform:S32DS-S32PLATFORM" target="_blank" rel="noopener"&gt;S32 Design Studio for S32 Platform&lt;/A&gt; page &lt;EM&gt;-&amp;gt; Downloads -&amp;gt; &lt;/EM&gt;&lt;BR /&gt;&lt;EM&gt;S32 Design Studio 3.6.4 – Windows/Linux&lt;/EM&gt;&lt;/P&gt;
&lt;P&gt;To download RTD, go to &lt;A href="https://www.nxp.com/products/S32K1" target="_blank" rel="noopener"&gt;S32K1&lt;/A&gt; page &lt;EM&gt;-&amp;gt; Design Resources -&amp;gt; Software-&amp;gt; Real-Time Drivers for S32K1 -&amp;gt; Automotive SW - S32K1_S32M24x - Real-Time Drivers for Cortex-M&lt;/EM&gt;&lt;/P&gt;
&lt;P&gt;Please check before &lt;STRONG&gt;Release Notes&lt;/STRONG&gt; for installation flow/details to each SW.&lt;/P&gt;
&lt;P&gt;Once you have installed SW, you could refer to FTM examples.&lt;/P&gt;
&lt;P&gt;By updating to the latest version of RTD you will benefit from recent bug fixes and performance improvements. The current version you're using is several releases behind, which may affect stability and compatibility. Keeping RTD up to date ensures you have access to the latest features and enhancements.&lt;/P&gt;
&lt;P&gt;I hope this information is helpful. Feel free to reach out if you have any further questions using Real-Time Drivers (RTD).&lt;/P&gt;</description>
      <pubDate>Wed, 15 Oct 2025 20:03:00 GMT</pubDate>
      <guid>https://community.nxp.com/t5/S32K/Unexpected-PWM-Behavior-on-S32K142-Using-FTM3-Duty-Cycle-Not/m-p/2186893#M53590</guid>
      <dc:creator>_Leo_</dc:creator>
      <dc:date>2025-10-15T20:03:00Z</dc:date>
    </item>
    <item>
      <title>Re: Unexpected PWM Behavior on S32K142 Using FTM3 – Duty Cycle Not Updating</title>
      <link>https://community.nxp.com/t5/S32K/Unexpected-PWM-Behavior-on-S32K142-Using-FTM3-Duty-Cycle-Not/m-p/2187256#M53608</link>
      <description>&lt;P&gt;Hi&amp;nbsp;&lt;A href="https://community.nxp.com/t5/user/viewprofilepage/user-id/199320" target="_self"&gt;&lt;SPAN class=""&gt;_Leo_&lt;/SPAN&gt;&lt;/A&gt;,&lt;/P&gt;&lt;P&gt;thanks for your answer.&amp;nbsp;&lt;/P&gt;&lt;P&gt;To be honest it was not helpful for me because it was not related to my question. I asked in detail if the FTM3 configuration for a certain PWM duty cycle update is correct or if it is necessary to stop the counter each time which I don't believe and which is contradictionary to the reference manual. Maybe I'm interpreting something wrong here.&lt;/P&gt;&lt;P&gt;I have to stick to my development environment for other reasons (BTW I didn't mention which version I am using currently) and wanted to clarify this problem without using any additional driver code but from register level and basic understanding of the reference manual.&lt;/P&gt;&lt;P&gt;Kind regards&lt;BR /&gt;Armin&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Thu, 16 Oct 2025 07:17:54 GMT</pubDate>
      <guid>https://community.nxp.com/t5/S32K/Unexpected-PWM-Behavior-on-S32K142-Using-FTM3-Duty-Cycle-Not/m-p/2187256#M53608</guid>
      <dc:creator>ArminD</dc:creator>
      <dc:date>2025-10-16T07:17:54Z</dc:date>
    </item>
  </channel>
</rss>

