problem with SD card reader

General discussion on mikroC.
Post Reply
Author
Message
vegcina
Posts: 1
Joined: 06 Aug 2011 02:03

problem with SD card reader

#1 Post by vegcina » 06 Aug 2011 02:13

I'm using PIC18F2550 on an easypic4 development board. I need to collect some data and store it on an SD card. I have the expansion for the easypic4 that has a MMC/SD card reader. I just can't get it to work. When I initialize the Mmc libraries or whatever it is that I initialize (you can see in the code at the end of the message), I just can't get a returned response from it that it recognizes the SD card. I've connected the easypic4 card reader expansion as it is said in the microchip datasheet. Here is a cut-out of the datasheet that explains the way to connect it:

19.3 SPI Mode
The SPI mode allows 8 bits of data to be synchronously
transmitted and received simultaneously. All four
modes of the SPI are supported. To accomplish
communication, typically three pins are used:
• Serial Data Out (SDO) – RC7/RX/DT/SDO
• Serial Data In (SDI) – RB0/AN12/INT0/FLT0/SDI/SDA
• Serial Clock (SCK) – RB1/AN10/INT1/SCK/SCL
Additionally, a fourth pin may be used when in a Slave
mode of operation:
• Slave Select (SS) – RA5/AN4/SS/HLVDIN/C2OUT
Figure 19-1 shows the block diagram of the MSSP
module when operating in SPI mode.


I've connected it in the exact same way except that I found on the internet that I also have to connect the "chip select pin" to the easypic so I've connected it to the RC6 pin. Oh, and here's my code that i used to test if the microchip recognizes the SD card:



void main() {
TRISA = 0;
PORTA = 0x0F; //00001111

Spi_Init_Advanced(MASTER_OSC_DIV64, DATA_SAMPLE_MIDDLE, CLK_IDLE_LOW, LOW_2_HIGH);
delay_ms(500);

PORTA = Mmc_Init(&PORTC, 6);
}

Inace ja sam nas :D nego sam vec iskuco pitanje na microchip-u pa me mrzelo opet da kucam... Nemojte mi zameriti :D

User avatar
filip
mikroElektronika team
Posts: 11874
Joined: 25 Jan 2008 09:56

Re: problem with SD card reader

#2 Post by filip » 08 Aug 2011 12:01

Hi,

Have you correctly set the oscillator bits ?
It can be tricky to do that for 18f2550, so I suggest you that you do it using the datasheet.

Also, you should disable comparators and analog inputs.
Bear in mind that the maximal SD card capacity is 2GB for FAT16 and that it must be properly formatted before you use it.

Regards,
Filip.

Post Reply

Return to “mikroC General”