Welcome to EDAboard.com

Welcome to our site! EDAboard.com is an international Electronic Discussion Forum focused on EDA software, circuits, schematics, books, theory, papers, asic, pld, 8051, DSP, Network, RF, Analog Design, PCB, Service Manuals... and a whole lot more! To participate you need to register. Registration is free. Click here to register now.

Register Log in

[SOLVED] Mmc_Fat_QuickFormat instruction not working in mikroC pro/Proteus

Status
Not open for further replies.

blacksnow

Junior Member level 2
Joined
Mar 1, 2010
Messages
20
Helped
1
Reputation
2
Reaction score
0
Trophy points
1,281
Location
India
Activity points
1,432
I am learning the PIC microcontroller and trying to simulate some of the project programs of the book “Advanced PIC18 Projects in C by Dogan Ibrahim”. Nowadays I am working on Interfacing of SD Card with PIC18f4520 (in proteus simulation only).
I copied the following code from the book to mikroC Pro for PIC Compiler. The Compilation/Creation of Hex file was successful but when I try to simulate using proteus the program goes into halt/hang state in proteus and the pin status of SD Card in proteus is also of grey color (Neither green nor red).

I connected the PIC18f4520 with SD Card in proteus. Created an image file with .mmc extension using WinImage software and provided the path of the image file to SD card’s properties in proteus.
Code:
char filename[] = "MYFILE55TXT";
unsigned char txt[] = "This is the added data...";
unsigned short character;
unsigned long file_size,i;
void main()
{
//
// Configure the serial port
//
Usart_Init(2400);
//
// Initialise the SPI bus
//
Spi_Init_Advanced(MASTER_OSC_DIV16,DATA_SAMPLE_MIDDLE,CLK_IDLE_LOW, LOW_2_HIGH);
//
// Initialise the SD card bus
//
while(Mmc_Init(&PORTC,2));
//
// Initialise the FAT file system
//
while(Mmc_Fat_Init(&PORTC,2));
//---------------------------------------------------The simulation works well till this line -----------------------------------------------------------
Mmc_Fat_QuickFormat(“AAA”));

// Create the file (if it doesn’t exist)
//
Mmc_Fat_Assign(&filename,0x80);
//
// Clear the file, start with new data
//
Mmc_Fat_Rewrite();
//
// Write data to the file
//
Mmc_Fat_Write("This is MYFILE.TXT.",19);
//
// Add more data to the end...
//
Mmc_Fat_Append();
Mmc_Fat_Write(txt,sizeof(txt));
//
// Now read the data and send to UART
//
Mmc_Fat_Reset(&file_size);
for(i=0; i<file_size; i++)
{
Mmc_Fat_Read(&character);
Usart_Write(character);
}
for(;;); // wait here forever
}
The proteus design works well till the fat initialization but when I add the quickformat function to the code the design does’nt do anything even it does not display any sent messages on uart (The file MYFILE.TXT is also not created in the image file when it is mounted).
The messages on uart are displayed successfully without the quickformat instruction.

Please provide me some solution or some suggestion. Also tell me if there are any other instructions required before the quickformat instruction.
 

blacksnow

Junior Member level 2
Joined
Mar 1, 2010
Messages
20
Helped
1
Reputation
2
Reaction score
0
Trophy points
1,281
Location
India
Activity points
1,432
yes. I tested the same program with the usb card reader as well, but without any luck.
 

JJA123

Newbie level 3
Joined
Dec 17, 2010
Messages
4
Helped
0
Reputation
0
Reaction score
0
Trophy points
1,281
Location
india
Activity points
1,292
send me the stimulated circuit of Proteus 6or 7
 

blacksnow

Junior Member level 2
Joined
Mar 1, 2010
Messages
20
Helped
1
Reputation
2
Reaction score
0
Trophy points
1,281
Location
India
Activity points
1,432
Ok i will send it to you tomorrow along with the hex file and c file.
 

blacksnow

Junior Member level 2
Joined
Mar 1, 2010
Messages
20
Helped
1
Reputation
2
Reaction score
0
Trophy points
1,281
Location
India
Activity points
1,432
I did it. The problem was with my proteus 7.6. I installed a newer version of it and then i was able to write to image file (mmc)from proteus.
 

JJA123

Newbie level 3
Joined
Dec 17, 2010
Messages
4
Helped
0
Reputation
0
Reaction score
0
Trophy points
1,281
Location
india
Activity points
1,292
ok cool if u hav any cool int ckt plz post
 

Status
Not open for further replies.
Toggle Sidebar

Part and Inventory Search

Welcome to EDABoard.com

Sponsor

Top