Microchip migration from config bits to pragma config bits - Page 1
Forum section: electronics / general

author: matb
author_rank: Regular Contributor
timestamp: October 12, 2022, 12:57:25 pm
content: Hi everyone,I'm trying to migrate from xc16 v1.25 to v1.26 to be able to use the license patch found on eev forum.I managed to migrate most of it using the Window > Target memory view > Configuration bits but I'm having a hard time with FAS and FUID0.My app uses a bootloader and for whatever reason previous devs (not here anymore obviously) used FAS and FUID0 to share software version and hardware version.So they do :Code:_FAS(0x7000 | (112 & 0x0FFF))This translate toCode:// FAS#pragma config AWRP = OFF // Auxiliary Segment Write-protect bit (Aux Flash may be written)#pragma config APL = OFF // Auxiliary Segment Code-protect bit (Aux Flash Code protect is disabled)#pragma config APLK = OFF // Auxiliary Segment Key bits (Aux Flash Write Protection and Code Protection is Disabled)Where it is missing the software version. Can anyone advise me a solution / docs ...Thanks a lot.

author: JPortici
author_rank: Super Contributor
timestamp: October 12, 2022, 02:54:31 pm
content: Which Part?

author: DavidAlfa
author_rank: Super Contributor
timestamp: October 12, 2022, 04:40:45 pm
content: If this is a commercial product bringing revenue, just buy the real stuff.- For DIY and non-profit -Isn't your patch working? Try xclm fixer:this,mirror(Password included in the ZIP comment), and just use v1.25, you'll save a heck of a work.Works with most versions. FYI, tested working with xc8 v1.x-v2.40, xc16 v1.25-v2.00, so I expect it to work with most compilers up to date.Edit: It seems MplabX v6.00 is causing some issues, complaining about wrong checksums when building, not happening with v5.50, so stay with that version or try yourself.Please don't insult or blame me for it (hack tool exe blah blah), download it at your own responsability.(Got it at Sonsrivri forum ages ago)

author: JPortici
author_rank: Super Contributor
timestamp: October 12, 2022, 06:34:24 pm
content: On XC8 too? got to try it just for kicksAnyway, in case the OP ever comes back with the crucial information that's missing...Compiler manual, search for "configuration" in the index and a chapter called "configuration bit access" (or a simillar name) will be found.I don't have the compiler manual for 1.26 at hand but for 1.70 it saysQuoteso (tested in the only device i could think of that has the AUX memory)Code:#pragma config UID0 = 8_bit_valuewill set UID0.It is also accessible from the configuration window. On the bottom left click on the "Memory" list menu. Change from configuration bits to "User ID Memory".Or you could find the definition on xc16_path/docs/config_index.htmlbut i can't find a way to set FAS as a whole. It surprises me that it worked anyway as the unimplemented bits should be set at a specific value

author: DavidAlfa
author_rank: Super Contributor
timestamp: October 12, 2022, 10:44:09 pm
content: Yeah, this patcher works with all. Perhabs with XC32 too, haven't tried.I've used that same patcher for the last...8 years or so lol.

author: JPortici
author_rank: Super Contributor
timestamp: October 13, 2022, 05:20:06 am
content: Oh, i never went beyond trying the specs.txt...Before making commercial products i always thought i NEEDED all the optimization. In truth, good enough is good enough, i prefer being able to debug, and still i most parts run way lower than the maximum frequency allowed

author: matb
author_rank: Regular Contributor
timestamp: October 13, 2022, 05:58:40 am
content: Wow thanks everyone.Maybe I wasn't clear enought I want to pass the 112 information using _FAS. This part works but now I'm moving to xc16 v1.26 to be able to use specs.txt file patch.Just on xc16 not interested in xc8 and xc32 for the moment.The µC is dsPIC33EP256MU810

author: JPortici
author_rank: Super Contributor
timestamp: October 13, 2022, 07:19:33 am
content: But the values don't make sense.What does 0x7000 means?What does 112 means?in any case it's writing to unimplemented bits of the configuration word FAS, they should always read back zero, and the higher byte of the configuration word should be unimplemented, always read back as zero112 could mean something if it's the firmware version and it's written in UID0by the way 112 is 0x70, if that means something (you would be writing 0x7070)

author: matb
author_rank: Regular Contributor
timestamp: October 13, 2022, 07:36:43 am
content: In p33EP256MU810.h we findCode:/* Register FAS (0xf80010) */extern __attribute__((space(prog))) unsigned int _FAS;#define _FAS(x) __attribute__((section("__FAS.sec"),space(prog))) unsigned int _FAS = (x);/*** Only one invocation of FAS should appear in a project,** at the top of a C source file (outside of any function).**** The following constants can be used to set FAS.** Multiple options may be combined, as shown:**** _FAS( OPT1_ON & OPT2_OFF & OPT3_PLL )**** Auxiliary Segment Write-protect bit:** AWRP_ON Aux Flash is write protected** AWRP_OFF Aux Flash may be written**** Auxiliary Segment Code-protect bit:** APL_ON Aux Flash Code protect is enabled** APL_OFF Aux Flash Code protect is disabled**** Auxiliary Segment Key bits:** APLK_OFF Aux Flash Write Protection and Code Protection is Disabled** APLK_ON Aux Flash Write Protection or Code Protection is Enabled***/#define AWRP_ON 0xFFFE#define AWRP_OFF 0xFFFF#define APL_ON 0xFFFD#define APL_OFF 0xFFFF#define APLK_OFF 0xFFCF#define APLK_ON 0xFFFFand then there is a bootloader define conditionif the bootloader is not there (for devs) we setCode://_FAS(APLK_OFF & APL_OFF & AWRP_OFF) /* Auxiliary program memory is not code-protected; Auxiliary program memory is not write-protected */else we setCode:_FAS(0x7000|(112 & 0x0FFF));and during bootup bootloader writes the normal values (ie _FAS(APLK_OFF & APL_OFF & AWRP_OFF) ) Software version is 1.12, 0x7000 is another software version.I guess the bootloader reads these values and determines if there is an app and what soft it is.To be 100% clear there are 2 values transfered from app to bootloader, software version and firmware version.Software version is written in _FAS and firmware version is written in _FUID0.Code:_FUID0(((0&0x0F)<<8)|(104&0xFF));Firmware version is 1.04

author: matb
author_rank: Regular Contributor
timestamp: October 18, 2022, 07:27:32 am
content: Nobody has got any idea ?I guess this is so not standard that it wouldn't work with another compiler version.The problem will be that I will have to change the bootloader and all associated softwares to reprogram the device.Maybe I should contact Microchip about that, what do you think ? Useless ?

author: DavidAlfa
author_rank: Super Contributor
timestamp: October 18, 2022, 09:04:32 am
content: Why are you still fighting it, when you could just compile with zero effort using patched v1.25 and carry on?

author: matb
author_rank: Regular Contributor
timestamp: October 18, 2022, 09:36:46 am
content: What's the password of your files ?

author: DavidAlfa
author_rank: Super Contributor
timestamp: October 18, 2022, 09:46:54 am
content: Edit: The pqssword is now in the zip comments (Download again from new l1nks)

author: matb
author_rank: Regular Contributor
timestamp: October 18, 2022, 11:27:18 am
content: Thanks I'm an idiot haha. I will try this patch and let you know.

author: matb
author_rank: Regular Contributor
timestamp: October 18, 2022, 11:39:43 am
content: Ok it works well thanks a lot for that

author: DavidAlfa
author_rank: Super Contributor
timestamp: October 18, 2022, 03:00:20 pm
content: Enjoy theviruspatch