10 years, 9 months ago.

How to place data table on ROM?

How to place data table on ROM?

I am a beginner of mbed and have a question like this.

I found the way on an arduino. But I cannot find the way.

static int DataTBL[10000]{}; is the way?

Where do I go to find such questions?

2 Answers

10 years, 9 months ago.

I assume you want your data table filled with a fixed value determined by your program? In that case it is very simple with mbed, easier then with arduino even: Simply put the 'const' keyword in front of your declaration. Since a const cannot be changed anymore, the mbed compiler automatically places that in the flash memory, so:

const static int DataTBL[10000] = {};

You will need to directly fill your table with data where you declare it, so:

const static int DataTBL[10000] = {1, 2, 3, 4, 5, 6, ...};

Since it is a constant it cannot be changed later in your code, so it needs to be directly defined.

Accepted Answer

Thanks. Is there any web site explaining such reserved words as a reference in mbed world. For example, const, static, struct, if, case, .... I found this on Arduino, but cannot on mbed.

posted by Hiroshi Fukuhara 28 Jan 2014

That is the only one I am aware of that does more than they do standard in C++ (although it is debatable if it actually does more, or just optimizes it better).

posted by Erik - 28 Jan 2014
10 years, 9 months ago.

Thanks, I will try this.