Mmc_Init() failed in proteus
Posted: 31 Aug 2013 05:24
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);
}
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);
}