cancel
Showing results for 
Search instead for 
Did you mean: 

1 MCU(stm32f103) - 2 Master SPI Communication error

Jdogk
Associate II
 

image.png

 

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();

 
 

 

1 ACCEPTED SOLUTION

Accepted Solutions
TDK
Guru

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.

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

View solution in original post

3 REPLIES 3
TDK
Guru

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.

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

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.

Jdogk
Associate II

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