lpc23xx FreeRTOS and sleep or power down mode

ben_fnr wrote on Wednesday, August 25, 2010:

I am trying to put an LPC2368 into power down or sleep mode.
I can get the chip to sleep and wakeup with out any problems, however I sometimes get data aborts after waking up.

Now I just want to check what I am doing with FreeRTOS is correct.

I have several tasks running. When it is time to sleep most of the tasks block on a semaphore.

So when going to sleep, I call taskENTER_CRITICAL(), stop the RTOS timer and put the chip into power down mode.

Upon waking I start the RTOS timer and call taskEXIT_CRITICAL().

Can anyone see any problems with this ?

Using GCC to compile.

thanks
Ben

rtel wrote on Thursday, August 26, 2010:

Where are the ENTER/EXIT critical functions called from, and is it as part of the same sequential code?

I don’t have experience of sleep modes on LPC2000’s I’m sorry to say, so assistance will be limited if there is some quirk of the architecture that could cause a problem, but I would suggest writing a test program without FreeRTOS included to see if it is kernel related or not.  For example, have a program that sets up a tick interrupt that does nothing much (maybe toggle an LED every 100ms), then execute code to disable interrupts and put into sleep mode - then when waking up enable interrupts and see if the LED starts flashing again.

Regards.

ben_fnr wrote on Tuesday, August 31, 2010:

the Enter- Sleep - Exit  are all inside a function called from one of the running tasks.

I am re-checking all the code paths inside the Enter/Exit calls to make sure no FreeRTOS calls are made ( I don’t think any are).

I think my problems are timing/interrupt based with some memory corruption, but I am not 100% sure on that. Most of the time everything resumes as normal.

Fairly sure it is not a stack issue. I have plenty of free RAM and so have increased stacks sizes quite a bit.  vTaskList() reports plenty of free space for the tasks.

I am assuming stopping the RTOS timer would in effect halt the RTOS and as long as I make no api calls that would result in a task switch, I would be pretty safe.

If you had to suspend the RTOS to put a chip to sleep how would you go about it ?