sdcard  1.5
Customations for HvA-Xmegaboard to SD-card library FatFs of Chan
sdcard Documentation


This documents the customazations of Chan's FatFs Library for the HvA-Xmegaboard.

FatFs is a very popular file system for all kind of devices and technologies. Chan's FatFs can be found at The zip with latest release and a zip with sample projects can be fpound at the bottom of the Chan's page.

FatFs exists of several files:

ff.c Functions for the File System Layer
ff.h Prototypes and definitions for File System Layer
ffconf.h Configuration file
ffunicode.c Optional unicode handling functions
ffsystem.c Sample Code of OS Dependent Functions
diskio.c Functions for specific device and technology (r11)
diskio.h Prototypes and definitions for specific device and technology (r11)

The sample projects show solutions for several devices (SD-cards) and several microcontrollers including AVR-microcontrollers. Unfortunately it contains no exmples for the Xmega. This site adds two solution for the Xmega, one with delays and one with a timer. The first is a modification of the sample generic release 11a. The file sdmm.c is adjusted for the Xmega. The bit banging is chnged to a normal SPI-interface. The second is a modification of the sample avr release 11a and the sample avr release 12 or later. The file mmc_avr.c from relelase 11a and mmc_avr_spi.c are combined and adjusted for the Xmega. The diskio-functions of this implementation uses the function bodies from the latest release and the fnction headers from release 11a.


To use the customized versions you need:

  • ff.c, ff.h, ffconf.h and optional ffunicode.c of the latest release from Chan
  • diskio.h, sdmm.c or mmc_avr.c from this zip Two examples are added.


Wim Dolman (
Latest version can be found here:
11 march 2020


This library is free software. You can redistribute it and/or modify it. This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY.