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

Problem related with "ex_mmcsd.c"

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



Joined: 03 Aug 2010
Posts: 26

View user's profile Send private message

Problem related with "ex_mmcsd.c"
PostPosted: Thu Dec 09, 2010 12:53 am     Reply with quote

I tried to work this example(ex_mmcsd.c).But I couldn't succeed to work.Could you show me an example connection to work this example, correctly?And I also post my connection between PIC and SD card:

I wrote the following codes;
Code:

#include <18F452.h>
#fuses NOWDT, HS, NOPROTECT
#use delay(clock=20000000)

#use rs232(baud=9600, UART1, errors)

#include <stdlib.h> // for atoi32

//meda library, a compatable media library is required for FAT.
#use fast_io(c)
#define MMCSD_PIN_SCL     PIN_C3 //o
#define MMCSD_PIN_SDI     PIN_C4 //i
#define MMCSD_PIN_SDO     PIN_C5 //o
#define MMCSD_PIN_SELECT  PIN_C2 //o
#include <mmcsd.c>

#include <input.c>

void main(void)
{
   BYTE value, cmd;
   int32 address;

   printf("\r\n\nex_mmcsd.c\r\n\n");
   
   if (mmcsd_init())
   {
      printf("Could not init the MMC/SD!!!!");
      while(TRUE);
   }
   
   do {
      do {
         printf("\r\nRead or Write: ");
         cmd=getc();
         cmd=toupper(cmd);
         putc(cmd);
      } while ( (cmd!='R') && (cmd!='W') );

      printf("\n\rLocation: ");

      address = gethex();
      address = (address<<8)+gethex();

      if(cmd=='R')
      { 
         mmcsd_read_byte(address, &value);
         printf("\r\nValue: %X\r\n", value);
      }

      if(cmd=='W') {
         printf("\r\nNew value: ");
         value = gethex();
         printf("\n\r");
         mmcsd_write_byte(address, value);
         mmcsd_flush_buffer();
      }
   } while (TRUE);   
}

Thanks.
Elysion



Joined: 03 Aug 2010
Posts: 26

View user's profile Send private message

PostPosted: Thu Dec 09, 2010 11:16 am     Reply with quote

Does this example program(ex_mmcsd.c) work only CCSC's development kit?
andrewg



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

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

PostPosted: Thu Dec 09, 2010 9:36 pm     Reply with quote

First, you're going to need to buffer SPI-MISO. The SD card will output 3.3V as a logic high, but the PIC requires 0.7VDD (3.5V @ 5V VCC) minimum as a logic high - see the data sheet. I've always used 3.3V PICs. You'll need to add a 5V logic gate with a suitably low input threshold.

Second, the CCS supplied MMCSD and FAT drivers have some issues. I've posted some threads on the library forum that might be relevant:

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



Joined: 03 Aug 2010
Posts: 26

View user's profile Send private message

PostPosted: Fri Dec 10, 2010 1:18 am     Reply with quote

I couldn't see anyone who works with "ex_mmcsd.c" correctly. Everyone says another example or another way.
PCM programmer



Joined: 06 Sep 2003
Posts: 21708

View user's profile Send private message

PostPosted: Fri Dec 10, 2010 1:22 pm     Reply with quote

Quote:
I couldn't see anyone who works with "ex_mmcsd.c" correctly

What is your compiler version ?

Are you testing this in hardware or in Proteus ?
Elysion



Joined: 03 Aug 2010
Posts: 26

View user's profile Send private message

PostPosted: Sat Dec 11, 2010 12:27 am     Reply with quote

My compiler version is 4.108. And I tested this program in Proteus and hardware. But I couldn't get any results from both of them.
Elysion



Joined: 03 Aug 2010
Posts: 26

View user's profile Send private message

PostPosted: Mon Dec 13, 2010 12:54 am     Reply with quote

Are my circuit and program true for this operation?If it is not,What should I do?
PCM programmer



Joined: 06 Sep 2003
Posts: 21708

View user's profile Send private message

PostPosted: Mon Dec 13, 2010 1:16 am     Reply with quote

I sent you a PM saying that I am still working on it. You should go to
your forum member 'Profile' page and enable this feature:
Quote:
Pop up window on new Private Message

Assuming that your browser allows pop-up windows, then you will
see any new PMs. I don't actually want to help you in PMs. I'd rather
do it here. I sent you a status PM to be nice.

Just to say what was in the PM: I tested it with vs. 4.108 on Sunday
afternoon (today) and I could not initially make it work. I will try again
over the next few days. I am using a Microchip MMC/SD "Pictail" board
with a PNY 2GB SD card for testing. This is connected to a PicDem2-Plus
board.

With regard to your circuit, it assumes that you are using software SPI.
That's because you don't have a 3v to 5v level translator chip or circuit
on the Dout pin of the SD card. The hardware SPI module in the PIC
requires 5v CMOS input levels. The 3v CMOS levels coming out of the
SD card will not work.

However, in the mmcsd.c driver file, it has a #use spi() statement and it
doesn't specify FORCE_HW. I've looked at the .LST file and it is in fact
using software SPI. So your circuit should be OK.

I have to look at the problem some more. I don't know what the problem
is yet.
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