Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8242995
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 7, 20262026-06-07T21:21:27+00:00 2026-06-07T21:21:27+00:00

I am using STM32F103ZE I am not getting SPI data correctly. Master is transmitting

  • 0

I am using STM32F103ZE
I am not getting SPI data correctly.
Master is transmitting correctly.
But always read as zero where a non zero value has been sent.

Master config: (MSP430)

The master configuration is correct. (I tested it.)
Master Mode, MSB First, 8-bit SPI, 
Inactive state is high, SS grounded, 1 MHz clock, no dividers

Slave Config (STM32F103ZE)

    Using SPI2.
    SPI_InitStructure.SPI_Direction = SPI_Direction_1Line_Rx
    SPI_InitStructure.SPI_Mode = SPI_Mode_Slave
    SPI_InitStructure.SPI_DataSize = SPI_DataSize_8b
    SPI_InitStructure.SPI_CPOL = SPI_CPOL_High
    SPI_InitStructure.SPI_CPHA = SPI_CPHA_1Edge
    SPI_InitStructure.SPI_NSS = SPI_NSS_Soft
    SPI_InitStructure.SPI_BaudRatePrescaler = SPI_BaudRatePrescaler_2
    SPI_InitStructure.SPI_FirstBit = SPI_FirstBit_MSB
    SPI_InitStructure.SPI_CRCPolynomial = 7

Anybody have an ANSWER,

Thanks
Hari

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-07T21:21:29+00:00Added an answer on June 7, 2026 at 9:21 pm

    I know, the question is quite old. Still, since I have faced the same problem the last days, I’ll try to give an answer for future readers.

    The following code works on the STM32F407, which is used on the STM32 discovery board. What I can see from the datasheet, the SPI peripheral is the same as on the STM32F103, so
    I expect the code to run on the other microcontroller without modifications.

    #include "stm32f4xx.h"
    
    [... configure the pins SCK, MISO, MOSI and NSS ...]
    
    // Configure the SPI as: Slave, 8 bit data, clock high when idle, capture on 
    // 1st edge, baud rate prescaler 2, MSB first.
    SPI1->CR1 = SPI_CR1_CPOL;
    // No interrupts, no DMA and Motorola frame format.
    SPI1->CR2 = 0;
    // Enable the peripheral.
    SPI1->CR1 |= SPI_CR1_SPE;
    
    // Wait until some data has been sent to the slave and print it.
    while ((SPI1->SR & SPI_SR_RXNE) == 0);
    printf("Received: %d\n", SPI1->DR);
    

    Two things are different in this initialization procedure from the code posted in the question:

    1. Do not select bidirectional mode for ordinary SPI with the 3 lines SCK, MISO and MOSI.
      Both MISO and MOSI are unidirectional lines.

    2. I use hardware slave select management, i.e. the bit SSM is not set. This way, the
      SPI peripheral can automatically detect when the device has been asserted (the pin
      NSS goes low) and will
      store the MOSI bits in a shift register. When enough bits have been read (8 or
      16 depending on the selected data format),
      the flag RXNE is set in the status register and the transmitted value can be read
      from the register DR.

    Hope that helps.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Using the navigator.geolocation object in JavaScript. Trying to establish accurate ranges, but wondering exactly
Using Android TelephonyManager an application can obtain the state of data activity over the
Using Core Data, I have a fetch request to fetch the minimum of a
Using Yii, I want to delete all the rows that are not from today.
Using Xcode4.2.1, with a basic PhoneGap template based app. (I say template, but I
Is there any GPIO interrupt available for STM32F103ZE? I went through the datasheet but
Using the C# Facebook SDK 5.0.3 everything works fine whit the client.Get(/me). But when
Using TortoiseSVN against VisualSVN I delete a source file that I should not have
Using C# and System.Data.SqlClient, is there a way to retrieve a list of parameters
Using a CSS image sprite, I'm creating an 'interactive' image where hovering over certain

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.