Serial Number in PIC Basic Pro


Closed Thread
Results 1 to 9 of 9

Hybrid View

  1. #1
    Join Date
    Mar 2009
    Location
    Colorado
    Posts
    378


    Did you find this post helpful? Yes | No

    Default Re: Serial Number in PIC Basic Pro

    Quote Originally Posted by mister_e View Post
    There's MPASM __idlocs who allow to do it like so, for 16F you can have an ID from 0 to 0xFFFF, just use this simple line in your code
    Code:
    @ __idlocs 0xffff
    However, you can't read it at run time, only 18F can
    [code]
    Steve, I would appreciate an explanation of how this works...does @_idlocs XXXXXX automatically read the TBLPTRx addresses from addresses 200000-20000h in an 18F MCU and put it into EEPROM or what? I have been doing this by the use of below code. If they are equivalent, your ASM single line of code is definitely preferable!
    Regards and extremely glad to see you back in the forum and contributing, John Ellis

    'Read MCU Serial Number from device ID Locations
    TBLPTRU=$20 ' Address $200000
    TBLPTRH=$00
    TBLPTRL=$00
    For i = 0 To 7
    @ TBLRD*+ ; Get value and increment the address
    ID(i) = TABLAT ; Store the byte as ID(i)
    Next
    deviceID1 = ID(0) ' MSB of MCU Device Serial Number
    deviceID2 = ID(1) ' LSB of MCU Device Serial Number
    WRITE 240, ID(0) ' Write serial number to EEPROM
    WRITE 241, ID(1)
    Last edited by jellis00; - 20th July 2011 at 00:55.

  2. #2
    Join Date
    Sep 2004
    Location
    montreal, canada
    Posts
    6,898


    Did you find this post helpful? Yes | No

    Default Re: Serial Number in PIC Basic Pro

    the idlocs line is an MPASM directive, it does the job at compile time. it store the value in a specific PIC location.. kinda black magic Check the MPASM user guide for all the details.
    Steve

    It's not a bug, it's a random feature.
    There's no problem, only learning opportunities.

Members who have read this thread : 0

You do not have permission to view the list of names.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts