<?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: LPC4370 DWT cycle counter in LPC Microcontrollers</title>
    <link>https://community.nxp.com/t5/LPC-Microcontrollers/LPC4370-DWT-cycle-counter/m-p/918788#M36661</link>
    <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hi Erich,&lt;BR /&gt;I'm trying to investigate further.&lt;BR /&gt;I simplified my code in order to test only the timer.&lt;BR /&gt;Here's what I do:&lt;/P&gt;&lt;PRE class="language-c line-numbers"&gt;&lt;CODE&gt;&lt;SPAN class="comment token"&gt;/*DEBUG Timer Init*/&lt;/SPAN&gt;

    uint32_t delta&lt;SPAN class="punctuation token"&gt;;&lt;/SPAN&gt;
    uint32_t max &lt;SPAN class="operator token"&gt;=&lt;/SPAN&gt; &lt;SPAN class="number token"&gt;0&lt;/SPAN&gt;&lt;SPAN class="punctuation token"&gt;;&lt;/SPAN&gt;
    uint32_t min &lt;SPAN class="operator token"&gt;=&lt;/SPAN&gt; &lt;SPAN class="number token"&gt;0xFFFFFFFF&lt;/SPAN&gt;&lt;SPAN class="punctuation token"&gt;;&lt;/SPAN&gt;

    &lt;SPAN class="token function"&gt;LPC4370_InitCycleCounter&lt;/SPAN&gt;&lt;SPAN class="punctuation token"&gt;(&lt;/SPAN&gt;&lt;SPAN class="punctuation token"&gt;)&lt;/SPAN&gt;&lt;SPAN class="punctuation token"&gt;;&lt;/SPAN&gt; &lt;SPAN class="comment token"&gt;/*Init DWT HW*/&lt;/SPAN&gt;

 &lt;SPAN class="keyword token"&gt;while&lt;/SPAN&gt;&lt;SPAN class="punctuation token"&gt;(&lt;/SPAN&gt;&lt;SPAN class="number token"&gt;1&lt;/SPAN&gt;&lt;SPAN class="punctuation token"&gt;)&lt;/SPAN&gt;
 &lt;SPAN class="punctuation token"&gt;{&lt;/SPAN&gt;
  &lt;SPAN class="token function"&gt;LPC4370_ResetCycleCounter&lt;/SPAN&gt;&lt;SPAN class="punctuation token"&gt;(&lt;/SPAN&gt;&lt;SPAN class="punctuation token"&gt;)&lt;/SPAN&gt;&lt;SPAN class="punctuation token"&gt;;&lt;/SPAN&gt; &lt;SPAN class="comment token"&gt;/* reset cycle counter */&lt;/SPAN&gt;

  &lt;SPAN class="token function"&gt;LPC4370_EnableCycleCounter&lt;/SPAN&gt;&lt;SPAN class="punctuation token"&gt;(&lt;/SPAN&gt;&lt;SPAN class="punctuation token"&gt;)&lt;/SPAN&gt;&lt;SPAN class="punctuation token"&gt;;&lt;/SPAN&gt; &lt;SPAN class="comment token"&gt;/* start counting */&lt;/SPAN&gt;
  LPC_GPIO_PORT&lt;SPAN class="operator token"&gt;-&amp;gt;&lt;/SPAN&gt;B&lt;SPAN class="punctuation token"&gt;[&lt;/SPAN&gt;DEBUGPIN_PORT&lt;SPAN class="punctuation token"&gt;]&lt;/SPAN&gt;&lt;SPAN class="punctuation token"&gt;[&lt;/SPAN&gt;DEBUG_PIN1&lt;SPAN class="punctuation token"&gt;]&lt;/SPAN&gt; &lt;SPAN class="operator token"&gt;=&lt;/SPAN&gt; TRUE&lt;SPAN class="punctuation token"&gt;;&lt;/SPAN&gt;
  LPC_GPIO_PORT&lt;SPAN class="operator token"&gt;-&amp;gt;&lt;/SPAN&gt;B&lt;SPAN class="punctuation token"&gt;[&lt;/SPAN&gt;DEBUGPIN_PORT&lt;SPAN class="punctuation token"&gt;]&lt;/SPAN&gt;&lt;SPAN class="punctuation token"&gt;[&lt;/SPAN&gt;DEBUG_PIN1&lt;SPAN class="punctuation token"&gt;]&lt;/SPAN&gt; &lt;SPAN class="operator token"&gt;=&lt;/SPAN&gt; FALSE&lt;SPAN class="punctuation token"&gt;;&lt;/SPAN&gt;

  delta &lt;SPAN class="operator token"&gt;=&lt;/SPAN&gt; &lt;SPAN class="token function"&gt;LPC4370_GetCycleCounter&lt;/SPAN&gt;&lt;SPAN class="punctuation token"&gt;(&lt;/SPAN&gt;&lt;SPAN class="punctuation token"&gt;)&lt;/SPAN&gt;&lt;SPAN class="punctuation token"&gt;;&lt;/SPAN&gt;

  &lt;SPAN class="keyword token"&gt;if&lt;/SPAN&gt;&lt;SPAN class="punctuation token"&gt;(&lt;/SPAN&gt;delta &lt;SPAN class="operator token"&gt;&amp;lt;&lt;/SPAN&gt; min&lt;SPAN class="punctuation token"&gt;)&lt;/SPAN&gt;
  &lt;SPAN class="punctuation token"&gt;{&lt;/SPAN&gt;
   min &lt;SPAN class="operator token"&gt;=&lt;/SPAN&gt; delta&lt;SPAN class="punctuation token"&gt;;&lt;/SPAN&gt;
  &lt;SPAN class="punctuation token"&gt;}&lt;/SPAN&gt;

  &lt;SPAN class="keyword token"&gt;if&lt;/SPAN&gt; &lt;SPAN class="punctuation token"&gt;(&lt;/SPAN&gt;max &lt;SPAN class="operator token"&gt;&amp;lt;&lt;/SPAN&gt; delta&lt;SPAN class="punctuation token"&gt;)&lt;/SPAN&gt;
  &lt;SPAN class="punctuation token"&gt;{&lt;/SPAN&gt;
      max &lt;SPAN class="operator token"&gt;=&lt;/SPAN&gt; delta&lt;SPAN class="punctuation token"&gt;;&lt;/SPAN&gt;
  &lt;SPAN class="punctuation token"&gt;}&lt;/SPAN&gt;
 &lt;SPAN class="punctuation token"&gt;}&lt;/SPAN&gt;‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍&lt;SPAN class="line-numbers-rows"&gt;&lt;SPAN&gt;‍&lt;/SPAN&gt;&lt;SPAN&gt;‍&lt;/SPAN&gt;&lt;SPAN&gt;‍&lt;/SPAN&gt;&lt;SPAN&gt;‍&lt;/SPAN&gt;&lt;SPAN&gt;‍&lt;/SPAN&gt;&lt;SPAN&gt;‍&lt;/SPAN&gt;&lt;SPAN&gt;‍&lt;/SPAN&gt;&lt;SPAN&gt;‍&lt;/SPAN&gt;&lt;SPAN&gt;‍&lt;/SPAN&gt;&lt;SPAN&gt;‍&lt;/SPAN&gt;&lt;SPAN&gt;‍&lt;/SPAN&gt;&lt;SPAN&gt;‍&lt;/SPAN&gt;&lt;SPAN&gt;‍&lt;/SPAN&gt;&lt;SPAN&gt;‍&lt;/SPAN&gt;&lt;SPAN&gt;‍&lt;/SPAN&gt;&lt;SPAN&gt;‍&lt;/SPAN&gt;&lt;SPAN&gt;‍&lt;/SPAN&gt;&lt;SPAN&gt;‍&lt;/SPAN&gt;&lt;SPAN&gt;‍&lt;/SPAN&gt;&lt;SPAN&gt;‍&lt;/SPAN&gt;&lt;SPAN&gt;‍&lt;/SPAN&gt;&lt;SPAN&gt;‍&lt;/SPAN&gt;&lt;SPAN&gt;‍&lt;/SPAN&gt;&lt;SPAN&gt;‍&lt;/SPAN&gt;&lt;SPAN&gt;‍&lt;/SPAN&gt;&lt;SPAN&gt;‍&lt;/SPAN&gt;&lt;SPAN&gt;‍&lt;/SPAN&gt;&lt;SPAN&gt;‍&lt;/SPAN&gt;&lt;/SPAN&gt;&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;So, If I run It for a while what I get is:&lt;BR /&gt;max = 2450 (~12us if running at 204 MHz)&lt;/P&gt;&lt;P&gt;min = 22 (~100ns&amp;nbsp;&lt;SPAN&gt;if running at 204 MHz).&lt;BR /&gt;Here's also a pic of my scope and my setup:&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN class="lia-inline-image-display-wrapper" image-alt="photo_2019-08-30_16-02-36.jpg"&gt;&lt;IMG alt="photo_2019-08-30_16-02-36.jpg" src="https://community.nxp.com/t5/image/serverpage/image-id/84429i5910FC7C0D720C0C/image-size/large?v=v2&amp;amp;px=999" title="photo_2019-08-30_16-02-36.jpg" /&gt;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN class="lia-inline-image-display-wrapper" image-alt="photo_2019-08-30_16-03-05.jpg"&gt;&lt;IMG alt="photo_2019-08-30_16-03-05.jpg" src="https://community.nxp.com/t5/image/serverpage/image-id/84461i9F7477B716AEBB54/image-size/large?v=v2&amp;amp;px=999" title="photo_2019-08-30_16-03-05.jpg" /&gt;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;BR /&gt;I noticed that this 2450 value happens just at the very beginning and then no more.&lt;BR /&gt;Do you have a hint about why I don't get consistent measurements?&lt;BR /&gt;Best,&lt;BR /&gt;Andrea&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
    <pubDate>Mon, 02 Nov 2020 14:23:29 GMT</pubDate>
    <dc:creator>a_bet</dc:creator>
    <dc:date>2020-11-02T14:23:29Z</dc:date>
    <item>
      <title>LPC4370 DWT cycle counter</title>
      <link>https://community.nxp.com/t5/LPC-Microcontrollers/LPC4370-DWT-cycle-counter/m-p/918784#M36657</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hi to you all.&lt;BR /&gt;I need to monitor the execution time of some chunks of code and searching on the internet I found that the DWT cycle counter "present on most M3/M4/M7 mcus" is a good way to do that.&lt;BR /&gt;Here two blog entries: &lt;A href="https://mcuoneclipse.com/2017/01/30/cycle-counting-on-arm-cortex-m-with-dwt/"&gt;mcuoneclipse&lt;/A&gt; from the forum member &lt;A class="jx-jive-macro-user" href="https://community.nxp.com/people/BlackNight"&gt;BlackNight&lt;/A&gt;‌ and this other one on &lt;A href="https://www.embedded-computing.com/articles/measuring-code-execution-time-on-arm-cortex-m-mcus"&gt;embedded-computing&lt;/A&gt;.&lt;BR /&gt;The problem is that searching "DWT" or "Data Watchpoint and Trace" in the UM10503 LPC43xx User Manual doesn't lead to anything. No match.&lt;BR /&gt;So, is it called in a different way or not present at all? &lt;BR /&gt;If so, is there another similar (easy and lite) way I could measure exec time?&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Best,&lt;BR /&gt;Andrea&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Wed, 28 Aug 2019 18:09:52 GMT</pubDate>
      <guid>https://community.nxp.com/t5/LPC-Microcontrollers/LPC4370-DWT-cycle-counter/m-p/918784#M36657</guid>
      <dc:creator>a_bet</dc:creator>
      <dc:date>2019-08-28T18:09:52Z</dc:date>
    </item>
    <item>
      <title>Re: LPC4370 DWT cycle counter</title>
      <link>https://community.nxp.com/t5/LPC-Microcontrollers/LPC4370-DWT-cycle-counter/m-p/918785#M36658</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hi Andrea,&lt;/P&gt;&lt;P&gt;I have to admit that I'm not familiar with the LPC4370, but at least on the M4 of this device I'm very confident that the DWT is implemented. The reason why you don't find anything about the DWT is because this is a ARM core feature and these ARM core things are usually not documented in a vendor implementation.&lt;/P&gt;&lt;P&gt;You could quickly try it with the NXP MCUXpresso IDE as it has a view to show the counter, see &lt;A class="link-titled" href="https://mcuoneclipse.com/2018/06/28/measuring-arm-cortex-m-cpu-cycles-spent-with-the-mcuxpresso-eclipse-registers-view/" title="https://mcuoneclipse.com/2018/06/28/measuring-arm-cortex-m-cpu-cycles-spent-with-the-mcuxpresso-eclipse-registers-view/"&gt;Measuring ARM Cortex-M CPU Cycles Spent with the MCUXpresso Eclipse Registers View | MCU on Eclipse&lt;/A&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;In version 11 (see &lt;A class="link-titled" href="https://mcuoneclipse.com/2019/06/16/new-nxp-mcuxpresso-ide-v11-0/" title="https://mcuoneclipse.com/2019/06/16/new-nxp-mcuxpresso-ide-v11-0/"&gt;New NXP MCUXpresso Eclipse IDE v11.0 | MCU on Eclipse&lt;/A&gt;&amp;nbsp;) it looks like this:&lt;/P&gt;&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper" image-alt="pastedImage_2.png"&gt;&lt;img src="https://community.nxp.com/t5/image/serverpage/image-id/81956i032C62D9B2AF2505/image-size/large?v=v2&amp;amp;px=999" role="button" title="pastedImage_2.png" alt="pastedImage_2.png" /&gt;&lt;/span&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;I hope this helps,&lt;/P&gt;&lt;P&gt;Erich&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Wed, 28 Aug 2019 18:30:33 GMT</pubDate>
      <guid>https://community.nxp.com/t5/LPC-Microcontrollers/LPC4370-DWT-cycle-counter/m-p/918785#M36658</guid>
      <dc:creator>BlackNight</dc:creator>
      <dc:date>2019-08-28T18:30:33Z</dc:date>
    </item>
    <item>
      <title>Re: LPC4370 DWT cycle counter</title>
      <link>https://community.nxp.com/t5/LPC-Microcontrollers/LPC4370-DWT-cycle-counter/m-p/918786#M36659</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hi Andrea,&lt;/P&gt;&lt;P&gt;Thank you for your interest in NXP Semiconductor products and for the opportunity to serve you.&lt;BR /&gt;The DWT feature is integrated into the Cortex-M4 core, the LPC43xx is based on Cortex-M4 core, it definitely supports the DWT feature.&lt;BR /&gt;You can learn the information about it via &lt;A href="https://www.google.com/url?sa=t&amp;amp;rct=j&amp;amp;q=&amp;amp;esrc=s&amp;amp;source=web&amp;amp;cd=1&amp;amp;cad=rja&amp;amp;uact=8&amp;amp;ved=2ahUKEwjvnLehhKfkAhVKMqwKHUPTCfcQFjAAegQIARAC&amp;amp;url=http%3A%2F%2F222.195.93.137%2Fgitlab%2Fwinston.wen%2Fbookshelf%2Fraw%2F82f0d2633bd8385c6a077fbfc1cf05a6e20c178c%2F%25E5%25B5%258C%25E5%2585%25A5%25E5%25BC%258F%2FThe%2520Definitive%2520Guide%2520to%2520ARM%2520Cortex-M3%2520and%2520Cortex-M4%2520Processors%25203ed.pdf&amp;amp;usg=AOvVaw3-cp0znDsZKOdKXtUryRnG"&gt;The Definitive Guide to ARM Cortex M3 and Cortex M4 Processors.&lt;/A&gt;&lt;BR /&gt;Have a great day,&lt;BR /&gt;TIC&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;-------------------------------------------------------------------------------&lt;BR /&gt;Note:&lt;BR /&gt;- If this post answers your question, please click the "Mark Correct" button. Thank you!&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;- We are following threads for 7 weeks after the last post, later replies are ignored&lt;BR /&gt; Please open a new thread and refer to the closed one, if you have a related question at a later point in time.&lt;BR /&gt;-------------------------------------------------------------------------------&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Thu, 29 Aug 2019 02:29:41 GMT</pubDate>
      <guid>https://community.nxp.com/t5/LPC-Microcontrollers/LPC4370-DWT-cycle-counter/m-p/918786#M36659</guid>
      <dc:creator>jeremyzhou</dc:creator>
      <dc:date>2019-08-29T02:29:41Z</dc:date>
    </item>
    <item>
      <title>Re: LPC4370 DWT cycle counter</title>
      <link>https://community.nxp.com/t5/LPC-Microcontrollers/LPC4370-DWT-cycle-counter/m-p/918787#M36660</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hi Erich,&lt;BR /&gt;thanks for the reply. You are right, I was able to perform my first measurement.&lt;BR /&gt;The problem is that maybe I use the wrong conversion from cycle counter to time.&lt;BR /&gt;I looked at the register before and after a block of code which moves un and down a pin, so that I can compare with a measurement from the scope.&lt;BR /&gt;What I do is Elapsed_Time = (DWT_after - DWT_before)*1/f_clk.&lt;BR /&gt;In my case f_clk is 204 MHz.&amp;nbsp;&lt;BR /&gt;So looking at DWT I got 50 us whereas the scope says 100 ns. Since we are talking order of magnitude here I suspect something is wrong with my DWT Measurement.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Thu, 29 Aug 2019 16:03:11 GMT</pubDate>
      <guid>https://community.nxp.com/t5/LPC-Microcontrollers/LPC4370-DWT-cycle-counter/m-p/918787#M36660</guid>
      <dc:creator>a_bet</dc:creator>
      <dc:date>2019-08-29T16:03:11Z</dc:date>
    </item>
    <item>
      <title>Re: LPC4370 DWT cycle counter</title>
      <link>https://community.nxp.com/t5/LPC-Microcontrollers/LPC4370-DWT-cycle-counter/m-p/918788#M36661</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hi Erich,&lt;BR /&gt;I'm trying to investigate further.&lt;BR /&gt;I simplified my code in order to test only the timer.&lt;BR /&gt;Here's what I do:&lt;/P&gt;&lt;PRE class="language-c line-numbers"&gt;&lt;CODE&gt;&lt;SPAN class="comment token"&gt;/*DEBUG Timer Init*/&lt;/SPAN&gt;

    uint32_t delta&lt;SPAN class="punctuation token"&gt;;&lt;/SPAN&gt;
    uint32_t max &lt;SPAN class="operator token"&gt;=&lt;/SPAN&gt; &lt;SPAN class="number token"&gt;0&lt;/SPAN&gt;&lt;SPAN class="punctuation token"&gt;;&lt;/SPAN&gt;
    uint32_t min &lt;SPAN class="operator token"&gt;=&lt;/SPAN&gt; &lt;SPAN class="number token"&gt;0xFFFFFFFF&lt;/SPAN&gt;&lt;SPAN class="punctuation token"&gt;;&lt;/SPAN&gt;

    &lt;SPAN class="token function"&gt;LPC4370_InitCycleCounter&lt;/SPAN&gt;&lt;SPAN class="punctuation token"&gt;(&lt;/SPAN&gt;&lt;SPAN class="punctuation token"&gt;)&lt;/SPAN&gt;&lt;SPAN class="punctuation token"&gt;;&lt;/SPAN&gt; &lt;SPAN class="comment token"&gt;/*Init DWT HW*/&lt;/SPAN&gt;

 &lt;SPAN class="keyword token"&gt;while&lt;/SPAN&gt;&lt;SPAN class="punctuation token"&gt;(&lt;/SPAN&gt;&lt;SPAN class="number token"&gt;1&lt;/SPAN&gt;&lt;SPAN class="punctuation token"&gt;)&lt;/SPAN&gt;
 &lt;SPAN class="punctuation token"&gt;{&lt;/SPAN&gt;
  &lt;SPAN class="token function"&gt;LPC4370_ResetCycleCounter&lt;/SPAN&gt;&lt;SPAN class="punctuation token"&gt;(&lt;/SPAN&gt;&lt;SPAN class="punctuation token"&gt;)&lt;/SPAN&gt;&lt;SPAN class="punctuation token"&gt;;&lt;/SPAN&gt; &lt;SPAN class="comment token"&gt;/* reset cycle counter */&lt;/SPAN&gt;

  &lt;SPAN class="token function"&gt;LPC4370_EnableCycleCounter&lt;/SPAN&gt;&lt;SPAN class="punctuation token"&gt;(&lt;/SPAN&gt;&lt;SPAN class="punctuation token"&gt;)&lt;/SPAN&gt;&lt;SPAN class="punctuation token"&gt;;&lt;/SPAN&gt; &lt;SPAN class="comment token"&gt;/* start counting */&lt;/SPAN&gt;
  LPC_GPIO_PORT&lt;SPAN class="operator token"&gt;-&amp;gt;&lt;/SPAN&gt;B&lt;SPAN class="punctuation token"&gt;[&lt;/SPAN&gt;DEBUGPIN_PORT&lt;SPAN class="punctuation token"&gt;]&lt;/SPAN&gt;&lt;SPAN class="punctuation token"&gt;[&lt;/SPAN&gt;DEBUG_PIN1&lt;SPAN class="punctuation token"&gt;]&lt;/SPAN&gt; &lt;SPAN class="operator token"&gt;=&lt;/SPAN&gt; TRUE&lt;SPAN class="punctuation token"&gt;;&lt;/SPAN&gt;
  LPC_GPIO_PORT&lt;SPAN class="operator token"&gt;-&amp;gt;&lt;/SPAN&gt;B&lt;SPAN class="punctuation token"&gt;[&lt;/SPAN&gt;DEBUGPIN_PORT&lt;SPAN class="punctuation token"&gt;]&lt;/SPAN&gt;&lt;SPAN class="punctuation token"&gt;[&lt;/SPAN&gt;DEBUG_PIN1&lt;SPAN class="punctuation token"&gt;]&lt;/SPAN&gt; &lt;SPAN class="operator token"&gt;=&lt;/SPAN&gt; FALSE&lt;SPAN class="punctuation token"&gt;;&lt;/SPAN&gt;

  delta &lt;SPAN class="operator token"&gt;=&lt;/SPAN&gt; &lt;SPAN class="token function"&gt;LPC4370_GetCycleCounter&lt;/SPAN&gt;&lt;SPAN class="punctuation token"&gt;(&lt;/SPAN&gt;&lt;SPAN class="punctuation token"&gt;)&lt;/SPAN&gt;&lt;SPAN class="punctuation token"&gt;;&lt;/SPAN&gt;

  &lt;SPAN class="keyword token"&gt;if&lt;/SPAN&gt;&lt;SPAN class="punctuation token"&gt;(&lt;/SPAN&gt;delta &lt;SPAN class="operator token"&gt;&amp;lt;&lt;/SPAN&gt; min&lt;SPAN class="punctuation token"&gt;)&lt;/SPAN&gt;
  &lt;SPAN class="punctuation token"&gt;{&lt;/SPAN&gt;
   min &lt;SPAN class="operator token"&gt;=&lt;/SPAN&gt; delta&lt;SPAN class="punctuation token"&gt;;&lt;/SPAN&gt;
  &lt;SPAN class="punctuation token"&gt;}&lt;/SPAN&gt;

  &lt;SPAN class="keyword token"&gt;if&lt;/SPAN&gt; &lt;SPAN class="punctuation token"&gt;(&lt;/SPAN&gt;max &lt;SPAN class="operator token"&gt;&amp;lt;&lt;/SPAN&gt; delta&lt;SPAN class="punctuation token"&gt;)&lt;/SPAN&gt;
  &lt;SPAN class="punctuation token"&gt;{&lt;/SPAN&gt;
      max &lt;SPAN class="operator token"&gt;=&lt;/SPAN&gt; delta&lt;SPAN class="punctuation token"&gt;;&lt;/SPAN&gt;
  &lt;SPAN class="punctuation token"&gt;}&lt;/SPAN&gt;
 &lt;SPAN class="punctuation token"&gt;}&lt;/SPAN&gt;‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍&lt;SPAN class="line-numbers-rows"&gt;&lt;SPAN&gt;‍&lt;/SPAN&gt;&lt;SPAN&gt;‍&lt;/SPAN&gt;&lt;SPAN&gt;‍&lt;/SPAN&gt;&lt;SPAN&gt;‍&lt;/SPAN&gt;&lt;SPAN&gt;‍&lt;/SPAN&gt;&lt;SPAN&gt;‍&lt;/SPAN&gt;&lt;SPAN&gt;‍&lt;/SPAN&gt;&lt;SPAN&gt;‍&lt;/SPAN&gt;&lt;SPAN&gt;‍&lt;/SPAN&gt;&lt;SPAN&gt;‍&lt;/SPAN&gt;&lt;SPAN&gt;‍&lt;/SPAN&gt;&lt;SPAN&gt;‍&lt;/SPAN&gt;&lt;SPAN&gt;‍&lt;/SPAN&gt;&lt;SPAN&gt;‍&lt;/SPAN&gt;&lt;SPAN&gt;‍&lt;/SPAN&gt;&lt;SPAN&gt;‍&lt;/SPAN&gt;&lt;SPAN&gt;‍&lt;/SPAN&gt;&lt;SPAN&gt;‍&lt;/SPAN&gt;&lt;SPAN&gt;‍&lt;/SPAN&gt;&lt;SPAN&gt;‍&lt;/SPAN&gt;&lt;SPAN&gt;‍&lt;/SPAN&gt;&lt;SPAN&gt;‍&lt;/SPAN&gt;&lt;SPAN&gt;‍&lt;/SPAN&gt;&lt;SPAN&gt;‍&lt;/SPAN&gt;&lt;SPAN&gt;‍&lt;/SPAN&gt;&lt;SPAN&gt;‍&lt;/SPAN&gt;&lt;SPAN&gt;‍&lt;/SPAN&gt;&lt;SPAN&gt;‍&lt;/SPAN&gt;&lt;/SPAN&gt;&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;So, If I run It for a while what I get is:&lt;BR /&gt;max = 2450 (~12us if running at 204 MHz)&lt;/P&gt;&lt;P&gt;min = 22 (~100ns&amp;nbsp;&lt;SPAN&gt;if running at 204 MHz).&lt;BR /&gt;Here's also a pic of my scope and my setup:&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN class="lia-inline-image-display-wrapper" image-alt="photo_2019-08-30_16-02-36.jpg"&gt;&lt;IMG alt="photo_2019-08-30_16-02-36.jpg" src="https://community.nxp.com/t5/image/serverpage/image-id/84429i5910FC7C0D720C0C/image-size/large?v=v2&amp;amp;px=999" title="photo_2019-08-30_16-02-36.jpg" /&gt;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN class="lia-inline-image-display-wrapper" image-alt="photo_2019-08-30_16-03-05.jpg"&gt;&lt;IMG alt="photo_2019-08-30_16-03-05.jpg" src="https://community.nxp.com/t5/image/serverpage/image-id/84461i9F7477B716AEBB54/image-size/large?v=v2&amp;amp;px=999" title="photo_2019-08-30_16-03-05.jpg" /&gt;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;BR /&gt;I noticed that this 2450 value happens just at the very beginning and then no more.&lt;BR /&gt;Do you have a hint about why I don't get consistent measurements?&lt;BR /&gt;Best,&lt;BR /&gt;Andrea&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Mon, 02 Nov 2020 14:23:29 GMT</pubDate>
      <guid>https://community.nxp.com/t5/LPC-Microcontrollers/LPC4370-DWT-cycle-counter/m-p/918788#M36661</guid>
      <dc:creator>a_bet</dc:creator>
      <dc:date>2020-11-02T14:23:29Z</dc:date>
    </item>
  </channel>
</rss>

