<?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 Deep-sleep issue with PD0_SLEEP0_HW_ENA register in LPC Microcontrollers</title>
    <link>https://community.nxp.com/t5/LPC-Microcontrollers/Deep-sleep-issue-with-PD0-SLEEP0-HW-ENA-register/m-p/555203#M14909</link>
    <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;STRONG&gt;Content originally posted in LPCWare by wlan8051 on Thu Aug 08 03:13:50 MST 2013&lt;/STRONG&gt;&lt;BR /&gt;&lt;SPAN&gt;So I'm trying to put the LPC4330 to Deep-sleep. &lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;According to the manual the first thing to do is to enable the core initiating the transition, by writing a 1 (for the M4 core) or 2 (for the M0 core) to PD0_SLEEP0_HW_ENA. Only the first two bits in this register are to be written to, since 2:31 are Reserved and "user software should not write ones to reserved bits". Truth is that configuring this usually isn't really necessary since the default value for this bit field is "1", so if you want the M4 core to initiate putting the chip to sleep you can skip this step altogether. The CMSIS library does exactly that and doesn't touch it at all.&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;The problem I found is that if you actually do want to write to this register, it will mess up the sleep mode you're trying to put your chip to. For me it was losing the logic states of the GPIOs after entering what was configured as Deep-sleep, this should normally happen only in Deep Power-down mode. Also the current consumption was much lower than expected.&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;Long story short: there's a register you never really touch if you're using the peripheral library such that if you actually DO write to(even if it means just overwriting the default after-reset value), it will mess up the sleep mode you're trying to enter. Anyone had a similar experience?&lt;/SPAN&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
    <pubDate>Wed, 15 Jun 2016 18:41:03 GMT</pubDate>
    <dc:creator>lpcware</dc:creator>
    <dc:date>2016-06-15T18:41:03Z</dc:date>
    <item>
      <title>Deep-sleep issue with PD0_SLEEP0_HW_ENA register</title>
      <link>https://community.nxp.com/t5/LPC-Microcontrollers/Deep-sleep-issue-with-PD0-SLEEP0-HW-ENA-register/m-p/555203#M14909</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;STRONG&gt;Content originally posted in LPCWare by wlan8051 on Thu Aug 08 03:13:50 MST 2013&lt;/STRONG&gt;&lt;BR /&gt;&lt;SPAN&gt;So I'm trying to put the LPC4330 to Deep-sleep. &lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;According to the manual the first thing to do is to enable the core initiating the transition, by writing a 1 (for the M4 core) or 2 (for the M0 core) to PD0_SLEEP0_HW_ENA. Only the first two bits in this register are to be written to, since 2:31 are Reserved and "user software should not write ones to reserved bits". Truth is that configuring this usually isn't really necessary since the default value for this bit field is "1", so if you want the M4 core to initiate putting the chip to sleep you can skip this step altogether. The CMSIS library does exactly that and doesn't touch it at all.&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;The problem I found is that if you actually do want to write to this register, it will mess up the sleep mode you're trying to put your chip to. For me it was losing the logic states of the GPIOs after entering what was configured as Deep-sleep, this should normally happen only in Deep Power-down mode. Also the current consumption was much lower than expected.&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;Long story short: there's a register you never really touch if you're using the peripheral library such that if you actually DO write to(even if it means just overwriting the default after-reset value), it will mess up the sleep mode you're trying to enter. Anyone had a similar experience?&lt;/SPAN&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Wed, 15 Jun 2016 18:41:03 GMT</pubDate>
      <guid>https://community.nxp.com/t5/LPC-Microcontrollers/Deep-sleep-issue-with-PD0-SLEEP0-HW-ENA-register/m-p/555203#M14909</guid>
      <dc:creator>lpcware</dc:creator>
      <dc:date>2016-06-15T18:41:03Z</dc:date>
    </item>
    <item>
      <title>Re: Deep-sleep issue with PD0_SLEEP0_HW_ENA register</title>
      <link>https://community.nxp.com/t5/LPC-Microcontrollers/Deep-sleep-issue-with-PD0-SLEEP0-HW-ENA-register/m-p/555204#M14910</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;STRONG&gt;Content originally posted in LPCWare by xianghuiwang on Mon Sep 02 23:15:35 MST 2013&lt;/STRONG&gt;&lt;BR /&gt;&lt;SPAN&gt;Hi, &lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;Interesting observation. Let us try it - never touched this register.&lt;/SPAN&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Wed, 15 Jun 2016 18:41:04 GMT</pubDate>
      <guid>https://community.nxp.com/t5/LPC-Microcontrollers/Deep-sleep-issue-with-PD0-SLEEP0-HW-ENA-register/m-p/555204#M14910</guid>
      <dc:creator>lpcware</dc:creator>
      <dc:date>2016-06-15T18:41:04Z</dc:date>
    </item>
    <item>
      <title>Re: Deep-sleep issue with PD0_SLEEP0_HW_ENA register</title>
      <link>https://community.nxp.com/t5/LPC-Microcontrollers/Deep-sleep-issue-with-PD0-SLEEP0-HW-ENA-register/m-p/555205#M14911</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;I had the same problem using deep sleep mode (LPC_PMC-&amp;gt;PD0_SLEEP0_MODE = PMC_PWR_DEEP_SLEEP_MODE):&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Setting LPC_PMC-&amp;gt;PD0_SLEEP0_HW_ENA = 0x2 seems to put the whole chip in a weird state. The GPIO state seems to be completely lost. Current consumption is unknown, as the peripherals on my board use a lot of power with the GPIOs in undefined state. As far as I have seen this happens in two cases:&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;UL&gt;&lt;LI&gt;writing LPC_PMC-&amp;gt;PD0_SLEEP0_HW_ENA=0x2 while the M0 core is not yet booted: the GPIO state is immediately lost, M4 core hangs, even if not entering a sleep at all!&lt;/LI&gt;&lt;LI&gt;writing LPC_PMC-&amp;gt;PD0_SLEEP0_HW_ENA=0x2 before entering sleep mode on the M0 core: the GPIO state is lost as soon as sleep mode is entered on the M0 with Chip_PMC_Set_PwrState()&lt;/LI&gt;&lt;/UL&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;Solution/workaround:&lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;The order in which the LPC_PMC registers are set seem to be important. It looks like the PD0_SLEEP0_HW_ENA register must be set &lt;STRONG&gt;after&lt;/STRONG&gt; PD0_SLEEP0_MODE, contrary to the order as described in the user manual 12.2.3. See below for a fixed version of PCM_Set_PwrState(). &lt;STRONG&gt;Note the addition at line 15:&lt;/STRONG&gt;&lt;/P&gt;&lt;PRE class="language-c line-numbers"&gt;&lt;CODE&gt;&lt;SPAN class="keyword token"&gt;typedef&lt;/SPAN&gt; &lt;SPAN class="keyword token"&gt;enum&lt;/SPAN&gt; &lt;SPAN class="punctuation token"&gt;{&lt;/SPAN&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp; ENA_EVENT0 &lt;SPAN class="operator token"&gt;=&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="operator token"&gt;&amp;lt;&amp;lt;&lt;/SPAN&gt; &lt;SPAN class="number token"&gt;0&lt;/SPAN&gt;&lt;SPAN class="punctuation token"&gt;)&lt;/SPAN&gt;&lt;SPAN class="punctuation token"&gt;,&lt;/SPAN&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp; ENA_EVENT1 &lt;SPAN class="operator token"&gt;=&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="operator token"&gt;&amp;lt;&amp;lt;&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; ENA_EVENT&lt;SPAN class="punctuation token"&gt;;&lt;/SPAN&gt;

