1. This site uses cookies. By continuing to use this site, you are agreeing to our use of cookies. Learn More.

Electronics Reading a PIC Device ID

Discussion in 'Modding' started by paul_s57, 31 Aug 2008.

  1. paul_s57

    paul_s57 What's a Dremel?

    Joined:
    23 Dec 2005
    Posts:
    50
    Likes Received:
    0
    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.
     
  2. Hazer

    Hazer In time,you too will be relixalated

    Joined:
    14 Apr 2003
    Posts:
    957
    Likes Received:
    2
    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.
     
  3. SteveyG

    SteveyG Electromodder

    Joined:
    23 Nov 2002
    Posts:
    3,049
    Likes Received:
    8
    Hazer is correct, you can read these bits using the EEPROM pointers.
     
  4. paul_s57

    paul_s57 What's a Dremel?

    Joined:
    23 Dec 2005
    Posts:
    50
    Likes Received:
    0
    Thanks for the posts guys, I got it working fine now.
     

Share This Page