AnsweredAssumed Answered

How to load data into specific memory address and assign to a array in C

Question asked by jasmine on Mar 22, 2012
Latest reply on Mar 30, 2012 by CraigG
Branched from an earlier discussion

Thank you Harshit, that solve part of my question.

About the script, basically I learnt it from ADI discussion: 'how to use a script to retrieve memory blocks (data) and use them to simulate and compare with matlab' on how to fill and dump memory with script.

 

I would like to load a set of float data from external '.txt' file to memory automatically and the data are ready to be used (in array) after I build the project. 

 

As per your example, I allocate memory in .ldf and add #pragma section in  C source, then add the script to project options>pre-build.

When I build the project, I notice that the data were written to the allocated memory, but it becomes zero  (as shown in the memory>two column)after linking . I couldn't figure out why, maybe you could help to answer this?  I did not set zero_init in the ldf section.

 

I notice that you do not add $LIBRARIES to your seg_mydata, I request you kindly clear my doubt on when can I omit the $LIBRARIES ?

 

Also, do you have example on how and when to use RUNTIME_INIT and MEMINIT?

 

On another try out, I found that I could load the data with:

#pragma section("seg_mydata")

float testdata[2048] = {

#include "test.txt"

};

Please advise if there is other simpler and faster method to load real-time data.

 

Thank you in advance.

Outcomes