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

mmcsd and fat libs of CCS don't work?
Goto page Previous  1, 2
 
Post new topic   Reply to topic    CCS Forum Index -> General CCS C Discussion
View previous topic :: View next topic  
Author Message
temtronic



Joined: 01 Jul 2010
Posts: 9106
Location: Greensville,Ontario

View user's profile Send private message

PostPosted: Fri Dec 16, 2011 1:10 pm     Reply with quote

1a) Get rid of all resistors except the 2 pullups on the sdcard. ADD correct level shifter( translator) IC .

1b) CCS code is good.

2) See 1a above . Use correct level shifter IC, unless you're good at selecting the correct transistors and bias resistors for the Vcc5, Vcc3,current demands,speed, etc.

3) You're right, it will NOT work. Simple elementary logic level stuff, as previously stated 3.3v from sdcard is NOT a logic one for the PIC. You MUST have at LEAST 4.0 volts(80% of Vdd if 5 volt PIC).

4a) This is NOT a software problem and cannot be fixed by using a 'driver' from another library( if using hw spi).Unless you design a custom driver using the adc pins.

4b) see 3) above. PIC is only seeing zeros never any ones !
tesla80



Joined: 23 May 2007
Posts: 81

View user's profile Send private message

PostPosted: Wed Dec 21, 2011 1:47 pm     Reply with quote

Guys thanks for all your suggestions, I resolved the HW problem as you said and it now receives data from the card.

Can anyone answer to my question at: http://www.ccsinfo.com/forum/viewtopic.php?p=155266#155266
PCM programmer



Joined: 06 Sep 2003
Posts: 21708

View user's profile Send private message

PostPosted: Wed Dec 21, 2011 2:37 pm     Reply with quote

As you have learned, most people that post in the Code Library forum
don't want to answer questions. Or they may not even be active on the
forum any more.

With regard to your question in the link, it looks like you want to reduce
the array size to only 64 elements (from previous size of 512). But then
you try to compile lines that access the array at index 0x1C6.
Then you get "subscript out of range" for sure, because the index 0x1C6
is way beyond the last element, which is 63 (0x3F in hex).
tesla80



Joined: 23 May 2007
Posts: 81

View user's profile Send private message

PostPosted: Wed Dec 21, 2011 2:50 pm     Reply with quote

PCM programmer wrote:
you want to reduce
the array size to only 64 elements (from previous size of 512).

Exactly, the code uses more RAM when it is 512.
But I think its not so easy to reduce that number to 64. I need someone who really understand that code, because everything in that code is related to 512 number. For example; in the read/write block functions there are cnt2 and cnt3 variables, they help to read/write 2x256=512 bytes from/to the card etc..

I actually have another problem;
I can create many files,
I can only write data to first 1-8 files,
I _can't_ write to 9-16 files
I can write to 17-24 files
I _can't_ write to 25-(25+8) files...
Something happens after every 8 files...



except these problems, the code is working good.
PCM programmer



Joined: 06 Sep 2003
Posts: 21708

View user's profile Send private message

PostPosted: Wed Dec 21, 2011 3:05 pm     Reply with quote

I don't know that much about it. A quick easy solution is just to buy
asmallri's FAT code. Our company bought his SD card tester code and it
works. We didn't try his FAT code yet, but other people have bought it
and say it works well. You can spend days on this problem, or weeks.
If speed of development is important, I suggest buying his code. His
company link is in his sigline.
tesla80



Joined: 23 May 2007
Posts: 81

View user's profile Send private message

PostPosted: Wed Dec 21, 2011 3:14 pm     Reply with quote

You are right for totally not working systems but I need only a little bug fix in that code. I need to create many files in the card but when I can't write to some of them its bad... I need to solve this.
Maybe the solution is in the write block function, if someone helps me we could have another bugfree code here as forum
asmallri



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

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

PostPosted: Wed Dec 21, 2011 5:42 pm     Reply with quote

tesla80 wrote:
PCM programmer wrote:
you want to reduce
the array size to only 64 elements (from previous size of 512).

Exactly, the code uses more RAM when it is 512.
But I think its not so easy to reduce that number to 64. I need someone who really understand that code, because everything in that code is related to 512 number.


Write operations on SD/MMC cards must be performed in 512 byte chunks with the CS continuously asserted. There are NO workarounds if you intend to use the FAT file system, this is because when a directory or FAT update needs to be made you need to update (write) the entire sector in a single operation. This means you need to read in the relevant sector, update the values in the buffer, then write out the entire sector.

Quote:
....except these problems, the code is working good.


So other that the fact it does not work, you are happy with the code :-)
_________________
Regards, Andrew

http://www.brushelectronics.com/software
Home of Ethernet, SD card and Encrypted Serial Bootloaders for PICs!!
temtronic



Joined: 01 Jul 2010
Posts: 9106
Location: Greensville,Ontario

View user's profile Send private message

PostPosted: Wed Dec 21, 2011 6:50 pm     Reply with quote

If you get really,really frustrated with SD card software you can always buy a Vinculum flashdrive module for $30 and not have to worry about the 'low level' aspects of file management.

It all depends on what your time is worth,when the project is due,amount of data storage, etc.

From a data management perspective,if you only want 64 bytes of data per file, just group 4 of your logical files into one physical file.

In the old days (late 70s) it was very common to have 3 ,85 byte 'records' stored into one 256 byte file. Very efficient use of the then very,very costly floppy disc space.The math to 'parse' the physical record into logical is trivial.Any TRS-80 gut will know what I'm talking about !

The bottom line you either have to pay with time or money.Time to either work out the solution or find using Google....money to buy either the product already made or have someone else do the work.
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
Page 2 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