Sd card module problems

Discussion in 'Programmer's Corner' started by Drk_alien, Mar 6, 2013.

Thread Status:
Not open for further replies.
  1. Drk_alien

    Thread Starter New Member

    Feb 28, 2013
    This is my 2'nd thread and the first one was succesfuly closed.I have great hopes with this one...
    For 3 days i'm struggleing to get done a connection between pic18f4550 and an Panasonic Sd card (16 mb).I have bought from ebay an sd card module for this.

    The problem is that my pic is dies when i call any function from mmc library, excepting SPI1_Init_Advanced() or Spi1_Init().
    I have connected the pic to sd card module in this way:
    This is strange becouse i can't even debug it.
    The purpose is to write a txt file with some content in it.And for that i have used the code from this example:

    What can be the problem?...My compiler? libraryes?:confused:..If u have another simple code in order to do this i will be happy do test it.Thanks

    Below is my "work":
    Last edited: Mar 6, 2013
  2. tshuck

    Well-Known Member

    Oct 18, 2012
    It looks like your MOSI and MISO are swapped...RB0 is SDI, while RC7 is SDO, meaning that the SPI output is SDO....since the PIC is the master, this should be MOSI....

    EDIT: You image doesn't show up, Yahoo says the link is forbidden....
  3. tshuck

    Well-Known Member

    Oct 18, 2012
    Also, you do have the connections specified, right? As per the link you gave...

    Code ( (Unknown Language)):
    1. sfr sbit Mmc_Chip_Select at RB2_bit;
    2. sfr sbit Mmc_Chip_Select_Direction at TRISB2_bit;
  4. Drk_alien

    Thread Starter New Member

    Feb 28, 2013
    I have tried with the mosi and miso swaped but no effect.
    I don't understand why my pic dies.It just would not work properly?no?
    Also i have tried with
    sfr sbit Mmc_Chip_Select at LATB2_bit;
    sfr sbit Mmc_Chip_Select_Direction at TRISB2_bit;
    sfr sbit Mmc_Chip_Select at LATC0_bit;
    sfr sbit Mmc_Chip_Select_Direction at TRISC0_bit;

    Image must be visble now.
  5. tshuck

    Well-Known Member

    Oct 18, 2012
    You have decoupling caps? I don't see them in your picture(which, yes, is now visible...)

    EDIT: I see a small .1uF? cap, you may want to add a 100uF cap in there also...
  6. tshuck

    Well-Known Member

    Oct 18, 2012
    Do you have MCLR enabled? I don't see a pull-up resistor...
  7. Drk_alien

    Thread Starter New Member

    Feb 28, 2013
    My board is not on MCRL, i don't use a button for that.I reset my pic from PicKit2 software.
    My 10k resistor is on the bottom of the board.
  8. ErnieM

    AAC Fanatic!

    Apr 24, 2011
    Damn... I've got these things to work but if the library code doesn't work... well, then I have little idea what to try next. Do you have an in circuit debugger, and if so does it trace thru the library code line by line? That may give a clue where it "dies."

    Dies... that's a curious word with imprecise meaning. Do you mean you need to reset the PIC? I don't work with that compiler or libraries, but does it need heap or some memory defined/reserved? I've had failures due to that.

    Does the SD card work in another computer?

    Does it still die if you remove the SD card and run the code? The could mean a hardware line short or such.
  9. Drk_alien

    Thread Starter New Member

    Feb 28, 2013
    This microC compiller is craked, in order to let me compile this code that requires more than 2k.
    The microcontroller doesn't start when i call a function from this library, even is at the end of the code...
  10. Drk_alien

    Thread Starter New Member

    Feb 28, 2013
    Hi guys...
    I'm pretty good right now with this.
    My problem was that my cracked program didn't generate the hex corectly.
    The card works properly, i can create files, directories...etc.

    Now i'm facing another problem. I can't read the sd card to see the files...
    My code for this is the following and the result is 0:
    Any ideea what might be?
    I have files and direcories on my card.

    Thanks for your answers. :)

    Code ( (Unknown Language)):
    2. typedef struct
    3. {
    4.     unsigned char name[13];         // directory name
    5.     unsigned char attrib;           // directory attribute
    6.     unsigned char ctime[6];         // create time and date
    7.     unsigned char mtime[6];         // modification time and date
    8.     unsigned long size;             // directory size
    9.     unsigned int  first;            // directory start cluster
    10.     unsigned long sect;             // directory entry sector
    11.     unsigned int  entry;            // derectory entry number in the entry sector
    12. } DIR;
    13.   DIR varDir;
    14. void function_xxx()
    15. {
    16.   if(Mmc_Fat_ReadDir(&varDir)==1)
    17.   {
    18.      putstr(;
    19.       putstr("1");
    20.   }
    21.   else if(Mmc_Fat_ReadDir(&varDir)==0)
    22.   {
    23.     putstr("0");
    24.   }
    25.   else
    26.   {
    27.     putstr("-1");
    28.   }
    29. }//end function
  11. THE_RB

    AAC Fanatic!

    Feb 11, 2008
    I don't think people should help you try to debug code you are making on a "cracked" compiler.

    If you want a free C compiler there are some out there. You don't have to steal one.
    Brian Griffin likes this.
  12. tshuck

    Well-Known Member

    Oct 18, 2012
    Agreed. In addition to legal ramifications, there is no way to determine if the compiler is actually working like it should, as you've noted in not generating the .hex file properly(the function of a compiler like this)...
  13. Brian Griffin

    Active Member

    May 17, 2013
    The answer is no. There is no support, and support is refused for cracked programs. Either get a paid version, or use Microchip's MPLAB XC8/16.

    You do know that the MPLAB XC8/16/32 has support for very, very good libraries for SDCard? You can find "Microchip Application Libraries" in google. Plus, the free versions are still usable with these, provided if you have a bigger microcontroller.
  14. bertus


    Apr 5, 2008

    We can not support you with the use of a cracked version of copyrighted software:

Thread Status:
Not open for further replies.