CCS C Software and Maintenance Offers
FAQFAQ   FAQForum Help   FAQOfficial CCS Support   SearchSearch  RegisterRegister 

ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 

CCS does not monitor this forum on a regular basis.

Please do not post bug reports on this forum. Send them to CCS Technical Support

PIC 18F2620 and SD-Card FAT
Goto page 1, 2  Next
 
Post new topic   Reply to topic    CCS Forum Index -> General CCS C Discussion
View previous topic :: View next topic  
Author Message
Prefekt



Joined: 21 Oct 2010
Posts: 85

View user's profile Send private message

PIC 18F2620 and SD-Card FAT
PostPosted: Thu Nov 11, 2010 11:18 am     Reply with quote

Hello,

I try the ex_fat.c program from the example directory.
But I cant do any operation on the sd card. I have a 1GB SD-Card and formated it with fat32. But every operation brings me an error.

I'm only change the include File for the pic...

Does anybody an Idea?

Best regards
Volker
andrewg



Joined: 17 Aug 2005
Posts: 316
Location: Perth, Western Australia

View user's profile Send private message Visit poster's website

PostPosted: Thu Nov 11, 2010 8:22 pm     Reply with quote

Have a look at these two threads and see if they help:

CCS FAT driver bugfix!
CCS SD/MMC driver MBR support
_________________
Andrew


Last edited by andrewg on Sat Nov 13, 2010 9:00 pm; edited 1 time in total
Prefekt



Joined: 21 Oct 2010
Posts: 85

View user's profile Send private message

PostPosted: Fri Nov 12, 2010 12:06 pm     Reply with quote

Hi,

I have made the changes and I can now connect the SD Card from the pic. But I can't see the created directories and files on the card, if I read this on my pc!
And if I make a directory for file on the pc I can't see this on the pic!

I can put the sd card of the pic and reset the pic. Then I put the card into the slot from pic and I found my directories and fiels again. But on Windows I can't see nothing. And the winhex is also found nothing? How can it be?

Best regards
Volker
andrewg



Joined: 17 Aug 2005
Posts: 316
Location: Perth, Western Australia

View user's profile Send private message Visit poster's website

PostPosted: Fri Nov 12, 2010 9:31 pm     Reply with quote

Have you got the FAT16/32 matched? You must compile the correct variant for the cards you're using.
_________________
Andrew
Prefekt



Joined: 21 Oct 2010
Posts: 85

View user's profile Send private message

PostPosted: Sat Nov 13, 2010 2:23 am     Reply with quote

Hi,

yes, the card is formatted with fat32 and in the source file I set #define fat32.
How I can see directories, where there a nothing on the card? Are this information stored in the eeprom from the pic?

Best regards
Volker
andrewg



Joined: 17 Aug 2005
Posts: 316
Location: Perth, Western Australia

View user's profile Send private message Visit poster's website

PostPosted: Sat Nov 13, 2010 3:50 am     Reply with quote

Have you looked at the ex_fat.c example file? That covers everything you would want to do with an SD card.
_________________
Andrew
Prefekt



Joined: 21 Oct 2010
Posts: 85

View user's profile Send private message

PostPosted: Sat Nov 13, 2010 4:11 am     Reply with quote

I use the ex_fat.c example.
It works good, after the changes you have posted.
I have formatted the card on a pc, but I can't see the fiels an directories on the card. If I create a directory on the card with pc I'cant see this on the PIC.

It seems that the pc and the pic use to different cards, but it's the same!

I need this for my datalogger *ahhhh*

Best regards
Volker
Prefekt



Joined: 21 Oct 2010
Posts: 85

View user's profile Send private message

PostPosted: Sat Nov 13, 2010 4:17 am     Reply with quote

Has anybody a working code with the driver files?
I don't know what's wrong, and don't know what I can do!

Thanks
Volker
andrewg



Joined: 17 Aug 2005
Posts: 316
Location: Perth, Western Australia

View user's profile Send private message Visit poster's website

PostPosted: Sat Nov 13, 2010 9:04 pm     Reply with quote

If you're sure it's otherwise working, then all I can think of is that the PC is accessing one partition and the PIC is accessing another. If you've put in my MBR support code (see link in post above) then try commenting out all but one of the mmcsd_check_part() function calls. Do that for each in turn to force the use of a specific partition.
_________________
Andrew
Prefekt



