2024-06-03 01:48 PM
I have two SPI buses activated SPI1 (flash memory) and SPI3 (nrf24l01) on my STM32F407. Separately, they work fine. But, if I transfer something via SPI1, SPI3 read from the register always returns 0 (and in DR register for SPI3 is also 0, BUT sometimes it has value 3 (though has to be 46)). And I don't know where to look and dig dipper. Let me know if you need additional code or screenshots.
Solved! Go to Solution.
2024-06-04 02:13 PM
I've found the solution!
I've added HAL_SPI_DeInit(&hspi1); and it works now!
Thanks @Tesla DeLorean and @waclawek.jan for the help.
2024-06-03 02:09 PM
a) There shouldn't be any interrelationship between different SPI peripherals on an STM32
b) The DR write and read go to DIFFERENT registers, you can't inspect what you sent
c) The debugger is very invasive. Don't use a Peripheral View it breaks DR/SR and FIFO's
2024-06-04 01:25 AM
Thanks for the reply.
a) yes, I have 2 different handlers and they have different addresses in memory
c) the interesting thing that when I don't send anything to SPI1, I can read from SPI3->DR the value I need and it's working stable, but as soon as I transmit via SPI1, SPI3->DR == 0 and never changes
2024-06-04 02:05 AM
What is on the respective SPI3_MISO and SPI3_SCK lines?
JW
2024-06-04 12:02 PM
I tried to check SPI3_SCK line and when SPI1 was not used I saw signals there, but when SPI1 was in use, nothing happened.
I also debugged HAL_SPI_Transmit() function and what I've found: DR is '0' even if I try to set it like this.
Original code from library:
2024-06-04 12:19 PM
Why's it in the SLAVE branch?
Both peripherals you have described are SLAVE devices, and the STM32 is the MASTER.
Not sure how this situation is going to be replicated elsewhere with the presentation provided so far.
2024-06-04 12:28 PM
It's in SLAVE branch, because it has only 1 byte to transmit
I've pushed the whole project to github
https://github.com/litai-tech/colir_one/tree/main/rocket_code
2024-06-04 02:13 PM
I've found the solution!
I've added HAL_SPI_DeInit(&hspi1); and it works now!
Thanks @Tesla DeLorean and @waclawek.jan for the help.