<?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: PWM won't show up on pin in 8-bit Microcontrollers</title>
    <link>https://community.nxp.com/t5/8-bit-Microcontrollers/PWM-won-t-show-up-on-pin/m-p/158787#M9386</link>
    <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;I changed the clock source from the external clock to the BUSCLK and it works!&amp;nbsp; Not really sure why that would solve it, but I'm seeing the signal now.&amp;nbsp; Here's the updated code:&lt;/P&gt;&lt;PRE&gt;/** PWM frequency in Hz */#define PWM_FREQ      20000  //Hz#define BUS_FREQ        24000000#define TPM1_PRESCALER  1   //preescaler of 1    /*************************************************************************** MAIN ROUTINE**************************************************************************/void main(void){ unsigned int PWMValue = 1000; initSys(); TPM1MOD = (BUS_FREQ/TPM1_PRESCALER/PWM_FREQ);  TPM1C3SC = 0x28;  TPM1C3V = PWMValue; TPM1SC = 0x08;  //BUSCLK selected as source for(;;){}}&lt;/PRE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
    <pubDate>Thu, 29 Oct 2020 09:03:51 GMT</pubDate>
    <dc:creator>mahnac</dc:creator>
    <dc:date>2020-10-29T09:03:51Z</dc:date>
    <item>
      <title>PWM won't show up on pin</title>
      <link>https://community.nxp.com/t5/8-bit-Microcontrollers/PWM-won-t-show-up-on-pin/m-p/158784#M9383</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;I would like to use PWM to change the intensity of an LED, but the PWM signal from TPM1CH3 won't show up on the pin! I'm using the Tower development board with the S08MM128. Here is the code I've loaded onto the MCU:&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;#include &amp;lt;hidef.h&amp;gt; /* for EnableInterrupts macro */&lt;BR /&gt;#include "derivative.h" /* include peripheral declarations */&lt;BR /&gt;void initSys(void);&lt;BR /&gt;void initMCG(void);&lt;BR /&gt;void initMCU(void);&lt;BR /&gt;void Pwm1_Init(void);&lt;BR /&gt;void Pwm1_Start(unsigned int dutyCycle);&lt;BR /&gt;void Pwm1_Stop(void);&lt;/P&gt;&lt;P&gt;/** PWM frequency in Hz */&lt;BR /&gt;#define PWM_FREQ ((unsigned long)(20000)) //Hz&lt;BR /&gt;#define BUS_FREQ ((unsigned long)(24000000))&lt;BR /&gt;#define TPM1_PRESCALER (1) //preescaler of 1&lt;BR /&gt;#define TPM1_PRESCALER_VALUE (0b000) //preescaler of 1&lt;BR /&gt;#define TPM1_TICK_FREQ ((unsigned long)(BUS_FREQ/TPM1_PRESCALER))&lt;BR /&gt;#define TPM1C3SC_VALUE (TPM1C3SC_MS3B_MASK|TPM1C3SC_ELS3B_MASK)&lt;BR /&gt;#define TPM1_SC_VALUE ((unsigned char)(TPM1_PRESCALER_VALUE)&lt;BR /&gt;#define TPM1_MOD_VALUE ((unsigned int)(TPM1_TICK_FREQ/PWM_FREQ))&lt;BR /&gt;#define TMP1_CLEAR_OV_FLAG() TPM1SC_TOF = 0x00&lt;BR /&gt;#define TPM_MAX_VAL (unsigned long)(TPM1_TICK_FREQ/PWM_FREQ)&lt;BR /&gt;#define TPM1C3_PIN_DD PTDDD_PTDDD5&lt;BR /&gt;#define TPM1C3_PIN_D PTDD_PTDD5&lt;BR /&gt;#define TPM1_START() TPM1SC_CLKSx = 0x1&lt;BR /&gt;#define TPM1_STOP() TPM1SC_CLKSx = 0x0&lt;BR /&gt;/**************************************************************************&lt;BR /&gt;* MAIN ROUTINE&lt;BR /&gt;**************************************************************************/&lt;BR /&gt;void main(void)&lt;BR /&gt;{&lt;BR /&gt;unsigned int PWMValue = 100;&lt;BR /&gt;initSys();&lt;BR /&gt;Pwm1_Init();&lt;BR /&gt;for(;&lt;A href="http://freescale.i.lithium.com/i/smilies/16x16_smiley-wink.gif"&gt;&lt;IMG alt=":smileywink:" class="emoticon emoticon-smileywink" src="http://freescale.i.lithium.com/i/smilies/16x16_smiley-wink.gif" title="Smiley Wink" /&gt;&lt;/A&gt;&lt;BR /&gt;{&lt;BR /&gt;Pwm1_Start(PWMValue);&lt;BR /&gt;Pwm1_Stop();&lt;BR /&gt;}&lt;BR /&gt;}&lt;/P&gt;&lt;P&gt;void Pwm1_Init(void)&lt;BR /&gt;{&lt;BR /&gt;TPM1C3_PIN_D = 0;&lt;BR /&gt;TPM1C3_PIN_DD = 1;&lt;BR /&gt;&lt;BR /&gt;TPM1SC = TPM1_SC_VALUE;&lt;BR /&gt;TPM1MOD = TPM1_MOD_VALUE;&lt;BR /&gt;&lt;BR /&gt;TPM1C3SC = TPM1C3SC_VALUE;&lt;BR /&gt;&lt;BR /&gt;PTFDD_PTFDD2 = 1;&lt;BR /&gt;}&lt;/P&gt;&lt;P&gt;void Pwm1_Start(unsigned int dutyCycle)&lt;BR /&gt;{&lt;BR /&gt;TPM1C3_PIN_D = 0;&lt;BR /&gt;TPM1C3SC = TPM1C3SC_VALUE;&lt;BR /&gt;&lt;BR /&gt;if (dutyCycle == 0)&lt;BR /&gt;{&lt;BR /&gt;return; //don't start pwm&lt;BR /&gt;}&lt;BR /&gt;else if(dutyCycle &amp;gt;= TPM_MAX_VAL)&lt;BR /&gt;{&lt;BR /&gt;TPM1C3_PIN_D = 1;&lt;BR /&gt;return; //don't start pwm&lt;BR /&gt;}&lt;BR /&gt;else&lt;BR /&gt;{&lt;BR /&gt;TPM1C3V = (dutyCycle);&lt;BR /&gt;TPM1CNT = 0;&lt;BR /&gt;asm (nop);&lt;BR /&gt;asm (nop);&lt;BR /&gt;asm (nop);&lt;/P&gt;&lt;P&gt;TPM1_START();&lt;BR /&gt;}&lt;BR /&gt;}&lt;/P&gt;&lt;P&gt;void Pwm1_Stop(void)&lt;BR /&gt;{&lt;BR /&gt;TPM1_STOP();&lt;BR /&gt;TPM1C3SC = 0;&lt;BR /&gt;TPM1C3_PIN_D = 0;&lt;BR /&gt;TPM1CNT = 0;&lt;BR /&gt;}&lt;/P&gt;&lt;P&gt;/**************************************************************************&lt;BR /&gt;* SYSTEM INITIALIZATION ROUTINES&lt;BR /&gt;**************************************************************************/&lt;BR /&gt;void initSys(void)&lt;BR /&gt;{&lt;BR /&gt;initMCU();&lt;BR /&gt;initMCG();&lt;BR /&gt;}&lt;BR /&gt;void initMCU(void)&lt;BR /&gt;{&lt;BR /&gt;//System Options 2 Register&lt;BR /&gt;SOPT2 = 0x10;&lt;BR /&gt;/*0b00010000&lt;BR /&gt;||||||||__ bit0: Analog Comparator output not connected to TPM1&lt;BR /&gt;|||||||___ bit1: RESERVED&lt;BR /&gt;||||||____ bit2: RESERVED&lt;BR /&gt;|||||_____ bit3: RESERVED&lt;BR /&gt;||||______ bit4: CLKOUT_EN BUSCLK is available on external pin PTC7&lt;BR /&gt;|||_______ bit5: RESERVED&lt;BR /&gt;||________ bit6: COP normal mode selected&lt;BR /&gt;|_________ bit7: --- */&lt;BR /&gt;&lt;BR /&gt;//SIM Clock Set and Select Register&lt;BR /&gt;SIMCO = 0x04;&lt;BR /&gt;/*0b00000100&lt;BR /&gt;||||||||__ bit0: CS[0] CLKOUT = BUSCLK&lt;BR /&gt;|||||||___ bit1: CS[1]&lt;BR /&gt;||||||____ bit2: CS[2]&lt;BR /&gt;|||||_____ bit3: RESERVED&lt;BR /&gt;||||______ bit4: RESERVED&lt;BR /&gt;|||_______ bit5: RESERVED&lt;BR /&gt;||________ bit6: RESERVED&lt;BR /&gt;|_________ bit7: RESERVED */&lt;BR /&gt;&lt;BR /&gt;//System Options 1 Register&lt;BR /&gt;SOPT1 = 0x23;&lt;BR /&gt;/*0b00100011&lt;BR /&gt;||||||||__ bit0: RESET# pin enabled&lt;BR /&gt;|||||||___ bit1: BKGD/MS pin enabled&lt;BR /&gt;||||||____ bit2: RESERVED&lt;BR /&gt;|||||_____ bit3: BLMS Satus (read only)&lt;BR /&gt;||||______ bit4: RESERVEd&lt;BR /&gt;|||_______ bit5: Stop mode enabled&lt;BR /&gt;||________ bit6: COPT[0] COP is disabled&lt;BR /&gt;|_________ bit7: COPT[1] */&lt;BR /&gt;}&lt;BR /&gt;void initMCG(void)&lt;BR /&gt;{&lt;BR /&gt;//FBE MODE&lt;BR /&gt;/* Assume 16MHz external clock source connected. */&lt;BR /&gt;// RANGE = 1; HGO = 1; ERCLKEN=1; EREFS = 1; BDIV = 000&lt;BR /&gt;MCGC2 = 0x36;&lt;BR /&gt;/*0b00110110&lt;BR /&gt;||||||||_ bit0: EREFSTEN external reference clock is disabled in stop&lt;BR /&gt;|||||||__ bit1: ERCKLEN MCGERCLK active&lt;BR /&gt;||||||___ bit2: EREFS Oscillator requested&lt;BR /&gt;|||||____ bit3: LP FLL not disabled in bypass modes&lt;BR /&gt;||||_____ bit4: HGO Configure crystal oscillator for high gain operation&lt;BR /&gt;|||______ bit5: RANGE High frequency range selected&lt;BR /&gt;||_______ bit6: BDIV[0]=0&lt;BR /&gt;|________ bit7: BDIV[1]=0 Divides clock by 1 */&lt;BR /&gt;&lt;BR /&gt;// DIV32 =1&lt;BR /&gt;MCGC3 = 0x11;&lt;BR /&gt;/*0b00010001&lt;BR /&gt;||||||||_ bit0: VDIV[0]=0&lt;BR /&gt;|||||||__ bit1: VDIV[1]=0&lt;BR /&gt;||||||___ bit2: VDIV[2]=0&lt;BR /&gt;|||||____ bit3: VDIV[3]=0 ???&lt;BR /&gt;||||_____ bit4: DIV32 Divide-by-32 is enabled when RANGE=1&lt;BR /&gt;|||______ bit5: CME clock monitor is disabled&lt;BR /&gt;||_______ bit6: PLLS FLL is selected&lt;BR /&gt;|________ bit7: LOLIE no request on loss of lock */&lt;BR /&gt;&lt;BR /&gt;// CLKS = 10; RDIV = 100; IREFS = 0;&lt;BR /&gt;MCGC1 = 0xA0;&lt;BR /&gt;/*0b10100000&lt;BR /&gt;||||||||_ bit0: IREFSTEN internal ref clk disabled in stop&lt;BR /&gt;|||||||__ bit1: IRCLKEN MCGIRCLK inactive&lt;BR /&gt;||||||___ bit2: IREFS external reference clock selected&lt;BR /&gt;|||||____ bit3: RDIV[0]=0&lt;BR /&gt;||||_____ bit4: RDIV[1]=0&lt;BR /&gt;|||______ bit5: RDIV[2]=1 divide factor = 512 (since RANGE=1,DIV32=1)&lt;BR /&gt;||_______ bit6: CLKS[0]=0&lt;BR /&gt;|________ bit7: CLKS[1]=1 external reference clock is selected */&lt;/P&gt;&lt;P&gt;// Wait for Reference Status bit to update&lt;BR /&gt;while (MCGSC_IREFST);&lt;BR /&gt;// Wait for clock status bits to update&lt;BR /&gt;while (MCGSC_CLKST != 0b10);&lt;/P&gt;&lt;P&gt;//PBE MODE&lt;/P&gt;&lt;P&gt;// PLLS =1; DIV32 = 1; VDIV = 1001&lt;BR /&gt;MCGC3 = 0x5c;&lt;BR /&gt;/*0b01011100&lt;BR /&gt;||||||||_ bit0: VDIV[0]=0&lt;BR /&gt;|||||||__ bit1: VDIV[1]=0&lt;BR /&gt;||||||___ bit2: VDIV[2]=1&lt;BR /&gt;|||||____ bit3: VDIV[3]=1 Multiply by 48&lt;BR /&gt;||||_____ bit4: DIV32 Divide-by-32 is enabled when RANGE=1&lt;BR /&gt;|||______ bit5: CME clock monitor is disabled&lt;BR /&gt;||_______ bit6: PLLS PLL is selected&lt;BR /&gt;|________ bit7: LOLIE no request on loss of lock */&lt;BR /&gt;// wait for PLL status bit to update&lt;BR /&gt;while (!MCGSC_PLLST);&lt;BR /&gt;// Wait for LOCK bit to set&lt;BR /&gt;while (!MCGSC_LOCK);&lt;BR /&gt;&lt;BR /&gt;//PEE MODE&lt;/P&gt;&lt;P&gt;// CLKS = 00; RDIV = 100; IREFS = 0&lt;BR /&gt;MCGC1 = 0x20;&lt;BR /&gt;/*0b00100000&lt;BR /&gt;||||||||_ bit0: IREFSTEN internal ref clk disabled in stop&lt;BR /&gt;|||||||__ bit1: IRCLKEN MCGIRCLK inactive&lt;BR /&gt;||||||___ bit2: IREFS external reference clock selected&lt;BR /&gt;|||||____ bit3: RDIV[0]=0&lt;BR /&gt;||||_____ bit4: RDIV[1]=0&lt;BR /&gt;|||______ bit5: RDIV[2]=1 divide factor = 512 (since RANGE=1,DIV32=1)&lt;BR /&gt;||_______ bit6: CLKS[0]=0&lt;BR /&gt;|________ bit7: CLKS[1]=0 output of FLL or PLL is selected */&lt;BR /&gt;// Wait for clock status bits to update&lt;BR /&gt;while (MCGSC_CLKST != 0b11); ;&lt;BR /&gt;&lt;BR /&gt;/* Now MCGOUT=48MHz, BUS_CLOCK=24MHz */&lt;BR /&gt;}&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;To summarize, the bus clock is at 24MHz and the external clock source is a 16MHz xtal.&lt;/P&gt;&lt;P&gt;The TPM Module is configured in edge-aligned PWM mode for TPM1CH3. &amp;nbsp;The modulo value is 1200, and I'm updating TPM1C3V with a value of 100.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;On the Tower Development board, pin&amp;nbsp;PTD5/SCL/TPM1CH3 is routed to A7 on the A side expansion port. &amp;nbsp;I have an oscilloscope hooked up to this pin and when I run the code I do not see the PWM signal. &amp;nbsp;Please help!&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Thank you!&lt;/P&gt;&lt;P&gt;mahnac&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Mon, 30 Apr 2012 21:38:32 GMT</pubDate>
      <guid>https://community.nxp.com/t5/8-bit-Microcontrollers/PWM-won-t-show-up-on-pin/m-p/158784#M9383</guid>
      <dc:creator>mahnac</dc:creator>
      <dc:date>2012-04-30T21:38:32Z</dc:date>
    </item>
    <item>
      <title>Re: PWM won't show up on pin</title>
      <link>https://community.nxp.com/t5/8-bit-Microcontrollers/PWM-won-t-show-up-on-pin/m-p/158785#M9384</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hello Mahnac, and welcome to the forum.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;The main problem seems to be your main loop.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;FONT face="courier new,courier"&gt;for( ; ; ) {&lt;/FONT&gt;&lt;BR /&gt;&lt;FONT face="courier new,courier"&gt;&amp;nbsp;&amp;nbsp; Pwm1_Start(PWMValue);&lt;/FONT&gt;&lt;BR /&gt;&lt;FONT face="courier new,courier"&gt;&amp;nbsp;&amp;nbsp; Pwm1_Stop();&lt;/FONT&gt;&lt;BR /&gt;&lt;FONT face="courier new,courier"&gt;}&lt;/FONT&gt;&lt;/P&gt;&lt;P&gt;Your are continuously starting and stopping the PWM operation, so the output waveform will never start.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Another problem might be your TPM1_START() and TPM1_STOP() macros.&amp;nbsp; The register bit TPM1SC_CLKSx would seem an invalid name, unless it has been defined elsewhere.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;To my mind, the following macro definitions would be more meaningful.&lt;/P&gt;&lt;PRE&gt;#define TPM1_PS      0                        // preescale 1#define TPM1_START() TPM1SC = 0x08 | TPM1_PS  // Select bus clock#define TPM1_STOP()  TPM1SC = 0x00&lt;/PRE&gt;&lt;P&gt;&amp;nbsp;On a similar basis, I would use -&lt;/P&gt;&lt;P&gt;&lt;FONT face="courier new,courier"&gt;#define TPM1C3SC_value&amp;nbsp;&amp;nbsp;0x28&amp;nbsp;&amp;nbsp;&amp;nbsp;// PWM mode, high true pulse&lt;/FONT&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Also note that, whilst the TPM module is enabled, this will override any of the GPIO settings.&amp;nbsp; You may initialise the GPIO pin for when the TPM module is disabled, but it is unnessary to manipulate the pin&amp;nbsp;when the TPM module is running.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;A final issue - when defining constants, don't use casts, but use the suffix 'U' for unsigned and/or 'L' for 32-bit, as needed.&lt;/P&gt;&lt;P&gt;e.g.&lt;FONT face="courier new,courier"&gt;&amp;nbsp; #define PWM_FREQ&amp;nbsp; 20000UL&lt;/FONT&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Regards,&lt;/P&gt;&lt;P&gt;Mac&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Thu, 29 Oct 2020 09:03:48 GMT</pubDate>
      <guid>https://community.nxp.com/t5/8-bit-Microcontrollers/PWM-won-t-show-up-on-pin/m-p/158785#M9384</guid>
      <dc:creator>bigmac</dc:creator>
      <dc:date>2020-10-29T09:03:48Z</dc:date>
    </item>
    <item>
      <title>Re: PWM won't show up on pin</title>
      <link>https://community.nxp.com/t5/8-bit-Microcontrollers/PWM-won-t-show-up-on-pin/m-p/158786#M9385</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hi bigmac&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Thanks for the speedy response!&amp;nbsp; Here's what I tried next:&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;=&amp;gt; The CodeWarrior compiler didn't like "&lt;FONT face="courier new,courier"&gt;#define PWM_FREQ&amp;nbsp; 20000UL" &lt;FONT face="arial,helvetica,sans-serif"&gt;So I took out the typecasting all together.&lt;/FONT&gt;&lt;/FONT&gt;&lt;/P&gt;&lt;P&gt;&lt;FONT face="courier new,courier"&gt;&lt;FONT face="arial,helvetica,sans-serif"&gt;=&amp;gt; I simply turned on the PWM, then entered an empty for loop forever.&lt;/FONT&gt;&lt;/FONT&gt;&lt;/P&gt;&lt;P&gt;&lt;FONT face="courier new,courier"&gt;&lt;FONT face="arial,helvetica,sans-serif"&gt;=&amp;gt; I cleaned up the code a bit.&amp;nbsp; The updated code is shown below (I didn't include the system config code, that remains the same)&lt;BR /&gt;&lt;/FONT&gt;&lt;/FONT&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;FONT face="courier new,courier"&gt;&lt;FONT face="arial,helvetica,sans-serif"&gt;All of the registers are updating - after running Pwm1_Init() and Pwm1_Start(), TPM1MOD = 1200, TPM1C3SC = 40, TPM1C3V = 100, and TPM1SC = 24.&amp;nbsp; But I'm still not seeing the signal on the oscilloscope.&amp;nbsp; The only change is that before starting TPM1, the pin is pulled high (this might be because of another function?&amp;nbsp; It's also the SCL pin), and then after the clock source is indicted (TPM1_START()), the pin goes low.&lt;/FONT&gt;&lt;/FONT&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;FONT face="courier new,courier"&gt;&lt;FONT face="arial,helvetica,sans-serif"&gt;Thanks again for your help!!&lt;/FONT&gt;&lt;/FONT&gt;&lt;/P&gt;&lt;P&gt;&lt;FONT face="courier new,courier"&gt;&lt;FONT face="arial,helvetica,sans-serif"&gt;- mahnac&lt;/FONT&gt;&lt;/FONT&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;FONT face="courier new,courier"&gt;&lt;FONT face="arial,helvetica,sans-serif"&gt;Here's the updated code:&lt;BR /&gt;&lt;/FONT&gt;&lt;/FONT&gt;&lt;/P&gt;&lt;PRE&gt;#define PWM_FREQ      20000  //Hz#define BUS_FREQ        24000000#define TPM1_PRESCALER  1   //preescaler of 1    #define TPM_MAX_VAL    (BUS_FREQ/TPM1_PRESCALER/PWM_FREQ)     #define TPM1_START()  TPM1SC = 0x18;#define TPM1_STOP()   TPM1SC = 0x00;/*************************************************************************** MAIN ROUTINE**************************************************************************/void main(void){ unsigned int PWMValue = 100; initSys(); Pwm1_Init(); Pwm1_Start(PWMValue); for(;;){}}void Pwm1_Init(void){    TPM1MOD = (BUS_FREQ/TPM1_PRESCALER/PWM_FREQ);    TPM1C3SC = 0x28;}void Pwm1_Start(unsigned int dutyCycle){ TPM1C3SC = 0x28;  if (dutyCycle == 0) {  return; //don't start pwm } else if(dutyCycle &amp;gt;= TPM_MAX_VAL) {  return; //don't start pwm } else {  TPM1C3V = (unsigned int)(dutyCycle);  TPM1CNT = 0;   asm (nop);   asm (nop);  asm (nop);  TPM1_START(); }}&lt;/PRE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;FONT face="courier new,courier"&gt;&lt;FONT face="arial,helvetica,sans-serif"&gt;&lt;BR /&gt;&lt;/FONT&gt;&lt;/FONT&gt;&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Thu, 29 Oct 2020 09:03:50 GMT</pubDate>
      <guid>https://community.nxp.com/t5/8-bit-Microcontrollers/PWM-won-t-show-up-on-pin/m-p/158786#M9385</guid>
      <dc:creator>mahnac</dc:creator>
      <dc:date>2020-10-29T09:03:50Z</dc:date>
    </item>
    <item>
      <title>Re: PWM won't show up on pin</title>
      <link>https://community.nxp.com/t5/8-bit-Microcontrollers/PWM-won-t-show-up-on-pin/m-p/158787#M9386</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;I changed the clock source from the external clock to the BUSCLK and it works!&amp;nbsp; Not really sure why that would solve it, but I'm seeing the signal now.&amp;nbsp; Here's the updated code:&lt;/P&gt;&lt;PRE&gt;/** PWM frequency in Hz */#define PWM_FREQ      20000  //Hz#define BUS_FREQ        24000000#define TPM1_PRESCALER  1   //preescaler of 1    /*************************************************************************** MAIN ROUTINE**************************************************************************/void main(void){ unsigned int PWMValue = 1000; initSys(); TPM1MOD = (BUS_FREQ/TPM1_PRESCALER/PWM_FREQ);  TPM1C3SC = 0x28;  TPM1C3V = PWMValue; TPM1SC = 0x08;  //BUSCLK selected as source for(;;){}}&lt;/PRE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Thu, 29 Oct 2020 09:03:51 GMT</pubDate>
      <guid>https://community.nxp.com/t5/8-bit-Microcontrollers/PWM-won-t-show-up-on-pin/m-p/158787#M9386</guid>
      <dc:creator>mahnac</dc:creator>
      <dc:date>2020-10-29T09:03:51Z</dc:date>
    </item>
    <item>
      <title>Re: PWM won't show up on pin</title>
      <link>https://community.nxp.com/t5/8-bit-Microcontrollers/PWM-won-t-show-up-on-pin/m-p/158788#M9387</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hello,&lt;/P&gt;&lt;BLOCKQUOTE&gt;&lt;HR /&gt;mahnac wrote:&lt;BR /&gt;&lt;P&gt;I changed the clock source from the external clock to the BUSCLK and it works!&amp;nbsp; Not really sure why that would solve it, but I'm seeing the signal now.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;HR /&gt;&lt;/BLOCKQUOTE&gt;&lt;P&gt;Selecting the external clock for the TPM module requires that a square wave clock signal be applied to the TPMCLK pin.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Regards,&lt;/P&gt;&lt;P&gt;Mac&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Thu, 03 May 2012 09:46:10 GMT</pubDate>
      <guid>https://community.nxp.com/t5/8-bit-Microcontrollers/PWM-won-t-show-up-on-pin/m-p/158788#M9387</guid>
      <dc:creator>bigmac</dc:creator>
      <dc:date>2012-05-03T09:46:10Z</dc:date>
    </item>
  </channel>
</rss>

