Quality RTOS & Embedded Software

 Real time embedded FreeRTOS RSS feed 
Real time embedded FreeRTOS mailing list 
Quick Start Supported MCUs PDF Books Trace Tools Ecosystem TCP & FAT Training




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 ]    [ Sitemap ]    [ ]




Copyright (C) 2004-2010 Richard Barry. Copyright (C) 2010-2016 Real Time Engineers Ltd.
Any and all data, files, source code, html content and documentation included in the FreeRTOSTM distribution or available on this site are the exclusive property of Real Time Engineers Ltd.. See the files license.txt (included in the distribution) and this copyright notice for more information. FreeRTOSTM and FreeRTOS.orgTM are trade marks of Real Time Engineers Ltd.

Latest News:

FreeRTOS V9.0.0 is now available for download.


Free TCP/IP and file system demos for the RTOS


Sponsored Links

⇓ Now With No Code Size Limit! ⇓
⇑ Free Download Without Registering ⇑


FreeRTOS Partners

ARM Connected RTOS partner for all ARM microcontroller cores

Renesas Electronics Gold Alliance RTOS Partner.jpg

Microchip Premier RTOS Partner

RTOS partner of NXP for all NXP ARM microcontrollers

Atmel RTOS partner supporting ARM Cortex-M3 and AVR32 microcontrollers

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

Xilinx Microblaze and Zynq partner

Silicon Labs low power RTOS partner

Altera RTOS partner for Nios II and Cortex-A9 SoC

Freescale Alliance RTOS Member supporting ARM and ColdFire microcontrollers

Infineon ARM Cortex-M microcontrollers

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

Cypress RTOS partner supporting ARM Cortex-M3

Fujitsu RTOS partner supporting ARM Cortex-M3 and FM3

Microsemi (previously Actel) RTOS partner supporting ARM Cortex-M3

Atollic Partner

IAR Partner

Keil ARM Partner

Embedded Artists