CCS C Software and Maintenance Offers
FAQFAQ   FAQForum Help   FAQOfficial CCS Support   SearchSearch  RegisterRegister 

ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 

CCS does not monitor this forum on a regular basis.

Please do not post bug Reports on this forum. Send them to support@ccsinfo.com

Set unique serial number

 
Post new topic   Reply to topic    CCS Forum Index -> General CCS C Discussion
View previous topic :: View next topic  
Author Message
sunny
Guest







Set unique serial number
PostPosted: Wed Jan 30, 2008 10:02 am     Reply with quote

Dear all,

I got a request to assign an unique serial number for each of my intrument. This number would be settable in firmware at the time of manufacture and can be read later on.

I'm using PIC18F452. And I'm thinking of creating a variable that can take input value through RS232 or other port, and then store it in the EEPROM. Is it a right approach to do it?

I'm just wondering is there a more convenient way to do it?

Thanks for any suggestion!
treitmey



Joined: 23 Jan 2004
Posts: 1094
Location: Appleton,WI USA

View user's profile Send private message

PostPosted: Wed Jan 30, 2008 10:21 am     Reply with quote

Do you have someone like arrow electronics burning these, or are you programming them yourself one at a time?
Look at #serialize. and #id
sunny
Guest







PostPosted: Wed Jan 30, 2008 10:46 am     Reply with quote

Hi treitmey, thanks for your reply.

For now I'm just programming it by myself because it's still in prototype stage. But later on as the volume goes up, I probably will ask the board house (maybe actually their supplier) to burn it. So what's the difference between these two?

Thanks for the key words, I'll check on them.
sunny
Guest







PostPosted: Wed Jan 30, 2008 10:54 am     Reply with quote

BTW, the serial number has a special format that is related to the manufacturing location (this would possible stays the same for me), and the date it's manufactured. So it's not simply an increment.
treitmey



Joined: 23 Jan 2004
Posts: 1094
Location: Appleton,WI USA

View user's profile Send private message

PostPosted: Wed Jan 30, 2008 11:47 am     Reply with quote

I don't do this but I guess I would put the checksum in the #id
Then put checksum and date and mfr# in the #serialize.
programming info
http://ww1.microchip.com/downloads/en/DeviceDoc/39576b.pdf
sunny
Guest







PostPosted: Wed Jan 30, 2008 12:35 pm     Reply with quote

Thanks again for your reply.

I'm still a bit confused. I think the benifit for using #serialization is that the serial number is stored in a designated location (for 18F452 it's 3FFFFFEh-3FFFFFh, from the datasheet you provided). But do I need to have CCS ICD to enter the serial number? I just tried it in MPLAB IDE 8.0, didn't get any prompt allowing me to enter the data. And guess I'll also need it to read it back?

So for now I'm just thinking of store it in EEPROM and use serial port to access to it. Thus later on back at the manufactory can enter the serial number without the need of IDE. Volume won't be big anyway, so should be able to do it one by one manually.

Thanks for your help!
treitmey



Joined: 23 Jan 2004
Posts: 1094
Location: Appleton,WI USA

View user's profile Send private message

PostPosted: Wed Jan 30, 2008 12:49 pm     Reply with quote

It looks like mplab (or more importantly ICD2) don't support the #serialize.
http://www.ccsinfo.com/forum/viewtopic.php?t=26152&highlight=serialize
nurquhar



Joined: 05 Aug 2006
Posts: 149
Location: Redditch, UK

View user's profile Send private message Visit poster's website

The Soloution
PostPosted: Fri Feb 01, 2008 12:22 am     Reply with quote

I use #serialise a lot with my applications as I often have over a 100 pics hanging off a half duplex RS485 bus, thus I needed a way of addressing one at a time using a unique address. I actually program my pics with a boot loader that uses the #serialise to give each a unique address. Thus my PC can find the address of each PIC on the RS485 bus and then load an application program to each. The application can still read the serial number as it is stored at a fixed address. In my case at the top of memory where the bootloader sits.

Arrow You need to get the MachX programmer from CCS, it supports the #serialise option from within the code. What actually happes is when CCS compiles and see's a #serialise directive it puts some relavant comments at the end of the hex file. Thus regular programmmers like your ICD2 etc will just ignore them. However the MachX programmer app on the PC will read the comments and patch the program it loads from the hex with the next serial number. It will update a text file to keep track of your last serial number and you can have log file to track of when each number was programmed.

The CCS ICD unit might also work with #serialise, check with them if it does.

