<?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: Bug: Chip_RGU_TriggerReset starts M0 core</title>
    <link>https://community.nxp.com/t5/LPC-Microcontrollers/Bug-Chip-RGU-TriggerReset-starts-M0-core/m-p/576098#M19376</link>
    <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;STRONG&gt;Content originally posted in LPCWare by starblue on Wed Oct 07 02:00:54 MST 2015&lt;/STRONG&gt;&lt;BR /&gt;&lt;HR /&gt;&lt;SPAN style="color: #0000ff;"&gt;&lt;STRONG&gt;Quote: dstahlke&lt;/STRONG&gt;&lt;BR /&gt;I'm using LPC4370.&lt;/SPAN&gt;&lt;HR /&gt;&lt;BR /&gt;&lt;SPAN&gt;Note that the same reset behavior applies for M0SUB, not only M0APP.&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;For a general solution you should probably read RESET_ACTIVE_STATUSn first and make sure to preserve the reset status for the M0s when writing to RESET_CTRLn.&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;STRONG&gt;Note to NXP:&lt;/STRONG&gt;&lt;SPAN&gt; The paragraph preceding the tables for RESET_CTRLn should IMHO also mention M0SUB.&lt;/SPAN&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
    <pubDate>Wed, 15 Jun 2016 20:17:39 GMT</pubDate>
    <dc:creator>lpcware</dc:creator>
    <dc:date>2016-06-15T20:17:39Z</dc:date>
    <item>
      <title>Bug: Chip_RGU_TriggerReset starts M0 core</title>
      <link>https://community.nxp.com/t5/LPC-Microcontrollers/Bug-Chip-RGU-TriggerReset-starts-M0-core/m-p/576094#M19372</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;STRONG&gt;Content originally posted in LPCWare by dstahlke on Mon Oct 05 22:26:54 MST 2015&lt;/STRONG&gt;&lt;BR /&gt;&lt;SPAN&gt;I was experiencing an odd crash which, after a half day of debugging, I traced to the Chip_RGU_TriggerReset function.&amp;nbsp; I'm linking against an older version of LPCOpen, but it looks like 2.16 would have the same issue.&amp;nbsp; The function itself is quite simple, at least in 2.16:&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;TABLE border="1"&gt;&lt;TBODY&gt;&lt;TR&gt;&lt;TD bgcolor="#cacaca"&gt; &lt;PRE&gt;
