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 support@ccsinfo.com

Another MMC Over SPI FAT32 code!
Goto page Previous  1, 2, 3, 4, 5, 6  Next
 
Post new topic   Reply to topic    CCS Forum Index -> Code Library
View previous topic :: View next topic  
Author Message
PCM programmer



Joined: 06 Sep 2003
Posts: 20366

View user's profile Send private message

PostPosted: Sun Jan 11, 2009 5:41 pm     Reply with quote

Quote:
char * msg;

strcpy(msg,"Written!");

'msg' is just an uninitialized pointer here. It needs to point to a RAM
array. Or better, declare it as an array. Example:
Code:
char msg[20];

That's big enough to hold your sample message of "Written!".
ShellTox



Joined: 25 Jul 2007
Posts: 16

View user's profile Send private message

PostPosted: Mon Jan 12, 2009 8:51 am     Reply with quote

Hello

Thank you for your answer PCM programmer Smile


I've followed your suggestion but the EVENTS.LOG file remains unchanged.

Does anyone has any suggestion about this problem?


I'm using the 3.3V zener and 820R at the MMC card. The 100k pull-up (to 3.3V) is also there. For Vcc of the card I've used an LD29080PT33R (LDO 3.3V). I've used also a 100nF ceramic capacitor beside the vcc and gnd of the card.
As I've said, the code runs until the "END Writing" printf. I'm starting to think the problem comes from the card. Does anyone tried this code with a 512MB card? Now it's very hard to buy these kind of cards, specially with low storage capacities.

What kind of changes are needed to use a SD card instead of my MMC card?
ShellTox



Joined: 25 Jul 2007
Posts: 16

View user's profile Send private message

PostPosted: Wed Jan 14, 2009 7:36 pm     Reply with quote

Is there anybody out there?


I know this is an old thread but I don't understand why the users who got the problem resolved don't share their solutions.

This is a forum, a place to share ideas. Read the entire thread and in most cases you see a user saying he has a problem. Then some more experienced users kindly try to sugest solutions. Then what happens? Posts like:

Yay I've solved the problem! Cya

This doesn't help anybody... Sad
PCM programmer



Joined: 06 Sep 2003
Posts: 20366

View user's profile Send private message

PostPosted: Fri Jan 16, 2009 1:55 pm     Reply with quote

My advice is first make it work with an MMC card, since that's what the
original project code was for. This will prove if your hardware is correct.
Then when that works, try it with an SD card.
asmallri



Joined: 12 Aug 2004
Posts: 1554
Location: Perth, Australia

View user's profile Send private message Send e-mail Visit poster's website

PostPosted: Fri Jan 16, 2009 5:15 pm     Reply with quote

BLL wrote:
Some routines increase the clock speed after switching the card into SPI mode. If the clock is too fast you will have problems! I need div64 on a 2620 using a 20MHz oscillator in HS mode. Any less and it doesn't work.


This may be the case with this specific driver (I do not know) but it is not generally correct - meaning that an 18F2620 running at 40MHz will successfully work with an MMC card with div4 setting on the setup SPI.

Perhaps you have a hardware implementation problem loading the bus or not pulling up the DO from the card.
_________________
Regards, Andrew

http://www.brushelectronics.com/index.php?page=software
Home of Ethernet, SD card and Encrypted Serial Bootloaders for PICs!!
ShellTox



Joined: 25 Jul 2007
Posts: 16

View user's profile Send private message

PostPosted: Tue Jan 20, 2009 12:01 pm     Reply with quote

Thank you for the replies Surprised


I'll try to change the clock div on the SPI setup.
manish12



Joined: 18 Jan 2009
Posts: 15

View user's profile Send private message

PostPosted: Thu Feb 26, 2009 11:39 am     Reply with quote

I try all of the code with all possible changes but, not success.

Will any body help me out, I think this is just chat about nothing at last !!!

Than enjoy chat ,,, until anyone get dear to say I have complete solution.


Crying or Very sad
asmallri



Joined: 12 Aug 2004
Posts: 1554
Location: Perth, Australia

View user's profile Send private message Send e-mail Visit poster's website

PostPosted: Thu Feb 26, 2009 6:38 pm     Reply with quote

If you give up then check out my site. I sell the source for the file system that works for FAT12, FAT16 and FAT32 that works with MMC, SD and SDHC cards.
_________________
Regards, Andrew

http://www.brushelectronics.com/index.php?page=software
Home of Ethernet, SD card and Encrypted Serial Bootloaders for PICs!!
manish12



Joined: 18 Jan 2009
Posts: 15

View user's profile Send private message

PostPosted: Fri Feb 27, 2009 10:34 am     Reply with quote

asmallri wrote:
If you give up then check out my site. I sell the source for the file system that works for FAT12, FAT16 and FAT32 that works with MMC, SD and SDHC cards.


we need help , not a way to buy it, we want to make ourselves.
and if you not interested to help , plz dont make a comment like this ^^
andrewg



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

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

PostPosted: Fri Feb 27, 2009 9:48 pm     Reply with quote

How rude! You bought some PIC chips. You bought a compiler. Why not buy some library code too?
_________________
Andrew
CLK.Tech



Joined: 30 Apr 2009
Posts: 5

View user's profile Send private message

PostPosted: Wed May 20, 2009 6:04 am     Reply with quote

Hi guys!

I'm trying to port this code to a PIC24F but I've some problems: I put some 'printf' to see where the code is executing but it crashed the system and reset the PIC. So I think it doesn't work in PIC24.

Did anybody port the code to a PIC24? Can anybody help me in this?

C U L4T3R!
SuperMesna



Joined: 06 Sep 2009
Posts: 1

