Quality RTOS & Embedded Software

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




Loading

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 ***************************************************************************/
GPIO_Init();
UART1_Init();
UART_HandleInit(&huart);
ADC1_Init();

/* 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");

RTOS();
while(1)
{

}

}

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

vTaskStartScheduler();

while(1)
{
}

}

/* 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++)
	{
	__ASM("nop");
	}
	GPIOC->BRR |= 0x0040;      //Reset Red LED
	for(i = 0; i < offTime; i++)
	{
	__ASM("nop");
	}

}

~~~

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;
endif
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 configUSETRACEFACILITY 1
define configUSE16BIT_TICKS 0
define configIDLESHOULDYIELD 1
define configUSE_MUTEXES 1
define configQUEUEREGISTRYSIZE 8

//#define configCHECKFORSTACK_OVERFLOW 2

define configUSERECURSIVEMUTEXES 1

//#define configUSEMALLOCFAILED_HOOK 1

define configUSEAPPLICATIONTASK_TAG 0
define configUSECOUNTINGSEMAPHORES 1
define configGENERATERUNTIME_STATS 0

/* Co-routine definitions. */

define configUSECOROUTINES 0
define configMAXCOROUTINE_PRIORITIES ( 2 )

/* 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 );
portDISABLE_INTERRUPTS();
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:
http://www.freertos.org/implementing-a-FreeRTOS-task.html

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) Amazon Web Services, Inc. or its affiliates. All rights reserved.

Latest News

FreeRTOS kernel V10 is available for immediate download. Now MIT licensed.


FreeRTOS Partners

ARM Connected RTOS partner for all ARM microcontroller cores

IAR Partner

Microchip Premier RTOS Partner

RTOS partner of NXP for all NXP ARM microcontrollers

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