Forum Discussion

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

Interrupt-driven SPI?

Hi.

I'm using uC/OS-II (version 2.77) on Nios II platform using Quartus 6.0, Service Pack 1.

The SPI included provides a HAL interface that is pretty much limited to the alt_avalon_spi_command() function. This function does not give up control so other processes can run while waiting for transfers to complete.

I have attempted to use the IRQ given to the SPI Bus device in system.h, but the interrupt never seems to fire even though data is being transferred. Do I have to do something other than the following?

alt_irq_register( SPI_BUS_IF_IRQ, (void *)NULL, handle_spi_interrupts );

Thanks,

Bob.

3 Replies

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

    You also need to write the SPI controller's "control" register to enable the interrupt.

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

    Thanks. I forgot to mention that I am also doing this in my SPI access function:

    IOWR_ALTERA_AVALON_SPI_CONTROL( SPI_BUS_IF_BASE,

    ALTERA_AVALON_SPI_CONTROL_SSO_MSK ||

    ALTERA_AVALON_SPI_CONTROL_IRRDY_MSK );

    The inclusion of the ALTERA_AVALON_SPI_CONTROL_IRRDY_MSK seems to make my code always read 0xFF from the RxData register.

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

    Found the problem. I used logical OR (||) instead of bit-wise OR (|) in my IOWR_ALTERA_AVALON_SPI_CONTROL() call.

    Thanks.