Quality RTOS & Embedded Software

 Real time embedded FreeRTOS RSS feed 
Quick Start Supported MCUs PDF Books Trace Tools Ecosystem


Loading

how to use vTaskStartScheduler() with portUSE_PREEMPTION as parameter

Posted by manish9161 on July 8, 2014

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;
}


how to use vTaskStartScheduler() with portUSE_PREEMPTION as parameter

Posted by rtel on July 8, 2014

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.


how to use vTaskStartScheduler() with portUSE_PREEMPTION as parameter

Posted by manish9161 on July 9, 2014

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.


[ Back to the top ]    [ About FreeRTOS ]    [ Privacy ]    [ Sitemap ]    [ ]


Copyright (C) Amazon Web Services, Inc. or its affiliates. All rights reserved.

Latest News

NXP tweet showing LPC5500 (ARMv8-M Cortex-M33) running FreeRTOS.

Meet Richard Barry and learn about running FreeRTOS on RISC-V at FOSDEM 2019

Version 10.1.1 of the FreeRTOS kernel is available for immediate download. MIT licensed.

View a recording of the "OTA Update Security and Reliability" webinar, presented by TI and AWS.


Careers

FreeRTOS and other embedded software careers at AWS.



FreeRTOS Partners

ARM Connected RTOS partner for all ARM microcontroller cores

Espressif ESP32

IAR Partner

Microchip Premier RTOS Partner

RTOS partner of NXP for all NXP ARM microcontrollers

Renesas

STMicro RTOS partner supporting ARM7, ARM Cortex-M3, ARM Cortex-M4 and ARM Cortex-M0

Texas Instruments MCU Developer Network RTOS partner for ARM and MSP430 microcontrollers

OpenRTOS and SafeRTOS

Xilinx Microblaze and Zynq partner