cancel
Showing results for 
Search instead for 
Did you mean: 

Why my STM32 Nucleo 303RE board could not generate the correct SPI SCLK correctly with SPI mode 3?

HLu.11
Associate II

I am using a Nucleo 303RE discovery board to try the SPI interface setting with STM CUBEMX, the setting is as below:

  1. SPI peed set: 4M/s
  2. SPI mode: 3
  3. Use  HAL_SPI_Transmit API to send data

Problem: the SCLK clock shape is strange. The clock always has some extra pulse which makes the data sending is wrong. But if set the SPI mode is 0, there is no problem. But my project must use SPI mode 3. May I know what is the root cause? I have tried SPI1,2, 3. all have the same problem

0693W00000KaAwMQAV.png

5 REPLIES 5
TDK
Guru

Probably external noise on the line. What does an analog capture look like?

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

0693W00000KaBB7QAN.pngIs this the graphic you would like to check? Thanks for your help.

TDK
Guru

Yes, that's the capture, but it doesn't look like the analog bandwidth is sufficient to ascertain much here.

It's more likely to be external interference than anything internal to the STM32. The clock is steady except for the one glitch. Are these long jumper wires? Could be picking up spikes due to interference. You said you're testing multiple SPIs, which makes me think it could be a nucleo board or something with long leads that you're changing around.

Does the chip you're interfacing with experience problems consistent with this error? What chip are you interfacing with?

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

Thanks for your reply. I have tried on several Nucleo 303 RE boards and one F303K8 board. All have the same problem. The measurement is quite simple, there is no other board connected with it.0693W00000KaBEVQA3.jpg 

> SPI peed set: 4M/s

Where's your ground connection?

You can't handle megahertz clocks with long dangling wires.

JW