2022-04-29 08:37 AM
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?
2022-04-29 10:51 AM
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) {
...
}
2022-04-29 10:51 AM
Every SPI Controller has its own interrupt handler.
2022-04-29 11:03 AM
2022-04-29 11:09 AM
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.
2022-04-29 11:16 AM
How to solve thise Can you please elaborate how to solve
2022-04-29 11:20 AM
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
2022-04-29 01:01 PM
Compare against SPI3 instead of hspi3.
2022-05-01 12:29 PM
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.