Sd card module problems

Status
Not open for further replies.

Thread Starter

Drk_alien

Joined Feb 28, 2013
14
Hello,
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:
CS->RB2.
MOSI->RB0,
SCK->RB1,
MISO->RC7.
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: http://www.mikroe.com/download/eng/documents/compilers/mikroc/pro/pic/help/mmc_library.htm

What can be the problem?...My compiler?...my 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:

tshuck

Joined Oct 18, 2012
3,534
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....
 

tshuck

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

Ex:
Rich (BB code):
sfr sbit Mmc_Chip_Select at RB2_bit;
sfr sbit Mmc_Chip_Select_Direction at TRISB2_bit;
 

Thread Starter

Drk_alien

Joined Feb 28, 2013
14
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;
AND
sfr sbit Mmc_Chip_Select at LATC0_bit;
sfr sbit Mmc_Chip_Select_Direction at TRISC0_bit;

Image must be visble now.
 

tshuck

Joined Oct 18, 2012
3,534
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...
 

Thread Starter

Drk_alien

Joined Feb 28, 2013
14
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.
 

ErnieM

Joined Apr 24, 2011
8,377
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.
 

Thread Starter

Drk_alien

Joined Feb 28, 2013
14
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...
 

Thread Starter

Drk_alien

Joined Feb 28, 2013
14
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. :)

Rich (BB code):
typedef struct
{
    unsigned char name[13];         // directory name
    unsigned char attrib;           // directory attribute
    unsigned char ctime[6];         // create time and date
    unsigned char mtime[6];         // modification time and date
    unsigned long size;             // directory size
    unsigned int  first;            // directory start cluster
    unsigned long sect;             // directory entry sector
    unsigned int  entry;            // derectory entry number in the entry sector
} DIR;
  DIR varDir;
void function_xxx()
{
  if(Mmc_Fat_ReadDir(&varDir)==1)
  {
     putstr(varDir.name);
      putstr("1");
  }
  else if(Mmc_Fat_ReadDir(&varDir)==0)
  {
    putstr("0");
  }
  else
  {
    putstr("-1");
  }
}//end function
 

tshuck

Joined Oct 18, 2012
3,534
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.
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)...
 

Brian Griffin

Joined May 17, 2013
64
My problem was that my cracked program didn't generate the hex corectly.
The card works properly, i can create files, directories...etc.
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.
 

bertus

Joined Apr 5, 2008
22,270
Hello,

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

3. Copyrighted material. When referencing copyrighted material, please provide the relevant credit. In some cases, an intellectual property owner may require they give you permission before you can reprint or reuse their work. In most cases, a link to the original source is acceptable, if applicable.

Please do not make requests for, or post links to, material that otherwise contravenes the conditions of the original or subsequent author's copyright. All instances of such requests will be met firstly with a warning, and secondly with a ban. If you are in doubt raise the issue with a Moderator or Administrator.
Bertus
 
Status
Not open for further replies.
Top