Skip to main content
Associate
July 14, 2024
Question

SPI Communication is not initilizing

  • July 14, 2024
  • 7 replies
  • 3468 views

Hii, 

I am trying to interface ADC module cs5532 using SPI communication with STM32H563ZIT6 on NucleoH563zi board.

I have also completed pin configuration on .ioc file and successfully generated a code. But SPI communication is not initializing. 

I have also tried with other controllers and it is working fine with their spi. The issue is only for STM32 i am facing.

7 replies

AScha.3
Super User
July 14, 2024

Hi,

so after starting main - what you do with the spi ? (Nothing will happen on its own.)

 

>The issue is only for STM32 i am facing.

Whats the "issue" then , different to ...xx(which cpu ?) ?

 

>I have also tried with other controllers and it is working fine with their spi.

Which controllers and what you programmed there ?

"If you feel a post has answered your question, please click ""Accept as Solution""."
digambarAuthor
Associate
July 24, 2024

Yeah I am facing this issue with STM32 only.

I have successfully interfaced CS5532 with ESP32

STOne-32
Technical Moderator
July 14, 2024

Dear @digambar ,

Welcome in STCommunity! Can give more details in your configuration - Used pins /wiring ? And also code and environment to help you .

Ciao

STOne-32

digambarAuthor
Associate
July 24, 2024

Controller Used: STM32H563ZIT6 (Nucleo H563ZI)

Slave Used: CS5532

Communication Mode: SPI5

PF7: SCK, PF8: MISO, PF9: MOSI, PG1: CS, 5V, Gnd

SCK Speed: 2 MHz, SPIMode0, MSB bit first

 

The code is attached for your reference

The issue is not getting any data from CS5532 (it continuously giving FF as an output due to pullup.

 

digambarAuthor
Associate
July 26, 2024

STM32.jpg

ESP32 (Expected).jpg

The updated code is attached for reference. 

When I interfaced CS5532 with another microcontroller(ESP32), I got the output properly as shown in ESP32 (Expected) image (Second image).

Yellow line : MISO data

Blue Line: Clock 2MHZ

Pink line: MOSI data (0xC0)

But when I interfaced it with STM32 I didn't receive any signal.

The clock pulse is having set of 8 cycles (8 bit data). So while interfacing with STM32 the MOSI signal goes to high between two sets of clock pulses.

STOne-32
Technical Moderator
July 26, 2024

Dear @digambar ,

 

Can you check your VD+ pin voltage of the CS5532 Cirrus IC . To interface with STM32 SPI it should be at 3volts rail . If possible to have power schematics . As I see the one working ( second screen) the SPI clock for ESP32 is at 5 Volts.

Hope it helps .

STOne-32

digambarAuthor
Associate
July 26, 2024

I have also tried it with 3.3V, same issue occurred. 

 

STOne-32
Technical Moderator
July 26, 2024

Thank you for the follow up. This is two last suggestions :

 

1) in the code I do not see SPI5 GPIO configuration: MOSI, MISO , SCK pins in Alternate functions or I overlooked the code .

IMG_9081.jpeg

There are only clock enable if 3 ports F,H and G and configuration of PG1 ( CS) in software and No PF7-9  

 

2) try another SPI port for debugging purposes and using our reference code examples .

 

Hope it helps ,

STOne-32

digambarAuthor
Associate
July 26, 2024
digambar_1-1721999035358.png

These functions are included in stm32h5xx_hal_msp.c file which is generated by stm32cube.

I have also tried it with spi3 and spi1 and facing the same issue

STOne-32
Technical Moderator
July 26, 2024

Thanks , At this step I would recommend to reach out OnLine support and have a close contact to work with you . It is a weird behavior and we need to isolate it step by step if SPI is working with another Device, Clock , Hardware, etc. 

digambarAuthor
Associate
July 26, 2024

Thanks please let me know the good and fastest way to get the online support. 

STOne-32
Technical Moderator
July 26, 2024

Hi @digambar ,

Fastest way is our valuable STCommunity here where all experts are exchanging and sharing their experiences.  Reaching our Online support is here https://ols.st.com/s/ and will dispatch to our World wide teams and evaluate the business opportunity first.

have a great day

STOne-32.