Altera Forum






Threads: 18,921
Posts: 77,325
Members: 29,164
Welcome to our newest member, rbn
User
Reputation
9135
7620
5891
4150
2930
2197
2056
1706
1388
1300




 
Register
Quick Search
 
  Altera Forums > IP and Dev Kit Related > Nios Forum > General Discussion > General Discussion Forum

Writing SDRAM HELP !!!!!!!!

Reply
 
Thread Tools Display Modes
  #1  
Old February 9th, 2010, 07:02 AM
chema15 chema15 is offline
Altera Scholar
 
Join Date: Jun 2008
Posts: 49
Rep Power: 846
chema15 is on a distinguished road
Unhappy Writing SDRAM HELP !!!!!!!!

Hi, I wrote a function in C to W SDRAM memory :

void write_sdram()
{
int *buffer = (int *) 0x00800000; // SDRAM addr base

buffer[0]=0xaaaa;
buffer[1]=0xcccc;
}

When I read the SDRAM with altera DE1 control panel data is :
addr 0 = aaaa
addr 1 = 0000
addr 2 = cccc
addr 3 = 0000

Why ??? If the SDRAM data width is 16 bits , I'm waiting for
addr 0 = aaaa
addr 1 = cccc


Help me please !!!!!
__________________
José Ma. Valencia
Reply With Quote
  #2  
Old February 9th, 2010, 09:16 AM
aukums aukums is offline
Altera Scholar
 
Join Date: Apr 2009
Posts: 31
Rep Power: 542
aukums will become famous soon enough
Default Re: Writing SDRAM HELP !!!!!!!!

Could it be because int is 32 bits data type variable? Try alt_u16 for buffer and I think this will work.

Quote:
Originally Posted by chema15 View Post
Hi, I wrote a function in C to W SDRAM memory :

void write_sdram()
{
int *buffer = (int *) 0x00800000; // SDRAM addr base

buffer[0]=0xaaaa;
buffer[1]=0xcccc;
}

When I read the SDRAM with altera DE1 control panel data is :
addr 0 = aaaa
addr 1 = 0000
addr 2 = cccc
addr 3 = 0000

Why ??? If the SDRAM data width is 16 bits , I'm waiting for
addr 0 = aaaa
addr 1 = cccc


Help me please !!!!!
Reply With Quote
  #3  
Old February 9th, 2010, 12:24 PM
chema15 chema15 is offline
Altera Scholar
 
Join Date: Jun 2008
Posts: 49
Rep Power: 846
chema15 is on a distinguished road
Unhappy Re: Writing SDRAM HELP !!!!!!!!

Ok , Thanks !!!!! it was the solution, but now I have another problem:

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];

}
}
}
__________________
José Ma. Valencia
Reply With Quote
  #4  
Old February 9th, 2010, 01:50 PM
aukums aukums is offline
Altera Scholar
 
Join Date: Apr 2009
Posts: 31
Rep Power: 542
aukums will become famous soon enough
Default Re: Writing SDRAM HELP !!!!!!!!

Right click in your project and click "System library properties". Make sure that program memory, stack memory, etc are all set to SRAM and not SDRAM.

Kumaran
Reply With Quote
  #5  
Old February 9th, 2010, 06:28 PM
chema15 chema15 is offline
Altera Scholar
 
Join Date: Jun 2008
Posts: 49
Rep Power: 846
chema15 is on a distinguished road
Default Re: Writing SDRAM HELP !!!!!!!!

I'm sure all it's correct (SOPC builder, and monitor program are configure with SRAM) but running the program some code (maybe program code is on SDRAM) and when I execute the write sdram function it writes a zone with code causing the program stops.....
__________________
José Ma. Valencia
Reply With Quote
  #6  
Old February 10th, 2010, 06:16 PM
chema15 chema15 is offline
Altera Scholar
 
Join Date: Jun 2008
Posts: 49
Rep Power: 846
chema15 is on a distinguished road
Default Re: Writing SDRAM HELP !!!!!!!!

Thanks for the answer , my configuration is ok, now I can write exactly on SDRAM but the problem appears if the number of data to write on sdram is for example 1000, why ?? if the memory is 8 MB
Attached Images
File Type: jpg image_IDE_nios.JPG (139.4 KB, 7 views)
__________________
José Ma. Valencia
Reply With Quote
  #7  
Old February 10th, 2010, 11:07 PM
chema15 chema15 is offline
Altera Scholar
 
Join Date: Jun 2008
Posts: 49
Rep Power: 846
chema15 is on a distinguished road
Default Re: Writing SDRAM HELP !!!!!!!!

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 !!!!!!!!!!!!!!!!!!!!!!!
__________________
José Ma. Valencia
Reply With Quote
Reply



Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Forum Jump

Similar Threads
Thread Thread Starter Forum Replies Last Post
Writing to SRAM/SDRAM on DE-2 board ? eltonyo Development Kit Related 11 July 19th, 2010 10:59 PM
Writing to SDR SDRAM through Synposys designware mem controller gangireddy.p IP Discussion 6 April 13th, 2009 08:51 PM
Writing to memory jatinp Quartus II and EDA Tools Discussion 1 July 16th, 2008 11:55 PM
writing to a uart manns ecos Forum 1 August 22nd, 2005 04:58 AM
writing to register mstevens General Software Forum 1 February 14th, 2005 10:33 AM


All times are GMT -8. The time now is 02:43 PM.