PDA

View Full Version : How to embed user ID into PIC



Pic2008
- 8th February 2009, 14:39
I would like to know how to embed the user ID using PBP? Can I use poke above memory 1FFFH?

Acetronics2
- 8th February 2009, 15:16
Hi,

From µChip MPLAB Programmers HELP :



ID Location : Program or verify the User ID. You can set the User ID by selecting Configure>ID Memory.


From '628 Datasheet



14.10 User ID Locations
Four memory locations (2000h-2003h) are designated
as user 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.
Only the Least Significant 4 bits of the user ID locations
are used for checksum calculations although each
location has 14 bits.


I'd recommend you to read The MPASM Help chapter relative to "__idlocs" ...

I will become obvious for you, then ... even if you have a "non µChip" programmer.

Alain

mister_e
- 8th February 2009, 16:09
Déja-vue

Writing User ID
http://www.picbasic.co.uk/forum/showthread.php?t=7644&

Acetronics2
- 8th February 2009, 16:16
deuhhh, yes there's an easier way.... Always nice to read MPASM PDF


Wasn't it called " RTFM " in the good ol' Forum times ...

Quand la censure ne coupait pas systématiquement tout ce qui pouvait ressembler à de l'humour ...

Mheuuuuunoon, je l'ai pas dit ...

Alain

mister_e
- 8th February 2009, 16:56
:D hasquetèkon :D

Ioannis
- 9th February 2009, 09:09
Now I would ask, how do you read these ID location in PBP?

Ioannis

mister_e
- 9th February 2009, 17:07
From MPASM

Usage
This directive is used in the following types of code: absolute or relocatable. For information on types of code, see Assembler Operation.

This directive is not commonly used, but does provide an easy method of serializing devices. __idlocs can be read by a programmer. PIC18 devices can read this value at run-time, but PIC12/16 devices cannot.


For PIC18, I guess Darrel have the right ticket for that. Something based around the following
http://www.picbasic.co.uk/forum/showthread.php?t=4093

mister_e
- 9th February 2009, 17:29
I found this snip on Microchip website

// read serial number from PIC ID memory at address 0x200000 - 0x200007
DWORD ReadIDMemory(void) {
DWORD IdMemory=0;
DWORD Temp;
BYTE i;
TBLPTR = (unsigned short long) 0x200000;

for(i=0;i<8;i++) {
_asm
TBLRDPOSTINC
_endasm
Temp=TABLAT;
Temp<<=((7-i)*4);
IdMemory+=Temp;
}

return IdMemory;
}

Ioannis
- 10th February 2009, 11:57
I find these a little complicated and limited to 18 series.

My good old programmer, (ELNEC PIKprog+), is doing this serialization in a very good manner. Also gives an option where to store the serial number, so one can choose to store in EEPROM or Code space. Reading then is childs play.

Ooh, and it counts automatically of course with programmable step.

I'd like though to have this option on my ICD2. Maybe one day Microchip will do it. Hope I am alive then!

Ioannis

mister_e
- 10th February 2009, 16:26
It is limited to PIC18 only if you want to access it at RunTime, unless most programmer are capable of reading the IDLOCS. And as you say, some also offer the automatic serialization, a nice plus.

Pic2008
- 11th February 2009, 13:12
Alright, I manage to get it to work now. Thanks for the info guys.