The other soloution which I used prior to getting my MachX was to have C prog on the PC read the hex file from CCS, look at the #serrialise comments at the end and then patch the hex file with the next serial number. You need to fix the csum at the end of each line of hex. This was a bit clunkey as I had to manualy run the prog after each burn.
asmboy



Joined: 20 Nov 2007
Posts: 2116
Location: albany ny

View user's profile Send private message AIM Address

thats what flash ram is for
PostPosted: Mon Feb 04, 2008 5:33 pm     Reply with quote

i serialize F887's all the time - using serial port comm and un documented commands in the product's command set

during test - unique serilaization is loaded in by RS232 and set / retreived by a code snippet

thats assuming you can dedicate a bit of flash RAM to the purpose
nurquhar



Joined: 05 Aug 2006
Posts: 149
Location: Redditch, UK

View user's profile Send private message Visit poster's website

PostPosted: Tue Feb 05, 2008 2:14 am     Reply with quote

Thats interesting, do you have any examples or info on how to use the "un-documented" features ?
asmboy



Joined: 20 Nov 2007
Posts: 2116
Location: albany ny

View user's profile Send private message AIM Address

undocumented command you create
PostPosted: Tue Feb 05, 2008 8:17 am     Reply with quote

by undocumented command i mean - serial cmds you create for the device that are undocumented - - lets say you have serial cmds like RUN STOP READ etc - you also add a cmd - undocumented to the user - like SID=123456 which your program uses to WRITE that serial # or $ to flash ram - then the DOCUMENTED cmd GID? returns the 123456 by reading the same flash ram location - the SID value is set at test - via serial services and voila - you are serialized -
MikeW



Joined: 15 Sep 2003
Posts: 176
Location: Warrington UK

View user's profile Send private message

PostPosted: Tue Feb 05, 2008 12:18 pm     Reply with quote

I am also using the "undocumented" special command in my command parser routines.

at firmware blow into the pic, the serial number =0

a special undocumented command, say SID=1234 would write the serial number to eeprom.

It can be read using say GID? command.

if the serial number has previously been written ( so its non-zero), then any further SID=XXX returns an error to the user.

the command GID? still works of course.

I have set up a structure for all of my data that needs to be stored in eeprom, so its a simple matter of writing the whole structure to eeprom.

hope this helps

Mike
ckielstra



Joined: 18 Mar 2004
Posts: 3680
Location: The Netherlands

View user's profile Send private message

PostPosted: Tue Feb 05, 2008 5:19 pm     Reply with quote

One thing I've missed in the above discussion is 'when' do you want to set the serial number? At production time or when shipping the product? For small quantities this is not a problem but when your quantities get higher this will be a time/cost factor and you likely want to program the number at production time.

Microchip uses a serial number system with external data files called Serial Quick Turn Programming (SQTPSM). Search the internet for 'SQTP' or 'SQTPSM' and you will find many programmers capable of serialization.

Some programmers capable of programming a serial number and available at MicrochipDirect:
    - CCS Mach-X programmer, either by ZIF-socket or in-circuit. Works only in CCS IDE. US$199
    - Microchip MPLAB PM3, either by ZIF-socket or in-circuit. Works with MPLAB or stand alone. Write serial numbers using SQTP files. US$895
    - SoftLog ICP2. A production quality ICSP programmer. Works with MPLAB or stand alone. US$399
    - SoftLog ICP2GANG-D. Similar to ICP2 but can program 4 chips simultaneously (expandable to 64). US$1299
kender



Joined: 09 Aug 2004
Posts: 768
Location: Silicon Valley

View user's profile Send private message Send e-mail Visit poster's website Yahoo Messenger

PostPosted: Thu Mar 20, 2008 2:20 am     Reply with quote

Quick & dirty method of hacking the serial number (s/n) into the PIC using ICD-U40. It does not require any code for writing the s/n (like serial command interpreter). This method uses “One Word” feature of the ICD-U40 and read_program_memory()

1. Compile your code.
2. Look at the HEX file. Find the largest program address. Description for the Intel HEX format can be found here: http://www.keil.com/support/docs/1584.htm
3. Add read_program_memory() to the code. Specify the address to read considerably larger than the max program address.
4. Compile again.
5. Download. Gotcha - this method doesn’t work with debugging.
6. Start the ICD Control Program (mine is V2.92). Click “Advanced…”. Click “One Word”
7. Specify the same address that read_program_memory() will read at run time. Specify the s/n. It’s a 16-bit number.
8. Click write
_________________
Read the label, before opening a can of worms.
Display posts from previous:   
Post new topic   Reply to topic    CCS Forum Index -> General CCS C Discussion All times are GMT - 6 Hours
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum


Powered by phpBB © 2001, 2005 phpBB Group