View previous topic :: View next topic |
Author |
Message |
kypec
Joined: 20 Sep 2003 Posts: 54
|
Repeated conditional compilation? |
Posted: Sat Nov 26, 2005 3:25 am |
|
|
Hello,
may someone of you please help me with the following:
I need to place certain amount of table entries in ROM.
Their count is constant at the time of compilation but may
vary for different code revisions.
I know there is WHILE <expr> ... ENDW directive in Microchip's MPASM assembler which is doing exactly what I need.
Is there any way I could do the similar with CCS PCH 3.239?
To make myself clear it should work like this pseudo code:
Code: | const int32 table_begin=0x7000;
#define ENTRY_SIZE 64
#define TOTAL_ENTRIES 5
#define THIS_ENTRY 0
#while (THIS_ENTRY<TOTAL_ENTRIES)
#rom int8 table_begin+THIS_ENTRY*STEP_ENTRY_SIZE={1,2,3}
THIS_ENTRY++
#endw
|
|
|
![](templates/subSilver/images/spacer.gif) |
Eric Minbiole
Joined: 10 Jun 2004 Posts: 16 Location: USA
|
|
Posted: Sat Nov 26, 2005 8:00 pm |
|
|
I don't think there is any way to do this sort of thing directly within C. As an alternative, you could do the calculations at runtime (perhaps at startup), storing the results in RAM. (It looks to me that your table is 320 bytes, which may fit within some larger PICs, depending on your application.) If the calculations are rather simple (which they appear to be from your example) the lookup table may not be completely necessary, as the result could be calculated "on demand".
Assuming you really need things in ROM: In the past, I have had to do similar sorts of things. (Creating lookup tables, calculation results, etc., and storing them in ROM.) I've ended up using Excel (or similar) to do the calculations, and then paste the resulting table into a source or header file. It's not as convenient as doing it within the source code, but it still works okay, especially if the data doesn't change too often. |
|
![](templates/subSilver/images/spacer.gif) |
kypec
Joined: 20 Sep 2003 Posts: 54
|
|
Posted: Mon Nov 28, 2005 12:19 am |
|
|
Thank you Eric for your suggestions but the runtime RAM approach is not suitable for me.
I know how to embed large ROM tables in my source code.
I'm doing this regularly in Excel with heavy support of VBA programming and macros.
My tables are rather large because they consist of huge number of welding parameters and presets.
My exact problem is that I have let's say a short welding template occupying 64 bytes in ROM.
I want this template to be included many times during compilation at consecutive addresses in ROM.
The count of occurrences should be flexible upon my decision via #define or similar statement.
I hope this helped to explain my problem more accurately.
kypec |
|
![](templates/subSilver/images/spacer.gif) |
|