cancel
Showing results for 
Search instead for 
Did you mean: 

How to send DATA from Slave to Master over SPI

rozehtiyan
Associate II
Posted on November 17, 2014 at 16:12

Hey guys

I'm think to send data from Slave to Master over SPI but there is a problem. when I send the dummy data on SPI lines for create clock on SCK line for Slave, How can I send the data from slave to Maser when the clock is coming? How the SPI peripheral can know the clock is coming and it should send the data? I'm working with my STM32F103RET6

#stm32f103 #spi #spi-slave-mode
5 REPLIES 5
Posted on November 17, 2014 at 16:42

a) You'd watch the -CS signal going low

b) Look for RXNE interrupts
Tips, Buy me a coffee, or three.. PayPal Venmo
Up vote any posts that you find helpful, it shows what's working..
rozehtiyan
Associate II
Posted on November 17, 2014 at 17:06

Oh man, Sorry but are you sure? for example look this picture:

http://www.uploadax.com/images/27061574157374718625.jpg

page 684, reference manual. as you can see RXNE is set after the received data, thus it means the clocks is over! then we cannot send anythings! can we?

Posted on November 17, 2014 at 17:17

Well that would be why

a) You look at the -CS and stuff the TX register, I'd expect TXE to be true all the time prior to the first byte/word so not initially helpful.

b) SPI slaves often have 8 to 16-bit of slack data sent to them so they can recognize a command being send and respond to it in the next clocking window. Bit hard to predict the future until it gets here.

Tips, Buy me a coffee, or three.. PayPal Venmo
Up vote any posts that you find helpful, it shows what's working..
rozehtiyan
Associate II
Posted on November 17, 2014 at 17:32

Thanks clive

Do you have a Master and Slave program to send the data from Slave to Master?

I want to know how does it work exactly?

Posted on November 17, 2014 at 17:53

Not that I can share.

But, I'd recommend looking at the documentation for SPI EEPROM and FLASH devices, and example code in the libraries and utilities directories. Ponder how you might spoof such devices as a slave, and why things like the command and address have to go out before the slave can read the data and respond.

Perhaps

STM32F10x_StdPeriph_Lib_V3.5.0\Project\STM32F10x_StdPeriph_Examples\SPI\FullDuplex_SoftNSS

Look at some EXTI examples for catching a falling edge

Tips, Buy me a coffee, or three.. PayPal Venmo
Up vote any posts that you find helpful, it shows what's working..