FreeRTOS on sam3x8e reboot after 10s

funkystuff wrote on Wednesday, December 02, 2015:

Hi everyone!
I’m novice on freeRTOS…
i’m writing some code on sam3x8e and works great for the first 10s …
after this time freeRTOS seems to reboot and so on!!!
any ideas for the problem!?
thanks a lot.
Tommaso

rtel wrote on Wednesday, December 02, 2015:

I’m afraid you will have to provide more information in order to get a helpful reply. As it is all we could do is list out 100 different possibilities from the power supply browning out to your code overwritting critical data to a watchdog not being kicked.

Places to start:
http://www.freertos.org/FAQ-how-to-use-the-FreeRTOS-support-forum.html
http://www.freertos.org/FAQHelp.html

funkystuff wrote on Wednesday, December 02, 2015:

okey…Well…

uController -> Atmel sam3x8e
compiler -> ARM/GNU C compiler
freeRTOS version -> 7.3.0
SDK -> Atmel studio 7.0 with ASF

My application it’s composed by a simple task(sender) that create som messages and send theme to a specifica Queue and than it delete itself. To the other side there’s a task(motor_manager) that recive the messages from the queue and do some stuff. There’s the code:

Task sender:

void sender(void* pvParameters)
{
uint8_t rxValue;
motor_cmd cmd2 = {10,CCW,1,START};
motor_cmd cmd3 = {10,CCW,2,START};
motor_cmd cmd4 = {10,CCW,3,START};
motor_cmd cmd1 = {10,CCW,0,START};
uint8_t carattere = 33;
vTaskDelay(1000/portTICK_RATE_MS);
xQueueSend(tx_queue,&carattere,0);
xQueueSend(incoming_message,&cmd1,0);
xQueueSend(incoming_message,&cmd2,0);
xQueueSend(incoming_message,&cmd3,0);
xQueueSend(incoming_message,&cmd4,0);
while(1);
}

Task motor_manager:
void motor_manager(void* pvParameters)
{
portBASE_TYPE xStatus;
motor_cmd in_msg;
for (int i = 0;i < 8;i++)
{
if(pwm_ch_enable[i] == 1)
{
pwm_ch_enabled[i] = i;
nMotors[i].status = IDLE;
nMotors[i].isEnabled = true;
nMotors[i].cmd_steps = 0;
nMotors[i].remaning_steps = 0;
pio_configure_pin(CH0_PIN + i,PIO_TYPE_PIO_OUTPUT_0);
pio_set_pin_low(CH0_PIN + i);
xStatus = xTaskCreate(motor_channel_manager,“Gestore_canale”,configMINIMAL_STACK_SIZE,&pwm_ch_enabled[i],CHANNEL_TASK_PRIORITY,NULL);
if(xStatus != pdPASS)
{
A9488_drv_fault = true;
vTaskDelete(NULL);
}
}
}

vTaskPrioritySet(NULL,(configMAX_PRIORITIES - 3));
while(1)
{
	if (uxQueueMessagesWaiting(incoming_message) > 0)
	{
		xQueueReceive(incoming_message,&in_msg,portMAX_DELAY);
		if(nMotors[in_msg.ch].isEnabled && nMotors[in_msg.ch].status == IDLE)
		{
			nMotors[in_msg.ch].cmd_steps = in_msg.n_steps*2;
			nMotors[in_msg.ch].remaning_steps = nMotors[in_msg.ch].cmd_steps;
			nMotors[in_msg.ch].rot = in_msg.direction;
			nMotors[in_msg.ch].status = RUNNING;
		}
	}
	taskYIELD(); 
}

}

the main:

int main (void)
{
sysclk_init();
board_init();
irq_initialize_vectors();
cpu_irq_enable();

xTaskCreate(init_system_task,"Boot_task",configMINIMAL_STACK_SIZE,NULL,(configMAX_PRIORITIES - 2),NULL);
xTaskCreate(sender,"sender_task",configMINIMAL_STACK_SIZE,NULL,TX_PRIORITY,NULL);
vTaskStartScheduler();
while(1);

}

the code seems work great…but after 10s it crash and reboot…i tryed to disable the WDT but nothing happends!!!..the only things i’ve changed in freeRTOSConfig.h is:
configUSE_MALLOC_FAILED_HOOK (1 -> 0)
because the compiler give me some errors.
thanks
Tommaso.

funkystuff wrote on Wednesday, December 02, 2015:

the problem doesn’t appear during debug with atmel ICE JTAG!!!

davedoors wrote on Wednesday, December 02, 2015:

IAR JTAGs can run a script to config some registers before debugging starts. Does your ICE do the same?

Can you use a newer version so configASSERT() will be more useful to you?

alainm3 wrote on Wednesday, December 02, 2015:

So far ALL my problems of system rebooting after some time were due to
stack overflow…

But that was easy to catch as I implemented the function supplied as an
example that shows stack usage for each task.
I also added main stack usage and free memory…
That is really an invaluable tool

Alain

On 02-12-2015 09:24, Tommaso D’ippolito wrote:

Hi everyone!
I’m novice on freeRTOS…
i’m writing some code on sam3x8e and works great for the first 10s …
after this time freeRTOS seems to reboot and so on!!!
any ideas for the problem!?
thanks a lot.
Tommaso


FreeRTOS on sam3x8e reboot after 10s
https://sourceforge.net/p/freertos/discussion/382005/thread/7304bc6a/?limit=25#0b0e


Sent from sourceforge.net because you indicated interest in
SourceForge.net: Log In to SourceForge.net

To unsubscribe from further messages, please visit
SourceForge.net: Log In to SourceForge.net

funkystuff wrote on Wednesday, December 02, 2015:

SOLVED…it was a problem with the watch dog timer…
it wasn’t correctly disabled…i don’t no really why but disable the watch dog from a task won’t wok…but disable it from the main works correctly!!!
thanks everyone for HELP.
Tommaso.