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 CCS Technical Support

Reading User ID with a PIC16LF15344 [SOLVED]

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



Joined: 21 Jun 2010
Posts: 11

View user's profile Send private message

Reading User ID with a PIC16LF15344 [SOLVED]
PostPosted: Wed Nov 28, 2018 8:21 am     Reply with quote

I would like to read the 4 User ID registers of a PIC16LF15344. The register values are entered during programming, using the CCSLOAD application. I am entering a byte value (max value of 0xFF) into each of the 4 registers.

I would then like to read the values in software. I am using the following code below, to read the values. I get correct results for the first two registers (picUserId[0] and picUserId[1]). But the last two registers never show the correct value. Has anyone else run into this? Is there something else I am missing? Thanks for any advice!
Code:

void ReadDeviceId(void)
{
WORD picUserId[4];

read_configuration_memory(picUserId, 4);

UniqueDeviceId_Lsb = (BYTE)picUserId[0];
UniqueDeviceId_Mid1 = (BYTE)picUserId[1];
UniqueDeviceId_Mid2 = (BYTE)picUserId[2];
UniqueDeviceId_Msb = (BYTE)picUserId[3];
}


Last edited by KentR on Wed Nov 28, 2018 10:45 am; edited 1 time in total
PCM programmer



Joined: 06 Sep 2003
Posts: 21708

View user's profile Send private message

PostPosted: Wed Nov 28, 2018 8:48 am     Reply with quote

Make a test program that writes unique values to each register with
the write_configuration_memory() function. Then read them back
with read_configuration_memory().

If it works, then CCSload may be the problem.
Ttelmah



Joined: 11 Mar 2010
Posts: 19539

View user's profile Send private message

PostPosted: Wed Nov 28, 2018 9:39 am     Reply with quote

Remember the count for read_configuration_memory, is in bytes.
Two bytes per word.....
KentR



Joined: 21 Jun 2010
Posts: 11

View user's profile Send private message

PostPosted: Wed Nov 28, 2018 10:11 am     Reply with quote

Ttelmah wrote:
Remember the count for read_configuration_memory, is in bytes.
Two bytes per word.....


I did not realize this. So I will need the read count to be 8, then. Thanks.
KentR



Joined: 21 Jun 2010
Posts: 11

View user's profile Send private message

PostPosted: Wed Nov 28, 2018 10:40 am     Reply with quote

Ttelmah wrote:
Remember the count for read_configuration_memory, is in bytes.
Two bytes per word.....


Just tested and that was indeed the problem. I'll put the corrected code below. It is now correctly reading the low byte of each of the 4 User ID registers. Thanks again.
Code:

void ReadDeviceId(void)
{
unsigned int8 picUserId[8];

read_configuration_memory(picUserId, 8);

UniqueDeviceId_Lsb = picUserId[0];
UniqueDeviceId_Mid1 = picUserId[2];
UniqueDeviceId_Mid2 = picUserId[4];
UniqueDeviceId_Msb = picUserId[6];
}
Ttelmah



Joined: 11 Mar 2010
Posts: 19539

View user's profile Send private message

PostPosted: Wed Nov 28, 2018 11:21 am     Reply with quote

Very Happy
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