View previous topic :: View next topic |
Author |
Message |
pebbert9
Joined: 31 Dec 2010 Posts: 39
|
Reading Unique Device Identifier (UDID) from dsPIC33 |
Posted: Thu Dec 23, 2021 6:20 pm |
|
|
I need to read the Unique Device Identifier (UDID) from a DSPIC33CK32MP502.
The datasheet says the The UDID comprises five 24-bit program words which are stored in five read-only locations, located between 0x801200 and 0x801208 in the device configuration space.
I can find 3 potential CCS commands that might read these locations.
read_config_info()
read_configuration_memory( )
read_device_info( )
Each one can accept an offset memory location to start reading from.
Which command would read these memory locations and would I need an offset?
Thank you, |
|
|
PCM programmer
Joined: 06 Sep 2003 Posts: 21708
|
|
Posted: Fri Dec 24, 2021 5:02 am |
|
|
The CCS example code in the manual implies read_device_info() can do it:
Code: | unsigned int16 identifier[9];
read_device_info(identifier, 18); // reads Unique Identifier from DIA memory.
|
Their example shows no offset, so try it that way first. |
|
|
pebbert9
Joined: 31 Dec 2010 Posts: 39
|
|
Posted: Thu Dec 30, 2021 7:22 pm |
|
|
It turns out that none of those commands work with this chip.
You can read the the code with this but you need to discard every 4th byte after reading
Code: | read_program_memory(0x801200, rData, 20); |
|
|
|
temtronic
Joined: 01 Jul 2010 Posts: 9241 Location: Greensville,Ontario
|
|
Posted: Thu Dec 30, 2021 7:52 pm |
|
|
Sounds correct, pretty sure that PIC is 32-bit based but only 24 bits are used.
Others will know that use it...just something I see here every so often.... |
|
|
Ttelmah
Joined: 11 Mar 2010 Posts: 19537
|
|
Posted: Fri Dec 31, 2021 1:27 am |
|
|
Yes.
Key here is that the UDID, is not the normal 'device ID' that the device_info
command is designed to read. This doesn't exist on this chip.
As you have found it simply has to be read directly from the program
memory. What you read then is five 32bit words, containing the ID in
the low 24bits of each word.
The read_configuration_memory function will also access this, but because
it is offset from the start of the calibration memory itself, it is actually harder
than just using the read_program_memory function as you already show. |
|
|
|