cancel
Showing results for 
Search instead for 
Did you mean: 

STM32H723 SPI clock issue

carloV
Associate III

In my project I've set the SPI clock to 125MHz; with a SPI prescaler value=4 all works good, when I set it to 2 the SPI stops working and ther is no clock signal.

Any helps ?

 

Thank you

CarloV

1 ACCEPTED SOLUTION

Accepted Solutions
TDK
Super User

Ensure GPIO pin speed is set to VERY HIGH. This is not the default.

If you feel a post has answered your question, please click "Accept as Solution".

View solution in original post

11 REPLIES 11
LCE
Principal II

Check the datasheet - maybe 62.5 MHz is above the limit ?

carloV
Associate III

I configured the SPI1 as "Master Transmit only", the maximum clock frequency should be 133MHz; kernel clock=500MHz, SPI1 clock=125MHz, prescaler=2 ---> 62.5MHz

TDK
Super User

Ensure GPIO pin speed is set to VERY HIGH. This is not the default.

If you feel a post has answered your question, please click "Accept as Solution".
carloV
Associate III

Yes SCLK and MOSI are VERY HIGH...

TDK
Super User

Should work. It's possible that you aren't measuring it correctly, perhaps sample rate is insufficient. It's also possible changing this caused something else in the code to break and SPI commands no longer get executed. To address those:

How are you measuring it and what does "no clock signal" look like? How do you know the code is being executed?

Could also be something else wrong in the code but if you're only changing the prescaler, unlikely. The more info you provide the more likely someone is to spot the problem.

If you feel a post has answered your question, please click "Accept as Solution".
carloV
Associate III



<meta charset="UTF-8" />



 


Hi,if I set a prescaler=4 all works good...I measure the clock using an oscilloscope...


 


 


@TDK has totally valid points. If its custom hardware, as it sounds like, then I think you need to look carefully at electronic signals quality. If the slew rate is low (e.g. due to bad traces/wires) then raising clock frequency lowers the peak-to-peak amplitude. If you try to trigger oscilloscope on such signal at half the nominal voltage like it's done with digital signals, then it wont trigger.

You should share the oscilloscope images at prescaler 4 and 2. Oscilloscope shall have at least 50 MHz bandwidth (better if 100 MHz) and few hundred MHz sampling rate (better 1GHz). Use 1 MOhm input impedance. Trigger on falling CS with one channel and measure SCK on another.

These measurements should be done anyway to be sure there are no hardware issues to avoid banging head to the wall.

I'm sure the oscilloscope is working good, it is a digital oscilloscope with a 100MHz bandwidth, 2GSamp, compensated probe 10Mohm, no triggering problems...; when I set the prescaler to 2, something goes wrong also in the code, this is the routine where the code loops:

 

static HAL_StatusTypeDef SPI_WaitOnFlagUntilTimeout(const SPI_HandleTypeDef *hspi, uint32_t Flag, FlagStatus Status,

uint32_t Timeout, uint32_t Tickstart)

{

/* Wait until flag is set */

while ((__HAL_SPI_GET_FLAG(hspi, Flag) ? SET : RESET) == Status)

{

/* Check for the Timeout */

if ((((HAL_GetTick() - Tickstart) >= Timeout) && (Timeout != HAL_MAX_DELAY)) || (Timeout == 0U))

{

return HAL_TIMEOUT;

}

}

return HAL_OK;

}

 

I suppose that the reason may be the missing clock...

 

 

LCE
Principal II

You are absolutely sure you're using a 125 MHz capable peripheral?
I mean: which SPI block x?

And which H7 exactly?

Here's from the H723 datasheet, and the maximum clock depends on supply voltage and which SPI block (1..6) is used:

LCE_0-1767972534858.png

PS: using a 100 MHz scope for a 125 MHz signal is not really optimal... but you should see at least something (closer to a sine).