Skip to main content
Associate
February 24, 2025
Question

STM32F302: SPI data register not changing on write for certain modes

  • February 24, 2025
  • 1 reply
  • 495 views

Hi,
While using the SPI2 for transmitting a data in STM32F302R8, the transmitting data reflects in the DATA register only in the CPOL = 0(Low) and CPHA = 0(1st edge). In the other modes (CPOL and CPHA) the data is not reflecting in the DATA register.

My configurations:

Mode: Full-Duplex Master

Basic Parameters:
Frame Format: Motorola
Data Size: 8 Bits
First Bit: MSB first

Clock Parameters:
Prescaler (for Baud Rate):2
Baud Rate: 16.0 MBits/s
Clock Polarity (CPOL): High
Clock Phase (CPHA): 2 Edge

Advanced Parameters
CRC Calculation: Disabled
NSS Signal Type: Output Hardware (I tried for both Output Hardware and NSS signal type: Disable)

What might be problem with my configurations?

Here are my observations:

#

CPOL

CPHA

Status in DATA register

Mode 1

Low

Edge 1

Data reflected correctly

Mode 2

Low

Edge 2

Wrong data reflected

Mode 3

High

Edge 1

No data reflected

Mode 4

High

Edge 2

No data reflected

Also, it is not mentioned in the errata either.

Has anyone faced this? Kindly help me with this.

Best regards,

Sanjay

1 reply

KDJEM.1
Technical Moderator
March 6, 2025

Hello @Sanjay_Periyasamy and welcome to the Community,

 

Make sure that the CPOL and CPHA settings are correctly applied while the SPI is disabled.

Did you get a Hardfault or error_Handler?

 

Thank you.

Kaouthar

To give better visibility on the answered topics, please click on Accept as Solution on the reply which solved your issue or answered your question.
Associate
March 11, 2025

Hi @KDJEM.1 

Thanks for the response.

Actually, I have checked CPHA and CPOL bits in the corresponding and those bits were set correctly.

And also, I didn't get any Hardfault error.

MAIN ISSUE

The transferring data alone doesn't reflect in the data register for the Mode 3 and 4.