Important changes to forums and questions
All forums and questions are now archived. To start a new conversation or read the latest updates go to forums.mbed.com.
10 years, 10 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, 10 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.