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 3432536
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 18, 20262026-05-18T07:27:41+00:00 2026-05-18T07:27:41+00:00

I have a custom board based on an ST Microelectronics STM32F103VE microcontroller, with a

  • 0

I have a custom board based on an ST Microelectronics STM32F103VE microcontroller, with a MiniSD card plugged over the microcontroller’s SDIO bus. The electrical connections were done exactly as found in the STM3210E-EVAL board schematics, checked and rechecked so I have strong confidence they are correct. Unfortunately I don’t have that eval board to test whether what I’m experiencing is a hardware problem, but it doesn’t seem so. For the tests below, I’m using a Kingston 2 GB MicroSD card (model MBLYG2/2GB) bought very recently (so it should comply with the newest SD card spec) with the supplied MicroSD to MiniSD adapter; haven’t tested with any other cards yet.

I’m following the SD card physical layer simplified spec to understand what’s going on. The code that I’m using is the example SDIO code that comes with ST Micro’s standard peripheral library for this microcontroller. It starts out by sending CMD0 (GO_IDLE_STATE), then CMD8 (SEND_IF_COND), and then ACMD41 (SD_SEND_OP_COND), which is done by sending a CMD55 (APP_CMD) followed by CMD41. The clock line is clocked at 400 kHz, and as part of my debugging efforts, I’ve added a delay of about 100 clock cycles between CMD0 and CMD8, as I’ve read somewhere that it was required, at least when operating in SPI mode. Other than the modifications mentioned below, the code is exactly the same as the example code.

When I first tried to run the example code, CMD55 had a problem which happened to be because the microcontroller was buffering the response to CMD8, but the sample code didn’t retrieve CMD8’s response, so when checking the response to CMD55, the code was actually looking at the response to CMD8 and was upset by that. I fixed this problem by clearing the CMDREND flag on the microcontroller’s SDIO peripheral before sending out CMD55, so when the code checked the response to CMD55, it no longer had CMD8’s response buffered.

The next problem, and the one I’m currently stuck at, is that in the response to CMD55, bit 23 of the card status field (COM_CRC_ERROR) is set, which indicates the CRC check of the previous command failed according to the spec. Although the microcontroller automatically calculates the CRC, I hooked up a logic analyzer to the circuit to verify it was correct. I’m using a web app (sorry, can’t link because I’m a new user, but just Google for “CRC ghsi” and it’s the first result) to verify the CRCs, using the polynomial x^7 + x^3 + 1 as per the spec. This is the logic analyzer output, formatted and commented by me:

// uC sends CMD0, CRC OK, no response:
01 000000 00000000000000000000000000000000 1001010 1
// uC sends CMD8, CRC OK, check byte = 0xAA:
01 001000 00000000000000000000000110101010 1000011 1
// SD card responds to CMD8, CRC OK, check byte echoed back = 0xAA:
00 001000 00000000000000000000000110101010 0001001 1
// uC sends CMD55, CRC OK:
01 110111 00000000000000000000000000000000 0110010 1
// SD card responds to CMD55, CRC OK, note card status bits 23, 8 and 5 set;
// bit 23 = COM_CRC_ERROR, bit 8 = READY_FOR_DATA and bit 5 = APP_CMD:
00 110111 00000000100000000000000100100000 0000100 1

Also note that if I attempt CMD55 a second time immediately after the exchange above, bit 23 is unset:

// uC sends CMD55, CRC OK:
01 110111 00000000000000000000000000000000 0110010 1
// SD card responds to CMD55, CRC OK, bits 8 and 5 still set but 23 not set:
00 110111 00000000000000000000000100100000 1000001 1

Note that I tried sending CMD8 twice before sending CMD55, but it made no difference, the first CMD55 always returns bit 23 set. I can reproduce this every time I try, so I don’t believe it’s an issue with glitches or noise. Considering the CRCs are calculated by the microcontroller itself, they look correct as seen by an external entity (the logic analyzer), and have been verified on the website I mentioned above, I don’t see how the card’s CRC check could be failing.

Is this somehow expected? Maybe I should wait a set number of clock cycles between each command (somewhere I read it should be 8 cycles, and I believe I’m respecting that)? Can I just send a second CMD55 if the first fails and be on my way, or will there be any negative consequences? Even if that fixes the problem, I’d very much like to know why the CRC check is failing, as I don’t think I’m doing anything wrong.

  • 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-05-18T07:27:42+00:00Added an answer on May 18, 2026 at 7:27 am

    I found the problem. After I had to modify the code to flush the buffer for the CMD8 response, so that CMD55 read the correct response, every test I made had the logic analyzer hooked up to the circuit. After removing the logic analyzer, the code started working — probably it was injecting noise into the lines. No delays were required, but just to follow the spec, I added a 74+ clock cycles delay before CMD0.

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

Sidebar

Related Questions

I have created a custom JButton class for representing spaces on a monopoly board.
I have an embedded board with a 32 Micro-controller, and an custom built OS,
I have created a custom UIView that I would like to use on multiple
Background I have a custom collection that is binded to the datagridview this.datagridview.DataSource =
Consider custom network protocol. This custom protocol could be used to control robotic peripherals
I have a web application that needs to be built using PHP/MySQL. The application
I found an odd situation at work and I'm trying to figure out where
I dont know if this questions is relevant here or superuser, but ask anyway.
I'm writing a HandConverter of a poker hand. This is my first project and
I am moving to C++ from Java and I am having a lot of

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.