STATIC INLINE void Chip_RGU_TriggerReset(CHIP_RGU_RST_T ResetNumber)
{
LPC_RGU-&amp;gt;RESET_CTRL[ResetNumber &amp;gt;&amp;gt; 5] = 1 &amp;lt;&amp;lt; (ResetNumber &amp;amp; 31);
/* Reset will auto clear after 1 clock cycle */
}
&lt;/PRE&gt; &lt;/TD&gt;&lt;/TR&gt;&lt;/TBODY&gt;&lt;/TABLE&gt;&lt;BR /&gt;&lt;SPAN&gt;Herein lies an insidious bug.&amp;nbsp; Writing zero to bit 24 of LPC_RGU-&amp;gt;RESET_CTRL[1] will start the M0 core.&amp;nbsp; If you're not expecting that, and haven't set things up properly, M0 will start running random code, leading to unpredictable consequences.&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;There is a simple workaround:&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;TABLE border="1"&gt;&lt;TBODY&gt;&lt;TR&gt;&lt;TD bgcolor="#cacaca"&gt; &lt;PRE&gt;
if((ResetNumber &amp;gt;&amp;gt; 5) == 1) {
LPC_RGU-&amp;gt;RESET_CTRL[1] = (1 &amp;lt;&amp;lt; (ResetNumber &amp;amp; 31)) | (1 &amp;lt;&amp;lt; 24);
} else {
LPC_RGU-&amp;gt;RESET_CTRL[ResetNumber &amp;gt;&amp;gt; 5] = 1 &amp;lt;&amp;lt; (ResetNumber &amp;amp; 31);
}
&lt;/PRE&gt; &lt;/TD&gt;&lt;/TR&gt;&lt;/TBODY&gt;&lt;/TABLE&gt;&lt;BR /&gt;&lt;SPAN&gt;... but this assumes you don't want M0 running.&amp;nbsp; In general, I suppose you could set only bit (ResetNumber &amp;amp; 31) by using the bit-band memory.&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;It should be noted (if only for the benefit of people debugging via Google) that Chip_RGU_TriggerReset is called by Chip_HSADC_Init and Chip_ENET_Init, so those functions could also lead to a crash.&lt;/SPAN&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Wed, 15 Jun 2016 20:17:37 GMT</pubDate>
      <guid>https://community.nxp.com/t5/LPC-Microcontrollers/Bug-Chip-RGU-TriggerReset-starts-M0-core/m-p/576094#M19372</guid>
      <dc:creator>lpcware</dc:creator>
      <dc:date>2016-06-15T20:17:37Z</dc:date>
    </item>
    <item>
      <title>Re: Bug: Chip_RGU_TriggerReset starts M0 core</title>
      <link>https://community.nxp.com/t5/LPC-Microcontrollers/Bug-Chip-RGU-TriggerReset-starts-M0-core/m-p/576095#M19373</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;STRONG&gt;Content originally posted in LPCWare by briching on Tue Oct 06 08:51:14 MST 2015&lt;/STRONG&gt;&lt;BR /&gt;&lt;SPAN&gt;What part are you using?&amp;nbsp; On some parts, the reset functionality doesn't work as designed (or could even be undefined)&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;A href="http://http://www.nxp.com/documents/errata_sheet/ES_LPC435X_3X_2X_1X_FLASH.pdf"&gt;LPC4357 errata sheet&lt;/A&gt;&lt;SPAN&gt; - see the sections on RESET.1 and RESET.2&lt;/SPAN&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Wed, 15 Jun 2016 20:17:38 GMT</pubDate>
      <guid>https://community.nxp.com/t5/LPC-Microcontrollers/Bug-Chip-RGU-TriggerReset-starts-M0-core/m-p/576095#M19373</guid>
      <dc:creator>lpcware</dc:creator>
      <dc:date>2016-06-15T20:17:38Z</dc:date>
    </item>
    <item>
      <title>Re: Bug: Chip_RGU_TriggerReset starts M0 core</title>
      <link>https://community.nxp.com/t5/LPC-Microcontrollers/Bug-Chip-RGU-TriggerReset-starts-M0-core/m-p/576096#M19374</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;STRONG&gt;Content originally posted in LPCWare by dstahlke on Tue Oct 06 19:17:45 MST 2015&lt;/STRONG&gt;&lt;BR /&gt;&lt;SPAN&gt;I'm using LPC4370.&amp;nbsp; The errata sheet says MASTER_RST, M4_RST, and PERIPH_RST are non-functional.&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;The problem I was having was caused not by a hardware problem, but by LPCOpen.&amp;nbsp; I was calling Chip_RGU_TriggerReset(RGU_TIMER2_RST), which should (and does) set the corresponding bit in RESET_CTRL.&amp;nbsp; Problem is it also clears the M0_SUB_RST or M0APP_RST bit, depending on whether RESET_CTRL[0] or RESET_CTRL[1] is being altered.&amp;nbsp; This takes the M0 core out of reset or something (I don't really know much about the M0).&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;Note: when I wrote the above workaround, I didn't realize that RESET_CTRL[0] also has an M0 related bit.&amp;nbsp; So when RESET_CTRL[0] is written, make sure not to clear bit 12.&lt;/SPAN&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Wed, 15 Jun 2016 20:17:38 GMT</pubDate>
      <guid>https://community.nxp.com/t5/LPC-Microcontrollers/Bug-Chip-RGU-TriggerReset-starts-M0-core/m-p/576096#M19374</guid>
      <dc:creator>lpcware</dc:creator>
      <dc:date>2016-06-15T20:17:38Z</dc:date>
    </item>
    <item>
      <title>Re: Bug: Chip_RGU_TriggerReset starts M0 core</title>
      <link>https://community.nxp.com/t5/LPC-Microcontrollers/Bug-Chip-RGU-TriggerReset-starts-M0-core/m-p/576097#M19375</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;STRONG&gt;Content originally posted in LPCWare by dstahlke on Tue Oct 06 21:14:19 MST 2015&lt;/STRONG&gt;&lt;BR /&gt;&lt;SPAN&gt;In order to set a bit in RESET_CTRL without clearing the M0 related bits, I tried writing to the bit band region.&amp;nbsp; Didn't work, causes a hard fault.&amp;nbsp; I've heard bit band described as atomic read-modify-write, so maybe the issue is that RESET_CTRL is write-only so bit band can't be used.&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;TABLE border="1"&gt;&lt;TBODY&gt;&lt;TR&gt;&lt;TD bgcolor="#cacaca"&gt; &lt;PRE&gt;
