Dear Professor,
I have a question also related to the custom parallel port and IRQ.
So, I would like to set-up a simplest working interrupt logic and generate an interrupt, when '1' is written into the second bit in parallel port.
So, my condition for an interrupt:
IRQ <= '1' when iIRQEn = '1' and iRegDir(2) = '1' and ParPort(2) = '1' else '0';
iIRQEn is a signal which is always set (initialized) to '1'- interrupt for this component is always enabled. Second part of the condition says, that if direction is set as output and if in ParPort(2) is 1, which means simply that I set second bit in parallel port, then IRQ is set. I wrote a test bench and that logic works.
IP component irq configuration.
And design - irq number is set to 1, interrupt_sender connected with nios2_gen2_0 interrupt receiver.
All compiled with many warnings as always, but no errors. When I programmed a board I moved to the software part, so I regenerated BSP library and I added a code responsible for interrupt set-up on the software side:
I registered an interrupt:
int result = alt_ic_isr_register(PARALLEL_PORT_0_IRQ_INTERRUPT_CONTROLLER_ID,
PARALLEL_PORT_0_IRQ,par_port_response_isr, NULL,NULL);
printf("result=%d\n", result); // result 0, so interrupt registered without problems
I set iRegDir to "...1111..." as output:
IOWR_8DIRECT(PARALLEL_PORT_0_BASE,IREGDIR,MODE_ALL_OUTPUT);
And in the loop I set and reset with some delay all IREGPORT bits:
for (int k = 0; k < 10000000; k++); //software delay
IOWR_8DIRECT(PARALLEL_PORT_0_BASE,IREGPORT,0x00); // first zero
for (int k = 0; k < 10000000; k++); //software delay IOWR_8DIRECT(PARALLEL_PORT_0_BASE,IREGPORT,0xFF); //then 1 for all bit
I printed the registers using IORD_8DIRECT after every operation and their content is correct - what I wrote remains.
Then I wrote isr:
static void par_port_response_isr(void* context)
{
alt_printf("par_port_response_isr\n");
IOWR_8DIRECT(PARALLEL_PORT_0_BASE,IREGPORT,0);
}
I expect that after that operations above isr will be invoked and I will see on STDOUT "par_port_response_isr" message, but nothing is printed, so isr is not invoked.
I have already working IP timer interrupt - that one from the library, so interrupts from built-in components work. But from custom parallel port doesn't.
I understand that it is hard to say remotely, but maybe I missed something in the above lengthy operations.
Your Sincerely,
Jakub Wieczorek