• AVR Freaks

LockedWhere are CONFIG options defined?

Page: < 123 Showing page 3 of 3
Author
mad_c
Super Member
  • Total Posts : 1289
  • Reward points : 0
  • Joined: 2010/12/12 17:48:27
  • Location: Brisbane, Australia
  • Status: offline
Re:Where are CONFIG options defined? 2012/09/17 20:27:51 (permalink)
0
Ian.M
Its interesting to see how easy it is to abuse the parser that #pragma config  uses.  I even found that it *will* accept quoted <name>=<value> pairs (with judicious use of whitespace), so long as ONE pair is *NOT* quoted! WTF!!! LoL 

Can you give an example of this 'abuse'? Thanks.
 
Jeff.
 
#41
Ian.M
Super Member
  • Total Posts : 13273
  • Reward points : 0
  • Joined: 2009/07/23 07:02:40
  • Location: UK
  • Status: offline
Re:Where are CONFIG options defined? 2012/09/17 21:05:45 (permalink)
0
Hi, Jeff
 
Sure.  Still using the PIC16F675 and Microchip MPLAB XC8 C Compiler (Free Mode)  V1.10 as above, try:
   
#pragma  config " FOSC=INTRCIO MCLRE=OFF WDTE=OFF PWRTE=ON BOREN=ON CP=OFF " CPD=OFF

or
   
#pragma  config " FOSC=INTRCIO " " MCLRE=OFF " " WDTE=OFF " " PWRTE=ON " " BOREN=ON " " CP=OFF " " CPD=OFF 

The compiler likes them, but I certainly don't! (Due to the failure to finish the job of letting me use string literals . . . mr green)
   
#pragma  config "FOSC=INTRCIO MCLRE=OFF WDTE=OFF PWRTE=ON BOREN=ON CP=OFF " CPD=OFF

does not work, nor does any other variant that does not have whitespace between all " and the nearest config option:
   Error [1363] <filename elided>; 26.1 unknown configuration setting/register ("FOSC = INTRCIO) used (908) exit status = 1
 
   
#pragma  config " FOSC=INTRCIO MCLRE=OFF WDTE=OFF PWRTE=ON BOREN=ON CP=OFF  CPD=OFF "

does not work, nor any other variant that does not have at least one CONFIG parameter=setting pair outside the quotes at the end of the line.
  Error [1361] <filename elided>; 26.1 syntax error in configuration argument (908) exit status = 1
 
A further issue is that commas seem to be treated as whitespace.  Sprinkle them wherever you like within a #pragma config and they have no effect whatsoever unless you break a word or needed whitespace to separate " and a word.
 
Finally, for the cases the compiler accepted,  I did check that all CONFIG options were effective and the result was the same as the properly formed:
   
#pragma  config  FOSC=INTRCIO, MCLRE=OFF, WDTE=OFF, PWRTE=ON, BOREN=ON, CP=OFF, CPD=OFF

(without any conflicting #defines).
 
All tests were in MPLAB  version  8.83.00.00  Certified running on Windows XP   version   5.1.2600.2 Service Pack 3.
HTH
Ian
 
post edited by Ian.M - 2012/09/18 15:17:55
#42
mad_c
Super Member
  • Total Posts : 1289
  • Reward points : 0
  • Joined: 2010/12/12 17:48:27
  • Location: Brisbane, Australia
  • Status: offline
Re:Where are CONFIG options defined? 2012/09/18 14:46:27 (permalink)
0
Got it, thanks for the examples. I have created a case concerning this issue so that it will not be lost. My preliminary tests with XC16/32 see to indicate that the preprocessor does not parse the config pragma and make substitutions, but we tend to feel that is not the best way to proceed. If the string parser can be sorted out, that might be a better option. A 16F675? That is a typo, right?
 
Best regards, Jeff.
#43
Ian.M
Super Member
  • Total Posts : 13273
  • Reward points : 0
  • Joined: 2009/07/23 07:02:40
  • Location: UK
  • Status: offline
Re:Where are CONFIG options defined? 2012/09/18 15:14:41 (permalink)
0
Sorry about that. It should of course be PIC12F675.  Maybe I wasn't awake enough when I was composing my reply in the small hours.
 
#44
mad_c
Super Member
  • Total Posts : 1289
  • Reward points : 0
  • Joined: 2010/12/12 17:48:27
  • Location: Brisbane, Australia
  • Status: offline
Re:Where are CONFIG options defined? 2012/09/18 18:12:04 (permalink)
+1 (1)
Ian.M
Sorry about that. It should of course be PIC12F675.  Maybe I wasn't awake enough when I was composing my reply in the small hours.

I assumed that was the case. It is amazing, if you Google for it, the number of times that people claim to be using the 16F675. For a chip that was never produced, it is quite popular. :-)
 
The reasons for the strange parsing of the pragma arguments was code that managed to fluke it. The arguments are scanned using plain ol' strtok(), but the quote character was not included in the list of separator characters -- other code was managing to swallow the quotes, but only sometimes, as you have seen. The quote character will be instated in the list of separators so you should be able to quote the arguments more reliably, and thus allow you to avoid any interaction from the preprocessor, if desired. This change should make it into the 1.11 release.
 
Jeff.
 
#45
Ian.M
Super Member
  • Total Posts : 13273
  • Reward points : 0
  • Joined: 2009/07/23 07:02:40
  • Location: UK
  • Status: offline
Re:Where are CONFIG options defined? 2012/09/18 18:14:57 (permalink)
0
Great.  *MANY* thanks!
 
#46
Ian.M
Super Member
  • Total Posts : 13273
  • Reward points : 0
  • Joined: 2009/07/23 07:02:40
  • Location: UK
  • Status: offline
Re:Where are CONFIG options defined? 2013/08/20 20:31:56 (permalink)
#47
Page: < 123 Showing page 3 of 3
Jump to:
© 2021 APG vNext Commercial Version 4.5