Quality RTOS & Embedded Software

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


Loading

Help with tasks

Posted by DownyTif on March 12, 2009
Hi,

I'm quite new to the FreeRTOS world and I'm trying to build a application using it.

Platform: AVR32 (using AVR32 Studio)
Framework: AT32UC3A-1.4.0
Language: GNUC++

At the moment, I'm just trying to make the tasks work. I double checked eveything with the Atmel EVK1100 ControlPanel application that uses FreeRTOS and everything seems fine, but I always end up having the same problem...

My application is quite simple. Here is a code sample:
Note that:
configCPU_CLOCK_HZ == CP_CPU_SPEED == 48000000
and
configPBA_CLOCK_HZ == CP_PBA_SPEED == 12000000


--------------------------------- Main.cpp File ----------------------------------------

//=======================================================================================
// Main
// Main function. Starts the different tasks and wait forever.
//=======================================================================================
int main(void)
{
int bRet = FALSE;
CBDR29010 obj;

/* Primary Initialization.
-------------------------- */
// Switch the main clock to OSC0.
pm_switch_to_osc0(&AVR32_PM, FOSC0, OSC0_STARTUP);

// Initialize the delay driver.
delay_init(CP_CPU_SPEED);

// Init Clocks.
LocalStartPLL66MHZ();

// Start the tasks.
obj.Activate();

// Start the OS. It should never return from there.
vTaskStartScheduler();

return 0;
}


--------------------------------- BDR29010.cpp File ----------------------------------------

// Constants
//////////////////////////////////////////////////////////////////////////////
#define TASK_COMM_MANAGER_PRIORITY (tskIDLE_PRIORITY + 1)
#define TASK_COMM_MANAGER_STACK_SIZE 1024
#define TASK_COMM_MANAGER_DELAY 10

// Prototypes
//////////////////////////////////////////////////////////////////////////////
portTASK_FUNCTION_PROTO(CommManagerTask, pParams);

//=======================================================================================
// CBDR29010::Activate
//=======================================================================================
bool CBDR29010::Activate()
{
bool bRet = false;
int taskCreateRet = pdFAIL;
xTaskHandle createdTaskHdl = NULL;

taskCreateRet = xTaskCreate(CommManagerTask, (const signed portCHAR*) "COMM_MGR",
TASK_COMM_MANAGER_STACK_SIZE, (void*)this,
TASK_COMM_MANAGER_PRIORITY, &createdTaskHdl);

if(taskCreateRet == pdPASS)
{
bRet = true;
}
else
{
bRet = false;
}

return bRet;
}

//=======================================================================================
// TASK: ManagerCommTask
//=======================================================================================
portTASK_FUNCTION_PROTO(CommManagerTask, pParams)
{
do
{
vTaskDelay(TASK_COMM_MANAGER_DELAY);
int allo = 1;

} while (1);
}


I trace the execution of the task. It enters correctly, calls the vTaskDelay(...) function but never returns from there. If I pause the execution, I get this
"No source available for "_handle_Supervisor_Call() " "

Checking the stack, it looks like it hangs just after the "portEXIT_CRITICAL();" call of the xTaskResumeAll() function in task.c.

Here is a copy of my FreeRTOSConfig.h file:

#define configUSE_MUTEXES 1
#define configUSE_PREEMPTION 1
#define configUSE_IDLE_HOOK 0
#define configUSE_TICK_HOOK 0
#define configCPU_CLOCK_HZ ( CP_CPU_SPEED ) /* Hz clk gen */
#define configPBA_CLOCK_HZ ( CP_PBA_SPEED )
#define configTICK_RATE_HZ ( ( portTickType ) 1000 )
#define configMAX_PRIORITIES ( ( unsigned portBASE_TYPE ) 8 )
#define configMINIMAL_STACK_SIZE ( ( unsigned portSHORT ) 256 )
/* configTOTAL_HEAP_SIZE is not used when heap_3.c is used. */
#define configTOTAL_HEAP_SIZE ( ( size_t ) ( 1024*25 ) )
#define configMAX_TASK_NAME_LEN ( 20 )
#define configUSE_TRACE_FACILITY 0
#define configUSE_16_BIT_TICKS 0
#define configIDLE_SHOULD_YIELD 1

