• AVR Freaks

Read Device-ID in Hitech-C with PIC 16F182x

Author
gga
New Member
  • Total Posts : 20
  • Reward points : 0
  • Joined: 2013/02/24 06:38:32
  • Location: 0
  • Status: offline
2013/03/06 06:13:51 (permalink)
0

Read Device-ID in Hitech-C with PIC 16F182x

Hi,
there is a function described called device_id_read, but Hitech-C linker complains about undefined symbol.
Any hint to get device ID on those PICs are welcome !
thanks
#1

2 Replies Related Threads

    PaulEccles
    New Member
    • Total Posts : 2
    • Reward points : 0
    • Joined: 2013/03/05 18:07:12
    • Location: 0
    • Status: offline
    Re:Read Device-ID in Hitech-C with PIC 16F182x 2013/03/20 21:10:07 (permalink)
    0
    I just had the same problem and found a solution in a different forum thread. This seems to be working for me, but I'm using a PIC18F so you made need to modify it.

    //------------------------------------------------------------------------------
    // This replaces the old PICC18 "device_id_read" function which seems to have disappeared.
    // Code taken from Microchip forum thread "config_read() macro for XC8 ?"
    unsigned int readDeviceID(void) 
    {    
    // config bits on PIC18F46K80 start at 300000h    
    auto unsigned char devID1, devID2;       
     
    TBLPTRU = 0x3F;    
    TBLPTRH = 0xFF;    
    TBLPTRL = 0xFE;    
    asm( "TBLRD" );    
    devID1 = TABLAT;        
     
    TBLPTRL = 0xFF;    
    asm( "TBLRD" );    
    devID2 = TABLAT;        
     
    return (((unsigned int)devID2 << 8) | devID1);




    #2
    1and0
    Access is Denied
    • Total Posts : 9314
    • Reward points : 0
    • Joined: 2007/05/06 12:03:20
    • Location: Harry's Gray Matter
    • Status: offline
    Re:Read Device-ID in Hitech-C with PIC 16F182x 2013/03/21 06:20:57 (permalink)
    0
    gga
    there is a function described called device_id_read, but Hitech-C linker complains about undefined symbol.
    Any hint to get device ID on those PICs are welcome !
    Convert the assembly example in the datasheet to C.
    #3
    Jump to:
    © 2019 APG vNext Commercial Version 4.5