2020-09-24 03:32 AM
Hi All,
I am using SD card store something log on H743 with mbed. But I encounter a problem which will poll the strange status "HAL_SD_CARD_RECEIVING".
I can initial without any issue. Also can write a shot address and read. But when I write a continuous data for 1MB, it will fail at random address. Please check below:
test_addr=0;
HAL_SD_WriteBlocks(&hsd2, aTxBuffer, test_addr, 1,2000);
if( polling() )//polling state until HAL_SD_CARD_TRANSFER
record_fail();//pass to write
test_addr+=512;
HAL_SD_WriteBlocks(&hsd2, aTxBuffer, test_addr, 1,2000);
if( polling() )//polling state until HAL_SD_CARD_TRANSFER
record_fail();//pass to write
test_addr+=512;
HAL_SD_WriteBlocks(&hsd2, aTxBuffer, test_addr, 1,2000);
if( polling() )//polling state until HAL_SD_CARD_TRANSFER
record_fail();//pass to write
test_addr+=512;
HAL_SD_WriteBlocks(&hsd2, aTxBuffer, test_addr, 1,2000);
if( polling() )//polling state until HAL_SD_CARD_TRANSFER
record_fail(); // <----------fail to write, return HAL_SD_CARD_RECEIVING
test_addr+=512;
HAL_SD_WriteBlocks(&hsd2, aTxBuffer, test_addr, 1,2000);
if( polling() )//polling state until HAL_SD_CARD_TRANSFER
record_fail(); // <----------fail to write, return HAL_SD_CARD_RECEIVING
The fail address is random. I don't know why cause the issue happen. Does anyone have idea?
Tery
2020-09-29 05:20 PM
I resolved the issue by decrease clock rate from 50M to 20M.
//peripheral 200M
From hsd2.Init.ClockDiv = 2;
to hsd2.Init.ClockDiv = 5;