cancel
Showing results for 
Search instead for 
Did you mean: 

spi problem communication STM32F103c8t6

Skyy_Tsuki
Associate II

Hello, i have a problem with my spi communication i don't recieve the information from the slave to the master 

Master configuration :

master.png

masterclock.png

Slave configuration : 

spislave.png

spiclock.png

I want to receive how many time my led blink and i want to write it on my lcd screen. 

But everytime is printing 0.

  

1 ACCEPTED SOLUTION

Accepted Solutions
AScha.3
Chief II

Hi,

see ->

AScha3_0-1707730974687.png

So try using:  HAL_SPI_TransmitReceive(..)  in master, to do the data "loop exchange" 

and in slave also , giving the data to transmit and wait for ready .

(You cannot separately send or receive , as you tried before. )

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

View solution in original post

6 REPLIES 6
AScha.3
Chief II

Hi,

see ->

AScha3_0-1707730974687.png

So try using:  HAL_SPI_TransmitReceive(..)  in master, to do the data "loop exchange" 

and in slave also , giving the data to transmit and wait for ready .

(You cannot separately send or receive , as you tried before. )

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

Thanks that's working but my variable is stuck to 170 and don't move on my screen, and i have a question the frequency of my two cpu does influe on my spi connection ? i can have on my slave 93.5kHz and 72 MHz on my master ? 


@Skyy_Tsuki wrote:

 the frequency of my two cpu does influe on my spi connection ? 


An SPI connection includes a clock line: the Master provides the clock to the Slave - so, in principle, the internal clock speed of the processors is irrelevant.

 


@Skyy_Tsuki wrote:

 my slave 93.5kHz and 72 MHz on my master ? 


Really? Your Slave is 93 kilo Hertz?? That's extremely slow!!

If it's really running that slowly, that's going to severely restrict the maximum SPI rate that it can cope with.

You just need to ensure that your SCK rate is within the capabilities of the slave.


@Skyy_Tsuki wrote:

 my variable is stuck to 170 and don't move on my screen 


What do you mean by that? How are you observing it?

ie, is that just a problem with your screen display/updating, or are you sure that the variable itself is not getting updated?

the goal of my project is to count a number of pulses between two rising edges of a signal but it is very slow as a signal so I use a 90kHz operating card because I cannot count my number of pulse correctly would you have a code to count a number of pulses and I use the second master card at 72 MHz to do my value display as well as the calculations because the goal is to obtain a phase shift currently I wanted to increment a variable every, lighting the LED and sending it to the master to see if the communication works but currently I communicate but do not recover consistent values on the increment variable, I display my values using an st7920 LCD screen.

I think you need to start a separate thread on that - it's nothing to do with SPI comms