|
|
View previous topic :: View next topic |
Author |
Message |
hobgoblin
Joined: 10 Sep 2003 Posts: 7
|
How to use CONDITIONAL COMPILE for TABLES in eeprom & co |
Posted: Wed Aug 03, 2005 5:46 am |
|
|
Hi,
I have found that if I attempt to embed EEP or code space tables in my code that are subject to conditional compile statements, the code compiles ok but when I try to use the Simulator in MPLAB, executed code is completely out of sync with compiled code, many statements appear to be missing and it is impossible to set breakpoints or debug the code.
I am writing code for a project whilst the hardware is being developed in parallel and I have not yet decided if I will require tables that are 5-entry or 9-entry, so I declared both tables and used conditional compile statements to enable the 5-entry tables but disabled the 9-entry tables until/unless they are needed.
However I would still expect this to be a valid thing to do, so this may be a bug...
Here is one of the EEprom dual-table declarations (I have knocked-out all but the first and last entries to save space in this thread):
#if 5_SUB_BANDS
#rom EEP_DP0_TBL = {
//Hex Addr (Dec) No. Min Max Sub
//val Offset Val Taps Val Val Band
0x32, // 0 ( 50) 100 0 0x64 + 0MHz
0x32} // 4 ( 50) 100 0 0x64 + 20MHz
#endif
#if 9_SUB_BANDS
#rom EEP_DP0_TBL = {
//Hex Addr (Dec) No. Min Max Sub
//val Offset Val Taps Val Val Band
0x32, // 0 ( 50) 100 0 0x64 + 0MHz
0x32} // 8 ( 50) 100 0 0x64 + 20MHz
#endif
Here are the conditional compile declarations:
#define 5_SUB_BANDS true; //default length of calibration tables
//#define 5_SUB_BANDS false;
//#define 9_SUB_BANDS true; //alt. length of calibration tables
#define 9_SUB_BANDS false;
BTW - I have noticed that whilst conditional compile statements are defined as accepting 'an expresson with constants & standard operators', this is not the case. You cannot, as I have found, logically combine these conditional compile names e.g. '#if 9_SUB_BANDS || WIDE_BAND'. It seems you can only use a single boolean.
Anyway, if the above table declarations are present I get the problems I've already mentioned.
In addition to the above, I also have similar default tables in code space:
#if 5_SUB_BANDS
int8 const ROM5_DP0_TBL[5] = {
//Hex Addr (Dec) No. Min Max Sub
//val Offset Val Taps Val Val Band
0x32, // 0 ( 50) 100 0 0x64 + 0MHz
0x32};// 4 ( 50) 100 0 0x64 + 20MHz
#endif
#if 9_SUB_BANDS
int8 const ROM9_DP0_TBL[9] = {
//Hex Addr (Dec) No. Min Max Sub
//val Offset Val Taps Val Val Band
0x32, // 0 ( 50) 100 0 0x64 + 0MHz
0x32};// 8 ( 50) 100 0 0x64 + 20MHz
#endif
...and it doesn't like these either.
Furthermore, although for the EEP tables I use the same name 'EEP_DP0_TBL ' for 5 and 9-entry tables and it compiles ok, the compiler complains if you try to do this in the code space tables, which is why I had to give them unique names: 'ROM5_DP0_TBL' and 'ROM9_DP0_TBL' which is another pain.
...however even though this also compiles ok, it too causes the problems I've described. Only if I remove ALL sets of these particular tables does MPLAB return to normal operation (I have several other tables in EEP and code space that are not conditional compile enabled and are problem-free).
I DO need to have these tables embedded, is there a way of using conditional compilation on TABLES that will work?
Adrian |
|
|
Ttelmah Guest
|
|
Posted: Wed Aug 03, 2005 7:27 am |
|
|
First comment, is a minor one. I'd use ifdef, not if. Unless you know what value the compiler assigns to a 'undefined' form, it is dangerous to assume it will evaluate to untrue. This had caught me in the past with other compilers, so I have never pushed it on the CCS one!...
This may be the large part of your problem. Use ifdef, or test for the variable being 'defined'.
Second, on the ROM definitions, you can add the test after the ROM definition. So I have used:
Code: |
#rom 0xF0000 = {
#ifdef ROM1
0x100,0x200,0x144,0x244
#else
0x101,0x200,0x143,0x243
#endif
}
|
On the 'combining' the operators, you can. However you have to be aware that again there is not a standard fo the value returned by a variable that is defined. hence you have to use:
#if defined(9_SUB_BANDS) || defined(WIDE_BAND)
to logical 'or' the variables.
Best Wishes |
|
|
Guest
|
Why should this make a difference HERE? |
Posted: Wed Aug 03, 2005 8:33 am |
|
|
Ttelmah wrote: | I'd use ifdef, not if. Unless you know what value the compiler assigns to a 'undefined' form, it is dangerous to assume it will evaluate to untrue.
On the 'combining' the operators, you can. However you have to be aware that again there is not a standard fo the value returned by a variable that is defined. hence you have to use:
#if defined(9_SUB_BANDS) || defined(WIDE_BAND) |
Many thanks,
This now works.
Adrian |
|
|
|
|
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
|