CCS C Software and Maintenance Offers
FAQFAQ   FAQForum Help   FAQOfficial CCS Support   SearchSearch  RegisterRegister 

ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 

CCS does not monitor this forum on a regular basis.

Please do not post bug reports on this forum. Send them to support@ccsinfo.com

Reading Unique Device Identifier (UDID) from dsPIC33

 
Post new topic   Reply to topic    CCS Forum Index -> General CCS C Discussion
View previous topic :: View next topic  
Author Message
pebbert9



Joined: 31 Dec 2010
Posts: 36

View user's profile Send private message

Reading Unique Device Identifier (UDID) from dsPIC33
PostPosted: Thu Dec 23, 2021 6:20 pm     Reply with quote

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

View user's profile Send private message

PostPosted: Fri Dec 24, 2021 5:02 am     Reply with quote

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: 36

View user's profile Send private message

PostPosted: Thu Dec 30, 2021 7:22 pm     Reply with quote

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: 9081
Location: Greensville,Ontario

View user's profile Send private message

PostPosted: Thu Dec 30, 2021 7:52 pm     Reply with quote

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: 19195

View user's profile Send private message

PostPosted: Fri Dec 31, 2021 1:27 am     Reply with quote

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.
Display posts from previous:   
Post new topic   Reply to topic    CCS Forum Index -> General CCS C Discussion All times are GMT - 6 Hours
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum


Powered by phpBB © 2001, 2005 phpBB Group