[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [MiNT] TimerA interrupt handler



Searching through my old test sources for the Coldfire LITEKIT I found this. Enough for a (very simple, does nothing but printing the contents of SP) trap handler:

/* -------------------------------------------------------------------- */
typedef void (*trap_func)(void);

#define vbr 0x0L

trap_func *trap9_vector = (trap_func *) ((uint8_t *) vbr + 0x80 + 4 * 9);

void __attribute__((interrupt)) trap_9(void)
{
    volatile register int *sp asm("sp");

    printf("trap 9, SP=%p\r\n", sp);
}

void install_trap9(trap_func func)
{
    *trap9_vector = func;
}

int main(int argc, char *argv[])
{
    install_trap9(&trap_9);

    asm("trap    #9\n\t");

    return 0;
}