It is currently 20 Nov 2018 19:20

All times are UTC + 1 hour




Post new topic Reply to topic  [ 4 posts ] 
Author Message
PostPosted: 31 Aug 2013 05:24 
Offline

Joined: 31 Aug 2013 05:09
Posts: 2
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);

}


Attachments:
SDcard.rar [39.82 KiB]
Downloaded 407 times
Top
 Profile  
 
PostPosted: 02 Sep 2013 12:15 
Offline
User avatar

Joined: 18 Apr 2013 08:11
Posts: 2986
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


Top
 Profile  
 
PostPosted: 04 Sep 2013 12:18 
Offline

Joined: 22 Aug 2011 07:13
Posts: 219
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.


Top
 Profile  
 
PostPosted: 07 Oct 2013 13:05 
Offline

Joined: 08 May 2013 18:31
Posts: 627
Location: Bangalore
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.


Attachments:
New folder.rar [20.2 KiB]
Downloaded 515 times
sdcard.png
sdcard.png [ 40.4 KiB | Viewed 3378 times ]

_________________
[HW:] EasyPIC v7, mikroProg PIC, AVR, STM32, PSoC, Tiva, 8051
[SW:] mikroC PRO PIC, dsPIC, PIC32, AVR, ARM, 8051
mikroBasic PRO PIC, dsPIC, PIC32, AVR, ARM, 8051
mikroPascal PRO PIC, dsPIC, PIC32, AVR, ARM, 8051
Visual GLCD, Visual TFT
Top
 Profile  
 
Display posts from previous:  Sort by  
Post new topic Reply to topic  [ 4 posts ] 

All times are UTC + 1 hour


Who is online

Users browsing this forum: No registered users and 2 guests


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot post attachments in this forum

Search for:
Jump to: