Tasks not continuously executing and tick count not updating

I am very new to freeRTOS, and I’m currently just trying to implement a couple of communication protocols with some external devices that execute every 500ms.

Before I can do that though, I don’t think that any ticks are actually executing in the skeleton code I have. Each “task” I have designated runs only once, and the tick count never updates. I don’t know what is wrong.

I just need to figure out how to get the tasks running normally and continuously (instead of each running once and the program stopping) and I need the tick counter to work properly.

I am using a Microblaze processor.

I will put my code below. Any help would be greatly appreciated.


/*
    Copyright (C) 2017 Amazon.com, Inc. or its affiliates.  All Rights Reserved.
    Copyright (c) 2012 - 2022 Xilinx, Inc. All Rights Reserved.
	SPDX-License-Identifier: MIT


    http://www.FreeRTOS.org
    http://aws.amazon.com/freertos


    1 tab == 4 spaces!
*/

/* FreeRTOS includes. */
#include "FreeRTOS.h"
#include "task.h"
#include "queue.h"
#include "timers.h"
/* Xilinx includes. */
#include "xil_printf.h"
#include "xparameters.h"

#define TIMER_ID	1
#define DELAY_10_SECONDS	10000UL
#define DELAY_1_SECOND		1000UL
#define TIMER_CHECK_THRESHOLD	9
/*-----------------------------------------------------------*/

/* The Tx and Rx tasks as described at the top of this file. */
static void Task1( void *pvParameters );
static void Task2( void *pvParameters );
/*-----------------------------------------------------------*/

/*Setting up task handles*/
static TaskHandle_t xTask1;
static TaskHandle_t xTask2;


int main( void )
{
	xil_printf( "Hello from Freertos example main\r\n" );

	xTaskCreate( Task1,( const char * ) "Task 1", configMINIMAL_STACK_SIZE,NULL,tskIDLE_PRIORITY,&xTask1 );
	xTaskCreate( Task2,( const char * ) "Task 2", configMINIMAL_STACK_SIZE,NULL,tskIDLE_PRIORITY,&xTask2 );

	/* Start the tasks and timer running. */
	vTaskStartScheduler();

	for( ;; );
}



/*-----------------------------------------------------------*/
static void Task1( void *pvParameters )
{
	for( ;; )
	{
		/*Just printing #1 and the tick count to show task 1 executing and check if the
		 * tick count is increasing*/

		xil_printf("#1: %d\r\n", xTaskGetTickCount());

		/*delay 100 ms*/
		vTaskDelay(pdMS_TO_TICKS(500));
	}
}

/*-----------------------------------------------------------*/
static void Task2( void *pvParameters )
{
	for( ;; )
	{
		/*Just printing #2 and the tick count to show task 2 executing and check if the
		 * tick count is increasing*/
		xil_printf("#2: %d\r\n", xTaskGetTickCount());

		/*delay 100 ms*/
		vTaskDelay(pdMS_TO_TICKS(500));
	}
}
/*-----------------------------------------------------------*/

Hi @wnixon7, welcome to the FreeRTOS Community.

Your task function prototypes at the top of the code do not seem to match the task function definitions below. Were you able to compile this ?
void pvParameters should be replaced with void * pvParameters. A task function returns void and takes a void pointer as it’s only parameter.
You can go through this for more details about implementing a task.

Seems like your tick interrupt is not firing. Which FreeRTOS port are you using? Where did you get this project from?

In the code I have (and what I thought I pasted), the task function prototypes matches the task function definitions. They both have inputs of “void *pvParameters”.

My code compiles fine, it is just not continuously performing my tasks.

Here is the output I am getting:

Hello from Freertos example main
#1: 0
#2: 0

I am not certain which FreeRTOS port I am using. The processor is called microblaze_0 in one of the header files.

This project is just a modified version of the FreeRTOS Hello World initial project that is available when you create a new RTOS project in Vitis.

so does ghe hello world peogram run as expected in your environment? That is, without your additions?

No, it does not run properly either. When I run the original Hello World example, my output is:

Hello from Freertos example main
Hello from Freertos example main
Hello from Freertos example main

you very likely run into a fault then. Where does your debugger say you are when the output stops?

The output seems to stop after I “step over” vTaskStartScheduler();

The output is only one “Hello from Freertos example main” line until I step over the vTaskStartScheduler(); line, and then two more lines of “Hello from Freertos example main” are printed.

Please answer my question.

I apologize. I am very new to this.

I believe the code is stopping on the line:

“Xil_AssertCallbackRoutine = Routine;”

within the Xil_AssertSetCallback function which is in the xil_assert.c file.

I hope this answered your question

ok. An assert is normally associated with an error message and a code line nunber that explains what has gone wrong. You should be able to see that information in the stack backtrace. What is your assert message?

I do not know how to find the stack backtrace. The only relevant information I could find was from the debugger console. I’ll place it below. Please let me know how to view the stack backtrace.

C:\Xilinx\Vitis?3.1\gnu\microblaze
tin\mb64-gdb.exe: warning: Couldn’t determine a path for the index cache directory.
GNU gdb (GDB) 9.2
Copyright (C) 2020 Free Software Foundation, Inc.
License GPLv3+: GNU GPL version 3 or later
This is free software: you are free to change and redistribute it.
There is NO WARRANTY, to the extent permitted by law.
Type “show copying” and “show warranty” for details.
This GDB was configured as “–host=i686-w64-mingw32 --target=microblaze-xilinx-elf64”.
Type “show configuration” for configuration details.
For bug reporting instructions, please see:

Find the GDB manual and other documentation resources online at:

For help, type “help”.
Type “apropos word” to search for commands related to “word”.
warning: Can not parse XML target description; XML support was disabled at compile time
warning: No executable has been specified and target does not support
determining executable automatically. Try using the “file” command.
0x0000000000000000 in ?? ()

Temporary breakpoint 1, main () at …/src/freertos_hello_world.c:57
57 const TickType_t x10seconds = pdMS_TO_TICKS( DELAY_10_SECONDS );

Program received signal SIGTRAP, Trace/breakpoint trap.
0x0000000000003538 in memcpy () at xil_assert.c:103
103 Xil_AssertCallbackRoutine = Routine;
[Inferior 1 (process 1) detached]

sorry, I do not use gdb.

I understand. Hopefully someone will be able to help. Thank you for trying

Hi @wnixon7
You can try checking if the SysTick interrupt / its ISR is properly installed.
Note that this is port / BSP specific.
For STMF4 ie. Cortex-M4 architecture you have to prepare the exception vector table containing the interrupt handlers used by your application.
It should at least contain the entries required by FreeRTOS to run.
These are defined in your FreeRTOSConfig.h:

/* Definitions that map the FreeRTOS port interrupt handlers to their CMSIS standard names. */
#define vPortSVCHandler     SVC_Handler
#define xPortPendSVHandler  PendSV_Handler
#define xPortSysTickHandler SysTick_Handler

In addition, there seems to be an issue with how the Xilinx “Hello World” demo project has been setup. You can read more about the issue here, and see if this is the way you had been generating the project.

I do not see any lines of code like this in my FreeRTOSConfig.h file. I am not sure how to know whether my SysTick interrupt or its ISR are properly installed. There is no mention of SysTick in my configuration header file or in my port.c file.

I have not been generating this project this way. I’ve just been using the base template available after selecting freeRTOS as the operating system when creating the application project in Vitis.

This seems more like a Xilinx issue as to why the tick interrupt is not firing and how it is initialized . You can take a look at this thread for a solution and also reach out to Xilinx for a better solution.

1 Like