+ Post New Thread
Results 1 to 4 of 4
  1. #1
    Newbie level 4
    Points: 362, Level: 4

    Join Date
    Dec 2016
    Posts
    7
    Helped
    0 / 0
    Points
    362
    Level
    4

    MLA fileio library in mplab for PIC24FJ128GA106 with XC16 compiler

    hi everyone,
    i am new to PIC24 controller and most PIC24 has PPS configuration. in PIC24Fj128Ga106 i have done UART, I2C, interrupt and now now i want to sd card with PIC24Fj1328Ga106 by using SPI which is PPS configurable. for that i installed MLA and peripheral library. but i have some point that confuse me.
    MLA fileio library provides SD card interface which is SPI based. but SPI is PPS configurable.
    where it is declare in fileio library example so that i can used for my project. or if library not based on PPS then where is SDI, SDO, SCK pin configuration please provides me some hint so that i can get understand.

    thanks
    yogesh

    •   AltAdvertisment

        
       

  2. #2
    Advanced Member level 3
    Points: 6,741, Level: 19

    Join Date
    Jan 2015
    Posts
    977
    Helped
    307 / 307
    Points
    6,741
    Level
    19

    Re: MLA fileio library in mplab for PIC24FJ128GA106 with XC16 compiler

    Without looking at the library code, you can set the PPS up anywhere before you actually use the SPI peripheral. I would suggest somewhere right up front, perhaps around where you set up the oscillator.
    If you are using a UART, then you will be setting the PPS registers for that. Same for the external interrupts. Perhaps you should set the PPS register for SPI where you do the other PPS settings.
    One thing to check: if you have other PPS settings then either don't use the PPS unlock/lock sequences (the PPS registers are unlocked by default at POR) or make sure the IOL1WAY config bit is clear so you can unlock the PPS registers multiple times.
    Susan


    1 members found this post helpful.

    •   AltAdvertisment

        
       

  3. #3
    Newbie level 4
    Points: 362, Level: 4

    Join Date
    Dec 2016
    Posts
    7
    Helped
    0 / 0
    Points
    362
    Level
    4

    Re: MLA fileio library in mplab for PIC24FJ128GA106 with XC16 compiler

    ohh... i done PPS configuration and checked on proteus oscilloscope and its working. but what if i want to interface two sd card, is there any facility in fileio library. (FILEIO_Write1, FILEIO_Write2...). can i check this simulation in proteus like virtual memory card/SPI interface. because fileio library uses write protection , chip seelct and card detect pin which is not available in MMC model. is there another library other than MLA fileio for sd card interface.
    thanking you.



    •   AltAdvertisment

        
       

  4. #4
    Advanced Member level 3
    Points: 6,741, Level: 19

    Join Date
    Jan 2015
    Posts
    977
    Helped
    307 / 307
    Points
    6,741
    Level
    19

    Re: MLA fileio library in mplab for PIC24FJ128GA106 with XC16 compiler

    (Personal comment: I don't trust any simulator as they can simply be adding another layer of bugs over my own code. I always use real devices.)
    Looking at the pins on an SD card, the interface is a simple SPI one (allowing for single, dual and quad SPI interfaces as appropriate but it always starts as a single SPI interface). You can create a multi-slave situation with a single SPI master by driving the required \CS\ pin low (on the assumption that all of the slaves correctly tri-state their MISO pins when they are not selected). As the PIC SPI hardware does not drive the \CS\ pins in master mode you can simply select which SD card you are talking to at any time in your code.
    Generally MLA code uses a set of #define directives to set which pins are used for which signals. If you have multiple interfaces then perhaps you need to add a variable that is set to which interface is to be used, and then change all of the code references for the #define signals to 'switch' (or if/else) statements according to the variables value. This will include the\CS\ pin and the 'card detect' and other signals.
    Susan



--[[ ]]--