<?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>Kinetis Microcontrollers中的主题 Complementary PWM with Deadtime insertion</title>
    <link>https://community.nxp.com/t5/Kinetis-Microcontrollers/Complementary-PWM-with-Deadtime-insertion/m-p/709791#M43529</link>
    <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;I want to run #FRDMKW41ZUG &amp;nbsp;board with #MKW41Z mcu, using &amp;nbsp;frdmkw41z_driver_examples_tpm_combine_pwm example with #deadtime insertion, but cannot run it well. I try to change filter register directly with no result.&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper" image-alt="NewFile1.png"&gt;&lt;img src="https://community.nxp.com/t5/image/serverpage/image-id/31373iCCA51761C27AE034/image-size/large?v=v2&amp;amp;px=999" role="button" title="NewFile1.png" alt="NewFile1.png" /&gt;&lt;/span&gt;&lt;/P&gt;&lt;P&gt;You can see that no deadtime insertion.&lt;/P&gt;&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper" image-alt="NewFile2.png"&gt;&lt;img src="https://community.nxp.com/t5/image/serverpage/image-id/31423i2AB24A7836637A14/image-size/large?v=v2&amp;amp;px=999" role="button" title="NewFile2.png" alt="NewFile2.png" /&gt;&lt;/span&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Code from example:&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;#include "fsl_debug_console.h"&lt;BR /&gt;#include "board.h"&lt;BR /&gt;#include "fsl_tpm.h"&lt;/P&gt;&lt;P&gt;#include "pin_mux.h"&lt;BR /&gt;/*******************************************************************************&lt;BR /&gt; * Definitions&lt;BR /&gt; ******************************************************************************/&lt;BR /&gt;/* define instance */&lt;BR /&gt;#define BOARD_TPM_BASEADDR TPM2&lt;BR /&gt;/* TPM channel pair 0 works with TPM channels 0 and 1*/&lt;BR /&gt;#define BOARD_TPM_CHANNEL_PAIR kTPM_Chnl_0&lt;/P&gt;&lt;P&gt;/* Interrupt to enable and flag to read; depends on the TPM channel pair used */&lt;BR /&gt;//#define TPM_CHANNEL_INTERRUPT_ENABLE kTPM_Chnl0Interrupt&lt;BR /&gt;#define TPM_CHANNEL_FLAG kTPM_Chnl0Flag&lt;/P&gt;&lt;P&gt;/* Interrupt number and interrupt handler for the TPM instance used */&lt;BR /&gt;//#define TPM_INTERRUPT_NUMBER TPM2_IRQn&lt;BR /&gt;#define TPM_LED_HANDLER TPM2_IRQHandler&lt;BR /&gt;/* Get source clock for TPM driver */&lt;BR /&gt;#define TPM_SOURCE_CLOCK CLOCK_GetFreq(kCLOCK_McgFllClk)&lt;/P&gt;&lt;P&gt;/*******************************************************************************&lt;BR /&gt; * Prototypes&lt;BR /&gt; ******************************************************************************/&lt;/P&gt;&lt;P&gt;/*******************************************************************************&lt;BR /&gt; * Variables&lt;BR /&gt; ******************************************************************************/&lt;BR /&gt;volatile bool brightnessUp = true; /* Indicate LED is brighter or dimmer */&lt;BR /&gt;volatile uint8_t updatedDutycycle = 10U;&lt;BR /&gt;volatile uint8_t getCharValue = 0U;&lt;/P&gt;&lt;P&gt;/*******************************************************************************&lt;BR /&gt; * Code&lt;BR /&gt; ******************************************************************************/&lt;BR /&gt;/*!&lt;BR /&gt; * @brief Main function&lt;BR /&gt; */&lt;BR /&gt;int main(void)&lt;BR /&gt;{&lt;BR /&gt; tpm_config_t tpmInfo;&lt;BR /&gt; tpm_chnl_pwm_signal_param_t tpmParam;&lt;BR /&gt; tpm_pwm_level_select_t pwmLevel = kTPM_LowTrue;&lt;BR /&gt; uint8_t deadtimeValue;&lt;BR /&gt; uint32_t filterVal;&lt;/P&gt;&lt;P&gt;/* Configure tpm params with frequency 24kHZ */&lt;BR /&gt; tpmParam.chnlNumber = BOARD_TPM_CHANNEL_PAIR;&lt;BR /&gt; tpmParam.level = pwmLevel;&lt;BR /&gt; tpmParam.dutyCyclePercent = 35U;&lt;BR /&gt; tpmParam.firstEdgeDelayPercent = 0U;&lt;/P&gt;&lt;P&gt;/* Board pin, clock, debug console init */&lt;BR /&gt; BOARD_InitPins();&lt;BR /&gt; BOARD_BootClockRUN();&lt;BR /&gt; BOARD_InitDebugConsole();&lt;/P&gt;&lt;P&gt;/* Select the clock source for the TPM counter as MCGPLLCLK */&lt;BR /&gt; CLOCK_SetTpmClock(1U);&lt;/P&gt;&lt;P&gt;/* Need a deadtime value of about 200nsec */&lt;BR /&gt; deadtimeValue = (((uint64_t)TPM_SOURCE_CLOCK * 400) / 1000000000) / 4;&lt;/P&gt;&lt;P&gt;/* Print a note to terminal */&lt;BR /&gt; PRINTF("\r\nTPM example to output combined complementary PWM signals on two channels\r\n");&lt;BR /&gt; PRINTF("\r\nIf an LED is connected to the TPM pin, you will see a change in LED brightness if you enter different values");&lt;BR /&gt; PRINTF("\r\nIf no LED is connected to the TPM pin, then probe the signal using an oscilloscope");&lt;/P&gt;&lt;P&gt;TPM_GetDefaultConfig(&amp;amp;tpmInfo);&lt;/P&gt;&lt;P&gt;/* Initialize TPM module */&lt;BR /&gt; TPM_Init(BOARD_TPM_BASEADDR, &amp;amp;tpmInfo);&lt;/P&gt;&lt;P&gt;TPM_SetupPwm(BOARD_TPM_BASEADDR, &amp;amp;tpmParam, 1U, kTPM_CombinedPwm, 24000U, TPM_SOURCE_CLOCK);&lt;/P&gt;&lt;P&gt;#if defined(FSL_FEATURE_TPM_HAS_POL) &amp;amp;&amp;amp; FSL_FEATURE_TPM_HAS_POL&lt;BR /&gt; /* Change the polarity on the second channel of the pair to get complementary PWM signals */&lt;BR /&gt; BOARD_TPM_BASEADDR-&amp;gt;POL |= (1U &amp;lt;&amp;lt; ((BOARD_TPM_CHANNEL_PAIR * 2) + 1));&lt;BR /&gt;#endif&lt;/P&gt;&lt;P&gt;/* Set deadtime insertion for the channel pair using channel filter register */&lt;BR /&gt; filterVal = BOARD_TPM_BASEADDR-&amp;gt;FILTER;&lt;BR /&gt; /* Clear the channel pair's filter values */&lt;BR /&gt;// filterVal &amp;amp;= ~((TPM_FILTER_CH0FVAL_MASK | TPM_FILTER_CH1FVAL_MASK)&lt;BR /&gt;// &amp;lt;&amp;lt; (BOARD_TPM_CHANNEL_PAIR * (TPM_FILTER_CH0FVAL_SHIFT + TPM_FILTER_CH1FVAL_SHIFT)));&lt;BR /&gt; /* Shift the deadtime insertion value to the right place in the register */&lt;BR /&gt; filterVal |= (TPM_FILTER_CH0FVAL(deadtimeValue) | TPM_FILTER_CH1FVAL(deadtimeValue))&lt;BR /&gt; &amp;lt;&amp;lt; (BOARD_TPM_CHANNEL_PAIR * (TPM_FILTER_CH0FVAL_SHIFT + TPM_FILTER_CH1FVAL_SHIFT));&lt;BR /&gt; BOARD_TPM_BASEADDR-&amp;gt;FILTER = filterVal;&lt;/P&gt;&lt;P&gt;TPM_StartTimer(BOARD_TPM_BASEADDR, kTPM_SystemClock);&lt;/P&gt;&lt;P&gt;while (1) &amp;nbsp;{}&lt;/P&gt;&lt;P&gt;}&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Is anybody who run it well?&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
    <pubDate>Thu, 21 Sep 2017 15:22:00 GMT</pubDate>
    <dc:creator>vitaliycheban</dc:creator>
    <dc:date>2017-09-21T15:22:00Z</dc:date>
    <item>
      <title>Complementary PWM with Deadtime insertion</title>
      <link>https://community.nxp.com/t5/Kinetis-Microcontrollers/Complementary-PWM-with-Deadtime-insertion/m-p/709791#M43529</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;I want to run #FRDMKW41ZUG &amp;nbsp;board with #MKW41Z mcu, using &amp;nbsp;frdmkw41z_driver_examples_tpm_combine_pwm example with #deadtime insertion, but cannot run it well. I try to change filter register directly with no result.&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper" image-alt="NewFile1.png"&gt;&lt;img src="https://community.nxp.com/t5/image/serverpage/image-id/31373iCCA51761C27AE034/image-size/large?v=v2&amp;amp;px=999" role="button" title="NewFile1.png" alt="NewFile1.png" /&gt;&lt;/span&gt;&lt;/P&gt;&lt;P&gt;You can see that no deadtime insertion.&lt;/P&gt;&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper" image-alt="NewFile2.png"&gt;&lt;img src="https://community.nxp.com/t5/image/serverpage/image-id/31423i2AB24A7836637A14/image-size/large?v=v2&amp;amp;px=999" role="button" title="NewFile2.png" alt="NewFile2.png" /&gt;&lt;/span&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Code from example:&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;#include "fsl_debug_console.h"&lt;BR /&gt;#include "board.h"&lt;BR /&gt;#include "fsl_tpm.h"&lt;/P&gt;&lt;P&gt;#include "pin_mux.h"&lt;BR /&gt;/*******************************************************************************&lt;BR /&gt; * Definitions&lt;BR /&gt; ******************************************************************************/&lt;BR /&gt;/* define instance */&lt;BR /&gt;#define BOARD_TPM_BASEADDR TPM2&lt;BR /&gt;/* TPM channel pair 0 works with TPM channels 0 and 1*/&lt;BR /&gt;#define BOARD_TPM_CHANNEL_PAIR kTPM_Chnl_0&lt;/P&gt;&lt;P&gt;/* Interrupt to enable and flag to read; depends on the TPM channel pair used */&lt;BR /&gt;//#define TPM_CHANNEL_INTERRUPT_ENABLE kTPM_Chnl0Interrupt&lt;BR /&gt;#define TPM_CHANNEL_FLAG kTPM_Chnl0Flag&lt;/P&gt;&lt;P&gt;/* Interrupt number and interrupt handler for the TPM instance used */&lt;BR /&gt;//#define TPM_INTERRUPT_NUMBER TPM2_IRQn&lt;BR /&gt;#define TPM_LED_HANDLER TPM2_IRQHandler&lt;BR /&gt;/* Get source clock for TPM driver */&lt;BR /&gt;#define TPM_SOURCE_CLOCK CLOCK_GetFreq(kCLOCK_McgFllClk)&lt;/P&gt;&lt;P&gt;/*******************************************************************************&lt;BR /&gt; * Prototypes&lt;BR /&gt; ******************************************************************************/&lt;/P&gt;&lt;P&gt;/*******************************************************************************&lt;BR /&gt; * Variables&lt;BR /&gt; ******************************************************************************/&lt;BR /&gt;volatile bool brightnessUp = true; /* Indicate LED is brighter or dimmer */&lt;BR /&gt;volatile uint8_t updatedDutycycle = 10U;&lt;BR /&gt;volatile uint8_t getCharValue = 0U;&lt;/P&gt;&lt;P&gt;/*******************************************************************************&lt;BR /&gt; * Code&lt;BR /&gt; ******************************************************************************/&lt;BR /&gt;/*!&lt;BR /&gt; * @brief Main function&lt;BR /&gt; */&lt;BR /&gt;int main(void)&lt;BR /&gt;{&lt;BR /&gt; tpm_config_t tpmInfo;&lt;BR /&gt; tpm_chnl_pwm_signal_param_t tpmParam;&lt;BR /&gt; tpm_pwm_level_select_t pwmLevel = kTPM_LowTrue;&lt;BR /&gt; uint8_t deadtimeValue;&lt;BR /&gt; uint32_t filterVal;&lt;/P&gt;&lt;P&gt;/* Configure tpm params with frequency 24kHZ */&lt;BR /&gt; tpmParam.chnlNumber = BOARD_TPM_CHANNEL_PAIR;&lt;BR /&gt; tpmParam.level = pwmLevel;&lt;BR /&gt; tpmParam.dutyCyclePercent = 35U;&lt;BR /&gt; tpmParam.firstEdgeDelayPercent = 0U;&lt;/P&gt;&lt;P&gt;/* Board pin, clock, debug console init */&lt;BR /&gt; BOARD_InitPins();&lt;BR /&gt; BOARD_BootClockRUN();&lt;BR /&gt; BOARD_InitDebugConsole();&lt;/P&gt;&lt;P&gt;/* Select the clock source for the TPM counter as MCGPLLCLK */&lt;BR /&gt; CLOCK_SetTpmClock(1U);&lt;/P&gt;&lt;P&gt;/* Need a deadtime value of about 200nsec */&lt;BR /&gt; deadtimeValue = (((uint64_t)TPM_SOURCE_CLOCK * 400) / 1000000000) / 4;&lt;/P&gt;&lt;P&gt;/* Print a note to terminal */&lt;BR /&gt; PRINTF("\r\nTPM example to output combined complementary PWM signals on two channels\r\n");&lt;BR /&gt; PRINTF("\r\nIf an LED is connected to the TPM pin, you will see a change in LED brightness if you enter different values");&lt;BR /&gt; PRINTF("\r\nIf no LED is connected to the TPM pin, then probe the signal using an oscilloscope");&lt;/P&gt;&lt;P&gt;TPM_GetDefaultConfig(&amp;amp;tpmInfo);&lt;/P&gt;&lt;P&gt;/* Initialize TPM module */&lt;BR /&gt; TPM_Init(BOARD_TPM_BASEADDR, &amp;amp;tpmInfo);&lt;/P&gt;&lt;P&gt;TPM_SetupPwm(BOARD_TPM_BASEADDR, &amp;amp;tpmParam, 1U, kTPM_CombinedPwm, 24000U, TPM_SOURCE_CLOCK);&lt;/P&gt;&lt;P&gt;#if defined(FSL_FEATURE_TPM_HAS_POL) &amp;amp;&amp;amp; FSL_FEATURE_TPM_HAS_POL&lt;BR /&gt; /* Change the polarity on the second channel of the pair to get complementary PWM signals */&lt;BR /&gt; BOARD_TPM_BASEADDR-&amp;gt;POL |= (1U &amp;lt;&amp;lt; ((BOARD_TPM_CHANNEL_PAIR * 2) + 1));&lt;BR /&gt;#endif&lt;/P&gt;&lt;P&gt;/* Set deadtime insertion for the channel pair using channel filter register */&lt;BR /&gt; filterVal = BOARD_TPM_BASEADDR-&amp;gt;FILTER;&lt;BR /&gt; /* Clear the channel pair's filter values */&lt;BR /&gt;// filterVal &amp;amp;= ~((TPM_FILTER_CH0FVAL_MASK | TPM_FILTER_CH1FVAL_MASK)&lt;BR /&gt;// &amp;lt;&amp;lt; (BOARD_TPM_CHANNEL_PAIR * (TPM_FILTER_CH0FVAL_SHIFT + TPM_FILTER_CH1FVAL_SHIFT)));&lt;BR /&gt; /* Shift the deadtime insertion value to the right place in the register */&lt;BR /&gt; filterVal |= (TPM_FILTER_CH0FVAL(deadtimeValue) | TPM_FILTER_CH1FVAL(deadtimeValue))&lt;BR /&gt; &amp;lt;&amp;lt; (BOARD_TPM_CHANNEL_PAIR * (TPM_FILTER_CH0FVAL_SHIFT + TPM_FILTER_CH1FVAL_SHIFT));&lt;BR /&gt; BOARD_TPM_BASEADDR-&amp;gt;FILTER = filterVal;&lt;/P&gt;&lt;P&gt;TPM_StartTimer(BOARD_TPM_BASEADDR, kTPM_SystemClock);&lt;/P&gt;&lt;P&gt;while (1) &amp;nbsp;{}&lt;/P&gt;&lt;P&gt;}&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Is anybody who run it well?&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Thu, 21 Sep 2017 15:22:00 GMT</pubDate>
      <guid>https://community.nxp.com/t5/Kinetis-Microcontrollers/Complementary-PWM-with-Deadtime-insertion/m-p/709791#M43529</guid>
      <dc:creator>vitaliycheban</dc:creator>
      <dc:date>2017-09-21T15:22:00Z</dc:date>
    </item>
    <item>
      <title>Re: Complementary PWM with Deadtime insertion</title>
      <link>https://community.nxp.com/t5/Kinetis-Microcontrollers/Complementary-PWM-with-Deadtime-insertion/m-p/709792#M43530</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Helllo Vitaliy,&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;I have reported this issue to the SW team. I will update this thread when a resolution is available.&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Regards,&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Fri, 27 Oct 2017 17:13:15 GMT</pubDate>
      <guid>https://community.nxp.com/t5/Kinetis-Microcontrollers/Complementary-PWM-with-Deadtime-insertion/m-p/709792#M43530</guid>
      <dc:creator>gerardo_rodriguez</dc:creator>
      <dc:date>2017-10-27T17:13:15Z</dc:date>
    </item>
  </channel>
</rss>