&lt;SPAN class="keyword token"&gt;void&lt;/SPAN&gt; &lt;SPAN class="token function"&gt;PMC_Set_PwrState&lt;/SPAN&gt;&lt;SPAN class="punctuation token"&gt;(&lt;/SPAN&gt;CHIP_PMC_PWR_STATE_T pwr_state&lt;SPAN class="punctuation token"&gt;,&lt;/SPAN&gt; ENA_EVENT ena_event&lt;SPAN class="punctuation token"&gt;)&lt;/SPAN&gt;
&lt;SPAN class="punctuation token"&gt;{&lt;/SPAN&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp; uint32_t prev_scr &lt;SPAN class="operator token"&gt;=&lt;/SPAN&gt; SCB&lt;SPAN class="operator token"&gt;-&amp;gt;&lt;/SPAN&gt;SCR&lt;SPAN class="punctuation token"&gt;;&lt;/SPAN&gt;

&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;SPAN class="comment token"&gt;// Set deep sleep mode bit in core-specific System Control Register&lt;/SPAN&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;SCB&lt;SPAN class="operator token"&gt;-&amp;gt;&lt;/SPAN&gt;SCR&lt;SPAN class="operator token"&gt;|&lt;/SPAN&gt;&lt;SPAN class="operator token"&gt;=&lt;/SPAN&gt; &lt;SPAN class="number token"&gt;0x4&lt;/SPAN&gt;&lt;SPAN class="punctuation token"&gt;;&lt;/SPAN&gt;

&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;SPAN class="comment token"&gt;/* Set power state in PMC */&lt;/SPAN&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;LPC_PMC&lt;SPAN class="operator token"&gt;-&amp;gt;&lt;/SPAN&gt;PD0_SLEEP0_MODE &lt;SPAN class="operator token"&gt;=&lt;/SPAN&gt; &lt;SPAN class="punctuation token"&gt;(&lt;/SPAN&gt;uint32_t&lt;SPAN class="punctuation token"&gt;)&lt;/SPAN&gt; pwr_state&lt;SPAN class="punctuation token"&gt;;&lt;/SPAN&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp; LPC_PMC&lt;SPAN class="operator token"&gt;-&amp;gt;&lt;/SPAN&gt;PD0_SLEEP0_HW_ENA &lt;SPAN class="operator token"&gt;=&lt;/SPAN&gt; &lt;SPAN class="punctuation token"&gt;(&lt;/SPAN&gt;uint32_t&lt;SPAN class="punctuation token"&gt;)&lt;/SPAN&gt; ena_event&lt;SPAN class="punctuation token"&gt;;&lt;/SPAN&gt;

&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;SPAN class="token function"&gt;__WFI&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;
&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;SPAN class="comment token"&gt;// restore deep sleep bit&lt;/SPAN&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;SCB&lt;SPAN class="operator token"&gt;-&amp;gt;&lt;/SPAN&gt;SCR &lt;SPAN class="operator token"&gt;=&lt;/SPAN&gt; prev_scr &lt;SPAN class="operator token"&gt;&amp;amp;&lt;/SPAN&gt; &lt;SPAN class="number token"&gt;0x1F&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;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;So far this code works for me. To put the LPC43xx in deep sleep mode from the M0 core, call the new PMC_Set_PwrState function:&lt;/P&gt;&lt;PRE class="language-c line-numbers"&gt;&lt;CODE&gt;&lt;SPAN class="comment token"&gt;// Put the LPC43xx in deep sleep from the M0 core&lt;/SPAN&gt;
&lt;SPAN class="token function"&gt;PMC_Set_PwrState&lt;/SPAN&gt;&lt;SPAN class="punctuation token"&gt;(&lt;/SPAN&gt;PMC_PWR_DEEP_SLEEP_MODE&lt;SPAN class="punctuation token"&gt;,&lt;/SPAN&gt; ENA_EVENT1&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;/CODE&gt;&lt;/PRE&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Mon, 08 May 2017 11:16:37 GMT</pubDate>
      <guid>https://community.nxp.com/t5/LPC-Microcontrollers/Deep-sleep-issue-with-PD0-SLEEP0-HW-ENA-register/m-p/555205#M14911</guid>
      <dc:creator>sdw</dc:creator>
      <dc:date>2017-05-08T11:16:37Z</dc:date>
    </item>
  </channel>
</rss>

