Certain tasks stop running

mishung wrote on Thursday, March 30, 2017:

Hello! I have a problem that after a random ammount of time (10minutes - 12hours) certain tasks stop executing. I believe this is caused by some kind of data corruption caused by me but I can’t seem to find when and what gets corrupted. Can you suggest any dubugging utility that could help me find out what happens? Or where to set data breakpoint?

What I know so far:
Total ammount of SRAM available: 16kB
Total ammount of SRAM used: 10,9kB
Heap size: 6kB (only 3,8kB actually used)
Number of tasks: 12
Number of priorities: 4
No stack overflow detected anywhere, every task has at least 50 words high water mark

I called the vTaskList after 2 of the tasks stopped working and one of these two was in Blocked state and the other one was in Ready state. Both of them had about 100words of stack still unused. One of them had a priority of 4 which no other task has and it is the simplest task of them all so there is no way it could get stuck in a loop (actually there is no loop in that task).

Here is the code to the priority 4 task that stopped executing:

void pwrTask(void* p)
{
	for ever
	{
		if(power_is_dropout())
			go_sleep();
			
		vTaskDelay(1);
		
		// monitor for maximal stack depth
		pwrTask_high_water_mark = uxTaskGetStackHighWaterMark(NULL);
	}
}

I am using a port of FreeRTOS on AVR atmel xmega256a3u (8 bit).

Any suggestion would be greatly appreciated!

rtel wrote on Thursday, March 30, 2017:

There are a few debug aware plug-ins and the trace tool available, but
that’s a pretty small and basic device, so I don’t think they are going
to work for you.

What does the go_sleep() function do?

mishung wrote on Thursday, March 30, 2017:

Yes indeed, the trace tool does not work in this case, unfortunately. The go_sleep() does something in this manner:

disable_peripheral_x();
disable_peripheral_y();

while(!power_is_stable)
sleep_cpu();

enable_peripheral_x();
enable_peripheral_y();

but if the power was out and go_sleep() was called, nothing would work because it stops everything except the RTC. And this function has been tested numerous times, if I turn the power off, the MCU goes to sleep mode and after the power is back on it wakes up no problem.