Difficulties with FreeRTOS and Sleep

キャンセル
次の結果を表示 
表示  限定  | 次の代わりに検索 
もしかして: 

Difficulties with FreeRTOS and Sleep

1,181件の閲覧回数
lpcware
NXP Employee
NXP Employee
Content originally posted in LPCWare by artk on Wed Apr 20 16:34:48 MST 2011
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.

I'm using the RTC to schedule a waking interrupt.

The code in question:

Quote:
RTC_Init( LPC_RTC );

RTC_CntIncrIntConfig( LPC_RTC, RTC_TIMETYPE_SECOND, DISABLE );
RTC_AlarmIntConfig( LPC_RTC, RTC_TIMETYPE_SECOND, ENABLE );

RTC_ClearIntPending( LPC_RTC, RTC_INT_ALARM );

while(1){

   RTC_SetTime( LPC_RTC, RTC_TIMETYPE_SECOND, 0 );
   RTC_SetAlarmTime( LPC_RTC, RTC_TIMETYPE_SECOND, 5 );
   RTC_ResetClockTickCounter( LPC_RTC );

   RTC_Cmd( LPC_RTC, ENABLE );
   NVIC_EnableIRQ( RTC_IRQn );

   consoleprint("Good night 3O...\n");
   CLKPWR_Sleep();
   consoleprint(";O Good morning...\n");

}

void RTC_IRQHandler( void ) {

   if ( RTC_GetIntPending( LPC_RTC, RTC_INT_ALARM ) ) {
      RTC_ClearIntPending( LPC_RTC, RTC_INT_ALARM );
      RTC_Cmd( LPC_RTC, DISABLE );
      NVIC_DisableIRQ( RTC_IRQn );
   }

}



The problem:
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.

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.

Suggestions? Thank you very much!
0 件の賞賛
返信
1 返信

1,066件の閲覧回数
lpcware
NXP Employee
NXP Employee
Content originally posted in LPCWare by artk on Fri Apr 22 11:48:17 MST 2011
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:

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.

The solution to this is to include portDISABLE_INTERRUPTS() before setting up the alarm and going to sleep and including portENABLE_INTERRUPTS() after.
0 件の賞賛
返信