SD/MMC interface to my xmega256 a3bu xplained board

Go To Last Post
8 posts / 0 new
Author
Message
#1
  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

Hello all,

 

I need help to interface the SD/MMC (fatFS) card into my xmega256 a3bu board.

And need to read & write some files into it, card should be FAT formatted.

Do you have any example or reference code that I can try ?

 

Also I have got the below code from github and its not working.

https://github.com/qbazd/xmega-s...

 

And got the issue in SD card initialization.

https://github.com/qbazd/xmega-s...

 

For using MMC in SPI mode in J4 connector of the board then the below configurations are correct ?

//! \name SPI microSD
//@{
#define SD_MMC_SPI_MEM_CNT              1
#define SD_MMC_0_CD_GPIO                IOPORT_CREATE_PIN(PORTC, 6)
#define SD_MMC_0_CD_DETECT_VALUE        0
#define SD_MMC_SPI_USES_USART_SPI_SERVICE // To signal that is a USART in SPI mode
#define SD_MMC_SPI                      &USARTD0
#define SD_MMC_SPI_SCK                  IOPORT_CREATE_PIN(PORTD, 1)
#define SD_MMC_SPI_MISO                 IOPORT_CREATE_PIN(PORTD, 2)
#define SD_MMC_SPI_MOSI                 IOPORT_CREATE_PIN(PORTD, 3)
#define SD_MMC_SPI_0_CS                 IOPORT_CREATE_PIN(PORTD, 0)

 

Can you anyone help to me come out of this issue ?

 

Thanks for your help.

 

Regards,

Titus S.

Regards,
Titus S.

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

The FatFs user manual itself has some examples. The code given to illustrate how to use f_open() for example is pretty much a standalone test of FatFs...

 

http://elm-chan.org/fsw/ff/doc/o...

 

The code there is:

 

/* Read a text file and display it */

FATFS FatFs;   /* Work area (file system object) for logical drive */

int main (void)
{
    FIL fil;       /* File object */
    char line[82]; /* Line buffer */
    FRESULT fr;    /* FatFs return code */


    /* Register work area to the default drive */
    f_mount(&FatFs, "", 0);

    /* Open a text file */
    fr = f_open(&fil, "message.txt", FA_READ);
    if (fr) return (int)fr;

    /* Read all lines and display it */
    while (f_gets(line, sizeof line, &fil))
        printf(line);

    /* Close the file */
    f_close(&fil);

    return 0;
}

Obviously there's a bit more to it - for AVR the printf() may not work immediately. But this shows the general technique of f_mount() then f_open().

 

Now above you simply said:

titusece wrote:
from github and its not working.

"not working" says almost nothing about the problems you may be encountering??

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

Hello,

Thanks for your reply.

Can you please refer to the below link where I have mentiond the issues ?

https://github.com/qbazd/xmega-s...

 

I've not connected any serial port and using debugger and found that MMC/SD is failed in initialization.

 

I can't do this FatFS example since MMC/SD card is itself failed in initialization right.

 

Can you please help me on this ?

Thanks again.

Regards,
Titus S.

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

Since you are using ASF, why don't you try looking at the FATFS Access Example project for the XMEGA-A3BU Xplained?  

Greg Muth

Portland, OR, US

Xplained Boards mostly

Atmel Studio 7.0 on Windows 10

 

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

Did you solve this issue with that library?

 

The Acces Example code from ASF did not work for me

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

Hi Greg,

Thanks for your reply.

Its just test example for fatfs, and its using SDRAM to test the FatFS, but I need example for MMC/SD.

 

Regards,
Titus S.

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

Hi fabianpi,

Unfortunately, no.

Please update here if you able to make it work.

Thanks !

Regards,
Titus S.

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

I've found this thread http://www.avrfreaks.net/forum/solved-micro-sd-card-interface-spi-elm-chans-fatfs?skey=xmega%20fatfs

 

I'm planning to use the github files but I don't know how to start to use it with the xMEGA256A3BU Xplained