Dear all,
I have followed your instructions in the previous posts, but it still doesn't work (I think my C-code is wrong) :(
I attach the snapshot of the configuration of my component in SOPC builder. As your suggestions I added an additional Avalon MM slave that is responsible to store the IRQ bit (I named it 'interrupt handler'). This Avalon MM consists of this following signals :
- IRQ_bit (the register that stores the IRQ bit, the signal type is readdata)
- READ_IRQ (read signal of the Avalon MM slave to read the IRQ_bit)
- interrupt (the register that used to set / clear the IRQ_bit)
- interrupt_en (write signal of the Avalon MM slave to clear the IRQ_bit).
The interrupt sender is assigned to this Avalon MM slave (interrupt handler).
I also attach the verilog code of my component and its testbench.
And here is the snapshot of my C code :
volatile int fifo_interrupt;
# ifdef ALT_ENHANCED_INTERRUPT_API_PRESENT
void FIFOinterrupt_handler(void* context)
# else
void FIFOinterrupt_handler(void* context, alt_u32 id)
# endif
{
INT8U error_code;
volatile int* fifo_interrupt_ptr = (volatile int*) context;
printf("IRQ bit 1 : %d\n",IORD(FIFIO_DUALWIDE_INTERRUPT_HANDLER_BASE,0));
*fifo_interrupt_ptr = IORD(FIFIO_DUALWIDE_INTERRUPT_HANDLER_BASE,0); // get the IRQ bit
IOWR(FIFIO_DUALWIDE_INTERRUPT_HANDLER_BASE,0,0x0); // clear the IRQ bit
printf("IRQ bit 2 : %d\n",IORD(FIFIO_DUALWIDE_INTERRUPT_HANDLER_BASE,0));
OSSemPost(DMAActvSem);
alt_uCOSIIErrorHandler(error_code, 0);
IORD(FIFIO_DUALWIDE_INTERRUPT_HANDLER_BASE,0);
}
void main()
{
.....
.....
void* fifo_interrupt_ptr = (void*) &fifo_interrupt;
printf("IRQ bit 0 : %d\n",IORD(FIFIO_DUALWIDE_INTERRUPT_HANDLER_BASE,0));
IOWR(FIFIO_DUALWIDE_INTERRUPT_HANDLER_BASE,0,0x0); // reset the IRQ bit
printf("IRQ bit 0 : %d\n",IORD(FIFIO_DUALWIDE_INTERRUPT_HANDLER_BASE,0));
# ifdef ALT_ENHANCED_INTERRUPT_API_PRESENT
alt_ic_isr_register(FIFIO_DUALWIDE_INTERRUPT_HANDLER_IRQ_INTERRUPT_CONTROLLER_ID,
FIFIO_DUALWIDE_INTERRUPT_HANDLER_IRQ,
FIFOinterrupt_handler,
fifo_interrupt_ptr, 0x0);
# else
alt_irq_register(FIFIO_DUALWIDE_INTERRUPT_HANDLER_IRQ,
fifo_interrupt_ptr,
FIFOinterrupt_handler);
# endif
.....
.....
}
When I ran my program, the program didn't recognize the interrupt. The SignalTap showed that when the IRQ signal (wrfinish) was active, the IRQ bit (IRQ_bit) was also active which meant there was no mistake in the hardware (I think..). So the problem should be in my C code...
Would you check my verilog code and the above C code? Hope you can help me to find where the problem is..:(
Thanks a lot