<?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>8-bit Microcontrollers中的主题 Re: PWM in HCS08PA16 stays silent</title>
    <link>https://community.nxp.com/t5/8-bit-Microcontrollers/PWM-in-HCS08PA16-stays-silent/m-p/1269149#M23343</link>
    <description>&lt;P&gt;OK, so let me put some code how it is initialized :&lt;/P&gt;&lt;P&gt;mov #0,t0modh&lt;BR /&gt;mov #100,t0modl&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; modulo value is set&lt;BR /&gt;mov #%00001011,T0SC&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; clock source and prescaler&lt;/P&gt;&lt;P&gt;MOV #%00101000,T0SC1&amp;nbsp;&amp;nbsp;&amp;nbsp; PWM Edge, High active&lt;BR /&gt;mov #0,t0ch1h&lt;BR /&gt;mov #10,t0ch1l&lt;/P&gt;&lt;P&gt;On pin related to Timer 0 Channel 1 low state all the time.&lt;/P&gt;&lt;P&gt;The version with interrupts as below :&lt;/P&gt;&lt;P&gt;MOV #%01101000,T0SC1 ;PWM Edge, High active&lt;BR /&gt;mov #0,t0ch1h&lt;BR /&gt;mov #10,t0ch1l&lt;BR /&gt;lda t0sc1&lt;BR /&gt;bclr ch01f,t0sc1&lt;BR /&gt;bset chie01,t0sc1&lt;/P&gt;&lt;P&gt;----------------------&lt;/P&gt;&lt;P&gt;&lt;BR /&gt;pwm:&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; interrupt from T0CH1 service routine&lt;/P&gt;&lt;P&gt;lda t0sc1&lt;BR /&gt;bclr ch01f,t0sc1&lt;BR /&gt;mov #0,t0ch1h&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; refreshing this value just for tirial (later on it will be increased in steps)&lt;BR /&gt;mov #10,t0ch1l&lt;BR /&gt;rti&lt;/P&gt;&lt;P&gt;this interrupt works and is called when counter reaches channel value indeed. But pin 29 (LQFP32) still stays on low state.&lt;/P&gt;&lt;P&gt;So what is wrong ??&lt;/P&gt;</description>
    <pubDate>Tue, 27 Apr 2021 21:42:51 GMT</pubDate>
    <dc:creator>lucyperek</dc:creator>
    <dc:date>2021-04-27T21:42:51Z</dc:date>
    <item>
      <title>PWM in HCS08PA16 stays silent</title>
      <link>https://community.nxp.com/t5/8-bit-Microcontrollers/PWM-in-HCS08PA16-stays-silent/m-p/1267674#M23342</link>
      <description>&lt;P&gt;Hi,&lt;/P&gt;&lt;P&gt;maybe strange but I've started to suspect a bug in MCU. I want to generate just simple, trivial PWM on T0CH1 output pin (pin 29 in LQFP32 package). I went through all application notes, read several times RM. I have also tried differenet configurations : with ISR (updating channel registers - edge mode) or w/o. Also playing with MODE and other registers gives no results. Output pin stays at low level (but debugger shows counter activity and interrupt from timer 0 channel 1 works..).&lt;/P&gt;&lt;P&gt;Pin is not burned - I have configured it as I/O pin toggling at timer 0 overflow with required modulo also set up). So what can be the reason ? Frankly speaking I had several times problems with this PWM so I have generated it "manually" but this time I just want to "unload" from MCU this task .&lt;/P&gt;&lt;P&gt;regards&lt;/P&gt;&lt;P&gt;Jacek&lt;/P&gt;</description>
      <pubDate>Sun, 25 Apr 2021 16:05:28 GMT</pubDate>
      <guid>https://community.nxp.com/t5/8-bit-Microcontrollers/PWM-in-HCS08PA16-stays-silent/m-p/1267674#M23342</guid>
      <dc:creator>lucyperek</dc:creator>
      <dc:date>2021-04-25T16:05:28Z</dc:date>
    </item>
    <item>
      <title>Re: PWM in HCS08PA16 stays silent</title>
      <link>https://community.nxp.com/t5/8-bit-Microcontrollers/PWM-in-HCS08PA16-stays-silent/m-p/1269149#M23343</link>
      <description>&lt;P&gt;OK, so let me put some code how it is initialized :&lt;/P&gt;&lt;P&gt;mov #0,t0modh&lt;BR /&gt;mov #100,t0modl&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; modulo value is set&lt;BR /&gt;mov #%00001011,T0SC&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; clock source and prescaler&lt;/P&gt;&lt;P&gt;MOV #%00101000,T0SC1&amp;nbsp;&amp;nbsp;&amp;nbsp; PWM Edge, High active&lt;BR /&gt;mov #0,t0ch1h&lt;BR /&gt;mov #10,t0ch1l&lt;/P&gt;&lt;P&gt;On pin related to Timer 0 Channel 1 low state all the time.&lt;/P&gt;&lt;P&gt;The version with interrupts as below :&lt;/P&gt;&lt;P&gt;MOV #%01101000,T0SC1 ;PWM Edge, High active&lt;BR /&gt;mov #0,t0ch1h&lt;BR /&gt;mov #10,t0ch1l&lt;BR /&gt;lda t0sc1&lt;BR /&gt;bclr ch01f,t0sc1&lt;BR /&gt;bset chie01,t0sc1&lt;/P&gt;&lt;P&gt;----------------------&lt;/P&gt;&lt;P&gt;&lt;BR /&gt;pwm:&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; interrupt from T0CH1 service routine&lt;/P&gt;&lt;P&gt;lda t0sc1&lt;BR /&gt;bclr ch01f,t0sc1&lt;BR /&gt;mov #0,t0ch1h&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; refreshing this value just for tirial (later on it will be increased in steps)&lt;BR /&gt;mov #10,t0ch1l&lt;BR /&gt;rti&lt;/P&gt;&lt;P&gt;this interrupt works and is called when counter reaches channel value indeed. But pin 29 (LQFP32) still stays on low state.&lt;/P&gt;&lt;P&gt;So what is wrong ??&lt;/P&gt;</description>
      <pubDate>Tue, 27 Apr 2021 21:42:51 GMT</pubDate>
      <guid>https://community.nxp.com/t5/8-bit-Microcontrollers/PWM-in-HCS08PA16-stays-silent/m-p/1269149#M23343</guid>
      <dc:creator>lucyperek</dc:creator>
      <dc:date>2021-04-27T21:42:51Z</dc:date>
    </item>
    <item>
      <title>Re: PWM in HCS08PA16 stays silent</title>
      <link>https://community.nxp.com/t5/8-bit-Microcontrollers/PWM-in-HCS08PA16-stays-silent/m-p/1269910#M23344</link>
      <description>&lt;P&gt;Sorry I am not good in ASM code but I have a C code that maybe can help you&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;/P&gt;
