FreeRTOS Support Archive
The FreeRTOS support forum is used to obtain active support directly from Real
Time Engineers Ltd. In return for using our top quality software and services for
free, we request you play fair and do your bit to help others too! 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.
[FreeRTOS Home] [Live FreeRTOS Forum] [FAQ] [Archive Top] [June 2008 Threads] ATMega2560 reset when exiting taskPosted by Jesper Matthiesen on June 17, 2008 Hi,
i have 3 tasks running and a shutdown condition that causes every task to exit its main loop. if i after the main loop have each task enter an infinite loop, everything is fine; if *any* one of them exit out of the task function, the device reboots.. this also happens when only running 1 task and at any stack size.. watch dog is turned off...
since the kernel, according to the documentation, never exits vTaskStartScheduler unless vTaskEndScheduler is called, what happens to tasks that return? do they just end as one would expect with the scheduler continuing? maybe it's when the idle task tries to do post-task cleanup that the device crashes/reboots? im using heap_1.c by the way...
RE: ATMega2560 reset when exiting taskPosted by Dave on June 17, 2008 From the WEB "Task functions should never return so are typically implemented as a continuous loop".
If you want to leave a task then you have to write something like this -
void TaskFunction(void *pv) { while(1) { // task code that contains a break to jump out of the loop. }
// Must not run off end of function so delete ourselves. vTaskDelete(NULL); }
RE: ATMega2560 reset when exiting taskPosted by JMR on June 17, 2008 Further to davedoors' comment: The tasks are simply functions when you create a task at start-up all you do is put a pointer to the functions entry point in the TCB list of the scheduler. When the function then terminates, unless you explicitely call vTaskDelete(NULL) the function exit will cause a stack underflow, that is items that hadn't been pushed on the stack get popped and the program counter made to point somewhere in oblivion. Resulting in the reset that you observed.
RE: ATMega2560 reset when exiting taskPosted by Jesper Matthiesen on June 17, 2008 great advice...
since vTaskDelete can be omitted from the build to save space, i probably will put a "for ( ;; );" at the end of the tasks in question instead..
thanks..
RE: ATMega2560 reset when exiting taskPosted by Dave on June 17, 2008 If you never want the task to run again and don't want to free the memory it is using you can instead use vTaskSuspend(NULL); This will prevent the task using CPU time, unlike the for(;;) solution.
RE: ATMega2560 reset when exiting taskPosted by Jesper Matthiesen on June 17, 2008 it's not that important if the tasks use cpu or not when entering shutdown.. i tried the vTaskSuspend ( NULL) option anyway (since i have it included in the build already), but this trigs a spontaneous device reboot in about 50% of cases also, which i find very strange...
Copyright (C) Amazon Web Services, Inc. or its affiliates. All rights reserved.
|