MUI (Microchip Unique Identifier)

Coding and general discussion relating to the compiler

Moderators: David Barker, Jerry Messina

Post Reply
animo3d
Posts: 24
Joined: Sun Sep 18, 2011 6:02 am
Location: Monterrey Mexico

MUI (Microchip Unique Identifier)

Post by animo3d » Mon May 30, 2022 7:51 pm

Hello,

Does anyone has information on how to read the MUI (Microchip Unique Identifier) on the Q41 Family?

Thanks in advance...

Sergio de la Peña

Jerry Messina
Swordfish Developer
Posts: 1469
Joined: Fri Jan 30, 2009 6:27 pm
Location: US

Re: MUI (Microchip Unique Identifier)

Post by Jerry Messina » Tue May 31, 2022 11:22 am

The DIA is located in the program memory space. Since it's read-only you should be able to access it using the TBLPTR like so:

Code: Select all

device = 18F16Q41

// read the Q41 DIA area located in program memory space
// MUI0-MUI8 (9 words, 18 bytes) from $2C0000-$2C0011

// set tableptr address
inline sub set_flash_addr(addr as longword)
    TBLPTRU = addr.bytes(2)
    TBLPTRH = addr.bytes(1)
    TBLPTRL = addr.bytes(0)
end sub

// read byte at TBLPTR
inline function TBLRD_() as TABLAT
    asm-
        TBLRD*
    end asm
end function

// read byte at TBLPTR and increment ptr
inline function TBLRD_POSTINC() as TABLAT
    asm-
        TBLRD*+
    end asm
end function

dim mui(18) as byte
dim i as byte

// set tableptr to point to the Q41 MUI area
set_flash_addr($2C0000)

// read 18 bytes
for i = 0 to bound(mui)
    mui(i) = TBLRD_POSTINC()
next

// must set TBLPTRU back to 0 when done
set_flash_addr(0)

animo3d
Posts: 24
Joined: Sun Sep 18, 2011 6:02 am
Location: Monterrey Mexico

Re: MUI (Microchip Unique Identifier)

Post by animo3d » Tue May 31, 2022 5:33 pm

Thanks Jerry, you are the Man!!!

Sergio

Post Reply