Quantcast
Channel: MEL PICBASIC Forum
Viewing all articles
Browse latest Browse all 4796

SD card does not initialize

$
0
0
i am running a simple code that is supposed to create a txt file on sd card and write a line in it. My code starts from initializing command. i checked the return value. and the card does not initialize. what do i do now??? what can be the possible reasons for this???
please help.
Just for information i am using 8gb sd card. if it has anything to do with it. My code now is as follows
My code is as follows

i checked the return value. and yes the card does not initialize. what do i do now??? what can be the possible reasons for this???
please help.
Just for information i am using 8gb sd card. if it has anything to do with it. My code now is as follows
My code is as follows

void delay (unsigned int k)
for (i=0;i<=k;i++)
{
;
}
void main(void)
{
FSFILE *MyFile;
unsigned char txt[ ]="This is a TEXT message";
TRISB=0;
//
// Initialize the SD card routines
//
FSInit( );
if (FSInit()!=TRUE)
{PORTB=0xFF;
delay(10000);
PORTB=0x0;
delay(10000);
}
//
// Create a new file called MESSAGE.TXT
//
MyFile = FSfopenpgm("MESSAGE.TXT", "w+");
//
// Write message to the file
//
FSfwrite(txt, 1, 22, MyFile);
// Close the file
//
FSfclose(MyFile);
while(1);
}

When i run the code, the portb leds blink. which means the sd card does not initialize.
Attached Files

Viewing all articles
Browse latest Browse all 4796

Latest Images

Trending Articles



Latest Images