Electronic Projects, forums and more.

Go Back   Electronic Circuits Projects Diagrams Free > Electronics Categories > Micro Controllers


Micro Controllers Discuss all aspects of micro controllers - building them, coding them, etc. All controllers are welcome - PIC, BASIC, Z8 Encore!, etc.

Reply
 
LinkBack Thread Tools Display Modes
Old 21st May 2008, 12:32 PM   (permalink)
Default mikroC lib troubble

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 )
__________________
Simplicity rules

Good enought - its perfect ??

2 Gig of free online backup space

Are you a Chemist?
Kryten is offline  
Old 21st May 2008, 12:53 PM   (permalink)
Default

Quote:
Originally Posted by Kryten View Post
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 ...
__________________
http://www.it4um.com
arhi is offline  
Old 21st May 2008, 01:09 PM   (permalink)
Default

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)
__________________
Simplicity rules

Good enought - its perfect ??

2 Gig of free online backup space

Are you a Chemist?
Kryten is offline  
Old 21st May 2008, 01:25 PM   (permalink)
Default

Quote:
Originally Posted by Kryten View Post
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...
__________________
http://www.it4um.com
arhi is offline  
Old 21st May 2008, 01:31 PM   (permalink)
Default

Im using a 18F4550
How to determin if its SW or HW spi?

Edit:
Yes i have formatted on a XP machine
__________________
Simplicity rules

Good enought - its perfect ??

2 Gig of free online backup space

Are you a Chemist?

Last edited by Kryten; 21st May 2008 at 01:32 PM.
Kryten is offline  
Old 21st May 2008, 02:00 PM   (permalink)
Default

Quote:
Originally Posted by Kryten View Post
Im using a 18F4550
How to determin if its SW or HW spi?
I;m not sure my comment on hw/sw spi had any value as I'm looking now at the dsheet and SPI is on RC7, RB0, RB1 and RA5 ... The test I made with MMC reader was MMC reader dev card connected to portC .. so all 4 lines are connected to portC
http://www.mikroe.com/pdf/mmc-sd_board_schematic.pdf
CS - C2
SCK - C3
SDI - C4
SDO - C5

and it works for me ...
__________________
http://www.it4um.com
arhi is offline  
Old 21st May 2008, 02:15 PM   (permalink)
Default

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
__________________
Simplicity rules

Good enought - its perfect ??

2 Gig of free online backup space

Are you a Chemist?

Last edited by Kryten; 21st May 2008 at 02:15 PM. Reason: forgot something
Kryten is offline  
Old 22nd May 2008, 05:29 PM   (permalink)
Default

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)
__________________
http://www.it4um.com
arhi is offline  
Old 26th May 2008, 12:08 PM   (permalink)
Default

Ok i might have to change it then.. It might be that 600 samples thing
__________________
Simplicity rules

Good enought - its perfect ??

2 Gig of free online backup space

Are you a Chemist?
Kryten is offline  
Old 27th May 2008, 11:38 AM   (permalink)
Default

Here is the connections between the SD /MMC card holder and uC
(I think now that using a PIC18F425 could have been better )
Attached Images
File Type: png Conn.png (64.0 KB, 10 views)
__________________
Simplicity rules

Good enought - its perfect ??

2 Gig of free online backup space

Are you a Chemist?
Kryten is offline  
Old 27th May 2008, 02:49 PM   (permalink)
Default

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.
__________________
Bill
Smart Kits build Smart People

http://www.blueroomelectronics.com
blueroomelectronics is online now  
Old 27th May 2008, 03:10 PM   (permalink)
Default

blue, I'm not sure as
http://www.mikroe.com/pdf/mmc-sd_board_schematic.pdf
works perfectly with 18F4520 and that is 5V uC afaik.
__________________
http://www.it4um.com
arhi is offline  
Old 27th May 2008, 03:16 PM   (permalink)
Default

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.
http://www.ljcv.net/library/sc/pic10t-2.0.pdf
__________________
Bill
Smart Kits build Smart People

http://www.blueroomelectronics.com
blueroomelectronics is online now  
Old 27th May 2008, 03:23 PM   (permalink)
Default

Quote:
Originally Posted by blueroomelectronics View Post
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.
http://www.ljcv.net/library/sc/pic10t-2.0.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 ( http://www.mikroe.com/pdf/mmc-sd_board_schematic.pdf ) should have some 3.3->5V logic conversion on Dout from SD card for it to work "properly"
__________________
http://www.it4um.com
arhi is offline  
Old 27th May 2008, 07:15 PM   (permalink)
Default

Try lowering the VDD on the PIC with a diode, your top speed will go down but the ST threshold is VDD * 0.8 so that will go down too.
__________________
Bill
Smart Kits build Smart People

http://www.blueroomelectronics.com
blueroomelectronics is online now  
Reply

Bookmarks

Thread Tools
Display Modes



Similar Threads
Title Starter Forum Replies Latest
mikroC demo version limits ssylee Micro Controllers 8 19th October 2007 09:21 PM



All times are GMT. The time now is 05:34 PM.


Electronic Circuits  |  Learning Electronics
Powered by vBulletin® Version 3.7.0
Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.

eXTReMe Tracker