cancel
Showing results for 
Search instead for 
Did you mean: 

How to distinguish the multiple spi interrupt is there which hspi is get interrupted?

MDeva.1
Associate II

Hello,

I am working on stm32h745. I have to use 3 spi in interrupt mode, then how I can know which spi is get interrupted?

8 REPLIES 8
TDK
Guru

If you're using HAL, the function will pass a handle. Check the handle instance with the relevant SPI peripheral.

if (hspi->Instance == SPI1) {
  ...
} else if (hspi->Instance == SPI2) {
  ...
}

If you feel a post has answered your question, please click "Accept as Solution".
LBöhm.1
Associate III

Every SPI Controller has its own interrupt handler.

0693W00000LzVX7QAN.png0693W00000LzVYKQA3.pngThis error is getting

Okay, well you didn't write what I wrote, so the error is expected.

Either compare the instance or the handle. Don't compare the instance against the handle. The error message is descriptive of the problem.

If you feel a post has answered your question, please click "Accept as Solution".

How to solve thise Can you please elaborate how to solve

Match the right things.. with equivalent TYPES

hspi == &hspi3

Preferred is

hsip->Instance == SPI3

The address of the PERIPHERAL instance, not the handle/pointer to the structure pointer

Tips, Buy me a coffee, or three.. PayPal Venmo
Up vote any posts that you find helpful, it shows what's working..

Compare against SPI3 instead of hspi3.

If you feel a post has answered your question, please click "Accept as Solution".
Piranha
Chief II

TDK wrote an exact example, but the person is not even capable of doing a copy-paste...

And the code inside is just totally broken. Shifting something left by 8 bits and then assigning to 8-bit variable will always result in zero. All of those shifts seem to be trying to do what a simple casting can do. The ADC range is 4096 values, not 4095. And then dividing an integer with an ADC range also as an integer, will again result in a zero.