Serial number inclusion

キャンセル
次の結果を表示 
表示  限定  | 次の代わりに検索 
もしかして: 

Serial number inclusion

3,397件の閲覧回数
UtopiaTim
Contributor III
Hi Folks,
 
The project that I am currently working on requires a serial number
to be transferred out of the unit via USB.  All of the USB stuff is done, and
a serial number that I place in RAM using the following code works great.
 
unsigned char serial_number[5] = {0x00,0x00,0x03,0xe9,0xf3};
 
I know that P&E has a program that I can use to serialize the unit, but I am
at a loss as how to set up the location in flash.  It would have to be a
'hard wired' location that I know the actual addresses of.
 
How can I set that up in C?

Thanks,
 
Tim
ラベル(1)
0 件の賞賛
返信
6 返答(返信)

1,593件の閲覧回数
Ake
Contributor III
Hi,
In CodeWarrior's version of C, you write
 
const unsigned char serial_number[5] = {0x00,0x00,0x03,0xe9,0xf3};
 
to get the string in readonly memoory.
 
I am not sure if this can be done with the P&E C-compiler.
 
Regards,
Ake
0 件の賞賛
返信

1,593件の閲覧回数
bigmac
Specialist III
Hello Tim,
 
I presume you are actually using the CW compiler.  If so, the following method seems to produce the expected result.
 
Firstly you need to define a specific segment within the .PRM file to contain the serial number value, that is not used by any other code.  For example, the following would be suitable for a QG8 device (obviously not the device you are using) -
    SER_NUM =  READ_ONLY    0xE000 TO 0xE00F;
    ROM     =  READ_ONLY    0xE010 TO 0xFFAD;
 
The serial number array could then be defined as follows -
const unsigned char serial_number[5] @0xE000 = {0x00,0x00,0x03,0xe9,0xf3};
 
Regards,
Mac
 
0 件の賞賛
返信

1,593件の閲覧回数
UtopiaTim
Contributor III
Hi Mac,
 
Thanks for the info.
 
I set up the .PRM file with the addresses that I wanted to be able to store
the data to, but under the definitions that you suggested, I don't want the
compiler to pre-assign values, I want the P&E serializer program to be able
to write directly to the flash with the serial number they provide (through their
program).
 
Of course, I want to be able to reference it in the software, perhaps I only
need to do the following??
 
const unsigned char serial_number[5] @ 0xFF00;
 
Thanks,
 
Tim
0 件の賞賛
返信

1,593件の閲覧回数
bigmac
Specialist III
Hello Tim,
 
Using FCS for testing purposes, it would appear that the compiler does initialise each element of the array to 0x00 by default - not what you require.  You might try explicit initialisation to a value of 0xFF, the unprogrammed flash state, and see if this can be made to work in conjunction with the serialize utility.
 
Regards,
Mac
 
0 件の賞賛
返信

1,593件の閲覧回数
CompilerGuru
NXP Employee
NXP Employee
This should work:

Code:
unsigned char serial_number[5] @ 0xFF00;

 or the ANSI-C version:

Code:
#define serial_number (*(const unsigned char*)0xFF00)

 
Daniel
0 件の賞賛
返信

1,593件の閲覧回数
UtopiaTim
Contributor III
Hi Mac & all,
 
That's how I did it - initialized it to ff's, & then the P&E standalone serialize program
could program those ff's to the new serial number. (given the absolute address in memory, etc)
 
Thanks again to all!
 
Tim
0 件の賞賛
返信