<?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 Difficulties with FreeRTOS and Sleep in LPCXpresso IDE</title>
    <link>https://community.nxp.com/t5/LPCXpresso-IDE/Difficulties-with-FreeRTOS-and-Sleep/m-p/540064#M6774</link>
    <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;STRONG&gt;Content originally posted in LPCWare by artk on Wed Apr 20 16:34:48 MST 2011&lt;/STRONG&gt;&lt;BR /&gt;&lt;SPAN&gt;Hello all, I've been trying for a couple of days now to get my LPC1769 board running FreeRTOS to either go into sleep or into deep power down without much success. Some advise would be much appreciated.&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;I'm using the RTC to schedule a waking interrupt.&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;The code in question:&lt;/SPAN&gt;&lt;BR /&gt;&lt;HR /&gt;&lt;SPAN style="color: #0000ff;"&gt;&lt;STRONG&gt;Quote: &lt;/STRONG&gt;&lt;BR /&gt;RTC_Init( LPC_RTC );&lt;BR /&gt;&lt;BR /&gt;RTC_CntIncrIntConfig( LPC_RTC, RTC_TIMETYPE_SECOND, DISABLE );&lt;BR /&gt;RTC_AlarmIntConfig( LPC_RTC, RTC_TIMETYPE_SECOND, ENABLE );&lt;BR /&gt;&lt;BR /&gt;RTC_ClearIntPending( LPC_RTC, RTC_INT_ALARM );&lt;BR /&gt;&lt;BR /&gt;while(1){&lt;BR /&gt;&lt;BR /&gt;&amp;nbsp;&amp;nbsp; RTC_SetTime( LPC_RTC, RTC_TIMETYPE_SECOND, 0 );&lt;BR /&gt;&amp;nbsp;&amp;nbsp; RTC_SetAlarmTime( LPC_RTC, RTC_TIMETYPE_SECOND, 5 );&lt;BR /&gt;&amp;nbsp;&amp;nbsp; RTC_ResetClockTickCounter( LPC_RTC );&lt;BR /&gt;&lt;BR /&gt;&amp;nbsp;&amp;nbsp; RTC_Cmd( LPC_RTC, ENABLE );&lt;BR /&gt;&amp;nbsp;&amp;nbsp; NVIC_EnableIRQ( RTC_IRQn );&lt;BR /&gt;&lt;BR /&gt;&amp;nbsp;&amp;nbsp; consoleprint("Good night 3O...\n");&lt;BR /&gt;&amp;nbsp;&amp;nbsp; CLKPWR_Sleep();&lt;BR /&gt;&amp;nbsp;&amp;nbsp; consoleprint(";O Good morning...\n");&lt;BR /&gt;&lt;BR /&gt;}&lt;BR /&gt;&lt;BR /&gt;void RTC_IRQHandler( void ) {&lt;BR /&gt;&lt;BR /&gt;&amp;nbsp;&amp;nbsp; if ( RTC_GetIntPending( LPC_RTC, RTC_INT_ALARM ) ) {&lt;BR /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; RTC_ClearIntPending( LPC_RTC, RTC_INT_ALARM );&lt;BR /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; RTC_Cmd( LPC_RTC, DISABLE );&lt;BR /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; NVIC_DisableIRQ( RTC_IRQn );&lt;BR /&gt;&amp;nbsp;&amp;nbsp; }&lt;BR /&gt;&lt;BR /&gt;}&lt;BR /&gt;&lt;/SPAN&gt;&lt;HR /&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;The problem:&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;When I run my code in main, it works as expected: every 5 seconds I manage to print to the console. I then create a task/thread and cut and paste the same code into this new task. Now, there is no 5 second wait.&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;I've determined that if I replace CLKPWR_Sleep(); with a while(1) and place a breakpoint in the IRQ handler, the interrupt is indeed occuring. With CLKPWR_Sleep(), the IRQ handler is never entered.&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;Suggestions? Thank you very much!&lt;/SPAN&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
    <pubDate>Wed, 15 Jun 2016 21:53:34 GMT</pubDate>
    <dc:creator>lpcware</dc:creator>
    <dc:date>2016-06-15T21:53:34Z</dc:date>
    <item>
      <title>Difficulties with FreeRTOS and Sleep</title>
      <link>https://community.nxp.com/t5/LPCXpresso-IDE/Difficulties-with-FreeRTOS-and-Sleep/m-p/540064#M6774</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;STRONG&gt;Content originally posted in LPCWare by artk on Wed Apr 20 16:34:48 MST 2011&lt;/STRONG&gt;&lt;BR /&gt;&lt;SPAN&gt;Hello all, I've been trying for a couple of days now to get my LPC1769 board running FreeRTOS to either go into sleep or into deep power down without much success. Some advise would be much appreciated.&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;I'm using the RTC to schedule a waking interrupt.&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;The code in question:&lt;/SPAN&gt;&lt;BR /&gt;&lt;HR /&gt;&lt;SPAN style="color: #0000ff;"&gt;&lt;STRONG&gt;Quote: &lt;/STRONG&gt;&lt;BR /&gt;RTC_Init( LPC_RTC );&lt;BR /&gt;&lt;BR /&gt;RTC_CntIncrIntConfig( LPC_RTC, RTC_TIMETYPE_SECOND, DISABLE );&lt;BR /&gt;RTC_AlarmIntConfig( LPC_RTC, RTC_TIMETYPE_SECOND, ENABLE );&lt;BR /&gt;&lt;BR /&gt;RTC_ClearIntPending( LPC_RTC, RTC_INT_ALARM );&lt;BR /&gt;&lt;BR /&gt;while(1){&lt;BR /&gt;&lt;BR /&gt;&amp;nbsp;&amp;nbsp; RTC_SetTime( LPC_RTC, RTC_TIMETYPE_SECOND, 0 );&lt;BR /&gt;&amp;nbsp;&amp;nbsp; RTC_SetAlarmTime( LPC_RTC, RTC_TIMETYPE_SECOND, 5 );&lt;BR /&gt;&amp;nbsp;&amp;nbsp; RTC_ResetClockTickCounter( LPC_RTC );&lt;BR /&gt;&lt;BR /&gt;&amp;nbsp;&amp;nbsp; RTC_Cmd( LPC_RTC, ENABLE );&lt;BR /&gt;&amp;nbsp;&amp;nbsp; NVIC_EnableIRQ( RTC_IRQn );&lt;BR /&gt;&lt;BR /&gt;&amp;nbsp;&amp;nbsp; consoleprint("Good night 3O...\n");&lt;BR /&gt;&amp;nbsp;&amp;nbsp; CLKPWR_Sleep();&lt;BR /&gt;&amp;nbsp;&amp;nbsp; consoleprint(";O Good morning...\n");&lt;BR /&gt;&lt;BR /&gt;}&lt;BR /&gt;&lt;BR /&gt;void RTC_IRQHandler( void ) {&lt;BR /&gt;&lt;BR /&gt;&amp;nbsp;&amp;nbsp; if ( RTC_GetIntPending( LPC_RTC, RTC_INT_ALARM ) ) {&lt;BR /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; RTC_ClearIntPending( LPC_RTC, RTC_INT_ALARM );&lt;BR /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; RTC_Cmd( LPC_RTC, DISABLE );&lt;BR /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; NVIC_DisableIRQ( RTC_IRQn );&lt;BR /&gt;&amp;nbsp;&amp;nbsp; }&lt;BR /&gt;&lt;BR /&gt;}&lt;BR /&gt;&lt;/SPAN&gt;&lt;HR /&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;The problem:&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;When I run my code in main, it works as expected: every 5 seconds I manage to print to the console. I then create a task/thread and cut and paste the same code into this new task. Now, there is no 5 second wait.&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;I've determined that if I replace CLKPWR_Sleep(); with a while(1) and place a breakpoint in the IRQ handler, the interrupt is indeed occuring. With CLKPWR_Sleep(), the IRQ handler is never entered.&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;Suggestions? Thank you very much!&lt;/SPAN&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Wed, 15 Jun 2016 21:53:34 GMT</pubDate>
      <guid>https://community.nxp.com/t5/LPCXpresso-IDE/Difficulties-with-FreeRTOS-and-Sleep/m-p/540064#M6774</guid>
      <dc:creator>lpcware</dc:creator>
      <dc:date>2016-06-15T21:53:34Z</dc:date>
    </item>
    <item>
      <title>Re: Difficulties with FreeRTOS and Sleep</title>
      <link>https://community.nxp.com/t5/LPCXpresso-IDE/Difficulties-with-FreeRTOS-and-Sleep/m-p/540065#M6775</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;STRONG&gt;Content originally posted in LPCWare by artk on Fri Apr 22 11:48:17 MST 2011&lt;/STRONG&gt;&lt;BR /&gt;&lt;SPAN&gt;I've figured out what the problem was and I just wanted to let anyone that is having/will have the same problem know the solution:&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;The CLKPWR_Sleep() includes the WFI (wait for interrupt) assembly instruction. So the microcontroller will wake up at anytime that an interrupt is occurring. The problem was within the scheduler: it runs on interrupts, so the WFI instruction would only wait a very short amount of time since the scheduler is constantly running interrupts.&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;The solution to this is to include portDISABLE_INTERRUPTS() before setting up the alarm and going to sleep and including portENABLE_INTERRUPTS() after.&lt;/SPAN&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Wed, 15 Jun 2016 21:53:35 GMT</pubDate>
      <guid>https://community.nxp.com/t5/LPCXpresso-IDE/Difficulties-with-FreeRTOS-and-Sleep/m-p/540065#M6775</guid>
      <dc:creator>lpcware</dc:creator>
      <dc:date>2016-06-15T21:53:35Z</dc:date>
    </item>
  </channel>
</rss>

