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] [July 2014 Threads]
Hello I am working with stm32f3Discovery with FreeRTOS .I have created task with various priorities.I have to schedule that task in preemptive scheduling algorithum.
so I have added
1.#define portUSEPREEMPTION 1 in portmacro.h
and pass to vTaskStartScheduler(portUSEPREEMPTION)
But code isn't compiled because vTaskStartScheduler(void ) in task.c
so how should i use preemptive scheduling algorithum..?
my code
#include "FreeRTOS.h"
#include "task.h"
#include "stm32f3_discovery.h"
#include
#include
/*!**************************************************************
* \fn init()
* \brief LED init function
*
* \param -
* \return -
******************************************************************/
void init()
{
STM_EVAL_LEDInit(LED3 | LED4 | LED5 | LED6 );
}
/*!**************************************************************
* \fn void TaskA()
* \brief taskA callback function
*
******************************************************************/\
void TaskA()
{
for(uint8_t i= 0; i< 10 ; i++)
{
STM_EVAL_LEDOn(LED3);
vTaskDelay(10);
STM_EVAL_LEDOff(LED3);
}
}
/*!**************************************************************
* \fn void TaskB()
* \brief taskB callback function
*
******************************************************************/\
void TaskB()
{
for(uint8_t i= 0; i< 10 ; i++)
{
STM_EVAL_LEDOn(LED4);
vTaskDelay(10);
STM_EVAL_LEDOff(LED4);
}
}
/*!**************************************************************
* \fn void TaskC()
* \brief taskC callback function
*
******************************************************************/\
void TaskC()
{
for(uint8_t i= 0; i< 10 ; i++)
{
STM_EVAL_LEDOn(LED5);
vTaskDelay(10);
STM_EVAL_LEDOff(LED5);
}
}
/*!**************************************************************
* \fn void TaskD()
* \brief taskD callback function
*
******************************************************************/
void TaskD()
{
for(uint8_t i= 0; i< 10 ; i++)
{
STM_EVAL_LEDOn(LED6);
vTaskDelay(10);
STM_EVAL_LEDOff(LED6);
}
}
/*!**************************************************************
* \fn main()
* \brief main function
*
******************************************************************/
int main(void) {
init();
/*! TaskA is having highest priority */
xTaskCreate(TaskA, (signed char*)"TaskA", 128, NULL, configMAX_PRIORITIES, NULL);
/*! TaskB having medium priority */
xTaskCreate(TaskB, (signed char*)"TaskB", 128, NULL, tskIDLE_PRIORITY+2, NULL);
/*! TaskC ,and TaskD Idle tasks */
xTaskCreate(TaskC, (signed char*)"TaskC", 128, NULL, tskIDLE_PRIORITY, NULL);
xTaskCreate(TaskD, (signed char*)"TaskD", 128, NULL, tskIDLE_PRIORITY, NULL);
vTaskStartScheduler(portUSE_PREEMPTION);
return 0;
}
Please refer to the online documentation and the many hundreds of pre-configured examples that are provided for you to use and reference.
I'm not sure where you got the idea that you had to pass a parameter into vTaskStartScheduler(), because as you have said yourself the prototype for the function is void, and the online API documentation for the function shows it as a void function, and the example on the API documentation page showing you how to use the function does not show it taking a parameter, neither does any of the examples provided in the download.
http://www.freertos.org/FreeRTOS-quick-start-guide.html
http://www.freertos.org/a00132.html
http://www.freertos.org/a00110.html#configUSE_PREEMPTION
Please also note that all your task definitions are wrong too, so even if you start the scheduler using the correct semantics, you will end up in an assert() when the task attempts to exit without calling vTaskDelete( NULL ). Again all this information is provided for you....
Regards.
Thanks a lot for your valuable response.I have modified my code as per your suggestions.Now its working fine just I have to test it.
Copyright (C) Amazon Web Services, Inc. or its affiliates. All rights reserved.