I am writing some firmware for an STM8S, and I want to have my SPI transmissions and receptions be handled in an ISR rather than polling.
According to pg. 284 of the reference manual, I should be able to set the SPI_ICR register to 0xC0 and have an interrupt triggered on both a SPI RXNE and TXE flag.
However, when I try and set this, it causes a fault and the device resets. Any idea why that is happening?
I have tried two methods:
The first is to use the STM8s SPL functions to set the register like this:
SPI_ITConfig(SPI_IT_TXE,ENABLE); SPI_ITConfig(SPI_IT_RXNE,ENABLE);
This works when I only set one one the interrupt sources, but when I do both it causes a fault. I read the code for this, and when you call both of them, it ends up just writing 0xC0 to the register.
I also tried directly setting the register like this:
SPI->ICR |= 0xC0;
This causes the exact same fault.
I can't get OpenOCD to work on my computer, so I am pretty much going blind here, but I can't figure it out, please let me know how I can fix this issue, or if it is just not possible to have both interrupts.
Thanks.