cancel
Showing results for 
Search instead for 
Did you mean: 

SPI communication between STM32H743ZI2 and Adafruit MAX31865 using Simulink encoder

mhostyn
Associate II

Hello, 

I would like to read the temperature value from PT1000 (AT103), to ease the reading, I am using an Adafruit MAX31865 (configured as 2 wires RTD reader). 

I plugged all components to an Arduino (both UNO and MEGA) and everything works perfectly, however I am required to do it over an STM32H743ZI2 board and here comes troubles...

I am using the Embedded Coder Support Package for STM32 add-on for Simulink alongside STM32CubeMX to configure my board.

I am using SPI1 with the following pinout configuration:

  • PB3 = SPI1_SCK
  • PB4 = SPI1_MISO
  • PB5 = SPI1_MOSI
  • D7 = CS 

On Simulink side, I am using SPI Controller Transfer blocks configured as follow: 

  • SPI module = SPI1
  • Clock Polarity = Low
  • Clock Phase = 1 Edge (as required by MAX31865 board) 
  • Register Address = 0x00 (to configure MAX board) and then 0x01 and 0x02 to read RTD data
  •  Data bits = 8
  • Chip select calling method = Explicit GPIO calls
  • Chip select polarity = Active Low 
  • Chip select port name = GPIOD
  • Chip select pin number = 7 

With all those configuration, it should work but, when I plug in my scope here is what I observe: 

img_4671_720.jpg

In order to debug, I tried to plug the Arduino over the scope and here is what is observed: 

img_4668.jpg

For both captures, the signals are: 

  • Yellow = SCK 
  • Blue = MOSI
  • Purple = MISO 

The first question that comes to my mind is: Why when the Arduino is plugged, the MOSI is always set to '1' except when transmitting data while STM32 is always set to '0' even when transmitting data? Do I need to pull up the MOSI? Why do I never receive data while the register address appears to be properly send (regardless of the register address)?  

 

Regards, 

Mathieu

6 REPLIES 6
liaifat85
Senior III

 MOSI being '1' when not transmitting data might be a result of how the STM32 SPI is configured or potentially due to an issue with the configuration in Simulink. Ensure that the STM32 SPI configuration and Simulink settings for SPI communication are correct.

MOSI is set to '1' while not transmitting data only when I am using the Arduino setup (which is the properly working setup).

On Simulink-STM32 side, MOSI is set to '0' when not transmitting data and both data and register address are not transmitted to the "slave" board.

_alaBaster
Associate III

Hi @mhostyn 

thank you for your exhaustive and well detailed post.
I think I am experiencing a similar issue with MAX31865, coupled to a STM32L051 though(but I guess the issue is more on the MAX device side)

Long story short, I am sending as per MAX datasheet address and data to configure the chip and later I am sending the read commands to 0x01 and to 0x02 to retrieve temperature conversion.

I never get anything meaningful back from MAX31865.

The best I could get by setting different clock polarity, pull up options, speed in my SPI driver was a MISO going low from MAX31865. So no answer from the Resistance to Digital converter!

Have you found your solution? Maybe you can share it here?
One thing that I noticed in your post, the write command for the configuration register should be 0x80 while 0x00 is for a read.

Thanks, bye

Hi _alaBaster,

Unfortunately we did not found a solution to this issue. We even thought at some point that we broke STM32's ADC.

As a last test we changed the Adafruit device and went from MAX31865 to MAX31855.

However, as we used an MBSE approach to implement the data reading, we had to decode the Adafruit data bit per bit according to its datasheet.

Regards,

Hi there, 

 okay, thank you for sharing.

In my opinion the issue is with timing between adjacent send with respect to /CS. I am working with LL libraries, where I need explicit control over such pin (/CS). It may be better with HAL driver for SPI.

I am onto that today, will keep you posted.

Regards

HI mhostyn

the problem that i see is with timing.
Clock generated with SPI transmit call and subsequent send of the word on MOSI line is not respecting the constraint tDC, data to SCLK setup, of 35 ns from MAX32865 datasheet. Not sure how to solve this now.

Regards