Forum Discussion

Altera_Forum's avatar
Altera_Forum
Icon for Honored Contributor rankHonored Contributor
13 years ago

alt_irq_register can't work

I have added a component CAN controller into SOPC builder, and it work well. I can send and receive data correctly. But i can't register the interrupt(IRQ) send out from the controller. I checked anything i know....

Here is my code, it can be compiled and no errors, but just die in the alt_irq_register function. Anybody have experience to use CAN controller in

SOPC builder can tell me where is the problem?

static void handle_CAN2_interrupts(void* context, alt_u32 id)

{

int q;

q =IORD(CAN2_BASE, 0x4);

printf(" interupt = %d \n",q);

}

int main()

{

printf("Hello from Nios II!\n");

alt_irq_register(CAN2_IRQ,NULL, handle_CAN2_interrupts );

tx_basic_frame();

}

i use quartus 8.0 and NIOS ii 7.2 to do this

3 Replies

  • Altera_Forum's avatar
    Altera_Forum
    Icon for Honored Contributor rankHonored Contributor

    also i test to use the timer interrupt, and it worked fine. i can't figure why me controller can't even register irq...

  • Altera_Forum's avatar
    Altera_Forum
    Icon for Honored Contributor rankHonored Contributor

    I don't know your CAN controller, but I guess you probably need to clear the irq inside the handler function, otherwise the irq would continuously retrigger just after you have serviced it.

  • Altera_Forum's avatar
    Altera_Forum
    Icon for Honored Contributor rankHonored Contributor

    --- Quote Start ---

    I don't know your CAN controller, but I guess you probably need to clear the irq inside the handler function, otherwise the irq would continuously retrigger just after you have serviced it.

    --- Quote End ---

    Thanks for your advise, i find my controller send a unexpected interrupt after reset, and it cause the retrigger problem you said.