cancel
Showing results for 
Search instead for 
Did you mean: 

SPI NSS-Signal by Hardware, using IIS3DWB on an STM32L432 MCU

PR.4
Associate II

Hello!

We are developing with the sensor IIS3DWB. I am able to interface it by spi like mentioned in st's github example, and I'm able to use st's platform independend c-drivers. It works fine, I get Acceleration, Temperature, device-ID...

In that example the SPI is used in blocking mode and the NSS pin is set by software.

Now I want to drive the SPI (with st's SPI-HAL) in non-blocking mode, and I want to drive the NSS-Pin by hardware.

Refering the sensor's data sheet, it seems that I need to configure the SPI with CPOL high (CPOL-bit =1), and CPHA to second clock phase (CPHA-bit = 1). But the MCU's reference manual (RM0394, page 1326) says, that the NSS-Hardware-Output-Mode requires clock-pahse-configuration CPHA-Bit==0 (=first clock edge).

Is there any way to bring it to work? (If that helps: The sensor will be the only spi device connected to the mcu)

Does the sensor accept any other spi setup which is compatible to the MCU when the MCU generates the NSS by hardware?

Is there any further documentation or information about the sensor's spi interface than the sensor's data sheet?

Thank for your help! Kind Regards, Patrick

1 ACCEPTED SOLUTION

Accepted Solutions
PR.4
Associate II

Thank You for your answer! The information that the sensor only accepts SPI mode 3 was helpful for deciding how to further proceed with the SPI. In the meantime I have decided to control the NSS pin via software and I use the HAL SPI function HAL_SPI_TransmitReceive_It(...) to efficiently read the fifo's data. Fortunately that works well. (Maybe I will improve that lateron to use DMA, to learn / do experiences for future embedded projects). Kind Regards and thank you for your help!

View solution in original post

2 REPLIES 2
Eleon BORLINI
ST Employee

Hi @PR.4​ , I believe unfortunately that the IIS3DWB accepts only the SPI Mode3 as described in the timings diagram of the datasheet p.8, but maybe there is the possibility to differently configure the NSS-Hardware-Output-Mode with CPHA-Bit==1. I have added STM32L4 topics for more help. Regards

PR.4
Associate II

Thank You for your answer! The information that the sensor only accepts SPI mode 3 was helpful for deciding how to further proceed with the SPI. In the meantime I have decided to control the NSS pin via software and I use the HAL SPI function HAL_SPI_TransmitReceive_It(...) to efficiently read the fifo's data. Fortunately that works well. (Maybe I will improve that lateron to use DMA, to learn / do experiences for future embedded projects). Kind Regards and thank you for your help!