Hi Mark,
I did some further investigation on that issue and it seems - as you said - that the MCI_CLK_PwrSave is not responsible for the
trouble.
I have made some progress and meanwhile can write files to the SD card.
The tests I made so far were limited to small files, so no further errors arised.
Now, to store nearly 32MB of data to a SD card, I am running a loop that puts 512 bytes per loop cycle into the file:
while(j) { // j here is 62765
Sd.Anz = 512;
result = utWriteFile(&Sd.utFile, Sd.ptSrc, Sd.Anz);
if(result != UTFAT_SUCCESS) { // Fehler
ErrorPrint("File write error: ", -1); printf("%x %s", result,Sd.ptWrFileName);
}
SendMsgU0(" %x", k-j); // to monitor how many loops are done finally
// some results: 0x5fE, 0x60fE,0x269E, 0xE8DE
j -= 1;
Sd.ptSrc += Sd.Anz;
}
The programme still hangs in function _fnGetSector() at
while (!(MCIStatus & DataEnd)) { } // wait until the DMA has completed the transfer to the destination buffer
but this time lots of write operations were succesful.
(The contents of location 0xe008c034 (MCIStatus) remains at 0x200,
i.e. StartBitErr - Start bit not detected on all data signals in wide bus mode.)
The clock already has been reduced from 18 to 9MHz as I remembered your comment regarding 18MHz.
Also the 2 delay times in function _fnGetSector() have been increased temporarily.
The test was done in debug mode and as a release.
I might try reduce the clock to a value beneath 9MHz but that would slow down the whole process and I can't imagine that this would solve the problem.
Perhaps it would be best to have a time-out loop and try to rewrite the last memory block.
But when I do that, re-initialize the SD card and try to open the last file, utOpenFile() returns a UTFAT_DISK_READ_ERROR.
Does anybody have a better suggestion? One that eliminates the reason for that fault?
Thanks!
Martin