cancel
Showing results for 
Search instead for 
Did you mean: 

FSMC & SRAM wrong data

rudikoster
Associate II
Posted on December 30, 2009 at 11:36

FSMC & SRAM wrong data

6 REPLIES 6
rudikoster
Associate II
Posted on May 17, 2011 at 13:35

Hi,

I am using a STM3210E-EVAL board in combination with Keil and an Ulink2.

I am trying to use the FSMC in combination with the SRAM on the board.

I studied the SRAM example program from STM. Works perfect.

I will be using the SRAM as a data buffer. I read sample data from an ADC and store these values in the SRAM. This happens in an interrupt. In another interrupt I read data from the SRAM.

Interrupt are configured with different priority. I use the NVIC_SETPRIMASK(); and RESET when reading, so the writing cant interrupt the read process.

My problem is that I read wrong values from the SRAM! The memory of the SRAM you can see in Keil, here all data is correct! So reading from the SRAM goes wrong!

I have to read and write fast after each other, and I think here goes something wrong. Although i don't know what.

Down here is a piece of code that gives the same wrong data as my actual program.

Am I doing anything wrong or do I have to do anything between writes and reads?

FSMC setup code is the same as the example program.

Hope someone can point me in the right direction!

Code:

for (i=0; i<=1000;i++)

{

num_samples++;

FSMC_SRAM_WriteBuffer(&num_samples, adc_data_write_pointer + ch_write_offset, 2);

FSMC_SRAM_ReadBuffer(&lees, adc_data_write_pointer + ch_write_offset, 2);

if (num_samples != lees) /*to see what values are wrong*/

{

help0=num_samples;

help1=lees;

help2= adc_data_write_pointer;

help3= ch_write_offset;

help4++;

hulp5[help4] = help0;

}

if (num_samples == 0x200)

{

help0++; /* i put my breakpoint here */

}

ch_write_offset += 4;

if (ch_write_offset == 32)

{

ch_write_offset = 0;

adc_data_write_pointer += 32;

}

}

jj
Associate II
Posted on May 17, 2011 at 13:35

Hi - would like to help - may I ask for further clarification?

''The memory of the SRAM you can see in Keil, here all data is correct!''

Are you saying here that the Keil IDE can read/store & display the content of the external SRAM IC(s)?

Each time there is mention of SRAM I am not smart/aware enough to know whether you are referencing STM ''on chip'' or ''off-chip/external'' SRAM. This would aid me/others to assist.

Often problems such as these are solved by introducing delays - and systematically reducing them to gauge/learn sensitivities.

rudikoster
Associate II
Posted on May 17, 2011 at 13:35

Hi, sorry if i wasn't clear enough.

When i mention the SRAM in my post i refer to the external SRAM IC on the STM3210E-EVAL board.

The Keil IDE can indeed read the memory and display it when the program is running.

Quote:

The µVision Memory Window allows you to watch four separate memory areas. As your program runs, µVision updates the contents of the Memory Window.

http://www.keil.com/uvision/db_view_memory.asp

When i scroll in this memory window there is alot of activity on the SRAM pins (CE, OE and WR), so this is indeed updated. I also tried without watching the memory, so here is no interaction that could cause the wrong data.

I already tried inserting a delay before, between and after the write/read, this doesn't change anything, the same read errors occur.

jj
Associate II
Posted on May 17, 2011 at 13:35

Now - that is clear - thank you. (was unaware of that neat IDE capability)

So - the SRAM example program works well - HW and ''that SW'' approach succeed. You have a ''real world'' application - have had to modify the working approach. Further - you have inserted variable/suitable(?) delays to guard against potential timing/cycle-time errors. (would have bet on that!)

a) How badly is your data in error? Every byte, most, few?

b) How badly is the ''average'' byte corrupted? Are particular bits more in error than others?

c) Your sample size appears to be 0x200 - have you tried both smaller and larger values - ''just in case?'' What happens with a single byte transfer?

d) Are you absolutely sure that you're reading from the correct starting address - and subsequent ones?

e) What is the result of a ''later, greatly slowed/relaxed'' SRAM read? Do you read exactly the same as in the Keil window under this condition?

My group often succeeds by modeling code closely after ''known, working'' examples - and then ''changing only one factor at a time'' - to try and uncover error conditions early - before they become ''buried'' by number/complexity. I would review your code and see if/how it can more closely follow the example which worked for you. And - often the same person consistently ''misses'' an error/misinterpretation - which is quickly detected by another - have someone else look at ''all'' of your modified code.

rudikoster
Associate II
Posted on May 17, 2011 at 13:35

Hi jj.sprague

It's working! finally :)

I was testing all things i could think off, and then i saw the TFT display on the eval board flickering. It seems that FSMC pins are also connected to the TFT. The OE, WE and all data and adress pins connected to the SRAM IC are also connected to the TFT. The TFT CS pin was low, so the chip was active. After setting the TFT CS pin high everything was fine ... no idea why, not using the TFT so i dont know how it works. But it solved my problem!

After my ''simple'' SRAM test program worked, i still received wrong data in Labview with my actual program, but this was a fault in the USB driver i made, also fixed now.

So its working like a charm now :D

thanks very much for the help!

bikash
Associate II
Posted on September 08, 2012 at 13:47