cancel
Showing results for 
Search instead for 
Did you mean: 

SPI interrupt problem

ph_zupancic
Associate II
Posted on March 15, 2016 at 00:27

Good evening!

I am trying to move from blocking to nonblocking SPI communication but I have trouble getting the RXNE interrupts to run, while TXE works fine.

Running ''HAL_SPI_Receive(hspi, buffer, 2, TIMEOUT)'' works, but when I do

''HAL_SPI_Receive_IT(hspi, buffer, 2)'' there is no call happening to HAL_SPI_RxCpltCallback, but instead HAL_SPI_ErrorCallback is called with the OVR-flag set.

The SPI configuration code is from CubeMX with global interrupt enabled.

Any insights would be greatly appreciated.

Thanks!
4 REPLIES 4
TDK
Guru
Posted on March 15, 2016 at 06:04

Is it receiving more than 2 bytes before you handle it?  Are you handling the interrupt correctly?

Could be a lot of things.  TXE shouldn't be a factor if you're receiving.

If you feel a post has answered your question, please click "Accept as Solution".
re.wolff9
Senior
Posted on March 15, 2016 at 08:29

Sometimes the SPI module seems to think it's received data even before it has done so. This usually messes with the polled implementation because you end up falling trhough ''wait for RXNE'' immediately with invalid data. But maybe it causes you interrupt problems too. Clear the RX fifo before you start. ... 

ph_zupancic
Associate II
Posted on March 15, 2016 at 09:48

That's exactly the point that I do not get - how can I receive more than 2 bytes in master mode if I only ask for two?

What I meant with TXE is that the interrupt routine is called correctly when I send data.

ph_zupancic
Associate II
Posted on March 15, 2016 at 10:28

I tried resetting RXNE, but it did not help.