Linker error using sd card and pic18f458

Thread Starter

Bushratariq

Joined May 15, 2014
13
hey everyone!

I am trying to write/read to SD card using PIC18f458. I am using microchip software and all the libraries that supports writing to sd cards.
When i compile i get the error

'.code_FSIo_O' can not fit the section. Section '.code_FSIo_O' length = 0x0000e84c

Can anyone please guide me? What is this error about?
 

ErnieM

Joined Apr 24, 2011
8,377
It's about memory size. The way you have it now you are asking for more memory then exists. It may be the case where you have memory, just not in one segment as your code is expecting but SD apps take a huge amount of RAM and ROM.

I cannot get more specific without seeing and playing with the entire project.
 

Thread Starter

Bushratariq

Joined May 15, 2014
13
Thanks everyone. i changed my pic to 64k memory(i.e. pic18f4680) and was able to compile the code.

Now i am facing another problem. 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. the card sends some data on its output pin in response which makes me think the card has initialized. the other commands are then to write to the sd card. when i connect sd card to computer , the card is empty.
I dont know whats wrong? can anyone please help???
My code is as follows

Rich (BB code):
void main(void)
{
FSFILE *MyFile;
unsigned char txt[ ]="This is a TEXT message";
//
// Initialize the SD card routines
//
FSInit( );
//
// 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);
}
 
Last edited by a moderator:

Thread Starter

Bushratariq

Joined May 15, 2014
13
thank you for your reply. i am working on this for the first time.i have no idea how to check return values. Can you please guide me??
Also i formatted the card using laptop and then i connected it to the circuit.
 

Thread Starter

Bushratariq

Joined May 15, 2014
13
thank you everyone. 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

Rich (BB code):
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.
 
Last edited by a moderator:

ErnieM

Joined Apr 24, 2011
8,377
While it is probably acceptable to FSInit the card twice in a row, take the first one out anyway just to rule it out.

After that it is time to post your schematic.

Pictures of the build may also be useful.
 

Thread Starter

Bushratariq

Joined May 15, 2014
13
I am posting my code and diagram. Please have a look at it. I am still not able to initialize the sd card. And i have absolutely no idea why.
 

Attachments

Thread Starter

Bushratariq

Joined May 15, 2014
13
hey everyone. please help me. i have posted my code and schematics. please have a look at it. and help me what am doing wrong. why my card is not initializing????
 
Top