1

I want to put a string in the program memory of a pic18f. Inside this string I need specific values at some positions.

E.G.

rom const unsigned char date_const_array[]="Date:";

will place the string Date: inside program memory.

What I want is to insert to position 3 of the array the value 15 at compile time. If the array was in ram I could do:

date_const_array[3]=15;

inside main function. But since I do not want this array to be altered and I value my ram I want it to be placed inside rom.

How can I do it?

Thanks in advance

4

2 回答 2

1

You could embed 15 right in the string using escape sequences: "Dat\017:" (017 is an octal constant: 1*81+7*80=15).

于 2012-09-19T15:22:59.287 回答
0

试试这个,我想这会成功

rom const unsigned char date_const_array[]=__DATE__; // 许多编译器使用这种方式。

于 2013-01-18T12:46:54.547 回答