cancel
Showing results for 
Search instead for 
Did you mean: 

Software SPI

Nico3
Senior

Hello friends, 

I need to connect thirdparty accelerometer SENSOR to STM32F4 series MCU via SPI. 

The Sensor Data sheet says:

1) Designed to support any MCU  that used software implemented SPI. It is not designed to support any particular hardware implemented SPI.

2) MISO: data bits are shifted out on falling edge of SCK

3) MOSI: each bit is sampled on the rising edge of SCK. 

4) Sensor supports full duplex communication

___________________________________________________________________

Please suggest how to implement. Can I use SPI peripheral of MCU? If yes, I am not sure about what should be CPHA for CPOL = 0. 

I need full duplex communication.

1 ACCEPTED SOLUTION

Accepted Solutions
TDK
Super User

CPOL = 0 and CPHA = 0 clearly from the SPI diagram.

The chip doesn't know if you're using software or hardware SPI. It'll work fine with hardware SPI.

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

View solution in original post

9 REPLIES 9
######
Senior II

Hello,

What is the part number / datasheet link for the sensor?

Thanks

Andrew Neil
Super User

@Nico3 wrote:

thirdparty accelerometer 


Why so secretive? Tell us the manufacturer and part number!

How to write your question to maximize your chances to find a solution

 


@Nico3 wrote:

The Sensor Data sheet says:

1) Designed to support any MCU  that used software implemented SPI..


That's an odd thing to say!

Please post a link to the datasheet - so that we can see exactly what they said, in context.

 

 

Have you tried an internet search for "STM32 + <sensor part number>" ?

A complex system that works is invariably found to have evolved from a simple system that worked.
A complex system designed from scratch never works and cannot be patched up to make it work.
Nico3
Senior

Murata is mfg. Please find the detailed data sheet attached. On page 20, it mentions about SPI.   I planned to use P/N SCA3100-D04.  

STM32+ SCA3100-D04 internet search already tried. Couldn't find anything. All information about sensor posted in below post.

thanks

Thanks.

Indeed, there it is:

AndrewNeil_0-1758187233281.png

You'll have to contact Murata to ask them what they actually mean by that.

 

But the Murata SPI frame is shown here:

AndrewNeil_1-1758187354942.png

And the STM32's is here:

AndrewNeil_2-1758187429758.png

https://www.st.com/resource/en/reference_manual/rm0368-stm32f401xbc-and-stm32f401xde-advanced-armbased-32bit-mcus-stmicroelectronics.pdf#page=565

via: https://www.st.com/en/microcontrollers-microprocessors/stm32f401rd.html#documentation

So see which one matches.

There's only 4 modes to choose from ...

https://en.wikipedia.org/wiki/Serial_Peripheral_Interface#Mode_numbers

A complex system that works is invariably found to have evolved from a simple system that worked.
A complex system designed from scratch never works and cannot be patched up to make it work.
Andrew Neil
Super User

Note that the "automatic" NSS operation in the STM32F4 is probably not what you expect - or want:

AndrewNeil_0-1758190840698.png

So you'll probably want to do it "manually" in your software.

A complex system that works is invariably found to have evolved from a simple system that worked.
A complex system designed from scratch never works and cannot be patched up to make it work.

I think this is what they meant when they are saying Hardware and software. i have to use CS pin manually.    Other than this,   I am yet  to find out CHPA polarity.

I think the lanugage written in manual is confusing ..looks like auto converted from Chinese/Japanese to English...


@Nico3 wrote:

I think this is what they meant when they are saying Hardware and software. i have to use CS pin manually


I very much doubt it - that's a specific STM32 gotcha!

Yes, it does look like something got lost in translation.

Please feed back to Murata!

A complex system that works is invariably found to have evolved from a simple system that worked.
A complex system designed from scratch never works and cannot be patched up to make it work.
TDK
Super User

CPOL = 0 and CPHA = 0 clearly from the SPI diagram.

The chip doesn't know if you're using software or hardware SPI. It'll work fine with hardware SPI.

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