Continue to Site

Welcome to our site!

Electro Tech is an online community (with over 170,000 members) who enjoy talking about and building electronic circuits, projects and gadgets. To participate you need to register. Registration is free. Click here to register now.

  • Welcome to our site! Electro Tech is an online community (with over 170,000 members) who enjoy talking about and building electronic circuits, projects and gadgets. To participate you need to register. Registration is free. Click here to register now.

mikroC lib troubble

Status
Not open for further replies.

Kryten

New Member
Hi anybody here that can help me with some code made in mikroC compiler?
Im using this compiler becase of its MMC FAT16 lib..

But its not working (at least not for me:( )
 
Hi anybody here that can help me with some code made in mikroC compiler?
Im using this compiler becase of its MMC FAT16 lib..

But its not working (at least not for me:( )

I might be able to help you ... I have v8.0 and I managed to use fat16 library ...
The important note about it thoe is
1. you have to format the MMC/SD card on the PC (the format routine actually does not format the card, but just clear fat table)
2. it is fat16 library *only* meaning if you for e.g. use 32MB MMC card it will *NOT* work, because it is formated using fat12 (I spent 2 days on this until I figured it out and tried 1G card)

If you are trying with the "small" card like I did (fat12) you can write "raw data" to card (sectors) and then use some raw read sw on PC to read the data ...
 
No im using a 1G (SD)card but i cant seem to get anything on it.

I have tried to implement the quick format but with no luck (i will keep trying)
And using the help file have only confused me (well a bit cos its using portb in code and portc on the schematic example)
 
I have tried to implement the quick format but with no luck (i will keep trying)
And using the help file have only confused me (well a bit cos its using portb in code and portc on the schematic example)

you have to format the SD card on PC ... (preferably on windows)... the quick format from the library cannot format the card that is not "preformated" already... the quick format from the lib just erase all files...

have you tried the example ...\Examples\EasyPic4\extra_examples\MMC\Mmc_Fat16

what uC are you using? If IIRC mikroC lib uses hw SPI to talk with the mmc card, most of uC's I used have SPI on port C ... The software SPI might not be fast enough to talk with the card...
 
Im using a 18F4550
How to determin if its SW or HW spi?

Edit:
Yes i have formatted on a XP machine
 
Last edited:
Well I have made a PCB that is purposbuilt for my application.
Im using the SPI pins (RB 0,1 and 4 (Using RB4 CSSPP as chip select) and RC7) I might have to change my CS pin to RA5
 
Last edited:
the mmc_fat_init() just takes parameter what pin you want to use for
CS ... the other 3 pins are HW spi and for 18F452 they are:

RC3/SCK/SCL -> (spi sck) -> SCK pin on MMC
RC4/SDI/SDA -> (spi data in) -> Dout pin on MMC
RC5/SDO -> (spi data out ) -> Din pin on MMC

now, the library use always SCK/SDI/SDO so as you use pic18f4550 then
you need to connect the MMC to

RB1/SCK/... spi clock
RB0/SDI/... - spi data in
RC7/RX/DT/SDO - spi data out

the "chip select" is passed to mmc_fat_init, so you can use any pin for that

I have just tried your project locally and it works but I had to put the 18F452 in, as my MMC board is idc10 connector to easypic4 so I was not able to connect it to pins on 4550, I removed the "adc" part of the project and it just append "blank" data to the file .. and that part is ok .. I'll try later on to connect it using wires to try the project with 4550 but that has to wait a bit as i'm kinda out of free time for now (I can probably test it during weekend)
 
Here is the connections between the SD /MMC card holder and uC
(I think now that using a PIC18F425 could have been better :confused: )
 

Attachments

  • Conn.png
    Conn.png
    64 KB · Views: 419
If your running the 18F425 at 5V and the SD card at 3.3V you'll probably need a 74HCT125 or the like as a level converter as the SDI pin is ST (3.3V is too low)
The schematic below is for an AVR but the idea is the same.
**broken link removed**
 
It's not recommended, the ST inputs want higher than 3.3V when the hardware SPI is used. Check the electrical specifications of the datasheet.
https://www.electro-tech-online.com/custompdfs/2008/05/pic10t-20-1.pdf

thank you for clearing it up .. so .. it actually should not work, or at least it is not recommended ... the interesting thing is, now I get the reason why "Write" always work and "read" fails from time to time with no apparent reason (output from pic is divided with R1 trough R6 so SD receives 3.3V, but PIC does not always catch that 3.3V as "on") .. in general, this schematic ( https://www.electro-tech-online.com/custompdfs/2008/05/mmc-sd_board_schematic-2.pdf ) should have some 3.3->5V logic conversion on Dout from SD card for it to work "properly"
 
And when i simulate it it stops wery early on in the asm code. its almost like the 4550 are not sutable for MMC_FAT libs. Im now trying to rewrite it to suit the 425 (Its only minor changes to the code cos of pinning) Whis me luck. ;)
 
Status
Not open for further replies.

Latest threads

Back
Top