Nios® V/II Embedded Design Suite (EDS)
Support for Embedded Development Tools, Processors (SoCs and Nios® V/II processor), Embedded Development Suites (EDSs), Boot and Configuration, Operating Systems, C and C++

Interrupt-driven SPI?

Altera_Forum
Honored Contributor II
1,257 Views

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.
0 Kudos
3 Replies
Altera_Forum
Honored Contributor II
519 Views

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

0 Kudos
Altera_Forum
Honored Contributor II
519 Views

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?
0 Kudos
Altera_Forum
Honored Contributor II
519 Views

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

 

Thanks.
0 Kudos
Reply