PDA

View Full Version : How to read Serial number programmed into PIC



freddayz
- 16th April 2008, 21:38
Hello to all,

Is there a method "i assume there is" to read a programmed serial number value from a PIC?

Darrel Taylor
- 16th April 2008, 22:06
That depends.

16F's can NOT read the serial number at Run-Time.
They can only be read by an ICSP Programmer.

18F's CAN read the numbers at run-time.

If you have PBP2.50, it can be read with READCODE.
If you have a prior version of PBP, you can use this ...

Run-Time Config
http://www.picbasic.co.uk/forum/showthread.php?t=4093
<br>

mister_e
- 16th April 2008, 22:08
ok... i'd misread the post... once again ;)
<hr>
maybe not after all... do you mean in your PIC code or with YOUR PIC programmer?

tenaja
- 17th April 2008, 23:28
Hello to all,

Is there a method "i assume there is" to read a programmed serial number value from a PIC?

I believe the other guys are off here. The programmer allows you to change any memory position at all, during programming. That way you can set a random value in your code, and change it to a specific serial number when you program. For instance, you can set "x=123" in your code, and look at where the MOVW 123 command is in the asm file, and change that to your new serial number.

Darrel Taylor
- 17th April 2008, 23:57
Yup, I was thinking of the wrong thing. :o

tenaja has the right idea.
<br>

falingtrea
- 18th April 2008, 15:44
The picture he put in comes from the meprog application. The help file has this table:

Device Type Code Data EEPROM ID
Address Address Address
12-bit core 0-1FF none 200-203
0-3FF none 400-403
0-7FF none 800-803
14-bit core 0-1FFF 2100-21FF 2000-2003
17Cxxx 0-3FFF none none
18Xxxxx 0-1FFFF F00000-F003FF 200000-200007
24FJxxx 0-157FE none none
24HJxxxx 0-2ABFE none F80010-F80016
30Fxxxx 0-17FFE 7FF000-7FFFFE none
33FJxxxx 0-2ABFE none F80010-F80016

From one of the data sheets for a 14 bit core I got this:

13.10 ID Locations
Four memory locations (2000h - 2003h) are designated as ID locations where the user can store checksum or other code identification numbers. These locations are not accessible during normal execution, but are readable and writable during program/verify. It is recommended that only the four least significant bits of the ID location are used.

So the answer to his question is that the locations programmed by the meprog serial number function are only accessable during program/verify.

tenaja
- 18th April 2008, 16:35
Tim, I believe you are mixing up two unrelated features with two different products.

Yes, the picture comes from meprog; I am aware of this because I have it. The meprog allows you to program that incrementable "serial number" into any location you wish. You may program it into the "run-time unreadable" PIC ID Location if you want--but you don't have to! If you want to read it during run-time, then it would be advisable to find a different location to program the serial number to. Again, Meprog allows you to specify any location in memory. The last memory location (or near it) is an easy one, since you can be certain you aren't overwriting code (unless you have a bootloader).

Just because the PIC has a "serial number/ID" location does not mean you have to program the meprog "serial number" into that location. They are two entirely separate--yet compatible--features in two different products.

falingtrea
- 18th April 2008, 19:58
Now I'm confused. I ran MeProg and looked everywhere, including the ini file and could not find anything about changing the location where the serial number is programmed, when using the automatic Serial Numbering option. I agree that you could put the serial number anywhere, but my point is that MeProg seems to hard code the Serial Number function to the ID memory locations. I am using the beta version of the software, which may or maynot make a difference.

tenaja
- 18th April 2008, 20:11
Look at the JPG in the original post. The third textbox is "Starting Address." Not only do you get to select where the serial number goes, but you get to select the size of it, too.

freddayz
- 21st April 2008, 17:36
Tenaja,

So there is indeed a way to read the programmed Serial number during run time. Can you show me an exmaple on how to read it? I am a rookie at reading EEPROMS from PIC's.

Thanks-N-Advance - Freddayz

tenaja
- 22nd April 2008, 02:36
I have done it with a different compiler, the commands will not be the same in PBP.
Since MELabs makes PBP and the programmer, I think a short call to them will get you a trustworthy answer.