static inline volatile uint32_t *bitband_peri(volatile void *p, int bit) {
&amp;nbsp;&amp;nbsp;&amp;nbsp; uint32_t base = 0x42000000;
&amp;nbsp;&amp;nbsp;&amp;nbsp; uint32_t ref&amp;nbsp; = 0x40000000;
&amp;nbsp;&amp;nbsp;&amp;nbsp; return (uint32_t *)(base + (uint32_t(p)-ref)*32 + bit*4);
}

static inline void my_reset(int bit) {
&amp;nbsp;&amp;nbsp;&amp;nbsp; *bitband_peri(LPC_RGU-&amp;gt;RESET_CTRL, bit) = 1;
}

int main() {
&amp;nbsp;&amp;nbsp;&amp;nbsp; ....
&amp;nbsp;&amp;nbsp;&amp;nbsp; my_reset(RGU_TIMER2_RST);
&amp;nbsp;&amp;nbsp;&amp;nbsp; ....
}
&lt;/PRE&gt; &lt;/TD&gt;&lt;/TR&gt;&lt;/TBODY&gt;&lt;/TABLE&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Wed, 15 Jun 2016 20:17:39 GMT</pubDate>
      <guid>https://community.nxp.com/t5/LPC-Microcontrollers/Bug-Chip-RGU-TriggerReset-starts-M0-core/m-p/576097#M19375</guid>
      <dc:creator>lpcware</dc:creator>
      <dc:date>2016-06-15T20:17:39Z</dc:date>
    </item>
    <item>
      <title>Re: Bug: Chip_RGU_TriggerReset starts M0 core</title>
      <link>https://community.nxp.com/t5/LPC-Microcontrollers/Bug-Chip-RGU-TriggerReset-starts-M0-core/m-p/576098#M19376</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;STRONG&gt;Content originally posted in LPCWare by starblue on Wed Oct 07 02:00:54 MST 2015&lt;/STRONG&gt;&lt;BR /&gt;&lt;HR /&gt;&lt;SPAN style="color: #0000ff;"&gt;&lt;STRONG&gt;Quote: dstahlke&lt;/STRONG&gt;&lt;BR /&gt;I'm using LPC4370.&lt;/SPAN&gt;&lt;HR /&gt;&lt;BR /&gt;&lt;SPAN&gt;Note that the same reset behavior applies for M0SUB, not only M0APP.&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;For a general solution you should probably read RESET_ACTIVE_STATUSn first and make sure to preserve the reset status for the M0s when writing to RESET_CTRLn.&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;STRONG&gt;Note to NXP:&lt;/STRONG&gt;&lt;SPAN&gt; The paragraph preceding the tables for RESET_CTRLn should IMHO also mention M0SUB.&lt;/SPAN&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Wed, 15 Jun 2016 20:17:39 GMT</pubDate>
      <guid>https://community.nxp.com/t5/LPC-Microcontrollers/Bug-Chip-RGU-TriggerReset-starts-M0-core/m-p/576098#M19376</guid>
      <dc:creator>lpcware</dc:creator>
      <dc:date>2016-06-15T20:17:39Z</dc:date>
    </item>
  </channel>
</rss>

