DE0-CV User Manual
54
www.terasic.com
May 4, 2015
Figure 5-8
shows the software stack of this demonstration. The Nios PIO block provides basic IO
functions to access hardware directly. The functions are provided from Nios II system and the
function prototype is defined in the header file <io.h>. The SD Card block implements 4-bit mode
protocol for communication with SD Cards. The FAT File System block implements reading
function for FAT16 and FAT 32 file system. Long filename is supported. By calling the public FAT
functions, users can browse files under the root directory of the MicroSD Card. Furthermore, users
can open a specific file and read the contents from the file. The main block implements main
control of this demonstration. When the program is executed, it detects whether an Micro SD Card
is inserted. If an MicroSD Card is found, it will check whether the MicroSD Card is formatted as
FAT file system. If so, it searches all files in the root directory of the FAT file system and displays
their names in the Nios II terminal. If a text file named “test.txt” is found, it will dump the file
contents. If it successfully recognizes the FAT file system, it will turn on the LEDR4~LEDR0. On
the other hand, it will turn on the LEDR9~LEDR5 if it fails to parse the FAT file system or if there
is no SD card found in the SD Card socket of the DE0-CV board. If users press KEY3 of the
DE0-CV board, the program will perform the above process again.
Figure 5-8 Software of micro SD demonstration
D
D
e
e
s
s
i
i
g
g
n
n
T
T
o
o
o
o
l
l
s
s
Quartus II14.0
Nios IIEclipse14.0
D
D
e
e
m
m
o
o
n
n
s
s
t
t
r
r
a
a
t
t
i
i
o
o
n
n
S
S
o
o
u
u
r
r
c
c
e
e
C
C
o
o
d
d
e
e
Quartus Project directory: DE0_CV_SD_DEMO
Nios II Eclipse: DE0_CV_SD_DEMO\Software
N
N
i
i
o
o
s
s
I
I
I
I
P
P
r
r
o
o
j
j
e
e
c
c
t
t
C
C
o
o
m
m
p
p
i
i
l
l
a
a
t
t
i
i
o
o
n
n