Hi, I am currently working with a PIC18F452, however that is not to say that In the future that I might want to change / have to change processor. Thus I decided it would be a good idea to have a function which can read the device ID of the processor. After looking in the Datasheet Clicky Here (Page 251) I see that there are 2 fields which hold the Processor ID and Processor Revision but I can't seem to read these bits. I am working in C, and looking in the linker scripts etc, there are no definitions to read these fields like you would a normal register, and I didn't seem to have any success reading directly from the address. So I was just wondering if these fields are protected, or something so you can't read them. Or I am being thick and missed something. If anybody has done this before I would be grateful of info on how you managed it. Thanks in advance.
The device ID is the last part of the configuration bits. Normally, these are only accessed in program mode (as in when you flash the program to the chip and make your fuse settings for ocs type, code protection, etc). In this chip, this area is still accessable using the EEPROM FLASH read/write module. Parusing through the datasheet, I found that on pg. 249 you need to do a table read of the program flash memeory. On page 73 shows how to do the table read and you simply enter in 3FFFFE and 3FFFFF as the address. If you still have questions, download the 18F refference manual. The refference manual for each family gives much better descriptions of the common features of all of the chips with example code.