From: horst on
Hi,
I've some trouble with NIOS II PIO interrupts and need some help.
The pio port is configured as follows:
Width= 2 bits
Both input and output ports (not tri-state)
Synchronously capture: Rising Edge
IRQ= edge sensitiv

I dont want to use HAL to keep the code size small, that's why I use
alt_main.

static void AudioCodecInISR(void* context, alt_u32 id) {
volatile int inChL = 0;
inChL = IORD_ALTERA_AVALON_PIO_EDGE_CAP(CodecIRQRegBase);
/* Reset the Button's edge capture register. */
IOWR_ALTERA_AVALON_PIO_EDGE_CAP(CodecIRQRegBase, 0);
}

int main (void) __attribute__ ((weak, alias ("alt_main")));
int alt_main (void)
{
void * context;
alt_irq_init(ALT_IRQ_BASE);
IOWR_ALTERA_AVALON_PIO_IRQ_MASK(CodecIRQRegBase, 0x3);
/* Reset the Button's edge capture register. */
IOWR_ALTERA_AVALON_PIO_EDGE_CAP(CodecIRQRegBase, 0x0);
/* Register the interrupt handler. */
alt_irq_register( CodecIRQRegBase, context, AudioCodecInISR );

while (1)
{
}
return 0;
}

Does anybody has any clue where the bug is?

Thanks,
Horst

From: nobody on
On Wed, 13 Sep 2006 09:23:32 -0700, horst wrote:

> Hi,
> I've some trouble with NIOS II PIO interrupts and need some help.
> The pio port is configured as follows:
> Width= 2 bits
> Both input and output ports (not tri-state)
> Synchronously capture: Rising Edge
> IRQ= edge sensitiv
>
> I dont want to use HAL to keep the code size small, that's why I use
> alt_main.
>
> static void AudioCodecInISR(void* context, alt_u32 id) {
> volatile int inChL = 0;
> inChL = IORD_ALTERA_AVALON_PIO_EDGE_CAP(CodecIRQRegBase);
> /* Reset the Button's edge capture register. */
> IOWR_ALTERA_AVALON_PIO_EDGE_CAP(CodecIRQRegBase, 0);
> }
>
> int main (void) __attribute__ ((weak, alias ("alt_main")));
> int alt_main (void)
> {
> void * context;
> alt_irq_init(ALT_IRQ_BASE);
> IOWR_ALTERA_AVALON_PIO_IRQ_MASK(CodecIRQRegBase, 0x3);
> /* Reset the Button's edge capture register. */
> IOWR_ALTERA_AVALON_PIO_EDGE_CAP(CodecIRQRegBase, 0x0);
> /* Register the interrupt handler. */
> alt_irq_register( CodecIRQRegBase, context, AudioCodecInISR );

The order of the calls after alt_irq_init() need to be reversed.
In particular, you want to register the ISR before enabling
interrupts.

>
> while (1)
> {
> }
> return 0;
> }
>
> Does anybody has any clue where the bug is?

Could you give more details on how the bug manifests?
The code posted here doesn't do much of anything even
if the interrupt occurs.

Mark


From: horst on
Thanks for your answer.

I tried it that way

alt_irq_init(ALT_IRQ_BASE);
/* Register the interrupt handler. */
alt_irq_register( CodecIRQRegBase, context, AudioCodecInISR );
IOWR_ALTERA_AVALON_PIO_IRQ_MASK(CodecIRQRegBase, 0x3);
/* Reset the Button's edge capture register. */
IOWR_ALTERA_AVALON_PIO_EDGE_CAP(CodecIRQRegBase, 0x0);

but it isn't working.

You're right the code doesn't have any effect. I shortened it to post
it here.
I set a Breakpoint inside the ISR but the breakpoint never breaks the
running debugging execution, so I know that the interrupt newer gets
triggered.

From: nobody on
On Thu, 14 Sep 2006 09:27:07 -0700, horst wrote:

> Thanks for your answer.
>
> I tried it that way
>
> alt_irq_init(ALT_IRQ_BASE);
> /* Register the interrupt handler. */
> alt_irq_register( CodecIRQRegBase, context, AudioCodecInISR );
> IOWR_ALTERA_AVALON_PIO_IRQ_MASK(CodecIRQRegBase, 0x3);
> /* Reset the Button's edge capture register. */
> IOWR_ALTERA_AVALON_PIO_EDGE_CAP(CodecIRQRegBase, 0x0);
>
> but it isn't working.
>
> You're right the code doesn't have any effect. I shortened it to post
> it here.
> I set a Breakpoint inside the ISR but the breakpoint never breaks the
> running debugging execution, so I know that the interrupt newer gets
> triggered.

The next thing I'd try is to read the edge capture and data in
registers in the while loop, printing the contents when they
change. That way you can drive the IRQ inputs manually and
see if the signals are actually getting to the PIO.

Mark


From: horst on
The signals getting to the pio and the edge capture register responds
to the inputs.
I really don't have any idea why the interrupt doesn't work.