View user's profile Send private message

PostPosted: Sun Sep 06, 2009 2:09 am     Reply with quote

hi

I'm using your code on a 18F452 but it doesn't work correctly yet.
I always get the message:
Quote:

1st file in list was probably a dir

I tried a few cards, all are formated Fat32 and on each there are a
couple of files (no directories).

I tried to print out the information in initFAT().

For a 256MB SD I got:
Quote:

Bytes Per Sector: 512
Sectors per Cluster: 4
Reserved: 32
Fatcopies: 2
Max Root Entries: 0
hSectors: 0
Descriptor: 248
hold Sectors per Fat: 0
hSectors per Track: 63
Number of Heads: 255
Number of Hidden: 107
Number of Sectors: 474645
hSectors per Fat: 924
hFlags: 0
hFat32 Version: 0
RootStartCluster: 2


For a 512MB SD:
Quote:

Bytes Per Sector: 512
Sectors per Cluster: 16
Reserved: 6
Fatcopies: 2
Max Root Entries: 512
hSectors: 0
Descriptor: 248
hold Sectors per Fat: 245
hSectors per Track: 63
Number of Heads: 255
Number of Hidden: 233
Number of Sectors: 1002263
hSectors per Fat: 2116616448
hFlags: 57172
hFat32 Version: 19980
RootStartCluster: 1095639119


And another 512MB:
Quote:

Bytes Per Sector: 512
Sectors per Cluster: 8
Reserved: 34
Fatcopies: 2
Max Root Entries: 0
hSectors: 0
Descriptor: 248
hold Sectors per Fat: 0
hSectors per Track: 63
Number of Heads: 255
Number of Hidden: 233
Number of Sectors: 1000215
hSectors per Fat: 975
hFlags: 0
hFat32 Version: 0
RootStartCluster: 2

The information is the same every time I try to read the card.
Do you have any suggestions?

Peter
tesla80



Joined: 23 May 2007
Posts: 81

View user's profile Send private message

PostPosted: Fri Dec 16, 2011 7:28 am     Reply with quote

===================
Mr Moderator:
This questions is very different than my other question related to mmcsd lib of CCS! Please don't delete this.
===================


Hello.

I got problem with this code.

My program enters into infinite loop at FindDirEntry function when I call fopen function.
I put some lcd_putc lines in the function and my lcd is filled by 'b' chars. So it cannot leave the do-while loop.

I see "abbbbbbbbbbbbbbbbbbbbbbbb...." on my lcd

I have pull-up resistors on DO(7) and CS(1) pins.

SD -- PIC
DO->SDI
SCLK->SCL
DI->SDO
CS->CS

Code:
// Function: Finds a file
char FindDirEntry(char *fname,char f)
{
   DIR *pDir;
   int16 i;
   char filename[16];
   int32 nextcluster,actsector;

   if (f > (MAXFILES-1))
   {
      return FALSE;
   }
   lcd_putc('a');
   gFAT32Vars.gFirstEmptyDirEntry = 0xFF;
   gFAT32Vars.gFirstDirEntryCluster = 0x0FFFFFFF;
   do
   {
      pDir = (DIR*)(gFiles[f].IOpuffer);
      for (i=0;i<DIRENTRYS_PER_SECTOR;i++)
      {
         if ((pDir->sName[0] == 0xE5 || pDir->sName[0] == 0) && gFAT32Vars.gFirstEmptyDirEntry == 0xFF) // store first free
         {
            gFAT32Vars.gFirstEmptyDirEntry = i;
            gFAT32Vars.gFirstDirEntryCluster = gFiles[f].CurrentCluster;
         }
         if (pDir->sName[0] == 0)
         {
            return FALSE;
         }
         ConvertFilename(pDir,filename);
         if (!strcmp(filename,fname))
         {
            memcpy(&(gFiles[f].DirEntry),pDir,32);
            gFiles[f].dirIdx = i;
            gFAT32Vars.gDirEntryIdx = i;
            return TRUE;
         }
         pDir++;
      }
      lcd_putc('b');
      nextcluster = GetNextCluster(gFiles[f].CurrentCluster);
      if (nextcluster != 0x0FFFFFFF && nextcluster != 0)
      {
         actsector = nextcluster + gFAT32Vars.gFirstDataSector;
         ReadSector(actsector,gFiles[f].IOpuffer);
         gFAT32Vars.gDirEntrySector = actsector;
         gFiles[f].dirSector = actsector;
         gFiles[f].CurrentCluster = nextcluster;
      }
   } while (nextcluster != 0x0FFFFFFF && nextcluster != 0);
   lcd_putc('c');
   return FALSE;
}



What could be the problem?
tesla80



Joined: 23 May 2007
Posts: 81

View user's profile Send private message

PostPosted: Sun Dec 18, 2011 2:29 pm     Reply with quote

Hi,

I found the problem.

I made the same circuit on proteus and made a .mmc image file using WinImage program. So it doesn't enter infinite loop in that function. It has some problems but it works.
I formatted the image with these parameters:


On real hardware, it enters into infinite loop because I can not format the card as required.

Do you know a detailed formatter tool to help me?

Another important question:
If I cannot format it as required, what about if I change "512"s (for ex:IOpuffer[512];) to 16348 ?
tesla80



Joined: 23 May 2007
Posts: 81

View user's profile Send private message

PostPosted: Tue Dec 20, 2011 1:43 pm     Reply with quote

Please help me about that
Display posts from previous:   
Post new topic   Reply to topic    CCS Forum Index -> Code Library All times are GMT - 6 Hours
Goto page Previous  1, 2, 3, 4, 5, 6  Next
Page 5 of 6

 
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