Intel® FPGA University Program
University Program Material, Education Boards, and Laboratory Exercises
1182 Discussions

SD Card IP Core cannot read

Honored Contributor II

Dear people, 


I am making a home brewed WAV player, with a delta sigma converter. 

For this I am using the prototyping board from Terasic: DE0 NANO with Altera web edition. 


I have written in VHDL a delta sigma converter (connected to an DAC converter with an speaker) and I have tested it by sending signals with the NIOS cpu (build with the tutorial from Terasic and Altera) and that part works. But because of the small memory of the FPGA I want to use an SD card for storage. 


For this I have used the SD IP core from the University Program from Altera to read the (big) files from the SD card. There for i have used this tutorial:


The interfacing with the SD Card works only on some points. The software example from the tutorial works. I can write files (with the alt_up_sd_card_write() function) and when I open the file with the computer where there is written i see the same buffer as I have written. You can find more information about the SD IP core and the library here: 


My problem is, that when I want to read files like an .txt or an .wav file the output is not what stays in the file (printed in the console). All the characters are the same. But the only thing is that the read output match exactly the same number characters as are viable in the file. Like an example, if in the .txt file stays: helloTESTsens (13 char) i also get 13 chars (witch are all the same). 


After a lot of test with code changes I still don't know how to fix this. My fist idea was that this problem or fault is of a char conversion? An other option is that this is because of a read fault because of a bad sd card (but why the write works?) of because i use to long wires between the de0 nano board and the sd card shield (but why the write works?). 


After opening th sd with the same routine as in the tutorial, I use this routine for reading the file on the SD card: 


int z = 0; short int handler = alt_up_sd_card_fopen("music.wav", false); printf("\n\n"); if(handler >= 0) { int read; while ((read = alt_up_sd_card_read(handler)) != -1) { //printf("%i\n", read); //usleep(1000000); //1sec delay z++; } printf("%d\n", z); } 


I am already sitting about more than a week with this confusing problem and i appreciate every help or tips with many can lead to a solution. 


Thank you in advance.
0 Kudos
0 Replies