How to change RTEMS real time interrupt source to external pin of LEON UT699

Richard.Glossop at Richard.Glossop at
Wed Aug 30 14:07:50 UTC 2017

Want to change the source of RTEMS time tick interrupt from Timer 0 on the LEON to a GPIO pin.  Have had success enabling the GPIO pin for the interrupt source (I get Spurious Interrupt 5 messages on the gdb console - we are using GPIO 5 - this tells me the interrupt is happening).  When I try to use rtems_interrupt_catch to install a new vector isr for the GPIO, the system crashes.

Here is the code:

rtems_isr_entry reMapRealTimeInterrupt (void)
    int level;
    rtems_isr_entry old_handler;
    rtems_status_code retVal;

    rtems_interrupt_disable (level);     // disable all maskable interrupts

    retVal = rtems_interrupt_catch(         // re-map vector 5 to our handler (GPIO 5)

    printf("Remap retVal:0x%x\n",retVal);

    *(unsigned int*)TIMCTR1 &= ~0x00000009; // disable timer 1 interrupt enable and timer enable
    *(unsigned int*)IMR &= ~0x00000040;     // mask interrupt for timer 1 interrupt since it is no longer used
    *(unsigned int*)IMR |=  0x00000020;     // enable GPIO 5 interrupt in IMR
    *(unsigned int*)ILR |=  0x00000020;     // set interrupt 5 to be a level 1 interrupt

    *(unsigned int*)GPIOIMR |= 0x00000020;  // enable bit 5 to cause interrupts (GPIO 5)
    *(unsigned int*)GPIOIER |= 0x00000020;  // set GPIO interrupt 5 to be edge triggered
    *(unsigned int*)GPIOIPR |= 0x00000020;  // set GPIO interrupt 5 to be rising edge

    rtems_interrupt_enable (level);       // enable all previously enabled interrupts

    return old_handler;                      // return original isr address in case want to restore


    rtems_isr handler (rtems_vector_number vector)
        printf("This is irq %d.\n",vector);


Can anyone help with this, or point me to example code to accomplish the same thing?

Effective immediately my new email address is Richard.Glossop at Please update your records.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <>

More information about the users mailing list