• AVR Freaks

AnsweredHot!Truncation when setting PIC ID Locations

Author
edware
Starting Member
  • Total Posts : 33
  • Reward points : 0
  • Joined: 2009/01/04 22:41:19
  • Location: 0
  • Status: offline
2019/06/23 21:21:22 (permalink)
0

Truncation when setting PIC ID Locations

XC8 V2.0 MPLABX 5.20, PIC16F15344
 
Hi
I would like to place some data in the four IDLOC words in our PIC16F1534x devices - for product/ batch identification in the future.
Using the method below, we are unable to assign  more than 7 bits to each ID location, despite the part having 14 bits at each location. Ideally we'd like to be able to utilize all 14 bits.
 
Example:
#pragma config IDLOC3 = 0x0123
Compiler responds with:
version.c:9:: warning: (1388) configuration setting/register of "IDLOC0" with 0x123 will be truncated by 0x7F
 
From the XC8 manual:
"....If value is larger than the maximum value allowable for each location on the target device, the value will be truncated and a warn-ing message is issued...."
 
Can anyone suggest a way to set all 14 bits of each of the ID locations, which is performed automatically (as opposed to entering the data manually) ?
 
Thanks
Ed
 
 
#1
edware
Starting Member
  • Total Posts : 33
  • Reward points : 0
  • Joined: 2009/01/04 22:41:19
  • Location: 0
  • Status: offline
Re: Truncation when setting PIC ID Locations 2019/06/23 22:02:49 (permalink)
+2 (2)
I managed to assign all 14 bits of each ID Location using the code below.
Note that this method allows me to assign 16 bits, and MLABX shows all 16 bits in the IDE. No warning is given but the programming of 14 bits proceeds as expected - truncating the upper 2 bits.
I think this method, when used with an #assert directive will do all I need.
Hope this post helps others.
 
#define NODE "S"
 
#define VERSION 0x19
 
#define __ILOC(a,b,c,d) \
  __asm("\tpsect idloc,class=IDLOC,delta=2");\
  __asm("\tdw\t" ___mkstr(a) "," ___mkstr(b) "," ___mkstr(c) "," ___mkstr(d))
 
__ILOC(NODE, 0, VERSION, 0xffff);


 
post edited by edware - 2019/06/23 22:04:04

Attached Image(s)

#2
1and0
Access is Denied
  • Total Posts : 9314
  • Reward points : 0
  • Joined: 2007/05/06 12:03:20
  • Location: Harry's Gray Matter
  • Status: offline
Re: Truncation when setting PIC ID Locations 2019/06/23 23:15:17 (permalink)
#3
ric
Super Member
  • Total Posts : 22728
  • Reward points : 0
  • Joined: 2003/11/07 12:41:26
  • Location: Australia, Melbourne
  • Status: online
Re: Truncation when setting PIC ID Locations 2019/06/23 23:55:11 (permalink) ☼ Best Answerby edware 2019/06/24 15:18:24
+3 (3)
1and0
https://www.microchip.com/forums/FindPost/1031817

That comment was talking about a PIC18F part.
The same section for a PIC16F15344 is:
CWORD:8000:7F:3FFF:IDLOC0
CWORD:8001:7F:3FFF:IDLOC1
CWORD:8002:7F:3FFF:IDLOC2
CWORD:8003:7F:3FFF:IDLOC3

so I guess you could try
CWORD:8000:3FFF:3FFF:IDLOC0
CWORD:8001:3FFF:3FFF:IDLOC1
CWORD:8002:3FFF:3FFF:IDLOC2
CWORD:8003:3FFF:3FFF:IDLOC3

 
in C:\Program Files (x86)\Microchip\xc8\v2.05\pic\dat\cfgdata\16f15344.cfgdata
 

I also post at: PicForum
Links to useful PIC information: http://picforum.ric323.co...opic.php?f=59&t=15
NEW USERS: Posting images, links and code - workaround for restrictions.
To get a useful answer, always state which PIC you are using!
#4
1and0
Access is Denied
  • Total Posts : 9314
  • Reward points : 0
  • Joined: 2007/05/06 12:03:20
  • Location: Harry's Gray Matter
  • Status: offline
Re: Truncation when setting PIC ID Locations 2019/06/24 00:07:45 (permalink)
0
Weird, 
C:\Program Files (x86)\Microchip\xc8\v2.00\pic\dat\cfgdata\16f15344.cfgdata
 
