cancel
Showing results for 
Search instead for 
Did you mean: 

Receive SPI data from an unknown device.

Dariush
Associate II

Hi

I want to communicate with a device that uses SPI, I want to grab data from this device but when it transmits a byte waits for an acknowledgment signal which is a positive pulse with 2us lent. So I should wait until it sends 1 byte of data, store it and make the acknowledgment signal.

could anyone help me to know what functions I need. I’m using HAL functions.

5 REPLIES 5
S.Ma
Principal

Is the ack signal a separate pin or it's mixed with MISO or MOSI ?

And which one is master, which one slave?

Dariush
Associate II

Hi

thank you for your attention firstly.

it is a separate pin and the unknown device that transmits is master and stm32 is going to be slave

additionally I have problem with receiving data and sending it through UART.

Dariush
Associate II

No one can answer my question?

> No one can answer my question?

Correct.

Take a look at the SPI peripheral section of the reference manual for your STM32, especially the configuration options. Seems you don't even know the required clock polarity.

Perhaps a trial-and-error approach, but getting to know your "unknown" device is the best way.

Dariush
Associate II

I’m using STM32F030F4P6. I set the clock polarity, slave mode and other settings using CubeMX so these things seem to be ok.

I think if I connect MOSI, CLK and CS pins, the SPI peripheral should get 8bit data coming from the “unknown device�? and generate interrupt. correct me if I’m wrong.

I want to read and store the data in a variable, send it through UART and generate ack on related pin when interrupt occurs.

what settings should I have on SPI in CubeMX to enable interrupt? And what functions is suitable for read and store the data in my case?

Hop this details enough someone who wants help me.

thanks