Microblaze Gpio Interrupt - xPortInstallInterruptHandler reference error

Hello!

I try to implement a GPIO Interrupt function on microblaze.
According to the documentation (Free-RTOS-for-Xilinx-MicroBlaze-on-Spartan-6-FPGA.html) I have to use xPortInstallInterruptHandler. My autocompletion finds the function"xPortInstallInterruptHandler" - fine. The problem is that I get following error after build: undefined reference to `xPortInstallInterruptHandler’.

I’m using Vitis 2023.1 and the FreeRtos-Hello-World-Example.

User 216004noaveevee reported a similar issue:
Xilinx/AMD forum title “Microblaze FreeRTOS Interrupts”
…but no solution there.
(Sorry, I’m not allowed to post links as new user)

my includes:
/* FreeRTOS includes. /
#include “FreeRTOS.h”
#include “task.h”
#include “queue.h”
#include “timers.h”
/
Xilinx includes. */
#include “xil_printf.h”
#include “xparameters.h”
#include “xgpio.h”
#include “xuartlite.h”
#include “xintc.h”
#include “portmacro.h”

key parts of my code
#define GpioDeviceId XPAR_AXI_GPIO_RGB_DEVICE_ID
#define GpioBaseAddr XPAR_AXI_GPIO_RGB_BASEADDR
#define GpioInterruptId XPAR_INTC_0_GPIO_0_VEC_ID
XGpio Gpio;
static void gpio_interrupt_handler(void *prvParams);

XGpio_Initialize(&Gpio, GpioDeviceId);
XGpio_SetDataDirection(&Gpio, 2, 0x0);
xPortInstallInterruptHandler(GpioInterruptId, gpio_interrupt_handler, NULL); //<- before vTaskStartScheduler();

Can you grep in your source and see if this function is implemented in any file? If yes, can you make sure that file is being built?

I made following progress:
xPortInstallInterruptHandler is available in the code, but deactivated by Xil_Timer. I disabled Xil_Timer and can build the code.
Interrupt is working with following lines:
xPortInstallInterruptHandler(GpioInterruptId, (XInterrruptHandler)gpio_interrupt_handler, &Gpio);
vPortEnableInterrupt(GpioInterruptId);
XGpio_InterruptEnable(&Gpio, 0x2); //Channel 2
XGpio_InterruptGlobalEnable(&Gpio);

With that lines the gpio handler gets executed, after a button pressed. (In my case many times…Maybe I have to implement some debouncing and InperrutpDisable. but that is another story:) )

I don’t know, if it is handled correctly in that way.
Is the sequence of calling that functions ok?
What is the purpose of Xil_Timer in the BSP?
In my example I put the lines in a task before the loop. Should I move the lines before scheduler-start or is it ok to leave the lines in a task?

best regards

It looks okay. If you have BSP specific questions, you need to contact the vendor.

It is okay to leave them in a task as long as you do not need the interrupt before that task is started.

@Dabrzn
Can you share the solution for the original problem?
I have the same issue

Thanks

Hello @carney,

I think the following solved the problem that the OP was having.

Thanks,
Aniruddha