xTimerCreate() function not going to callback function (Kintex-7 microblaze)

To make this concise, I have a timer in the background of my RTOS application that is supposed to process some tasks every x amount of seconds. I also have a pushbutton interrupt setup, which would have a higher priority, and do some processing when it is fired.

I set up xTimer the way the RTOS API references set them up, yet it doesn’t seem to work.

From within my idle task, I check if the timer is active, and it states it is. For some reason though my timer callback never fires.

I was under the impression that internally, the system uses queues for their timers to make sure it stops a task, sets off timer callback, then returns to previous task.

Could somebody give some advice on this, if they every worked on a microblaze port for FreeRTOS, or if there is any way to simulate a timer to fire a task every x seconds?

Thank you so much for reading!

TL;DR Timers callback function is not working properly, even though I set them up the way FreeRTOS docs says to set it up. Any help or advice?

Could it be the timer task is not getting any CPU time because of higher priority tasks that are not blocking? What is configTIMER_TASK_PRIORITY set to? Try setting it to (configMAX_PRIORITIES - 1).

There are 2 tasks, idle and idle+1.
I already checked the config, and it is set the properly at (configMAX_PRIORITIES-1).

Are the other tasks operating as you would expect? If you create a task that does nothing but sit in a loop blocking for 1 second [vTaskDelay( pdMS_TO_TICKS( 1000 ) );] then toggling an LED, does the LED toggle with the expected frequency?

If so, please show the code you are using the create and start the timer.

The other tasks are operating properly.

The code is copy and pasted from the FreeRTOS API documentation page for XTimerCreate(). It won’t let me link pages as I am new. The only difference between the API sample and my code is they use an array of timers, I only use 1, but I have changed the code to work with 1.

I start them before the scheduler just like the example.

Do xTimerCreate() and xTimerStart() both return pdPASS?

Try placing a breakpoint here: https://github.com/FreeRTOS/FreeRTOS-Kernel/blob/main/timers.c#L820 - does it get hit (not sure which version of code you are using so the line number might be different for you)? If so, step into the function to see what happens. The timer should get added to the list pointed to by pxCurrentTimerList here https://github.com/FreeRTOS/FreeRTOS-Kernel/blob/main/timers.c#L744

I bumped your privilege level so you should be able to post links now.

I will give it a shot and report back. I have checked xTimerCreate() and xTimerStart() in the past and they both have passed.

I have checked through my code, in multiple different locations such as my idle task, HW interrupt ISR, etc, and have checked to see if timer is active using xTimerisTimerActive(). Each time my timer is active. The whole time throughout my code the timer is active, but it just does not want to fire the callback function upon timeout.

Perhaps another seemingly obvious question, is the tic running in your system. if get look at the tick count, is it going up over time, or is it stuck at 0.

So I just checked that right before you posted. It may sounds stupid, and maybe this is my problem, but tick is always at 0 while it is waiting around in the idle task. This link is the FreeRTOS port, and the same dev board I am using for this project.

In the port of the project, it says

vApplicationSetupTimerInterrupt( void );
This is an application defined callback function used to install the tick interrupt handler. It is provided as an application callback, rather than being an integral part of the RTOS kernel port layer, because the RTOS kernel will run on lots of different MicroBlaze and FPGA configurations - not all of which will have the same timer peripherals defined or available.

vApplicationSetupTimerInterrupt() must install the RTOS kernel defined function vPortTickISR() as the tick interrupt handler.

The official demo application includes an example implementation of vApplicationSetupTimerInterrupt() in main.c. The example implementation uses the a Xilinx Timer/Counter as the tick interrupt source. If this peripheral is available on your hardware platform, then the example implementation can be used without modification.

I have tried to figure out how to set this function up, but have not been able to figure it out and cannot find the demo for this either. Maybe this could be my problem?

That is exactly why I asked this:

Best to get a periodic interrupt working by itself, just from main(), with no calls to the OS first.

The other tasks worked properly for some reason. But I guess I will have to investigate further.

My other problem is I have no clue how to use vApplicationSetupTimerInterrupt(). In the demo codes that I have seen, it looks like it is an extra function that is placed there and not called at any point. So it confuses me as to when I would call it and set it up for my said system.

Another thing to note, the timer was calling the callback function when I originally created this project with only the timer running. Once I added a pushbutton HW interrupt, the timer callback did not want to work anymore.

It is called from the port layer: FreeRTOS-Kernel/port.c at main · FreeRTOS/FreeRTOS-Kernel · GitHub


So if I set up the appropriate functions, the tick should be functioning?

Because this also makes me question, will my original problem with xTimerCreate() callback not being called be resolved if the ticks are setup appropriately?

Also, I have been using this line of code to print out the ticks during idle task. I am wondering if this is the appropriate way of printing out the ticks?

xil_printf(“Current ticks: %d\n\r”, xTaskGetTickCount());

Hopefully yes.

If you are calling this function from more than one task, you need to ensure that it is thread safe.


So I would like to thank @rtel @richard-damon for being so responsive throughout the thread.

The solution was in front of my face, I was not setting up vApplicationSetupTimerInterrupt( void *) appropriately before.

Upon setting it up appropriately and letting the program run, XTimer() functioned.

Thank you all for your help!