<?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>CodeWarrior Development ToolsのトピックRe: Reading Counter Register (PWMA_SMnCNT)</title>
    <link>https://community.nxp.com/t5/CodeWarrior-Development-Tools/Reading-Counter-Register-PWMA-SMnCNT/m-p/849256#M7310</link>
    <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hi, Md,&lt;/P&gt;&lt;P&gt;I do not think you can use your&amp;nbsp; code to start ADC.&lt;/P&gt;&lt;P&gt;you can use the process:&lt;/P&gt;&lt;P&gt;ADC_CTRL1 |= 1&amp;lt;&amp;lt;13; //start ADC&lt;/P&gt;&lt;P&gt;poll if the completion is over, read sample&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;for(;;) {&lt;BR /&gt;&amp;nbsp;&amp;nbsp;&lt;/P&gt;&lt;P&gt;ADC_CTRL1 |= 1&amp;lt;&amp;lt;13; //start ADC&lt;/P&gt;&lt;P&gt;//poll if the completion is over&lt;/P&gt;&lt;P&gt;while(!ADC_STAT&amp;amp;EOSI0) {}&lt;/P&gt;&lt;P&gt;unsigned int sample=ADC_RSLTx&lt;/P&gt;&lt;P&gt;}&lt;/P&gt;&lt;P&gt;Regarding the reducing the interrupt latency, you can use fast interrupt. Pls refer to the section:&lt;/P&gt;&lt;P&gt;12.3.3 Fast Interrupt Handling in RM of MC56F827xx.&lt;/P&gt;&lt;P&gt;You can use the signal in crossbar switch module to trigger ADC. pls refer to section 3.3.3 Inter-Peripheral Crossbar Switch (XBAR) and AND/OR/INVERT (AOI) Configuration&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Hope it can help you&lt;/P&gt;&lt;P&gt;BR&lt;/P&gt;&lt;P&gt;Xiangjun Rong&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
    <pubDate>Mon, 05 Nov 2018 09:03:27 GMT</pubDate>
    <dc:creator>xiangjun_rong</dc:creator>
    <dc:date>2018-11-05T09:03:27Z</dc:date>
    <item>
      <title>Reading Counter Register (PWMA_SMnCNT)</title>
      <link>https://community.nxp.com/t5/CodeWarrior-Development-Tools/Reading-Counter-Register-PWMA-SMnCNT/m-p/849253#M7307</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hi&lt;/P&gt;&lt;P&gt;I am trying to read the PWM counter register in MC56F827xx MCU (PWMA_SMnCNT) at a PWM reload ISR event (please see the attached code). It should read zero all the time as the reload event happens when the counter is reset, but, instead I read 143. Is there a delay once the Reload ISR is called and the counter register is read? Am I reading it correctly? Please help.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Thanks.&lt;/P&gt;&lt;P&gt;Rishad&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Mon, 29 Oct 2018 15:29:29 GMT</pubDate>
      <guid>https://community.nxp.com/t5/CodeWarrior-Development-Tools/Reading-Counter-Register-PWMA-SMnCNT/m-p/849253#M7307</guid>
      <dc:creator>rishadahmed</dc:creator>
      <dc:date>2018-10-29T15:29:29Z</dc:date>
    </item>
    <item>
      <title>Re: Reading Counter Register (PWMA_SMnCNT)</title>
      <link>https://community.nxp.com/t5/CodeWarrior-Development-Tools/Reading-Counter-Register-PWMA-SMnCNT/m-p/849254#M7308</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hi, Md,&lt;/P&gt;&lt;P&gt;I have reviewed your code, you enable Full Reload interrupt, in the ISR of Full Reload interrupt, you read the PWMA_SM0CNT;. From theory, the tick variable should be the value as PWMA_SM0INIT, which is zero.&lt;/P&gt;&lt;P&gt;As you know it takes time for the DSC core to execute ISR, for example, PC, SR register are stored to stack, jump to ISR, because you use the "#pragma interrupt saveall", all the DSC core registers have to be put into stack,that is why the delay exists and you get non-zero value when you read PWMA_SM0CNT;, it means that the PWMA_SM0CNT reaches up to 143 when you read it.&lt;/P&gt;&lt;P&gt;Pls delete the #pragma interrupt saveall and use #pragma interrupt on, have a try.&lt;/P&gt;&lt;P&gt;I suggest you toggle a GPIO in the ISR and compare the PWM and GPIO timing.&lt;/P&gt;&lt;P&gt;Hope it can help you&lt;/P&gt;&lt;P&gt;BR&lt;/P&gt;&lt;P&gt;Xiangjun Rong&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Tue, 30 Oct 2018 06:21:00 GMT</pubDate>
      <guid>https://community.nxp.com/t5/CodeWarrior-Development-Tools/Reading-Counter-Register-PWMA-SMnCNT/m-p/849254#M7308</guid>
      <dc:creator>xiangjun_rong</dc:creator>
      <dc:date>2018-10-30T06:21:00Z</dc:date>
    </item>
    <item>
      <title>Re: Reading Counter Register (PWMA_SMnCNT)</title>
      <link>https://community.nxp.com/t5/CodeWarrior-Development-Tools/Reading-Counter-Register-PWMA-SMnCNT/m-p/849255#M7309</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hi Xiangjun,&lt;/P&gt;&lt;P&gt;Thanks for your suggestion. &amp;nbsp;#pragma interrupt on slightly reduces the delay. If you can tell me any other way of further reduce the delay that would be great.&lt;/P&gt;&lt;P&gt;In another ISR , ADC High Limit Interrupt,&amp;nbsp;I am trying to read the ADC value at a specific point (please see the attached figure- I am trying to read the minimum value). I am using the following simple code to read the ADC result when the interrupt happens (Sample 0 &amp;gt; 0.85 V). However, I am reading multiple values (gradually increasing) instead of just one when the interrupt happens. Also the values are changing all the time. I am using a structure named adc0_array to save 100 values. Will you please let me know&amp;nbsp;where is the problem?&lt;/P&gt;&lt;P&gt;Thanks. Rishad&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper" image-alt="tek00005.bmp"&gt;&lt;img src="https://community.nxp.com/t5/image/serverpage/image-id/3950iF6F3E15E975A33F7/image-size/large?v=v2&amp;amp;px=999" role="button" title="tek00005.bmp" alt="tek00005.bmp" /&gt;&lt;/span&gt;&lt;/P&gt;&lt;P&gt;&lt;BR /&gt;&amp;nbsp;SIM_PCE0 |= 0x1&amp;lt;&amp;lt;6; // Enable GPIOA clock&lt;BR /&gt;&amp;nbsp;GPIOA_PER = 0x00FFU;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; // PER Enable for GPIOA 0-7&lt;BR /&gt;&amp;nbsp;&amp;nbsp;SIM_PCE2 |= 1&amp;lt;&amp;lt;7; // enable clock to ADC modules&lt;BR /&gt;&amp;nbsp;ADC_CTRL1 = 0x2105;&amp;nbsp;&lt;BR /&gt;&amp;nbsp;ADC_CTRL2 = 0x1804U;&lt;BR /&gt;&amp;nbsp;ADC_CLIST1 = 0x3210U; // SAMPLE3 - ANA3, SAMPLE2 - ANA2,SAMPLE1 - ANA1, SAMPLE0 - ANA0&lt;BR /&gt;&amp;nbsp;ADC_SDIS&amp;nbsp;&amp;nbsp; = 0xFEFEU; // enable ADC channels 0&amp;amp;8 -&amp;gt; ANA0 (pin 22), ANB0 (pin33)&lt;BR /&gt;&amp;nbsp;ADC_PWR &amp;nbsp; = 0x01A0U; // power-up delay set to 26 clocks&lt;BR /&gt;&amp;nbsp;ADC_HILIM0 = 0x431 &amp;lt;&amp;lt; 3; // High limit threshold&lt;BR /&gt;&amp;nbsp;&amp;nbsp;/* Enable high limit interrupt - priority 1 */&lt;BR /&gt;&amp;nbsp;INTC_IPR2 |= 1&amp;lt;&amp;lt;13;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;for(;;) {&lt;BR /&gt;&amp;nbsp;&amp;nbsp; ADC_CTRL1 |= 1&amp;lt;&amp;lt;13;&lt;/P&gt;&lt;P&gt;}&lt;/P&gt;&lt;P&gt;#pragma interrupt alignsp&lt;BR /&gt;#pragma interrupt on&lt;BR /&gt;void ADCA_Ch0_HighLimit_ISR() {&amp;nbsp;&lt;/P&gt;&lt;P&gt;adc_array* pAdc0_array = &amp;amp;adc0_array;&lt;/P&gt;&lt;P&gt;&amp;nbsp;adc0_array.array[adc0_array.c] = (0x7ff8 &amp;amp; ADC_RSLT0) &amp;gt;&amp;gt; 3;&amp;nbsp;&lt;BR /&gt;&amp;nbsp;adc0_array.c++;&lt;BR /&gt;ADC_HILIMSTAT = 0xFFFF;&lt;BR /&gt;}&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Fri, 02 Nov 2018 17:39:10 GMT</pubDate>
      <guid>https://community.nxp.com/t5/CodeWarrior-Development-Tools/Reading-Counter-Register-PWMA-SMnCNT/m-p/849255#M7309</guid>
      <dc:creator>rishadahmed</dc:creator>
      <dc:date>2018-11-02T17:39:10Z</dc:date>
    </item>
    <item>
      <title>Re: Reading Counter Register (PWMA_SMnCNT)</title>
      <link>https://community.nxp.com/t5/CodeWarrior-Development-Tools/Reading-Counter-Register-PWMA-SMnCNT/m-p/849256#M7310</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hi, Md,&lt;/P&gt;&lt;P&gt;I do not think you can use your&amp;nbsp; code to start ADC.&lt;/P&gt;&lt;P&gt;you can use the process:&lt;/P&gt;&lt;P&gt;ADC_CTRL1 |= 1&amp;lt;&amp;lt;13; //start ADC&lt;/P&gt;&lt;P&gt;poll if the completion is over, read sample&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;for(;;) {&lt;BR /&gt;&amp;nbsp;&amp;nbsp;&lt;/P&gt;&lt;P&gt;ADC_CTRL1 |= 1&amp;lt;&amp;lt;13; //start ADC&lt;/P&gt;&lt;P&gt;//poll if the completion is over&lt;/P&gt;&lt;P&gt;while(!ADC_STAT&amp;amp;EOSI0) {}&lt;/P&gt;&lt;P&gt;unsigned int sample=ADC_RSLTx&lt;/P&gt;&lt;P&gt;}&lt;/P&gt;&lt;P&gt;Regarding the reducing the interrupt latency, you can use fast interrupt. Pls refer to the section:&lt;/P&gt;&lt;P&gt;12.3.3 Fast Interrupt Handling in RM of MC56F827xx.&lt;/P&gt;&lt;P&gt;You can use the signal in crossbar switch module to trigger ADC. pls refer to section 3.3.3 Inter-Peripheral Crossbar Switch (XBAR) and AND/OR/INVERT (AOI) Configuration&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Hope it can help you&lt;/P&gt;&lt;P&gt;BR&lt;/P&gt;&lt;P&gt;Xiangjun Rong&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Mon, 05 Nov 2018 09:03:27 GMT</pubDate>
      <guid>https://community.nxp.com/t5/CodeWarrior-Development-Tools/Reading-Counter-Register-PWMA-SMnCNT/m-p/849256#M7310</guid>
      <dc:creator>xiangjun_rong</dc:creator>
      <dc:date>2018-11-05T09:03:27Z</dc:date>
    </item>
    <item>
      <title>Re: Reading Counter Register (PWMA_SMnCNT)</title>
      <link>https://community.nxp.com/t5/CodeWarrior-Development-Tools/Reading-Counter-Register-PWMA-SMnCNT/m-p/849257#M7311</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hi Xiang,&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Thanks for your recommendation. Polling seems to give me slightly better results. However, I am still getting different values for different cycles. My first question, what can do to get consistent ADC values for different cycles of the feedback signal? The second question is, how can I make sure HILIM ISR executes only once a cycle to get the minimum value from the feedback signal (ref to the previous figure)?&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Best regards,&lt;/P&gt;&lt;P&gt;Rishad&amp;nbsp;&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Wed, 14 Nov 2018 17:09:27 GMT</pubDate>
      <guid>https://community.nxp.com/t5/CodeWarrior-Development-Tools/Reading-Counter-Register-PWMA-SMnCNT/m-p/849257#M7311</guid>
      <dc:creator>rishadahmed</dc:creator>
      <dc:date>2018-11-14T17:09:27Z</dc:date>
    </item>
  </channel>
</rss>

