Thanks newbrain.
I wasn't using Transmit_IT, so right there is something to try.
When the regular
HAL_PPP_Transmit() calls are used, the "PPP" peripheral interrupt enable flags are not set.
So, one will never get an interrupt with the regular call, even though the global IRQ for the peripheral is enabled.
The flags are set inside the
HAL_PPP_Transmit_IT() calls and reset by the HAL IRQ handler.
It's possible to call again the transmit IT API inside the transmit complete callback.
Regarding #1, which interrupt should I enable? There are 3 options (not at a computer now so can't remember them)
As said above, the three interrupt enable flags (SPI_IT_RXNE, SPI_IT_TXE, SPI_IT_ERR) are taken care of by the HAL.
You only have to make sure the global interrupt is enabled, e.g. for SPI1 on an STM32F0xx:
HAL_NVIC_SetPriority(SPI1_IRQn, 1, 0);
HAL_NVIC_EnableIRQ(SPI1_IRQn);
Similar lines are placed usually at the end of the
HAL_PPP_MspInit(PPP_HandleTypeDef*) function.
CubeMX takes care of this, if instructed to use interrupts with the peripheral.
Lastly, regarding #2, I'm not 100% sure what this means. Something to dig into!
If one wants the HAL to handle interrupts, a call to
HAL_PPP_IRQHandler() needs to be placed inside the global ISR for the peripheral.
The specific ISR name used depends on the startup file, for the one provided by the HAL/CubeMX, it's
PPP_IRQHandler(), but depending on the specific family of STM32 there might be variations (e.g. shared interrupts as
CEC_CAN_IRQHandler() in an STMF0x2).
CubeMX will take care of generating the relevant code for this also, if interrupts are enabled for the peripheral.
Yes, I did use cubeMX to generate the setup.
So, if
in CubeMX you've specified to use interrupts for the SPI, the only thing would be using the correct transmit routine.
Thanks for the valuable hints. I'll try again tomorrow.
You're welcome.