IRQ of custom parallel port

IRQ of custom parallel port

by Kay Emanuel Lächler -
Number of replies: 4

Hi,

So in the "Interrupt times measurement by software", your custom parallel port is connected to an interrupt, however in the vhdl code provided in "Parallel port Implementation on Avalon Bus (slides)File" for the parallel port, there is no IRQ signal defined. I was wondering, how and when the interrupt signal from the parallel port should be set and cleared since we use this interrupt for the timing measurements afterwards?


- Kay Lächler

In reply to Kay Emanuel Lächler

Re: IRQ of custom parallel port

by René Beuchat -

Hello,

In the provided example, their is no IRQ, it's correct.

But you can imagine a way to do it:

  • Adding in a ctrl register, a bit for bIntEnable : to allow interrupt request to an IRQ pin
  • A status bit that can be polled to ask for the service. bIRQRq 
  • Adding the signal as output as IRQ sender, IRQRq when the bIRQRq and bIntEnable are activated
  • Adding a ctrl bit to be able to clear the bIRQRq, or it could be the same status register used for the request that you can clear by writing on it

To generate the interrupt, you can imagine different ways, as example:

  1. When you write to the parallel port to activate an output pin, ex. when you write a '1' on it you generate an interrupt
  2. You can add a specific register, when you write on it, you output the value on the parallel port pin if it's an output, and activate the IRQ as in 1)
  3. Image another way.

You can take inspiration to do it in looking for the 32 bits counter described during the lab.

I hope to answered your question.

Remember as an FPGA designer, it is possible to do almost everything you want.

RB

In reply to René Beuchat

Re: IRQ of custom parallel port

by Jakub Lukasz Wieczorek -

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

In reply to Jakub Lukasz Wieczorek

Re: IRQ of custom parallel port

by René Beuchat -

Hello,

I think there is just a typo error when cut and past, but verify.

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

No return after your //software delay !

never write a loop as you are doint with an int, always use

volatile int ...       // without volatile, with optimisation, the compiler will remove the loop !

What append on the GPIO with the logic analyser? the pins are toggling?

Did you enable the global interrupt?


You can put your source file as attachment.

Another error can be in system.h

Have a look in the IRQ number for your parallel interface. Depending on the version of QSYS, the generation of IRQ number is wrong and put at -1, you have to change it manually.

Put your result (working or not) on the forum.

Best.

RB

In reply to René Beuchat

Re: IRQ of custom parallel port

by René Beuchat -

You said:

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';

- You want the bit 2, thus the 3rd.


In general, do not put a printf () in a ISR.

What do you have on bit 2 with the logic analyzer ? a square wave ?