1 MCU(stm32f103) - 2 Master SPI Communication error
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Email to a Friend
- Report Inappropriate Content
‎2024-01-30 06:31 PM - edited ‎2024-01-30 06:32 PM
Hello, I am trying to control two Motor Drivers (TMC5041) through SPI communication using STM32F103. The compiler uses IAR. I am trying to communicate with two SPI Masters, but perhaps due to an initial configuration issue, only one SPI is controlled, so I am posting this to ask for help. ​ The current progress was controllable when each SPI2 and SPI3 were controlled one by one. For example, control is possible when TMC5041 Motor Driver 1 is controlled without defining SPI2. Controllable when controlling TMC5041 Motor Driver 2 without defining SPI3 Therefore, it is judged that there is no problem with the communication protocol with each TMC5041. ​ Here, when I try to use two SPIs 2 and 3 together, I am experiencing the problem that only one of the two SPIs can communicate and one is not communicating. In the process of specifying the initial configuration of two SPIs and sending and reading the data specified for each SPI, one SPI was able to write and read without a problem, and the other SPI was able to write data properly but not read. ​ I'm asking this question because I'm wondering if it's a problem with the communication Initialize above.
It seems that when initialzing SPI3 after initializing SPI2, the initialize contents of SPI2 are deleted..
Here's SPI_DRV.c code
then I initialized on main.c
SPI2_InitDriver();
SPI3_InitDriver();
Solved! Go to Solution.
- Labels:
-
STM32Cube MCU Packages
Accepted Solutions
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Email to a Friend
- Report Inappropriate Content
‎2024-01-31 06:35 AM
I don't see anything in the code presented which disables either SPI.
It is possible to use SPI2 and SPI3 simultaneously. If that isn't happening, it is likely to be a code bug. You can use a logic analyzer to look at what is happening on the bug. You can also debug, step through, and look at register values to understand what is or isn't happening.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Email to a Friend
- Report Inappropriate Content
‎2024-01-31 06:35 AM
I don't see anything in the code presented which disables either SPI.
It is possible to use SPI2 and SPI3 simultaneously. If that isn't happening, it is likely to be a code bug. You can use a logic analyzer to look at what is happening on the bug. You can also debug, step through, and look at register values to understand what is or isn't happening.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Email to a Friend
- Report Inappropriate Content
‎2024-01-31 06:47 AM
Why have you posted your text in a source code block? That makes it very hard to read!
Why have two SPI masters?
The whole point of a bus like SPI is that 1 master can control multiple slaves.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Email to a Friend
- Report Inappropriate Content
‎2024-03-18 05:50 PM
I think there were some parts that I didn't enable when I set it up.
When I tried it slowly again, it moved.
Thank you