I have several devices like for example connecting with ESP8266.

I have tried to use the SPI with it with STM32F4.

First I have tried to work with SPI interrupts, the result of the communication is not stable, sometimes the communication works between both, sometimes it doesn't.

When I switched to Polling mode of STM32F4, and let EPS8266 work with interrupts, everything is stable then.

My question, why sometimes is polling works rather than interrupts ? Is it timing issue ?


closed as unclear what you're asking by Dave Tweed Jul 7 at 20:20

Please clarify your specific problem or add additional details to highlight exactly what you need. As it's currently written, it’s hard to tell exactly what you're asking. See the How to Ask page for help clarifying this question. If this question can be reworded to fit the rules in the help center, please edit the question.

  • 2
    \$\begingroup\$ It sounds like you might be missing interrupts, or something is going wrong between the interrupt handler and the rest of the code. But if you don't show us your code, there's no way we can comment on it. Ideally, you'll create an MCVE, as well as explain exactly what the difference is between what you expect to happen and what actually happens. \$\endgroup\$ – Dave Tweed Jul 7 at 20:21

Almost certain that it is some type of software error. A correctly crafted interrupt implementation should provide operational behavior similar to polling.

It is hard to guess what the nature of the error from the over simplistic explanation that you provided. There may very well be a timing or synchronization issue that you are overlooking operating in the interrupt mode. One first good approach for debug is to use a digital oscilloscope or logic analyzer to probe and capture the SPI bus waveforms and see if, at time of failure, there is any aberration in the SPI_CLK to SPI_MISO and SPI_MOSI signal lines. Also check the SPI_CS signal line for proper framing and timing.


Probably you are missing interrupts when it doesn't work. Perhaps because your code (whether you know it or not, maybe some library is doing it) is intermittently disabling interrupts asynchroniusly to the interrupt events.

One way to notice this is to use a logic analyzer to observe the interrupt signal, then in your interior handler, toggle a pin and observe that. When it doesn't work, chances are you will see the interrupt signal but not the pin toggle showing you the interrupt handler firing. You might need to set up a fancy trigger to catch this happening.


Not the answer you're looking for? Browse other questions tagged or ask your own question.