CCS C Software and Maintenance Offers
FAQFAQ   FAQForum Help   FAQOfficial CCS Support   SearchSearch  RegisterRegister 

ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 

CCS does not monitor this forum on a regular basis.

Please do not post bug reports on this forum. Send them to support@ccsinfo.com

Repeated conditional compilation?

 
Post new topic   Reply to topic    CCS Forum Index -> General CCS C Discussion
View previous topic :: View next topic  
Author Message
kypec



Joined: 20 Sep 2003
Posts: 54

View user's profile Send private message

Repeated conditional compilation?
PostPosted: Sat Nov 26, 2005 3:25 am     Reply with quote

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
Eric Minbiole



Joined: 10 Jun 2004
Posts: 16
Location: USA

View user's profile Send private message Visit poster's website

PostPosted: Sat Nov 26, 2005 8:00 pm     Reply with quote

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.
kypec



Joined: 20 Sep 2003
Posts: 54

View user's profile Send private message

PostPosted: Mon Nov 28, 2005 12:19 am     Reply with quote

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
Display posts from previous:   
Post new topic   Reply to topic    CCS Forum Index -> General CCS C Discussion All times are GMT - 6 Hours
Page 1 of 1

 
Jump to:  
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