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

SD card not working on CCS Dev board

 
Post new topic   Reply to topic    CCS Forum Index -> General CCS C Discussion
View previous topic :: View next topic  
Author Message
eskimobob



Joined: 07 Feb 2009
Posts: 40

View user's profile Send private message

SD card not working on CCS Dev board
PostPosted: Sat Feb 14, 2009 5:00 pm     Reply with quote

I am experimenting with the CCS 3.3V Embedded Ethernet dev board and everything was going fine until I tried out the Webserver2 example which uses an SD card for HTML page storage.

I have tried the HEX file that was supplied with the examples and also tried compiling myself but neither work. When I debug the code, I find that there is some problem with the SD multimedia card access. The code calls "fat_init();" which is in fat_pic.c:

Snippet from fat_pic.c
Code:

   if(mmc_init() != MMC_EC_OK)
      return EOF;
   // start filling up variables
   ec += mmc_read_block(11, 2, &Bytes_Per_Sector);
   ec += mmc_read_block(13, 1, &Sectors_Per_Cluster);


It initialises fine and then it reads Bytes_Per_sector which returns code MMC_EC_OK (0x00) which is fine.
When it tries to read Sectors_Per_Cluster, it returns MMC_EC_SET_READ_BLOCKSIZE_FAIL (0x04) which is bad.

I've tried two SD cards (32MB and 64MB, both freshly formatted on WinXP to FAT).

Any suggestions gratefully received Confused
eskimobob



Joined: 07 Feb 2009
Posts: 40

View user's profile Send private message

PostPosted: Thu Feb 19, 2009 2:00 pm     Reply with quote

I've managed to make some limited progress on this:

1) MMC cards do not work with the TCP-IP examples, only SD cards! I have not found any mention of this in the examples although the excercise book says "for use with a SD card". It would be useful if CCS clearly stated that the examples do not work with MMC cards if that is the case.

2) SD cards formatted to FAT16 on WindowsXP or Windows Vista do not work.

3) SD cards formatted using the CCS code (compiled with #define FAT16) do not work.

4) SD cards formatted using the CCS code (compiled with #define FAT32) DO work.

It does not seem possible on Windows XP or Vista to format an SD card as FAT32 if it has previously been formatted as FAT16 therefore the only way to get this working is to write a test program which uses the FAT_pic.c and FAT_spi.c code to format an SD card as FAT32.

Once formatted as FAT32, the SD card can be accessed in Windows so Windows can be used to copy the required files to the card.

It ought to be possible to FTP the files to the card while it is in the dev board since the Webserver2 example includes FTP capability however I have tried this and it appears that there must be a bug in either the FTP or FAT code because the file that is created on the card is corrupt when viewed on a Windows machine - the FTPed file cannot be read by Windows.

Since the Webserver2 example can happily read files from the card using FAT, it would seem likely that the bug will be in the FTP code but I have not investigated further yet.

I usually find the CCS examples to be very good but because of the number of bugs I am finding, I am starting to feel a bit like a Guinea Pig with the TCP-IP examples and stack Crying or Very sad
Guest








PostPosted: Fri Feb 20, 2009 8:33 am     Reply with quote

I had this from CCS when i emailed about bugs in the Ethernet board examples.

Quote:
we are aware that the SMTP driver has a few flaws. We are in the middle up updating the TCP/IP stack and drivers, we may have something in a week or two. In that time please e-mail me again and see what are status is.


Fair enough, except this was June 2008, all follow up emails about it were never replied to and there have been no updates either.

Jim
eskimobob



Joined: 07 Feb 2009
Posts: 40

View user's profile Send private message

PostPosted: Fri Feb 20, 2009 8:40 am     Reply with quote

Anonymous wrote:
Fair enough, except this was June 2008, all follow up emails about it were never replied to and there have been no updates either.


Hi Jim,

That's not good to hear Sad - but at least I am not alone Rolling Eyes
Have you had any experience with the Microchip Stack?
asmallri



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

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

PostPosted: Fri Feb 20, 2009 6:42 pm     Reply with quote

eskimobob wrote:
It does not seem possible on Windows XP or Vista to format an SD card as FAT32 if it has previously been formatted as FAT16 ...
e

This is not correct. XP and Vista will happily format a FAT16 card to FAT32 and visa versa. I do this all the time when testing my software. What you are more likely seeing is the driver you are using is not correctly interpreting the boot sector information and as a consequence operates on the wrong area of the card. This would give the impression of operating correctly from the cards perspective, creating and writing files, but the PC would not be able to find the files.

You might like to check out my drivers - they work with MMC, SD, and SDHC cards.
_________________
Regards, Andrew

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



Joined: 07 Feb 2009
Posts: 40

View user's profile Send private message

PostPosted: Sat Feb 21, 2009 2:03 am     Reply with quote

asmallri wrote:
This is not correct. XP and Vista will happily format a FAT16 card to FAT32 and visa versa. I do this all the time when testing my software.


Hi Andrew,

Can you clarify your comment for me. Do you mean the driver I am using on the PC is a problem or the SD card driver on the PIC (which is the CCS driver) is a problem?

If I take a MMC or SD card and put it in my USB connected card reader attached to my WinXP laptop, I can read and write files to the card however when I try to format it, I do not get the FAT32 option - see screenshot image below:



You can see there is no FAT32 option in the combo-box. Is there a way I can force WinXP to allow me to format this card as FAT32?

If I put a card in my card reader which is already formatted to FAT32, WinXP will happily let me reformat to FAT32 or FAT16 (both FAT32 and FAT then appear in the combo-box).
asmallri



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

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

PostPosted: Sat Feb 21, 2009 8:03 am     Reply with quote

You are only using a card with 30MB capacity. This is why Windows is not you the option to format it to FAT32.

FAT32 should be a last resort - it performs much slower than FAT16 on a PIC.

The driver bug I am referring to is one in your PIC driver software.
_________________
Regards, Andrew

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



Joined: 07 Feb 2009
Posts: 40

View user's profile Send private message

PostPosted: Sat Feb 21, 2009 8:35 am     Reply with quote

asmallri wrote:
You are only using a card with 30MB capacity. This is why Windows is not you the option to format it to FAT32.

FAT32 should be a last resort - it performs much slower than FAT16 on a PIC.

The driver bug I am referring to is one in your PIC driver software.


Ah, got it now Rolling Eyes - should have realised Wink
I will see if I can get the CCS FAT16 code working.
Thanks Cool
Jovem
Guest







fat+webserver2
PostPosted: Sun Jun 07, 2009 9:08 am     Reply with quote

hi

I have the example of Webserver2 working only a SD 128 MB, now I want switch the card but don't work.

I have formatted (XP and Vista) in FAT32 and the sector at 512 or 1024 and don't.

Someone have an idea what can be?
Display posts from previous:   
Post new topic   Reply to topic    CCS Forum Index -> General CCS C Discussion All times are GMT - 6 Hours
Page 1 of 1

 
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