Community
cancel
Showing results for 
Search instead for 
Did you mean: 
Altera_Forum
Honored Contributor I
4,756 Views

Writing .txt file in SD Card - DE2

Hello, I am Student from a University beginner in FPGAs, and I was doing a project with Nios II that uses a Altera DE2 Board to do some operations and save the results. The main ideia was to transmit to computer the results, but the USB take too much time to the FPGA. 

Now I am seaching a way to save those results at the SD card. But I couldn't find a way to store data in SD card. My idea was to create a .txt file that could receive at the end of each operation a value in the next line. 

If someone knows how save values in the SD card, I really appreciate your help, if you help send me.
0 Kudos
37 Replies
Altera_Forum
Honored Contributor I
133 Views

When I transfer data, I use a very simple and relatively fast connection via GPIO and Labview. For that you need a Labview card and box (expensive but in most university labs available) with digital I/O pins and a clock input. Then you connect the I/O pins from Labview to some pins of the GPIO port. 

The transfer rate is 1Mbit/s for each connected data pin with my labview card. 

 

I tried to write to the SD card once, but failed when my SD card was not even recognized by the board. There is also no example to actually write to the SD card, only to read from it.
Altera_Forum
Honored Contributor I
133 Views

Does anyone have a method of writing to th SD card without using LabView?

Altera_Forum
Honored Contributor I
133 Views

You could start with the DE2_115_SD_CARD demonstration project: it includes a function SDHAL_WriteData in the file sd_hal.c. You might be able to write using this function, if you find an SD card that is recognized by the board. 

I see that this demonstration is for the DE2-115 board; hopefully there is a similar demonstration for the DE2 board.
Altera_Forum
Honored Contributor I
133 Views

Awesome. Thanks for the advice I will have to take a look at the code. Do you know if there is a link on the altera website for the demonstration files? I can't seem to find them. 

 

What exactly is the trick to find an SD card that is recognized by the DE2 board? SDHC? Non SDHC? MicroSD into adapter? Certain brands?
Altera_Forum
Honored Contributor I
133 Views

you can find the files here: http://www.terasic.com.tw/cgi-bin/page/archive.pl?language=english&categoryno=139&no=502&partno=4 

In order to download, you need to sign up for a Terasic account.
Altera_Forum
Honored Contributor I
133 Views

What is the trick to finding an SD card that is recognized by the DE2 board? I've tried two cards now (PNY and Sandisk both 2GB) and neither one is being recognized.

Altera_Forum
Honored Contributor I
133 Views

I would ask Terasic (I think it's support@terasic.com); they should know, because they ship the high end boards with SD cards.

Altera_Forum
Honored Contributor I
133 Views

Hello everyone! I really appreciate your help! 

 

David Pavid: I don't have a labview card, but its a nice idea! 

 

I adapted the code for the DE2-115 to run in DE2. I am running the program but I am having problems with the sd card that is not being recognized. 

I tested 2 SD cards, both microSD into adapters, and both fail. (1gb KINGMAX microSD and 8gb microSDHC Class4 that doesn't says the brand). 

 

Anyone has already tested a old simple card (32-128mb) and without adapters? 

 

I am going to contact terasic, if I get answers I post here.
Altera_Forum
Honored Contributor I
133 Views

The SD card (2 GB ) that came with the DE4 card can be mounted by the demonstration project design. Therefore I don't think that it is the size of the SD card.

Altera_Forum
Honored Contributor I
133 Views

Hello! I'm still trying to write a .txt file in SD Card. I searched a lot in internet but I couldn't find the solution! 

If someone knows a way please tell! 

Thank you!
Altera_Forum
Honored Contributor I
133 Views

Not to get too far off topic here but does anyone know of a way to write to an SD card using SPI (low level write)? As long as you know what data is being written you could extract it using MATLAB. Any thoughts?

Altera_Forum
Honored Contributor I
133 Views

Hello! I'm need a way to save data from fpga. I couldn't find a easy way to store in SD card. Does anyone have some idea to transfer data in a quicker way?

Altera_Forum
Honored Contributor I
133 Views

If you always run your system with a USB cable attached, you could use the host file system software component, that will let you read/write files on the PS from the embedded application. You need to run in debug mode though.

Altera_Forum
Honored Contributor I
133 Views

Found the solution to the mysteries of the SD Card! 

http://www.alteraforum.com/forum/showthread.php?t=34101
Altera_Forum
Honored Contributor I
133 Views

PeteCSI, thank you for your support!!! 

 

I'm I going to try the method! After testing it, I post here my results!
Altera_Forum
Honored Contributor I
133 Views

Hello! It's possible to write data in a pendrive/flash device? using USB host? 

 

PeteCSI: I'm trying to understand the FreeRTOS! When I get something I post here my results!
Altera_Forum
Honored Contributor I
133 Views

You'll need quite a lot of USB driver code in order to access a USB drive. 

You'll also need fairly trivial (by comparison) code to access the FAT32 filesystem on the device.
Altera_Forum
Honored Contributor I
133 Views

On my DE2-115 it says it only accepts SD formatted on FAT16.

Altera_Forum
Honored Contributor I
133 Views

Larger devices are much more likely to have FAT32 (than FAT16). The crossover point is probably abut 128MB - although FAT16 can go higher. 

Nothing to stop you reformatting part of the device with FAT16 though.