1
\$\begingroup\$

I'm new in this forum, but I think this is the right forum to ask my question. I'm working on a project, where I need to store datas on an SD card. I use an STM32L443 microcontroller. The controller communicate with another device through UART communication, and save the datas to the SD card. The program works correctly with a no name SD card (I don't know the manufacturer, because I get it from smoebody). If I change the SD card to a 8GB Sony SD card, or to a Maxell 4GB SD card the controller doesn't recognize the card sometimes. Somtimes recognize, somtimes don't recognize. When I connect to the Debugger and go to debug mode, the program works fine and recognize the cards everytime. In this situation I don't debug the problem because the problem doesn't present in debug mode. If the program run free without debugger, and pull down the NRST pin manually to ground to restart the device, everytime recognize the cards. Can You help me? I think that the NRST pin influence it, but if this pin influence why don't influence with the no name SD card?

The project was generated form STM32CubeMx and the programming environment is System Workbench for STM32. I know that similar question exist in this forum, but he answers that I get there, isn't help for me.

Please help me.
Thank You for the answers,
Szabolcs

P.s. I tested with a buzzer that where fail the program. Inside of the SD_PowerON function exist a while loop. When the cards don't recognize this while loop run infinitelly and never go out from there.

/* Send ACMD41 SD_APP_OP_COND with Argument 0x80100000 */
while(validvoltage == 0)
{
  if(count++ == SDMMC_MAX_VOLT_TRIAL)
  {
    return HAL_SD_ERROR_INVALID_VOLTRANGE;
  }

  /* SEND CMD55 APP_CMD with RCA as 0 */
  errorstate = SDMMC_CmdAppCommand(hsd->Instance, 0);
  if(errorstate != HAL_SD_ERROR_NONE)
  {
    return HAL_SD_ERROR_UNSUPPORTED_FEATURE;
  }

  /* Send CMD41 */
  errorstate = SDMMC_CmdAppOperCommand(hsd->Instance, SDMMC_STD_CAPACITY);
  if(errorstate != HAL_SD_ERROR_NONE)
  {
    return HAL_SD_ERROR_UNSUPPORTED_FEATURE;
  }

  /* Get command response */
  response = SDMMC_GetResponse(hsd->Instance, SDMMC_RESP1);

  /* Get operating voltage*/
  validvoltage = (((response >> 31) == 1) ? 1 : 0);
}
\$\endgroup\$
  • 2
    \$\begingroup\$ Software not working without the debugger is a sure sign of race conditions or minimum delays not being respected. \$\endgroup\$ – Dmitry Grigoryev Aug 4 '17 at 9:33
  • \$\begingroup\$ Thank You for Your fast reply. Can You tell me, where do I begin the testing in this case? \$\endgroup\$ – Szabolcs Aug 4 '17 at 10:41
  • \$\begingroup\$ I tested with a buzzer that where fail the program. Inside of the SD_PowerON function exist a while loop when the cards don't recognize this while loop run infinitelly and never go out from there. \$\endgroup\$ – Szabolcs Aug 4 '17 at 11:05

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Browse other questions tagged or ask your own question.