2017-07-30 03:59 AM
I have a large data set int a[10000]. which is needed in program. But it is too large to write by hand to the .c file for me.
How could I put it into ROM? There any synthex for to help me to import it to program when compiling?
which may let the program looks like this:
const int a[10000];
#loaddata '10000*4 bytes', './a.bin', &a[0];
.
.
.
.
2017-07-30 05:15 AM
Hi..
Search in internet for 'Bin to C'
2017-07-30 05:34 AM
Use external programs/scripts as part of the build process to construct data tables. These could be added to makefile, or User tab in Keil.
If you can code in C and do file functions, you can automate the construction of data tables in a compilable form.
2017-07-30 10:04 AM
You can also use the ST-Link utility to open you data set BIN file, and then write the data to a vacant area of Flash.
Access your data set by reading from flash directly.
For instance;
int DataRead = *((int*)(the address where you stored your data set in Flash, plus the offset into the data set);
2017-08-03 01:47 PM
So, there is no nature support for importing a binary file while compiling.
2017-08-03 02:00 PM
Compilers typically don't accept binary input, most linkers will only take native format object files. Some linkers can, or you can use BIN2OBJ type tools.
Have the tool generating the data output to an object file, or compilable C source. The latter requires a high-school level understanding of data representation, and basic C coding skills.
2017-08-04 01:05 AM
There are many ways to insert a binary into a memory space. One is to look at linker level options, sometime you can add a binary at a specific base address. Otherwise, you can create in the linker file a specific memory segment which you create as a constant pointer to refer to the start of this zone, erase, flash your user program, then without erasing, write the binary onto this particular space (erase and twice write to create the image).
Last, put your binary in Excel and create a simple string macro which convert your byte by byte binary into a C structure which you can copy paste into a C file to add to your project.
It depends how often this binary changes.
2017-08-04 01:14 AM
Yes.
https://github.com/Jeroen6/bin2c
bin2c -m -d .\data\data.h -o .\data\data.c '.\data\a.bin'�?