FreeRTOS Support Archive

The FreeRTOS support forum can be used for active support both from Amazon Web Services
and the community. In return for using our software for
free, we request you play fair and do your bit to help others! Sign up
to receive notifications of new support topics then help where you can.

This is a read only archive of threads posted to the FreeRTOS support forum.
The archive is updated every week, so will not always contain the very latest posts.
Use these archive pages to search previous posts. Use the Live FreeRTOS Forum
link to reply to a post, or start a new support thread.

Tickless idle atmel sam3x device

I've been experimenting with the tickless idle functionality and have a few questions. I need to put our device into a lower power mode which involves changing the main clock speed to a lower value and restoring it upon waking. I've figured out all the details and it works as expected.

But I ran into an issue where the device would enter sleep mode while waiting on peripherals to complete. Unfortunately when entering sleep the resulting change in the main clock also changes affects the peripherals operation. So I modified the sleepmgr code that atmel provides to provide a locking mechanism around the code that deals with the peripherals.

As you can see I wrapped a mutex around a variable array that keeps the lock count for various depths of sleeping. So I though I would put the call sleepmgrgetsleepmode() to determine if we should sleep or not into the portSUPPRESSTICKSANDSLEEP call only to realize that portSUPPRESSTICKSAND_SLEEP is just another hook into the Idle task which can have no blocking calls.

How should I be handling this? How do i get around not blocking in the idle task?

Thanks in advance,
Bill

a snippet of the sleepmgr code:

static inline void sleepmgrinit(void)
{
uint8t i;

/* semaphore used to access the sleep level as it is written to from more than one task. */
sleepmgr_mutex = xSemaphoreCreateMutex();
xSemaphoreTake(sleepmgr_mutex, portMAX_DELAY);
for (i = 0; i < SLEEPMGR_NR_OF_MODES - 1; i++) {
sleepmgr_locks[i] = 0;
}
sleepmgr_locks[SLEEPMGR_NR_OF_MODES - 1] = 1;
xSemaphoreGive(sleepmgr_mutex);

Tickless idle atmel sam3x device

The semaphore is probably only needed when changing the lock count. So tasks that update the lock count could use the functions with the mutex, and the idle task could use a function without a mutex just to read the lock counts as long is it does not change them. Would that work for you?