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.

NOTE : Tasks run in system mode and the scheduler runs in Supervisor mode.The processor MUST be in supervisor mode when vTaskStartScheduler iscalled. The demo applications included in the FreeRTOS.org download switchto supervisor mode prior to main being called. If you are not using one ofthese demo application projects then ensure Supervisor mode is used here. */ //portBASE_TYPE xHigherPriorityTaskWoken = 0;vTaskStartScheduler();

/* We should never get here as control is now taken by the scheduler. */for( ;; );}

then I have the task definitions as --void vPWM_ON_Task(void){ TIM_DeInit(TIM1); VIC_DeInit(); TIM_ClearFlag(TIM1,TIM_FLAG_OC2);

RE: STR912:using binary semaphore between 2 tasks

- vPWM_ON_Task() has the wrong prototype to be a task. It should take a void* parameter.

- vPWM_ON_Task() must not exit just by dropping off the end of the function that implements the task. A task must either run forever (typically in an infinite loop), or delete itself before it reaches the end of the function that implements it.

RE: STR912:using binary semaphore between 2 tasks

Your interrupt service routine does not exit correctly. Why have you manually written the return from the function in assembly language? Write your interrupts as documented for the port on the FreeRTOS web pages.

RE: STR912:using binary semaphore between 2 tasks

You can pass a pointer to whatever you like to a task, as long as the code creating the task and the task itself agree on what the parameter points to.

I don't understand your scenario though.

If you create a task from main(), then start the task by calling vTaskStartScheduler(), main() will never run again. If you delete the task and there are no other tasks then the only code that will run (other than the kernel tick interrupt) is the Idle task.

RE: STR912:using binary semaphore between 2 tasks

Thank you Richard,That gave clue to the solution of problem,I was just going through the documentation about task states.

So if I want to poll on GPIO continuously I should do it in task only Right?? say taskA

Now solution could be - void main() will create only this task(taskA) which will continuously poll GPIO and in-turn will create another task (taskB) on GPIO event (and now taskB can be deleted also since taskA is running continuously).

But now I have one question how taskB will start / how it will switch to taskB?or do I need to create taskB in suspended state and resume on GPIO event in taskA.

RE: STR912:using binary semaphore between 2 tasks

“So if I want to poll on GPIO continuously I should do it in task only Right?? say taskA”

Once the scheduler has been started, tasks, interrupts and software timers are the only things that execute. There is no option to poll IO from main() as main() will never execute at that time.

The only way of running tasks is to call vTaskStartScheduler(). You cannot call a task function.

“Now solution could be - void main() will create only this task(taskA) which will continuously poll GPIO and in-turn will create another task (taskB) on GPIO event (and now taskB can be deleted also since taskA is running continuously). ”

You only need to create task B if task B needs to do something in parallel with task A. If task A is just polling IO and creating task B when the IO changes then consider having the IO trigger an interrupt and having the interrupt service routine signal a task. Generally repeatedly creating and deleting tasks is not necessary and wasteful.

“But now I have one question how taskB will start / how it will switch to taskB?or do I need to create taskB in suspended state and resume on GPIO event in taskA.”

Task B can be created (if really necessary) at any time that you are not in a critical section (and don't have the scheduler locked). It will run immediately that it is the highest priority task to run. Therefore, if Task A creates task B, and Task B has a higher priority than Task A, then Task B will start running immediately - before Task A has returned from the xTaskCreate() function even.