Serial number inclusion

cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 

Serial number inclusion

2,463 Views
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
Labels (1)
0 Kudos
Reply
6 Replies

659 Views
Ake
Contributor II
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 Kudos
Reply

659 Views
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 Kudos
Reply

659 Views
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 Kudos
Reply

659 Views
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 Kudos
Reply

659 Views
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 Kudos
Reply

659 Views
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 Kudos
Reply