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

Look up table with PIC12F683 in CCS C

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



Joined: 03 Feb 2011
Posts: 5
Location: Florence, Italy

View user's profile Send private message

Look up table with PIC12F683 in CCS C
PostPosted: Thu Apr 14, 2011 8:49 am     Reply with quote

Hello!!

I'm working with a PIC12F683 and I'm using a CCS C compiler.
I need to allocate in program memory two look up tables, the first is declared as

const char potenz[178]={...};

The second has 256 elements, each one 16 bits length:

const int16 potenz1[256]={...};

As a result, after building, the first table is correctly allocated, but the second one is missing.

Each words in program memory is 14 bits length.

Can allocate it a table with elements of 16 bits length?

Any suggestion is appreciated!!

Thanks!! Sad
_________________
Bugs will appear in one part of a working program when another 'unrelated' part is modified.

Doralice
PCM programmer



Joined: 06 Sep 2003
Posts: 21708

View user's profile Send private message

PostPosted: Thu Apr 14, 2011 12:21 pm     Reply with quote

What's your compiler version ? I tried it just now, and the compiler stores
it as a ton of RETLW's. It's there. But to see it, you need to edit the
12F683.h file and comment out the #nolist statement at the top of the file.
Then re-compile and look at the .LST file. You should see the RETLW's.

Also, to see the data, you need to access the const array with a variable.
If you just access a few elements with constant indexes, the compiler
will optimize those accesses into MOVLW statements. It won't put the
whole array into Flash memory. It does this to save ROM.
Doralice



Joined: 03 Feb 2011
Posts: 5
Location: Florence, Italy

View user's profile Send private message

Ram and Rom memory
PostPosted: Fri Apr 15, 2011 7:50 am     Reply with quote

Good evening,
my compiler version is:
"CCS C Compiler PCM version 4.118"

I've explained below the declarations I've made inside my declaration file "potenz.h". I have to store this two look up tables in the program memory.

Code:

const char potenz []=  //614 bytes
{142,
142,
142,
142,
142,
142,...};

const char potenz1 []=  //78 bytes
{55,
55,
55,...};


I've commented out, first of all, #nolist, but nothing happened, so I've tried to comment out also #list, but it stores in program memory only the first look up table. Looking at the lst file, I'll suppose it stores the second table in RAM memory because I've assigned an element of the second table to a variable and it has been translated with a MOVLW instruction.

How can I find out the address where each variables is allocated in Ram?

Can I force the compiler to store the second look up table in program memory?

Thx for your patience!
Rolling Eyes
_________________
Bugs will appear in one part of a working program when another 'unrelated' part is modified.

Doralice
Ttelmah



Joined: 11 Mar 2010
Posts: 19348

View user's profile Send private message

PostPosted: Fri Apr 15, 2011 2:38 pm     Reply with quote

It is not stored in RAM memory. What is applying is the second paragraph in PCM programmers reply. Since you are only accessing a fixed location, the compiler is 'optimising' the table away, and just storing the used value as a MOVLW.
You need a single line like:

val=potenzl[val];

where 'val' is a variable, to make the compiler realise that it can't predict what lines are needed, and it'll then store the whole table.

Best Wishes
Doralice



Joined: 03 Feb 2011
Posts: 5
Location: Florence, Italy

View user's profile Send private message

Code optimization
PostPosted: Mon Apr 18, 2011 1:37 am     Reply with quote

Yes,
thank you and PCM Programmer.
Now I've understood how the compiler optimizes the code in memory.
I'll try now to allocate a table with char elements and a table with int16 elements.

Doralice Very Happy
_________________
Bugs will appear in one part of a working program when another 'unrelated' part is modified.

Doralice
bells_electronics



Joined: 05 Dec 2009
Posts: 40

View user's profile Send private message

PostPosted: Sun Apr 22, 2012 12:24 pm     Reply with quote

@ Doralice

Did you solve your issue? if yes then how?
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