Nios® V/II Embedded Design Suite (EDS)
Support for Embedded Development Tools, Processors (SoCs and Nios® V/II processor), Embedded Development Suites (EDSs), Boot and Configuration, Operating Systems, C and C++
Announcements
FPGA community forums and blogs on community.intel.com are migrating to the new Altera Community and are read-only. For urgent support needs during this transition, please visit the FPGA Design Resources page or contact an Altera Authorized Distributor.

SDRAM and Audio problem

Altera_Forum
Honored Contributor II
1,195 Views

I want to write some data in SDRAM with a FOR cicle and connect the audio codec MIC (in) to audio codec spk(out), the audio code segment is ok, the problem is when I add the write sdram function because the program stops, I saw (before running program) that initially some data (probably code) is in sdram memory and I think maybe the write sdram function is changing the program code. Here the question is: Why program data in SDRAM if I configured in SOPC builder reset and exception vector in SRAM ??? What I can do to put the code program on SRAM and not SDRAM. 

 

Here the code : 

# include "sdram_to_audio.h" 

 

long i; 

alt_u16 cont=0; 

 

void write_sdram() 

alt_u16 *buffer = (alt_u16 *) 0x00800000; // base addr SDRAM 

 

for (i=0; i<=127; i++){ 

buffer[i]=cont; 

cont++; 

 

int main() 

volatile int * audio_ptr = (int *) 0x10003040; // audio port 

long audiobuf[128]; 

 

/* used for audio record/playback */ 

int fifospace;//, leftdata, rightdata; 

int buffer_index = 0; 

 

write_sdram(); 

 

while (1) 

fifospace = *(audio_ptr+1); // read the audio port fifospace register 

 

if ((fifospace & 0x000000FF) > 96) 

audiobuf[buffer_index] = *(audio_ptr + 3); // read right channel only 

buffer_index++; 

 

fifospace = *(audio_ptr+1); // read the audio port fifospace register 

 

if (((fifospace & 0x00ff0000)>>16) > 96) { 

buffer_index--; 

//Write to both channels 

*(audio_ptr + 2) = audiobuf[buffer_index]; 

*(audio_ptr + 3) = audiobuf[buffer_index]; 

 

}  

}
0 Kudos
3 Replies
Altera_Forum
Honored Contributor II
491 Views

Hi, 

 

Have you selected data memory to SDRAM ? If you do that your data segment stored into SDRAM even while you select SRAM for your program code. 

 

Regards, 

Hardik Sheth
0 Kudos
Altera_Forum
Honored Contributor II
491 Views

Ok, thanks for the answer, I have the next configuration : 

 

Read/write memory data is SDRAM 

 

http://www.pixilis.com/photos/55560/  

 

But the problem is not solve !!!!! 

 

When I write for example 10 values the sound is ok, but when I write 1000 the sound is ok for seconds buts after it stops, why ???? If SDRAM doesn't containg program code ( or yes ??) .....
0 Kudos
Altera_Forum
Honored Contributor II
491 Views

I found the solution !!!!!!!!!!! my system has a timer and my C program doesn't have a handler for timer interrupt, If I don't use the timer I have to desactivate it on system properties. 

 

 

Thanks for your help !!!!!!!!!!!!!!!!!!!!!!!
0 Kudos
Reply