cancel
Showing results for 
Search instead for 
Did you mean: 

Problems with clock prescalers and saleae on an STM32H563ZI nucleo board when using SPI

massimoperdigo
Associate III

Hello,

we are using the saleale logic 8 to read data transfer between an STM32 MCU and an IC through SPI (ADS8166 ADC).
The CLK frequency is 1.5 for the SPI configuration with a prescaler of 2 so at the end we have  CLK of 750 kHz. 
For some reason SOMETIMES we can't read the data properly through the MISO channel with this configuration, even though the saleale has a sample frequency of 50 Ms/s. The saleale configuration is correct and the MOSI signal is always read accordingly. The debugger always reads the correct values so the data being transfered is correct but the saleale reads it wrong. Find attached screenshots of the measurments.
Any idea of what could we be doing wrong?
should be reading 0xAA:

massimoperdigo_0-1706011612538.png

 

 

5 REPLIES 5

Probably arrow symbol on clock is edge used by sealae to read data value. But in signal you can see that transmited data use rising edge to set and falling edge to read. You have wrong SPI mode used on transmitter (STM32) and reciever (Sealae).

IMG_9567.png


this is my configuration, i think it is correct.

 

One of your configuration is not correct. If you need to read on rising edge, change configuration in MCU (CPHA). If you need to read on falling edge, change configuration in Sealae.

Im sure I have the right configuration since the ADC is configured to work as CPOL = 0 and CPHA = 0, like the MCU and the SALEAE (as you can see in the following images). 

massimoperdigo_0-1706017566674.png

massimoperdigo_1-1706017585162.png

massimoperdigo_3-1706017641564.png

 

 

 

Take a look at your trace from Sealae. You will see that data is set at rising edge and stable (to read) at falling edge. That corresponds to CPOL=0,CPHA=1. If you need CPOL=0, CPHA=0 (reading at rising edge), then you have to reconfigure MCU, because now it is obviously wrong. Don't trust too much to CubeMX... who knows what "1 edge" means ... does it mean "set data on 1st edge" or "read data on 1st edge" ? ;) Take a look at SPI->CFG2 on bits CPOL and CPHA if both are 0. I bet they are not and you simply misunderstood CubeMX naming ... because it is not clear.