sdcard  1.5
Customations for HvA-Xmegaboard to SD-card library FatFs of Chan
sdcard_test_mmc_avr.c File Reference

Test program for sd-card with Chan FatFS and customized mmc_avr.c. More...

#include <avr/io.h>
#include <avr/interrupt.h>
#include "ff/ff.h"
#include "ff/diskio.h"
#include "clock/clock.h"
#include "serialF0/serialF0.h"

Macros

#define F_CPU   32000000UL
 

Functions

void init_timer (void)
 Initialize timer/counter C1 as 100 Hz timer. More...
 
void demo_ff (void)
 Demonstration. It writes text to a file on the SD-card. After that it reads the file from the SD-card and print the text. This example is code D.2 from 'De taal C en de Xmega' second edition, see Voorbeelden uit 'De taal C en de Xmega' More...
 
int main (void)
 main routine for testting sdmm.c More...
 
 ISR (TCC1_OVF_vect)
 Timer Interrupt that triggers disk_timerproc() More...
 

Detailed Description

Test program for sd-card with Chan FatFS and customized mmc_avr.c.

Author
Wim Dolman (w.e.dolman@hva.nl)
Date
11-03-2020
Version
1.5

This implementation needs a timer for the necessary delays.

Usage with Atmel Studio.
This example uses the serialF0, see https://dolman-wim.nl/xmega/libraries/online/serialF0/html/index.html and the clock functions, see https://dolman-wim.nl/xmega/libraries/online/clock/html/index.html In the project directory uses three subfolders: clock, ff, and serialF0.

  1. Make an Atmel Studio project
  2. Add three subfolders (use New Folder...) to the project : clock, ff, and serialF0
  3. Place the necessary files in the Atmel Studio project folder/subfolders
    clock/clock.c Clock functions
    clock/clock.h Clock functions
    serialF0/serialF0.c Serial interface
    serialF0/serialF0.h Serial interface
    ff/ff.c Latest version from Chan's Library
    ff/ff.h Latest version from Chan's Library
    ff/ffconf.h Latest version from Chan's Library
    ff/diskio.h Version 2014 from Chan's avr releases 11a
    ff/ mmc_avr.c Customized version Chan's Sample avr releases 11a/12
    sdcard_test_mmc_avr.c This example
    demo_ff.c function with demo SD-card
  4. Add all c-files to the project
  5. Change these four defines in ffconf.h
               #define FF_USE_STRFUNC  2
               #define FF_USE_CHMO     1
               #define FF_FS_NORTC     1
               #define FF_USE_LFN      0 

You can place the library files also directly in the project folder or in an other folder. In that case you need to change the path in the #include lines.

This test program is based on the example D.2 and D.3 from 'De taal C en de Xmega' 2nd edition.

Macro Definition Documentation

◆ F_CPU

#define F_CPU   32000000UL

Function Documentation

◆ demo_ff()

void demo_ff ( void  )

Demonstration. It writes text to a file on the SD-card. After that it reads the file from the SD-card and print the text. This example is code D.2 from 'De taal C en de Xmega' second edition, see Voorbeelden uit 'De taal C en de Xmega'

Returns
void

◆ init_timer()

void init_timer ( void  )

Initialize timer/counter C1 as 100 Hz timer.

Returns
void

◆ ISR()

ISR ( TCC1_OVF_vect  )

Timer Interrupt that triggers disk_timerproc()

Returns
void

◆ main()

int main ( void  )

main routine for testting sdmm.c

It initialize the clock, the streams, the toimer, set the global interrupts and run the demo program once.

Returns
int