Continue to Site

Welcome to EDAboard.com

Welcome to our site! EDAboard.com is an international Electronics 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.

MikroC & SD CARD & PIC18F4520

Status
Not open for further replies.
Does anyone know what's allocation size to set for mikroC to work ?
I have formatted into FAT using windows XP and allocation size default.


Linspire
 

The SD card must be formatted with FAT16, not FAT32, with the default allocation size. Formatting the SD with FAT16 is a requirement of the MikroC MMC Library.

BigDog
 

Yap I formatted my sd card into FAT (Windows XP) with default allocation.
When I formatted sd card, I choose option of FAT instead of FAT32.
Still having problem sd card detection.

Linspire

---------- Post added at 18:37 ---------- Previous post was at 17:03 ----------

I have make image clone directly from my SD card.
I did simulation ISIS 7, it's working properly.
Sighed.
Still having problem detection SD card.

Linspire
 

So weird...
When I tried mikroC user manual example code, it's not working properly.
However, I rewrite my code with following these coding:
Code:
  SPI1_Init_Advanced(_SPI_MASTER_OSC_DIV64, _SPI_DATA_SAMPLE_MIDDLE,_SPI_CLK_IDLE_LOW, _SPI_LOW_2_HIGH);
  while (Mmc_Init());
  Lcd_Out(1,1,"reintialized");
  Delay_ms(1000);
  Delay_ms(1000);
  // use fat16 quick format instead of init routine if a formatting is needed
  while(1) {

             if (!Mmc_Fat_Init()) {
             SPI1_Init_Advanced(_SPI_MASTER_OSC_DIV64, _SPI_DATA_SAMPLE_MIDDLE,_SPI_CLK_IDLE_LOW, _SPI_LOW_2_HIGH);
             ......
             ......
             ......
             break;        // WHEN YOU CREATE FILE, GET OUT OF INFINITE WHILE LOOP
                               }
            }

It's working properly on my hardware.
Why is like that ?
Anyone know how to explain it ?


Linspire
 

Can you post your code, so that one of us may look at it? How about a schematic of your design?

How are you interfacing the SD interface with the rest of the circuit? Both SD and MMC are 3.3V devices and therefore need a 3.3V supply and 3.3V I/O either by a level translator or resistor divider.

The following book has several examples of SD interfaces using MikroC:

Advanced PIC Microcontroller Projects in C: From USB to RTOS with the PIC 18F Series

BigDog

Hi Bigdog,
I have posted a very similar querry. Please check it out and suggest me a way out
https://www.edaboard.com/threads/282589/
Thanks in Advance, Regards :)
 

The below 2 functions should be called once and so they should be in the main() function but before the while(1) loop.

Code C - [expand]
1
2
if (!Mmc_Fat_Init()) {
             SPI1_Init_Advanced(_SPI_MASTER_OSC_DIV64, _SPI_DATA_SAMPLE_MIDDLE,_SPI_CLK_IDLE_LOW, _SPI_LOW_2_HIGH);

 

Status
Not open for further replies.

Part and Inventory Search

Welcome to EDABoard.com

Sponsor

Back
Top