&lt;P&gt;#define OVF_COUNTS 50&lt;BR /&gt;unsigned char counts = OVF_COUNTS; //number of Timer Overflows before increasing the pulse-width&lt;BR /&gt;unsigned char up_down = 0; //0 for up, 1 for down&lt;BR /&gt;unsigned int capture;&lt;/P&gt;
&lt;P&gt;&lt;BR /&gt;void main(void) {&lt;BR /&gt;EnableInterrupts;&lt;BR /&gt;/* include your code here */&lt;BR /&gt;/* WDOG_CNT: CNT=0xC520 */&lt;BR /&gt;WDOG_CNT = 0xC520; /* First part of the WDG unlock sequence */ &lt;BR /&gt;/* WDOG_CNT: CNT=0xD928 */&lt;BR /&gt;WDOG_CNT = 0xD928; /* Second part of the WDG unlock sequence */ &lt;BR /&gt;/* WDOG_TOVAL: TOVAL=4 */&lt;BR /&gt;WDOG_TOVAL = 0x04; &lt;BR /&gt;/* WDOG_CS2: WIN=0,FLG=0,??=0,PRES=0,??=0,??=0,CLK=1 */&lt;BR /&gt;WDOG_CS2 = 0x01; &lt;BR /&gt;/* WDOG_CS1: EN=0,INT=0,UPDATE=0,TST=0,DBG=0,WAIT=0,STOP=0 */&lt;BR /&gt;WDOG_CS1 = 0x00; /* Disable watchdog */ &lt;BR /&gt;&lt;BR /&gt;//PTG0's Output Enable Register is set to enable output &lt;BR /&gt;PORT_PTGOE_PTGOE0 = 1 ;&lt;BR /&gt;//PTG0 pin is driven low (LED ON)&lt;BR /&gt;PORT_PTGD_PTGD0 = 0; &lt;BR /&gt;// FTM clock = BUSCLK = 8MHz, Overflow Interrupt Enabled&lt;BR /&gt;FTM2_SC = FTM2_SC_CLKS0_MASK | FTM2_SC_TOIE_MASK; &lt;BR /&gt;FTM2_MOD = 8000; // PWM frequency is about 1 KHz&lt;BR /&gt;&lt;BR /&gt;// Configure channel 0 to PWM mode (high-true pulses) &lt;BR /&gt;FTM2_C0SC = FTM2_C0SC_ELSB_MASK | FTM2_C0SC_MSB_MASK;&lt;BR /&gt;FTM2_C0V = 80; // channel 0 set to 1%&lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt;// FTM clock = BUSCLK = 8MHz&lt;BR /&gt;FTM1_SC = FTM1_SC_CLKS0_MASK; &lt;BR /&gt;&lt;BR /&gt;// Configure channel 0 to input capture mode, falling edge, channnel interrupt enable. &lt;BR /&gt;FTM1_C0SC = FTM1_C0SC_ELSB_MASK|FTM1_C0SC_CHIE_MASK;&lt;BR /&gt;&lt;BR /&gt;&lt;/P&gt;
&lt;P&gt;for(;;) {&lt;BR /&gt;// __RESET_WATCHDOG(); /* feeds the dog */&lt;BR /&gt;} /* loop forever */&lt;BR /&gt;/* please make sure that you never leave main */&lt;BR /&gt;}&lt;/P&gt;
&lt;P&gt;&lt;BR /&gt;/**************************************************************************************************/&lt;/P&gt;
&lt;P&gt;interrupt VectorNumber_Vftm2ovf void FTM2ovfISR (void)&lt;BR /&gt;{&lt;BR /&gt;//Clear interrupt flag&lt;BR /&gt;(void)FTM2_SC;&lt;BR /&gt;FTM2_SC_TOF = 0;&lt;BR /&gt;&lt;BR /&gt;counts--;&lt;BR /&gt;if (!counts)&lt;BR /&gt;{ &lt;BR /&gt;if (!up_down) //up counting&lt;BR /&gt;{&lt;BR /&gt;FTM2_C0V += 80;&lt;BR /&gt;if (FTM2_C0V == 7920) up_down = 1;&lt;BR /&gt;//when reaching 99%, change to down counting&lt;BR /&gt;} &lt;BR /&gt;else &lt;BR /&gt;{&lt;BR /&gt;FTM2_C0V -= 80;&lt;BR /&gt;if (FTM2_C0V == 80) up_down = 0;&lt;BR /&gt;//when reaching 1%, change to up counting&lt;BR /&gt;} &lt;BR /&gt;counts = OVF_COUNTS; &lt;BR /&gt;}&lt;BR /&gt;}&lt;/P&gt;
&lt;P&gt;/**************************************************************************************************/&lt;/P&gt;
&lt;P&gt;interrupt VectorNumber_Vftm1ch0 void FTM1ch0ISR (void)&lt;BR /&gt;{&lt;BR /&gt;//Clear interrupt flag&lt;BR /&gt;(void)FTM1_C0SC;&lt;BR /&gt;FTM1_C0SC_CHF = 0;&lt;BR /&gt;PORT_PTGD_PTGD0 = ~PORT_PTGD_PTGD0;&lt;BR /&gt;capture = FTM1_C0V;&lt;/P&gt;
&lt;P&gt;}&lt;/P&gt;
&lt;P&gt;/**************************************************************************************************/&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Wed, 28 Apr 2021 22:35:21 GMT</pubDate>
      <guid>https://community.nxp.com/t5/8-bit-Microcontrollers/PWM-in-HCS08PA16-stays-silent/m-p/1269910#M23344</guid>
      <dc:creator>vicentegomez</dc:creator>
      <dc:date>2021-04-28T22:35:21Z</dc:date>
    </item>
    <item>
      <title>Re: PWM in HCS08PA16 stays silent</title>
      <link>https://community.nxp.com/t5/8-bit-Microcontrollers/PWM-in-HCS08PA16-stays-silent/m-p/1270718#M23345</link>
      <description>&lt;P&gt;Vicent, in your code there are many command which, according to RM are not needed. They do not say anything about enabling overflow interrupts. But I think that I have discovered the solution.......&lt;/P&gt;&lt;P&gt;I will check it more carefully but it looks that two commands sequence is critical for this operation :&lt;/P&gt;&lt;P&gt;1. First the channel status register MUST be configured for PWM, edge etc.&lt;/P&gt;&lt;P&gt;2. Then channel value registers must be set&lt;/P&gt;&lt;P&gt;If these channel registers will be loaded first and THEN the status register (ELSEA:B, MSA:B etc) as the second one, the PWM doesn't work. OK, it can be so but it's a pity that it is not VERY clearly mentioned in RM or AN that this sequence is critical and must be respected.&lt;/P&gt;&lt;P&gt;regards, Jacek&lt;/P&gt;</description>
      <pubDate>Fri, 30 Apr 2021 07:34:49 GMT</pubDate>
      <guid>https://community.nxp.com/t5/8-bit-Microcontrollers/PWM-in-HCS08PA16-stays-silent/m-p/1270718#M23345</guid>
      <dc:creator>lucyperek</dc:creator>
      <dc:date>2021-04-30T07:34:49Z</dc:date>
    </item>
    <item>
      <title>Re: PWM in HCS08PA16 stays silent</title>
      <link>https://community.nxp.com/t5/8-bit-Microcontrollers/PWM-in-HCS08PA16-stays-silent/m-p/1270955#M23346</link>
      <description>&lt;P&gt;I believe that in the old S08 RM there is a note for that, but not sure&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Regards&lt;/P&gt;
&lt;P&gt;Vicente&amp;nbsp;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Fri, 30 Apr 2021 17:13:49 GMT</pubDate>
      <guid>https://community.nxp.com/t5/8-bit-Microcontrollers/PWM-in-HCS08PA16-stays-silent/m-p/1270955#M23346</guid>
      <dc:creator>vicentegomez</dc:creator>
      <dc:date>2021-04-30T17:13:49Z</dc:date>
    </item>
    <item>
      <title>Re: PWM in HCS08PA16 stays silent</title>
      <link>https://community.nxp.com/t5/8-bit-Microcontrollers/PWM-in-HCS08PA16-stays-silent/m-p/1271359#M23347</link>
      <description>&lt;P&gt;Vicente,&lt;/P&gt;&lt;P&gt;in old SH8 RM there is quite detailed description of PWM but they mainly concentrate on Timer Channel writing sequence. OK, no problem, luckily I have discovered how to initialize PWM. But would be very helpful if NXP could make a small correction in RM specifying in bold that such a sequence is necessary (first TxSCx configuration and &lt;STRONG&gt;after that&lt;/STRONG&gt; writing channel values).&lt;/P&gt;&lt;P&gt;Thanks for your replies !!&lt;/P&gt;&lt;P&gt;best regards&lt;/P&gt;&lt;P&gt;Jacek&lt;/P&gt;</description>
      <pubDate>Mon, 03 May 2021 16:31:46 GMT</pubDate>
      <guid>https://community.nxp.com/t5/8-bit-Microcontrollers/PWM-in-HCS08PA16-stays-silent/m-p/1271359#M23347</guid>
      <dc:creator>lucyperek</dc:creator>
      <dc:date>2021-05-03T16:31:46Z</dc:date>
    </item>
  </channel>
</rss>