Joined: 21 Oct 2010
Posts: 85

View user's profile Send private message

PostPosted: Sun Nov 14, 2010 12:35 pm     Reply with quote

Hi Andrew,

Good idea with the test function. I will try it tomorrow and post the effect...

I have try it more often and on the pc I see only the files that I created on my pc and on the pic I see only the files, that I created with the pic.

Is it possible that the values are stored in the PIC memory??

Volker
Prefekt



Joined: 21 Oct 2010
Posts: 85

View user's profile Send private message

PostPosted: Mon Nov 15, 2010 2:08 pm     Reply with quote

Andrew,

the test has nothing, same as ever :-(

In the mmcsd.c file is this: #if USE_SW_ONLY
But the compiler say that it's unknown!!!


I found my directories, that I have generade with pic with the winhex on the position:
00074A50, 00074A80

The directory from the pc is on:
00400060

On the pic, I see the directorys from the pic only
On the pc, I see the directorys from the pc only

SD Card formated specs:
Bytes per Cluster: 4096
Bytes per Sektor: 512
Size: 997128704 Bytes
FAT: FAT32

Here are 3 pics....

the first is the boot sector from the card:
the second is the 'pc_data' directory on the card from the pc (i can't see it on the pic)
the third is the 'data001' directory on the card from pic (i can't see it on the pc)

Why the directory on different places.





Volker[/url]
andrewg



Joined: 17 Aug 2005
Posts: 316
Location: Perth, Western Australia

View user's profile Send private message Visit poster's website

PostPosted: Tue Nov 16, 2010 10:06 am     Reply with quote

Prefekt wrote:
In the mmcsd.c file is this: #if USE_SW_ONLY
But the compiler say that it's unknown!!!

You are expected to #define that to either 0 or 1. 1 for a software SPI, 0 for a hardware SPI.

As for the rest, your first picture shows a partition boot sector not a master boot record (MBR). My MBR code should be calculating g_mmcsdPartitionOffset as zero (no master boot record), so that's one thing to check.

All I can suggest after that is to work out yourself what the PIC should be reading off the SD card and confirm those values, i.e. after fat_init, do all the global variables contain the expected values?
_________________
Andrew
Prefekt



Joined: 21 Oct 2010
Posts: 85

View user's profile Send private message

PostPosted: Wed Nov 17, 2010 12:40 am     Reply with quote

Andrew,
For the USE_SW_ONLY, I'm wondering that the compiler not know this, it's in the original mmcsd.c file!

I have read at wikipedia, there is written, that the mbr is starts at 0x000 and the MRB signature is on 0x01FE ' 55' 'AA', this is on it. Where you see that is not the MRB? Sorry I'm new with the FAT File System :-)

I have checked my files, mmcsd.c and fat.c for your changes. And I use the ex_fat.c sample. What could happened? I go crazy!
Do you have as simple code to the your function?

Best regards
Volker
andrewg



Joined: 17 Aug 2005
Posts: 316
Location: Perth, Western Australia

View user's profile Send private message Visit poster's website

PostPosted: Wed Nov 17, 2010 8:48 am     Reply with quote

An MBR and partition boot record have the same signature at the same place (55 AA at 01FE). To tell the difference, you look at where the partition table should be and check the four entries there. That's what my MBR support code does. If you trace through my code, you'll see that the tests fail for all four possible partition table entries, and so the MMCSD code assumes the partition starts at address zero, which it does in your case, since the card is not partitioned.
_________________
Andrew
Prefekt



Joined: 21 Oct 2010
Posts: 85

View user's profile Send private message

PostPosted: Thu Nov 18, 2010 2:29 pm     Reply with quote

@andrewq
Ah I understand, the check function can't find the place where the partion table should be an so decide the function, It's not a MBR...

So how I create the MBR on the sd card? It was formatted with windows...




I have bought the driver from Andrew Smallridge, because I must finished the project. (www.brushelectronics.com) and it works perfect. The driver is very easy to use and there are samples to test it.

But now, I can search how the error ist and will post the results here.

Special thanks to andrewg ...


Regards
Volker
Display posts from previous:   
Post new topic   Reply to topic    CCS Forum Index -> General CCS C Discussion All times are GMT - 6 Hours
Goto page 1, 2  Next
Page 1 of 2

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum


Powered by phpBB © 2001, 2005 phpBB Group