1

I'm trying to get a fixed timer in a MicroBlaze MCS core to call a function to toggle some LEDs as a proof of concept.

Here is my code I have now

#include <xparameters.h>
#include <xiomodule.h>
#include <xiomodule_l.h>

XIOModule gpo1;
volatile u32 ct = 0;

void timerTick(void* ref){
    ct++;
    XIOModule_DiscreteWrite(&gpo1, 1, ct);
    XIOModule_DiscreteWrite(&gpo1, 2, ct);
}

int main() {

    XIOModule_Initialize(&gpo1, XPAR_IOMODULE_0_DEVICE_ID);
    XIOModule_Start(&gpo1);

    XIOModule_EnableIntr(XPAR_IOMODULE_0_BASEADDR, XIN_IOMODULE_FIT_1_INTERRUPT_INTR);
    XIOModule_Connect(&gpo1, XIN_IOMODULE_FIT_1_INTERRUPT_INTR, timerTick, NULL);

    while (1) {
    }
}

The GPO stuff works. If I put it in the while loop I can get the LEDs to toggle as expected. However, as the code currently is, timerTick() never gets called. I am really confused on how to properly setup the interrupt and I haven't been able to find any documentation on this. The best I could find was http://www.xilinx.com/support/documentation/sw_manuals/xilinx14_4/pg048-microblaze-mcs.pdf which covers more about the hardware of the core and not how to program it.

What is the proper way to enable and connect an interrupt?

Alchitry
  • 1,369
  • 1
  • 16
  • 29

1 Answers1

0

I found the solution thanks to this forum post http://forums.xilinx.com/t5/Embedded-Development-Tools/Can-not-fire-MicroBlaze-MCS-interrupt/td-p/256372

#include <xparameters.h>
#include <xiomodule.h>
#include <xiomodule_l.h>

XIOModule gpo1;
volatile u32 ct = 0;

void timerTick(void* ref) {
    ct++;
    XIOModule_DiscreteWrite(&gpo1, 1, ct);
    XIOModule_DiscreteWrite(&gpo1, 2, ct);
}

int main() {

    XIOModule_Initialize(&gpo1, XPAR_IOMODULE_0_DEVICE_ID);

    microblaze_register_handler(XIOModule_DeviceInterruptHandler, XPAR_IOMODULE_0_DEVICE_ID);

    XIOModule_Start(&gpo1);

    XIOModule_Connect(&gpo1, XIN_IOMODULE_FIT_1_INTERRUPT_INTR, timerTick, NULL);
    XIOModule_Enable(&gpo1,XIN_IOMODULE_FIT_1_INTERRUPT_INTR);

    microblaze_enable_interrupts();
    while (1) {
    }
}
Alchitry
  • 1,369
  • 1
  • 16
  • 29