CCS News

Serial Numbering During Production Made Easier!

Thursday 06 April, 2017

Serializing devices in a production environment is simple and easy using the CCS C Compiler and the Prime8 Production Programmer. The CCS C Compiler allows for setting up serialization using the #serialize preprocessor directive. A serial number can be saved in binary or as a string, and can be stored in ROM or EEPROM if available.

This example shows a simple way to store a 32-bit binary serial number (4 bytes) in either EEPROM or ROM. The target device has 256 bytes of EEPROM and 32Kbytes of flash program memory, where the serial number is stored in the last 4 bytes of either depending on the defined location. The #ORG in the ROM variant is to reserve the program memory containing the serial number from being used elsewhere by the compiler.



Reading a binary serial number from memory is as simple as reading the raw data directly into a variable using a byte-pointer to that variable. In the example, a pointer is created to a 32-bit variable, which is used to index the raw data bytes. The result is the 32-bit number set by the programmer.

The serialization settings, or "burntime" settings, are saved in the hex file on compilation and are loaded into the Prime8's internal memory when writing the hex file to it. The initial serial number can then be set or changed on the job configuration screen.

Serial numbers are automatically incremented after each successful write, so each connected target will have a different serial number written to it.



To change the current serial number on the Prime8, select the Config button for the current job. On the Config screen, the file can be selected by touching the "Name/Location" setting, choosing "Internal Memory", and selecting the memory slot the file was written to. This will then show the file name and location on the Config screen. Touch the down arrow until the "Serial Number" setting is visible. Touch this setting to open a keypad where a new serial number can be entered. Once the number is entered, Press the Enter button to save the setting.



Now when the program is written to the targets, the serial number that was entered will be the first serial number written (in this case, 65536), and each successive target will have an incremented serial number (65537, 65538, ...). The number can always be changed or reset by changing the setting again under the job configuration screen.

Prime8 Production Programmer, visit: http://www.ccsinfo.com/product_info.php?products_id=P8_gang
CCS C Compilers, visit: http://www.ccsinfo.com/content.php?page=compilers


Like us on Facebook. Follow us on Twitter.

About CCS:

CCS is a leading worldwide supplier of embedded software development tools that enable companies to develop premium products based on Microchip PIC® MCU and dsPIC® DSC devices. Complete proven tool chains from CCS include a code optimizing C compiler, application specific hardware platforms and software development kits. CCS' products accelerate development of energy saving industrial automation, wireless and wired communication, automotive, medical device and consumer product applications. Established in 1992, CCS is a Microchip Premier 3rd Party Partner. For more information, please visit http://www.ccsinfo.com.

PIC® MCU, MPLAB® IDE, MPLAB® ICD2, MPLAB® ICD3 and dsPIC® are registered trademarks of Microchip Technology Inc. in the U.S. and other countries.