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


FreeRTOS gets stuck at prvTaskExitError()

Posted by rohirto on September 19, 2016

Hello all, I'm new to FreeRTOS. Im currently working with ST32F072RB Discovery board. I integrated the FreeRTOS with my test code. Im not using CubeMx, HAL library or Std Peripheral Lib. When running the code, it gets stuck at prvTaskExitError(). Here is my code

~~~ int main() { //Set priority of SYSTick NVICEnableIRQ(SysTickIRQn); NVICSetPriority(SysTickIRQn, 3); /* Clock checkin code *******************************************************************/ //Clock checking coreClock_1 = SystemCoreClock; / Store value of predefined SystemCoreClock / SystemCoreClockUpdate(); / Update SystemCoreClock according to register settings / coreClock_2 = SystemCoreClock; / Store value of calculated SystemCoreClock / if (coreClock2 != coreClock1) {
/ Without changing the clock setting both core clock values should be the same / // Error Handling } //returnCode = SysTick_Config(SystemCoreClock / 1000); / Configure SysTick to generate an interrupt every millisecond */ /

/* Initialization ***************************************************************************/

/* Debug purpose  */
if(DEBUG == 1)
	printf("UART1 test string \r\n");
	printf("This is sample ADC code \r\n");
	printf("ADC1 used			 USART1 used		\r\n");

printf("INITILIZATION DONE \r\n");




void RTOS() { xTaskCreate(vTaskFunction1, "Task 1", 128, NULL, 2, NULL);




/* Implementation of vTaskFunction----------------------------------------*/ void vTaskFunction1( void *pvParameters) { //Start the ADC conversion ADC1_Start();

	printf("ADC Value: %d \r\n",ADC_Value);
	//Get the conversion value
	onTime = ADC_Value;

	//PWM code
	offTime = 4096 - onTime;
	GPIOC->BSRR |= 0x0040;      //Set Red LED

	for(i = 0; i < onTime; i++)
	GPIOC->BRR |= 0x0040;      //Reset Red LED
	for(i = 0; i < offTime; i++)



Here is my FreeRTOSConfig.h ~~~ /* Ensure stdint is only used by the compiler, and not the assembler. */

ifdef _CCARM
#include <stdint.h>
extern uint32_t SystemCoreClock;
define configUSE_PREEMPTION 1
define configUSEIDLEHOOK 0
define configUSETICKHOOK 0
define configCPUCLOCKHZ ( SystemCoreClock )
define configTICKRATEHZ ( ( TickType_t ) 1000 )
define configMAX_PRIORITIES ( 5 )
define configMINIMALSTACKSIZE ( ( unsigned short ) 60 )
define configTOTALHEAPSIZE ( ( size_t ) ( 6500 ) )
define configMAXTASKNAME_LEN ( 5 )
define configUSE16BIT_TICKS 0
define configIDLESHOULDYIELD 1
define configUSE_MUTEXES 1



//#define configUSEMALLOCFAILED_HOOK 1


/* Co-routine definitions. */

define configUSECOROUTINES 0

/* Software timer definitions. */ //#define configUSETIMERS 1 //#define configTIMERTASKPRIORITY ( 2 ) //#define configTIMERQUEUELENGTH 5 //#define configTIMERTASKSTACKDEPTH ( 80 )

/* Set the following definitions to 1 to include the API function, or zero to exclude the API function. */

define INCLUDE_vTaskPrioritySet 1
define INCLUDE_uxTaskPriorityGet 1
define INCLUDE_vTaskDelete 1
define INCLUDE_vTaskCleanUpResources 1
define INCLUDE_vTaskSuspend 1
define INCLUDE_vTaskDelayUntil 1
define INCLUDE_vTaskDelay 1

/* Normal assert() semantics without relying on the provision of an assert.h header file. */

define configASSERT( x ) if( ( x ) == 0 ) { taskDISABLE_INTERRUPTS(); for( ;; ); }

/* Definitions that map the FreeRTOS port interrupt handlers to their CMSIS standard names - or at least those used in the unmodified vector table. */

define vPortSVCHandler SVC_Handler
define xPortPendSVHandler PendSV_Handler
define xPortSysTickHandler SysTick_Handler


The code gets stuck here, in port.c (indicated by >>) ~~~ static void prvTaskExitError( void ) { /* A function that implements a task must not exit or attempt to return to its caller as there is nothing to return to. If a task wants to exit it should instead call vTaskDelete( NULL ).

Artificially force an assert() to be triggered if configASSERT() is
defined, then stop here so application writers can catch the error. */
>>configASSERT( uxCriticalNesting == ~0UL );
for( ;; );

} ~~~

Im also using ADC1 and USART1 Interrupts. Both have priority 0.

On Serial port im getting the output >> UART1 test string >> This is sample ADC code >> ADC1 used USART1 used >> INITILIZATION DONE >> ADC Value: 0

The task is not running repeatedly.

FreeRTOS gets stuck at prvTaskExitError()

Posted by rtel on September 19, 2016

Unfortunately there is a lot wrong with this code. The first place to start would probably be the following link, so you can see how to structure a task:

After that the following links might help:
http://www.freertos.org/FreeRTOS-quick-start-guide.html http://www.freertos.org/Creating-a-new-FreeRTOS-project.html

[ 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