Home Forums MPLAB XC8 Tutorial Discussions Interfacing micro SD Card and PIC18F4550

This topic contains 13 replies, has 3 voices, and was last updated by  Bitahwa Bindu 2 months, 3 weeks ago.

  • Author
    Posts
  • #2586

    Masoud
    Participant

    I wante to use the project interfacing SD card with PIC Microcontroller that exists on this website and PIC18F45k22 is used in it. but I’m gonna do that with PIC18f4550 . What changes must I apply ?

     

    • This topic was modified 4 months ago by  Masoud.
  • #2588

    Bitahwa Bindu
    Keymaster

    They will be many changes. First off all we used MPLAB Code Configurator (MCC) to configure the SPI interface. MCC is not supported by PIC18F4550 yet. All the MCC generated codes will have to be changed.

    The rest will be the common changes like configuration bits settings to match this PIC etc.

    • #2590

      Masoud
      Participant

      I applyed  the configuration changes to adapt it  with PIC18f4550 but I’ve got following errors in the attachment. Also i attached my project files. Can you fix this error ?

      Attachments:
      You must be logged in to view attached files.
    • #2593

      Bitahwa Bindu
      Keymaster

      How did you use MCC with your project because PIC18F4550 is not supported by MCC?

    • #2594

      Masoud
      Participant

      I didn’t use MCC , I used the main project in the website with PIC18F45k22 but I changed MCC generated codes for my PIC Manually (change in pin_manager ,mcc and spi1 files), What is wrong ?

  • #2595

    Masoud
    Participant

    Great thanks for your consideration ,

    I made  some other changes in configuration codes but I still have the same errors in below.

    I attached my project. Can you help me fixing it?

    Attachments:
    You must be logged in to view attached files.
    • #2599

      Masoud
      Participant

      don’t worry about it , it worked finally  :))) .

    • #2605

      Bitahwa Bindu
      Keymaster

      That’s great news. Sorry we couldn’t assist you much, we were very busy. What was the problem?

      Can you share the the code? It might assist others instead of going through the same problems as you.

    • #2606

      Masoud
      Participant

      It seems that the DIR variable is used another place in libraries and codes i added in my project, so i changed the DIR names to DIR1 in ff.h and ff.c and the project build successfully.  The code didn’t change else.

      Now I wanna read from a specific text file from sd card, can you give an example in using of “f_read” function ?  What format should I choose for buff in “f_read” function ?

       

      • This reply was modified 4 months ago by  Masoud.
      Attachments:
      You must be logged in to view attached files.
    • #2612

      Bitahwa Bindu
      Keymaster

      Thank for the feedback.

      You can use the quick f_gets function. There is an example how to use it in the f_open  description.

      Or open the main.c of pic24 example in the FatFs  sample projects for various platforms  for an example how to use f_read function.

  • #2688

    SALOMON ROJAS
    Participant

    Hi.

    I had the same problema, I changed the DIR names but I have others errors. please could you help me becuase I don’t know why there are problems, I attached my Project.
    <div>

    It’s in:

    MPLAB X IDE v4.01

    </div>
    MPLAB® Code Configurator  v4.26

    Attachments:
    You must be logged in to view attached files.
    • #2690

      Bitahwa Bindu
      Keymaster

      Hi. Do you have the same project? Using the same PIC and configuring with MCC?

      Please clarify or you can use Masoud project. He posted it in this thread.

      Please specify what errors you are getting, which compiler version you are using and so on.

  • #2691

    SALOMON ROJAS
    Participant

    I wanted start only with PIC18f45k50 and doing  the same Project like your tutorial.

    I am configuring with MCC, the copiler versión is XC8 V1.43.

    i only wrote this:

     

    #include “mcc_generated_files/mcc.h”
    #include “ff.h”

    FATFS w_area; /* FatFs work area needed for each volume */
    FIL Fil; /* File object needed for each open file */

    void main(void)
    {
    UINT bw;
    // Initialize the device
    SYSTEM_Initialize();

    if (f_mount(&w_area, “”, 1) == FR_OK) { /* Mount SD */
    }
    while (1)
    { }
    }
    /**
    End of File
    */

     

     

     

     

     

     

     

     

    Attachments:
    You must be logged in to view attached files.
    • #2693

      Bitahwa Bindu
      Keymaster

      Hi. You seem to be using different fatFs files compared to the one we are using. Are you sure you downloaded the correct files from Chan’s FatFs website?

      Try to use the files in our in our project and see if it will compile.

You must be logged in to reply to this topic.