has this
CWORD:8000:3FFF:3FFF:IDLOC0
CWORD:8001:3FFF:3FFF:IDLOC1
CWORD:8002:3FFF:3FFF:IDLOC2
CWORD:8003:3FFF:3FFF:IDLOC3

while v2.05 has what Ric posted. 
 
Edit: My bad ... I looked into the wrong file.  The above code is from 16f18344.cfgdata.
post edited by 1and0 - 2019/06/24 00:27:38
#5
1and0
Access is Denied
  • Total Posts : 9314
  • Reward points : 0
  • Joined: 2007/05/06 12:03:20
  • Location: Harry's Gray Matter
  • Status: offline
Re: Truncation when setting PIC ID Locations 2019/06/24 00:15:21 (permalink)
+1 (1)
However, I just tried it with both v2.00 and v2.05 and still got the same warning. Perhaps mad_c (Jeff) will drop by and comment on this.
 
post edited by 1and0 - 2019/06/24 00:27:52
#6
1and0
Access is Denied
  • Total Posts : 9314
  • Reward points : 0
  • Joined: 2007/05/06 12:03:20
  • Location: Harry's Gray Matter
  • Status: offline
Re: Truncation when setting PIC ID Locations 2019/06/24 00:23:20 (permalink)
+1 (1)
Okay, modifying the v2.05 .cfgdata file as Ric shown works with XC8 compiler v2.05.
 
I guess v2.00 has the correct .cfgdata file but it has a bug with the compiler, and v2.05 has a "bad" .cfgdata file and the compiler is okay. So fixing this file for v2.05 works. 
 
Edit: I looked at the wrong .cfgdata file. 
 
16f15344.cfgdata has

CWORD:8000:7F:3FFF:IDLOC0
CWORD:8001:7F:3FFF:IDLOC1
CWORD:8002:7F:3FFF:IDLOC2
CWORD:8003:7F:3FFF:IDLOC3

while 16f18344.cfgdata has
CWORD:8000:3FFF:3FFF:IDLOC0
CWORD:8001:3FFF:3FFF:IDLOC1
CWORD:8002:3FFF:3FFF:IDLOC2
CWORD:8003:3FFF:3FFF:IDLOC3

post edited by 1and0 - 2019/06/24 00:30:44
#7
edware
Starting Member
  • Total Posts : 33
  • Reward points : 0
  • Joined: 2009/01/04 22:41:19
  • Location: 0
  • Status: offline
Re: Truncation when setting PIC ID Locations 2019/06/24 03:10:07 (permalink)
0
Thanks everyone for your input.
I'm slightly hesitant to modify the .cfgdata file as a compiler upgrade could revert to the current settings again.
 
So I wonder if this item is considered worthy of warranting a change by Microchip in an upcoming XC8 release?
 
I suppose I could add a reminder note in my file to check this, and rely on the warning generated by XC8 when/if the size exceeds the mask vale.....
 
Cheers
Ed
 
#8
ric
Super Member
  • Total Posts : 22728
  • Reward points : 0
  • Joined: 2003/11/07 12:41:26
  • Location: Australia, Melbourne
  • Status: online
Re: Truncation when setting PIC ID Locations 2019/06/24 03:18:12 (permalink)
+3 (3)
edware
I'm slightly hesitant to modify the .cfgdata file as a compiler upgrade could revert to the current settings again.

Valid point.
 

So I wonder if this item is considered worthy of warranting a change by Microchip in an upcoming XC8 release?

Yes, but it will only happen if someone can be bothered submitting an official "Support Ticket" to Microchip about it
 

I also post at: PicForum
Links to useful PIC information: http://picforum.ric323.co...opic.php?f=59&t=15
NEW USERS: Posting images, links and code - workaround for restrictions.
To get a useful answer, always state which PIC you are using!
#9
edware
Starting Member
  • Total Posts : 33
  • Reward points : 0
  • Joined: 2009/01/04 22:41:19
  • Location: 0
  • Status: offline
Re: Truncation when setting PIC ID Locations 2019/06/24 15:18:59 (permalink)
+1 (1)
Support Ticket raised. Fingers crossed wink: wink
#10
Jump to:
© 2019 APG vNext Commercial Version 4.5