SPI interrupts

28 Sep 2011

How do I attach an ISR for SPI TXE and RXNE interrupts?

Thanks and Regards, Shankar

29 Sep 2011

Hi, i am currently working on spi interrupts. But without success. The goal is to get an interrupt when data arrive to the slave.I have already testet following ideas:

1)

extern "C" void SPI_IRQHandler() {
    printf("spiSlave read IRQ - B\n\r");
    if (spiSlave.receive()) {
        state = spiSlave.read();
        spiSlave.reply(state);
        printf("spi read1: %i\n\r",state);
    }
}

2)

void spiCheck(){
        state = spiSlave.read();
        spiSlave.reply(state);
        printf("spi read1: %i\n\r",state);
}

main(){
    NVIC->IntSelect &= ~(1 << SPI_IRQn);
    NVIC_SetVector(SPI_IRQn, (uint32_t)&spiCheck);
    //NVIC_SetPriority(SPI_IRQn, 0);
    //LPC_SPI->SPINT=1;
    NVIC_EnableIRQ(SPI_IRQn);
    while(1);
}

What is the proper way to avoid a polling operation mode with SPI?

29 Sep 2011

A.H are you able to get the slave SPI to work? I am not able to get it to work even in polling mode.

Can I leave slave select line unconnected?

In my setup slave select is different. I have 4 adress lines coming to my slave and we enable SPI or disable SPI based on the address on this address lines. I have to drive the slave select by software on slave itself.

Any thoughts?

04 Oct 2011

Hi, SlaveSPI works with polling mode. Another workaround was to read the CS line also on a InterruptIn, so i can trigger the Read-Function to a flange of this signal.

For your problem i see only one quick solution at the moment. Set a output-pin when your adress is correct and set this output also on the CS of the spi. So you have to generate this CS-Signal by yourself.

04 Oct 2011

its wiered how this SPI slave interface works. It requires the CS line to be toggled everytime a byte comes in. If I keep it low(always selected) it did not work. On ST chips this is fine. anyway thanks for the input.

Regards, Shankar