cancel
Showing results for 
Search instead for 
Did you mean: 

SPI Communication is not initilizing

digambar
Associate II

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.

12 REPLIES 12
AScha.3
Chief III

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".
STOne-32
ST Employee

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

digambar
Associate II

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.

 

Yeah I am facing this issue with STM32 only.

I have successfully interfaced CS5532 with ESP32

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
ST Employee

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

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

 

STOne-32
ST Employee

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

digambar
Associate II
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