#define configUSE_CO_ROUTINES 0
#define configMAX_CO_ROUTINE_PRIORITIES ( 0 )

#define INCLUDE_vTaskPrioritySet 1
#define INCLUDE_uxTaskPriorityGet 1
#define INCLUDE_vTaskDelete 1
#define INCLUDE_vTaskCleanUpResources 0
#define INCLUDE_vTaskSuspend 1
#define INCLUDE_vTaskDelayUntil 1
#define INCLUDE_vTaskDelay 1
#define INCLUDE_xTaskGetCurrentTaskHandle 1
#define INCLUDE_xTaskGetSchedulerState 0

#define configTICK_USE_TC 0
#define configTICK_TC_CHANNEL 2

#define configHEAP_INIT 1


I have no idea if those settings are ok, but I presume they are since I based myself on a working application of the Atmel framework. But I suspect that I am missing some configuration to make this work...

Please, if you have any insight or suggestions, let me know.
Best regards,
Downy

RE: Help with tasks

Posted by Dave on March 13, 2009
Can you confirm that the tick interrupt is working? If the tick is not incrementing time then your block time will never time out after calling vTaskDelay() and the task will remain blocked.

RE: Help with tasks

Posted by DownyTif on March 13, 2009
I'm not sure where to look to confirm this... I'll search, but in the meantime, if you have any indications, please let me know.

Thanks again,
Downy

RE: Help with tasks

Posted by DownyTif on March 13, 2009
I traced in VTaskDelay() and xTickCount is 0... which I presume is the problem... I will try to find why, but again, any advice is welcome in the meantime.

Best regards.

RE: Help with tasks

Posted by DownyTif on March 13, 2009
ok, sorry, my vTickCount is incrementing... I traced in the "vTaskIncrementTick" function and the ticks are coming.

For some reason, my task that called vTaskDelay() looks to be never awoken...

RE: Help with tasks

Posted by MEdwards on March 13, 2009
Look at prvSetupTimerInterrupt() in port.c. This is where the tick interrupt is configured.

RE: Help with tasks

Posted by DownyTif on March 13, 2009
looks like my last post didn't proceed... I wrote that I was wrong. The xTickCount is indeed incrementing... I traced in the vTaskIncrementTick function.

Looks like my task is never awoken...

RE: Help with tasks

Posted by DownyTif on March 13, 2009
I found that it is a call to taskYIELD() that provokes the hanging... In the vTaskDelay function :

-----------------------------------------------------
xAlreadyYielded = xTaskResumeAll();
-----------------------------------------------------

returns false which provoke this:

-----------------------------------------------------
/* Force a reschedule if xTaskResumeAll has not already done so, we may
have put ourselves to sleep. */
if( !xAlreadyYielded )
{
taskYIELD();
}
-----------------------------------------------------

When called, those are the current values of the different variables:
xTicksToDelay = 10
xTickCount = 0
xTimeToWake = 10

I'm continuing my search... please feel free to give me advices, that will be much appreciated!

Best regards,
Downy

RE: Help with tasks

Posted by DownyTif on March 13, 2009
Problem solved!

Actually, it was a stupid problem (as I though).

In the AVR32 framework, there is a driver called INTC that has a "exception.x" file. So, in the project settings, I must exclude this file in order to use the "exception.x" file from FreeRTOS. I have examples in the AVR32 framework that work.

My error was to inconsciously exclude the "exception.x" file of FreeRTOS instead..........
Anyway, I hope this thread can help someone in the future!

Thanks to all,
Downy


[ 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