View previous topic :: View next topic |
Author |
Message |
KentR
Joined: 21 Jun 2010 Posts: 11
|
Reading User ID with a PIC16LF15344 [SOLVED] |
Posted: Wed Nov 28, 2018 8:21 am |
|
|
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
|
|
Posted: Wed Nov 28, 2018 8:48 am |
|
|
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: 19515
|
|
Posted: Wed Nov 28, 2018 9:39 am |
|
|
Remember the count for read_configuration_memory, is in bytes.
Two bytes per word..... |
|
|
KentR
Joined: 21 Jun 2010 Posts: 11
|
|
Posted: Wed Nov 28, 2018 10:11 am |
|
|
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
|
|
Posted: Wed Nov 28, 2018 10:40 am |
|
|
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: 19515
|
|
Posted: Wed Nov 28, 2018 11:21 am |
|
|
|
|
|
|