[En-Nut-Discussion] PHAT + mmc on Ethernut 1.3g
Joe Pepe
jpepe3 at comcast.net
Sat Nov 17 19:25:39 CET 2007
Hello.
Per Eklund has working code to read/write an MMC card using version
4.1.9-rc7 (Nut/OS assumed).
I'm trying to read / write to an SD card using Nut/OS version 4.1.1.99 but
I've read on an ethernut web page (
http://www.ethernut.de/en/documents/phat.html )
that version 4.2.1 or higher is required.
I presently can write and read a file on the card but subsequent to that my
program crashes.
Some of my code follows:
u_short *cReaderName = NULL;
int rrr, iResult;
int saved_memory_amount;
MMC_stream = fopen("PHAT0:/simple.txt", "w"); // Open file in
write mode
fprintf(MMC_stream, "JCP: -- First line in this file\n"); // Write one
line of text to file
fclose(MMC_stream);
MMC_stream = fopen("PHAT0:/simple.txt", "rb");
cReaderName = NutHeapAlloc(ftell(MMC_stream)/1000);
while (1)
{
if ( (iResult = fgetc(MMC_stream)) == -1)
{
break;
}
else
{
if ( (iResult == 0x0D) || (iResult == 0x0A) || (iResult == 0) )
{
break;
}
else
{
cReaderName[rrr++] = iResult;
}
}
}
I get through this code once, then, on second call, program crashes.
I've spent many hours on this and trying to upgrade to Nut/OS 4.4.0 using
the
configurator, both with no success.
Can PHAT work on 4.1.9.99 ?
Is Per Eklund's code available anywhere ?
Any other insight is much appreciated.
Thanks
Joe Pepe
MSL Electronics
More information about the En-Nut-Discussion
mailing list