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

MMC SD libraries - yap this topic again
Goto page Previous  1, 2, 3  Next
 
Post new topic   Reply to topic    CCS Forum Index -> General CCS C Discussion
View previous topic :: View next topic  
Author Message
PCM programmer



Joined: 06 Sep 2003
Posts: 21708

View user's profile Send private message

PostPosted: Tue Aug 12, 2014 11:00 am     Reply with quote

You're trying to create your own test program. I read some previous posts
where forum members say it does work. It occurred to me that they were
likely using the Ex_fat.c example to control the fat commands. So I did
that. It works.

I test this with compiler vs. 5.026. I did a clean install of the compiler.
The files don't have any of andrewg's fixes, or any changes.

First I edited Ex_fat.c to match my board, as shown below:
Code:

#include <18F4620.h>
//#include <18F67J60.h>  // *** Commented out
#device PASS_STRINGS = IN_RAM
#fuses NOWDT, HS, NOPROTECT
#use delay(clock=20M)  // *** Was 25 MHz


Actually, before that, I checked my hardware by running Brush Electronic's
SD Utils program. It said the SD card was activated OK. So I'm pretty
sure my hardware is working. I'm using a PNY brand, 2 GB SD card.
It's not an SDHC card.

I started TeraTerm and ran the Ex_fat program. The Ex_fat.c file has
a list of commands near the start of the file.

1. First I did a "makefile test.txt" command but it froze. It didn't display
a result code. So then I reset and re-started the Ex_fat program.

2. Then I did a Dir command (as shown below). It showed no files.

3. Then I decided it would be a good idea to format the card.
2 GB is 2097152 KB. So I used that as a parameter. It said OK.

4. Then I made test.txt and it said OK.

5. Then I did a Dir and it showed test.txt was there.

Code:

/> dir
--/--

/> format 2097152
Formatting media (size=2097152): OK

/> make test.txt
Making file '/test.txt': OK

/> dir
--/--
test.txt

/>
electr0dave



Joined: 10 Aug 2014
Posts: 24

View user's profile Send private message

PostPosted: Tue Aug 12, 2014 12:04 pm     Reply with quote

Oh God ...

I will test the sample program again .... but I still do not understand the reason for all this mess ...

You have pull-up in SD_DO?

I will do everything as you say!
I'm currently making a new installation of my version of CCS (5.025).
Ttelmah



Joined: 11 Mar 2010
Posts: 19378

View user's profile Send private message

PostPosted: Tue Aug 12, 2014 2:16 pm     Reply with quote

As a comment, one thing that might apply, is lack of good smoothing. The SD card draws significant current spikes, and required good smoothing close to it. This is the sort of thing that PCM_programmer would do 'automatically'....

On the pull-ups, it is worth quoting from the SD card spec's:

"All hosts shall provide pull-up resistors on all data lines DAT[3:0] as described in section 6 of the SD Physical Specification Version 1.01."

D3, can be 'got away with', since this has an internal 50K resistor in the card, that is enabled by default. The 'shall' says it all.

The point is that any line set as an input, can float into the 'transition' area, and this results in high consumption, and erratic behaviour...
electr0dave



Joined: 10 Aug 2014
Posts: 24

View user's profile Send private message

PostPosted: Tue Aug 12, 2014 2:21 pm     Reply with quote

In fact it works like you said ....

But I tried to do something else .... I did reset the circuit and "dir" again so I can see if the file was still there.
The answer is no :(.


image hosting sites
PCM programmer



Joined: 06 Sep 2003
Posts: 21708

View user's profile Send private message

PostPosted: Tue Aug 12, 2014 2:23 pm     Reply with quote

I'm at a different location for most of today. I'm not at hardware bench.
I can't work on it now. Maybe someone else can help.
electr0dave



Joined: 10 Aug 2014
Posts: 24

View user's profile Send private message

PostPosted: Tue Aug 12, 2014 2:41 pm     Reply with quote

OK, I added something written to the file and apparently works even after reset.

PCM programmer your help was invaluable!
Obviously, I also thank all those who came here to answer!

I will continue to put here some questions that may arise, but now finally I have something to "work".

Wink
Ttelmah



Joined: 11 Mar 2010
Posts: 19378

View user's profile Send private message

PostPosted: Tue Aug 12, 2014 3:22 pm     Reply with quote

Now, for the 'fixes'.
There are two sets. The generic ones linked to (which are worth doing), and the ones for MBR support:

<http://www.ccsinfo.com/forum/viewtopic.php?t=43402&highlight=mbr>

This fix would remove the need to reformat the card.

There are to fundamentally different ways of laying out the data on the card. The first is the 'floppy' layout, and the second the 'hd' layout. The CCS drivers as standard only support the former. This fix adds support for the latter.
PCM programmer



Joined: 06 Sep 2003
Posts: 21708

View user's profile Send private message

PostPosted: Tue Aug 12, 2014 3:40 pm     Reply with quote

There is also this fix posted by Douglas Kennedy:
http://www.ccsinfo.com/forum/viewtopic.php?t=51163&start=12
electr0dave



Joined: 10 Aug 2014
Posts: 24

View user's profile Send private message

PostPosted: Wed Aug 13, 2014 7:03 am     Reply with quote

I'm making some changes.

1st - fat.c file in line 221
Code:
#define FAT16
// # define FAT32


2nd - gives error while compiling

3rd - change line 1342 to
Code:
    if (write_fat (Next_Free_Clust, 0xFFFF) == EOF)


In this case, EOF is returned, giving error to initialize FAT, when the card is not inserted.

Without the card inserted:


free screen capture

I know that the next change can not be "the right one", but it seems to work ...

1 - I put in line 2601:
Code:
   ec += mmcsd_init();
   if(ec != GOODEC)
      return EOF;


2 - below the last "# endif" I commented:
Code:
   //if(ec != GOODEC)
   //   return EOF;


The image below shows two tests: the first without the card (error message) and the second with the card (showing the prompt).


images upload
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 Previous  1, 2, 3  Next
Page 2 of 3

 
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