<?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>LPC MicrocontrollersのトピックRe: mrt 1us resolution</title>
    <link>https://community.nxp.com/t5/LPC-Microcontrollers/mrt-1us-resolution/m-p/573418#M18794</link>
    <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;STRONG&gt;Content originally posted in LPCWare by onkel.jack@t-online.de on Sun Dec 29 03:53:05 MST 2013&lt;/STRONG&gt;&lt;BR /&gt;&lt;SPAN&gt;Spock,&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;your problem indeed is you dont&amp;nbsp; have enough CPU cycles to process interrups in 1 us resolution.&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;I dont know our one wire protocol, but maybe you could "abuse" SPI to generate the required puses at 1 MHz SPI speed.&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;Use either SCLK to get 8/16 pulses or use MOSI and send the number of bits. i.e. send a 0x07 would give you 3 pulses.&lt;/SPAN&gt;&lt;BR /&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
    <pubDate>Wed, 15 Jun 2016 20:13:42 GMT</pubDate>
    <dc:creator>lpcware</dc:creator>
    <dc:date>2016-06-15T20:13:42Z</dc:date>
    <item>
      <title>mrt 1us resolution</title>
      <link>https://community.nxp.com/t5/LPC-Microcontrollers/mrt-1us-resolution/m-p/573413#M18789</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;STRONG&gt;Content originally posted in LPCWare by Spock on Wed Jun 12 13:24:48 MST 2013&lt;/STRONG&gt;&lt;BR /&gt;&lt;P&gt;Hi,&lt;/P&gt;&lt;BR /&gt;&lt;P&gt;I just got my LPC800 mini kit and started evaluation.&lt;/P&gt;&lt;BR /&gt;&lt;P&gt;My target is wireless OneWire fish tank enviromental monitor.&lt;/P&gt;&lt;BR /&gt;&lt;P&gt;For support OneWire protocol I need 1us timing resolution&lt;/P&gt;&lt;BR /&gt;&lt;P&gt;I've tried to perform this in following way using mrt following function:&lt;/P&gt;&lt;BR /&gt;&lt;P&gt;void mrtInit(uint32_t delay)&lt;BR /&gt;{&lt;BR /&gt;&amp;nbsp; /* Enable clock to MRT and reset the MRT peripheral */&lt;BR /&gt;&amp;nbsp; LPC_SYSCON-&amp;amp;gt;SYSAHBCLKCTRL |= (0x1&amp;amp;lt;&amp;amp;lt;10);&lt;BR /&gt;&amp;nbsp; LPC_SYSCON-&amp;amp;gt;PRESETCTRL &amp;amp;amp;= ~(0x1&amp;amp;lt;&amp;amp;lt;7);&lt;BR /&gt;&amp;nbsp; LPC_SYSCON-&amp;amp;gt;PRESETCTRL |= (0x1&amp;amp;lt;&amp;amp;lt;7);&lt;BR /&gt;&lt;BR /&gt;&amp;nbsp; mrt_counter = 0;&lt;BR /&gt;&amp;nbsp; LPC_MRT-&amp;amp;gt;Channel[0].INTVAL = delay;&lt;BR /&gt;&amp;nbsp; LPC_MRT-&amp;amp;gt;Channel[0].INTVAL |= 0x1UL&amp;amp;lt;&amp;amp;lt;31;&lt;BR /&gt;&lt;BR /&gt;&amp;nbsp; LPC_MRT-&amp;amp;gt;Channel[0].CTRL = MRT_REPEATED_MODE|MRT_INT_ENA;&lt;BR /&gt;&lt;BR /&gt;&amp;nbsp; /* Enable the MRT Interrupt */&lt;BR /&gt;&lt;BR /&gt;&amp;nbsp; NVIC_EnableIRQ(MRT_IRQn);&lt;BR /&gt;&amp;nbsp; return;&lt;BR /&gt;}&lt;/P&gt;&lt;BR /&gt;&lt;P&gt;However passing values less than 60 as a function parameter gives result in not working system.&lt;/P&gt;&lt;BR /&gt;&lt;P&gt;Above thise value timer works properly and I can see test quare wave on my oscilloscope.&lt;/P&gt;&lt;BR /&gt;&lt;P&gt;What might be a problem ?&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Wed, 15 Jun 2016 20:13:39 GMT</pubDate>
      <guid>https://community.nxp.com/t5/LPC-Microcontrollers/mrt-1us-resolution/m-p/573413#M18789</guid>
      <dc:creator>lpcware</dc:creator>
      <dc:date>2016-06-15T20:13:39Z</dc:date>
    </item>
    <item>
      <title>Re: mrt 1us resolution</title>
      <link>https://community.nxp.com/t5/LPC-Microcontrollers/mrt-1us-resolution/m-p/573414#M18790</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;STRONG&gt;Content originally posted in LPCWare by wmues on Wed Jun 12 14:39:05 MST 2013&lt;/STRONG&gt;&lt;BR /&gt;&lt;P&gt;The problem is that the interrupt service function is using all available time, if it is called so often.&lt;/P&gt;&lt;BR /&gt;&lt;P&gt;Trying to get 1us Resolution with Interrupts is hopeless.&lt;/P&gt;&lt;BR /&gt;&lt;P&gt;You should use the SCT of the LPC800 for the OneWire protocol.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Wed, 15 Jun 2016 20:13:40 GMT</pubDate>
      <guid>https://community.nxp.com/t5/LPC-Microcontrollers/mrt-1us-resolution/m-p/573414#M18790</guid>
      <dc:creator>lpcware</dc:creator>
      <dc:date>2016-06-15T20:13:40Z</dc:date>
    </item>
    <item>
      <title>Re: mrt 1us resolution</title>
      <link>https://community.nxp.com/t5/LPC-Microcontrollers/mrt-1us-resolution/m-p/573415#M18791</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;STRONG&gt;Content originally posted in LPCWare by Spock on Thu Jun 13 06:56:55 MST 2013&lt;/STRONG&gt;&lt;BR /&gt;&lt;P&gt;Thanks,&lt;/P&gt;&lt;BR /&gt;&lt;P&gt;I will try with SCT with match configuration.&lt;/P&gt;&lt;BR /&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Wed, 15 Jun 2016 20:13:41 GMT</pubDate>
      <guid>https://community.nxp.com/t5/LPC-Microcontrollers/mrt-1us-resolution/m-p/573415#M18791</guid>
      <dc:creator>lpcware</dc:creator>
      <dc:date>2016-06-15T20:13:41Z</dc:date>
    </item>
    <item>
      <title>Re: mrt 1us resolution</title>
      <link>https://community.nxp.com/t5/LPC-Microcontrollers/mrt-1us-resolution/m-p/573416#M18792</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;STRONG&gt;Content originally posted in LPCWare by MarcVonWindscooting on Tue Aug 20 05:20:18 MST 2013&lt;/STRONG&gt;&lt;BR /&gt;&lt;SPAN&gt;On all LPCs prior to LPC800 one could simply run one of the 32bit timers with a prescaler of PCLK/1000/1000.&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;That way, I had a clock with 1us resolution. Each read of the TC got the current time (with a wraparoung of 1.5hours).&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;When using a 32-bit processor and a 32-bit timer, you simply ignore all carries or overflows if you don't measure differences/delays of hours. t1-t0 is always positive and the time between t1 and t0 in us, provided t1 is later than t0.&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;For very tight timings, you will have to use busy waits.&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;But the great engineers at NXP removed such simple timers. Now we have a 31-bit counter (how odd is that), down counters (I can live with that, but why?), and special timer 1, and timer 2, and... special timer xy.&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;I seem to be the only person on this planet who used to run nearly all timing from T0, free running at 1MHz. Because nobody complained so far.&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;The MRT is the one I like most after skimming the manual and the SCT is the ONLY timer that can provide me with a full 32-bit but not at a configurable tick period. I can't change clock frequency without changing the meaning of 'time'. Poor design that needs to be compensated for in software.&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;Please don't get me wrong. I'm not insisting on a huge number of timer bits, I'm insisting on timers having the same number of bits (for counting) as the ALU of the processor.&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;If I were you I would use MRT with 1024*1024*1024 reload value, free running and implementing 30bit overflow handling logic (sign extending bit 29). That gives you better than us resolution at register read speed.&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;When I was new to ARM processors, I chose NXP (Philips at that time) because I realized, the engineers have understood that a 32-bit processor works excellently with 32-bit peripherals. Atmel and ST at that time provided 16-bit timers. How stupid was that? A 32-bit processor can read (atomically) a 32-bit timer and they provided 16-bits? Hilarious!&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;But now I had a closer look at LPC800 and that thing reminds me of Atmel and ST 6 years ago, honestly.&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;SCT is a big leap forward, the other timers mostly&lt;/SPAN&gt;&lt;BR /&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Wed, 15 Jun 2016 20:13:41 GMT</pubDate>
      <guid>https://community.nxp.com/t5/LPC-Microcontrollers/mrt-1us-resolution/m-p/573416#M18792</guid>
      <dc:creator>lpcware</dc:creator>
      <dc:date>2016-06-15T20:13:41Z</dc:date>
    </item>
    <item>
      <title>Re: mrt 1us resolution</title>
      <link>https://community.nxp.com/t5/LPC-Microcontrollers/mrt-1us-resolution/m-p/573417#M18793</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;STRONG&gt;Content originally posted in LPCWare by MarcVonWindscooting on Sat Dec 28 04:56:15 MST 2013&lt;/STRONG&gt;&lt;BR /&gt;&lt;STRONG&gt;Not&lt;/STRONG&gt;&lt;SPAN&gt; sorry for bringing up this thread again&amp;nbsp; :p &lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;It took some time until I actually implemented my suggestion for a current project. "hr" stands for high resolution. However, instead of sign extending I did a shift left by 2. If I can't get my beloved 1us timer tick then I don't care if its 4*(something else) rather than 1*(something else). htTimer uses MRT channel 3. Delays/time measurements up to 17.5s at least are possible. I prefered to invert hrTimer()'s direction with respect to MRT (counting downwards) because that makes it easier to understand. That inversion costs on instruction, however.&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;I assume you provide the MRT structure and symbolic constants MEGA,PCLK, with their obvious meanings. And of course switch on the AHB clock and so on...&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;EDIT: failed to inline the code. Now as an attachment.&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;Any comments are welcome.&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;BTW: In my post above, the last word and the full stop got missing. Here they are: " NOT ."&lt;/SPAN&gt;&lt;BR /&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Wed, 15 Jun 2016 20:13:42 GMT</pubDate>
      <guid>https://community.nxp.com/t5/LPC-Microcontrollers/mrt-1us-resolution/m-p/573417#M18793</guid>
      <dc:creator>lpcware</dc:creator>
      <dc:date>2016-06-15T20:13:42Z</dc:date>
    </item>
    <item>
      <title>Re: mrt 1us resolution</title>
      <link>https://community.nxp.com/t5/LPC-Microcontrollers/mrt-1us-resolution/m-p/573418#M18794</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;STRONG&gt;Content originally posted in LPCWare by onkel.jack@t-online.de on Sun Dec 29 03:53:05 MST 2013&lt;/STRONG&gt;&lt;BR /&gt;&lt;SPAN&gt;Spock,&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;your problem indeed is you dont&amp;nbsp; have enough CPU cycles to process interrups in 1 us resolution.&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;I dont know our one wire protocol, but maybe you could "abuse" SPI to generate the required puses at 1 MHz SPI speed.&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;Use either SCLK to get 8/16 pulses or use MOSI and send the number of bits. i.e. send a 0x07 would give you 3 pulses.&lt;/SPAN&gt;&lt;BR /&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Wed, 15 Jun 2016 20:13:42 GMT</pubDate>
      <guid>https://community.nxp.com/t5/LPC-Microcontrollers/mrt-1us-resolution/m-p/573418#M18794</guid>
      <dc:creator>lpcware</dc:creator>
      <dc:date>2016-06-15T20:13:42Z</dc:date>
    </item>
  </channel>
</rss>

