October 10, 2024, 11:58:42 AM

Duinomite E maga config SD card

Started by lecat, January 21, 2013, 10:33:54 AM

Previous topic - Next topic

lecat

Hello
I just buy the Duinomite e Mega

in the HardwareProfile.h

   //SPI Configuration
      #define SPI_START_CFG_1     (SPI_OPEN_MSTEN | SPI_OPEN_MODE8 | SPI_OPEN_CKE_REV | SPI_OPEN_ON)
        #define SPI_START_CFG_2     (GetPeripheralClock() / SPI_FREQUENCY)

    // Define the SPI frequency
    #define SPI_FREQUENCY         (10000000)

    #define SD_CS            PORTGbits.RG12
    #define SD_CS_TRIS         TRISGbits.TRISG12
   
//    #define SD_CD            PORTFbits.RF0
//    #define SD_CD_TRIS         TRISFbits.TRISF0
//   
//    #define SD_WE            PORTFbits.RF1
//    #define SD_WE_TRIS         TRISFbits.TRISF1

    // Registers for the SPI module you want to use
    #define SPICON1            SPI3ACON
    #define SPISTAT            SPI3ASTAT
    #define SPIBUF            SPI3ABUF
    #define SPISTAT_RBF         SPI3ASTATbits.SPIRBF
    #define SPICON1bits         SPI3ACONbits
    #define SPISTATbits         SPI3ASTATbits
    #define SPIENABLE           SPI3ACONbits.ON
    #define SPIBRG             SPI3ABRG
    // Tris pins for SCK/SDI/SDO lines
        // Description: The TRIS bit for the SCK pin
        #define SPICLOCK            TRISDbits.TRISD15
        // Description: The TRIS bit for the SDI pin
        #define SPIIN               TRISFbits.TRISF8
        // Description: The TRIS bit for the SDO pin
        #define SPIOUT              TRISFbits.TRISF2

      #define putcSPI(data)       SpiChnPutC(SPI_CHANNEL3A, data)
      #define getcSPI()           SpiChnGetC(SPI_CHANNEL3A)
      #define OpenSPI(config1, config2)      SpiChnOpen(SPI_CHANNEL3A, config1, config2)
       
        // Will generate an error if the clock speed is too low to interface to the card
        #if (GetSystemClock() < 100000)
            #error Clock speed must exceed 100 kHz
        #endif   




But I can't write on the SD card

you would have a code that works on the duimite e Mega


thank you