PDA

View Full Version : Reading Device ID from within PBP



Charles Linquis
- 24th February 2007, 17:23
I need to determine the chip type I'm running in, as well as the oscillator configuration. I seem to vaguely remember a thread on reading the configuration bytes and the Device ID from within PBP, but a search turns up nothing. Could someone please tell me where to look?

mister_e
- 24th February 2007, 17:35
mmm, i think some part of it are available... but for 18Fs

i think you refer to the following...
http://www.picbasic.co.uk/forum/showthread.php?t=4093

Charles Linquis
- 24th February 2007, 17:50
Thanks. That is what I was looking for. I only work with 18F parts, so this should do it.

Thanks to you (and Darrel)

Charles Linquist

mister_e
- 24th February 2007, 17:53
I just opened the 18F4550.inc file...look what you got at the end of...


_DEVID1 EQU H'3FFFFE'
_DEVID2 EQU H'3FFFFF'

_IDLOC0 EQU H'200000'
_IDLOC1 EQU H'200001'
_IDLOC2 EQU H'200002'
_IDLOC3 EQU H'200003'
_IDLOC4 EQU H'200004'
_IDLOC5 EQU H'200005'
_IDLOC6 EQU H'200006'
_IDLOC7 EQU H'200007'


Sure there's something to do with it...

mister_e
- 24th February 2007, 18:19
yes indeed that was simple to read the PIC ID using one part of the Darrel's code and a 18F4680


' READING pic18f4680 DEVICE ID
'
DEFINE OSC 20
DEFINE LOADER_USED 1
DEFINE HSER_RCSTA 90h ' Enable serial port & continuous receive
DEFINE HSER_TXSTA 24h ' Enable transmit, BRGH = 1
DEFINE HSER_SPBRG 129 ' 9600 Baud @ 20MHz, 0.16%
DEFINE HSER_CLROERR 1 ' Clear overflow automatically
ID1 var byte
ID2 var byte
GOTO START

@ #include "RTconfig.inc"

START:
@ ReadConfig?CB _DEVID1, _ID1
@ ReadConfig?CB _DEVID2, _ID2
HSEROUT ["DEVID1=",HEX ID1," DEVID2=",HEX ID2]
STOP

Serial communicator show...


DEVID1=82 DEVID2=0E

Using a my programmer to read the device, i have...


L0100: >> 24.02.2007, 13:10:13
L0101: Reading device: Microchip PIC18F4680.
L0102: Device insertion test ...
L0103: Checking device ID ...
L0104: Device ID: DEVID2=0Eh DEVID1=82h
L0105: Reading device ...
L0106: Verifying device at VCCmax. ...
L0107: Verifying device at VCCmin. ...
L0108: Reading device - done.
L0109: Elapsed time: 0:00:30.6
L0110: Buffer checksum in range of device [0h..7FFFh]: 00FD3D23h

Somehow interesting. i bet you will be able to change and create your own device ID in the ID locations at run time as well. Nice place to save the software version...

nomad
- 20th October 2007, 03:05
Along with erasing osccal values, some of the free software or maybe a glitch has managed to erase the device id as well. i have a few pics that show up as unknown. I'm quickly becoming an expert on what NOT to do. lol.