Page 1 of 1

Mmc_Init() failed in proteus

Posted: 31 Aug 2013 05:24
by magicboy_267
I"m working on a simple sd card project using mikroc's mmc library.
It will read CID register and display on Virtual terminal.
but mmc_init() doesn't work.
Anyone can help me?
I use pic18f452 with osc=20MHz.
MY schematic, hex file and mmc image file are included.
This is my code:

sbit Mmc_Chip_Select at LATC2_bit;
sbit Mmc_Chip_Select_Direction at TRISC2_bit;

char *text="SD CARD CID REGISTER";
void newline()
{
while (UART1_Tx_Idle()!=1){};
UART1_Write(0x0D);
while (UART1_Tx_Idle()!=1){};
UART1_Write(0x0A);
}
void main()
{
char message[16];
unsigned int error;
UART1_Init(9600);
delay_ms(100);
while (UART1_Tx_Idle()!=1){};
UART1_Write_Text(text);
newline();
SPI1_Init_Advanced(_SPI_MASTER_OSC_DIV64, _SPI_DATA_SAMPLE_MIDDLE, _SPI_CLK_IDLE_LOW, _SPI_LOW_2_HIGH);
error= Mmc_Init();
if (error) UART1_Write_Text("failed");
else UART1_Write_Text("success");

SPI1_Init_Advanced(_SPI_MASTER_OSC_DIV4, _SPI_DATA_SAMPLE_MIDDLE, _SPI_CLK_IDLE_LOW, _SPI_LOW_2_HIGH);
Mmc_Read_Cid(message);
UART1_Write_Text(message);

}

Re: Mmc_Init() failed in proteus

Posted: 02 Sep 2013 12:15
by marina.petrovic
Hi,

Did you try your project on real hardware or only in Proteus?
We usually recommend to our users to try their projects on real hardware.

Please, make sure that your card is properly formatted.
MMC/SD card has to be formatted to FAT16 file system.

Please, can you try MMC example from our compiler to see whether you have the same problem with that example:
...\mikroC PRO for PIC\Examples\Extra Boards\MMC\MMC Fat16

I can't see the schematic or MMC image file from the folder that you posted.

Best regards,
Marina

Re: Mmc_Init() failed in proteus

Posted: 04 Sep 2013 12:18
by borris
Proteus works fine with MikroC and the FAT Libraries. The issues are filesystems that Proteus works with on the host. My solution was writing a small routine that allowed me to call FAT32_Format first. That gave me an image file that could be used on other projects.

Re: Mmc_Init() failed in proteus

Posted: 07 Oct 2013 13:05
by jayanthd
What do you mean by not working. What should happen according to you code? I see there is a txt file inside the image file (.mmc file created using WinImage). The text inside the file is "This is File 1"

Do you want to write data received through UART to text file in the image file?

I have done SD card project using mikroC Compilers and it works fine in hardware and also Proteus. In Proteus you should not use the pullup resistors on the SPI lines with SD card.

To open .mmc file you have to rename it to .ima file and open it in WinImage.