+ Reply to Thread
Page 1 of 2
1 2 Last
Results 1 to 15 of 19

Thread: mikroC lib troubble

  1. #1
    Kryten Newbie
    Join Date
    Oct 2007
    Location
    Stavern, Norway
    Posts
    292

    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 )
    The best is yet to come

    Good enough - its perfect !!

    2 Gig of free online backup space

    cq cq de LA3BNA


  2. #2
    arhi Excellent arhi Excellent arhi Excellent arhi Excellent arhi Excellent arhi Excellent
    Join Date
    Apr 2008
    Location
    Belgrade, .rs
    Posts
    832

    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 ...

  3. #3
    Kryten Newbie
    Join Date
    Oct 2007
    Location
    Stavern, Norway
    Posts
    292

    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)
    The best is yet to come

    Good enough - its perfect !!

    2 Gig of free online backup space

    cq cq de LA3BNA

  4. #4
    arhi Excellent arhi Excellent arhi Excellent arhi Excellent arhi Excellent arhi Excellent
    Join Date
    Apr 2008
    Location
    Belgrade, .rs
    Posts
    832

    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...

  5. #5
    Kryten Newbie
    Join Date
    Oct 2007
    Location
    Stavern, Norway
    Posts
    292

    Default

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

    Edit:
    Yes i have formatted on a XP machine
    Last edited by Kryten; 21st May 2008 at 12:32 PM.
    The best is yet to come

    Good enough - its perfect !!

    2 Gig of free online backup space

    cq cq de LA3BNA

  6. #6
    arhi Excellent arhi Excellent arhi Excellent arhi Excellent arhi Excellent arhi Excellent
    Join Date
    Apr 2008
    Location
    Belgrade, .rs
    Posts
    832

    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 ...

  7. #7
    Kryten Newbie
    Join Date
    Oct 2007
    Location
    Stavern, Norway
    Posts
    292

    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
    Last edited by Kryten; 21st May 2008 at 01:15 PM. Reason: forgot something
    The best is yet to come

    Good enough - its perfect !!

    2 Gig of free online backup space

    cq cq de LA3BNA

  8. #8
    arhi Excellent arhi Excellent arhi Excellent arhi Excellent arhi Excellent arhi Excellent
    Join Date
    Apr 2008
    Location
    Belgrade, .rs
    Posts
    832

    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)

  9. #9
    Kryten Newbie
    Join Date
    Oct 2007
    Location
    Stavern, Norway
    Posts
    292

    Default

    Ok i might have to change it then.. It might be that 600 samples thing
    The best is yet to come

    Good enough - its perfect !!

    2 Gig of free online backup space

    cq cq de LA3BNA

  10. #10
    Kryten Newbie
    Join Date
    Oct 2007
    Location
    Stavern, Norway
    Posts
    292

    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
    The best is yet to come

    Good enough - its perfect !!

    2 Gig of free online backup space

    cq cq de LA3BNA

  11. #11
    Help us help you blueroomelectronics Excellent blueroomelectronics Excellent blueroomelectronics Excellent blueroomelectronics Excellent blueroomelectronics Excellent blueroomelectronics Excellent blueroomelectronics Excellent blueroomelectronics Excellent blueroomelectronics Excellent blueroomelectronics Excellent
    Join Date
    Jan 2007
    Location
    Toronto, Canada
    Posts
    10,709
    Blog Entries
    5

    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/

  12. #12
    arhi Excellent arhi Excellent arhi Excellent arhi Excellent arhi Excellent arhi Excellent
    Join Date
    Apr 2008
    Location
    Belgrade, .rs
    Posts
    832

    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.

  13. #13
    Help us help you blueroomelectronics Excellent blueroomelectronics Excellent blueroomelectronics Excellent blueroomelectronics Excellent blueroomelectronics Excellent blueroomelectronics Excellent blueroomelectronics Excellent blueroomelectronics Excellent blueroomelectronics Excellent blueroomelectronics Excellent
    Join Date
    Jan 2007
    Location
    Toronto, Canada
    Posts
    10,709
    Blog Entries
    5

    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/

  14. #14
    arhi Excellent arhi Excellent arhi Excellent arhi Excellent arhi Excellent arhi Excellent
    Join Date
    Apr 2008
    Location
    Belgrade, .rs
    Posts
    832

    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"

  15. #15
    Help us help you blueroomelectronics Excellent blueroomelectronics Excellent blueroomelectronics Excellent blueroomelectronics Excellent blueroomelectronics Excellent blueroomelectronics Excellent blueroomelectronics Excellent blueroomelectronics Excellent blueroomelectronics Excellent blueroomelectronics Excellent
    Join Date
    Jan 2007
    Location
    Toronto, Canada
    Posts
    10,709
    Blog Entries
    5

    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/

+ Reply to Thread
Page 1 of 2
1 2 Last

Similar Threads

  1. mikroC demo version limits
    By ssylee in forum Micro Controllers
    Replies: 8
    Latest: 19th October 2007, 08:21 PM

Tags for this Thread