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

Data tables

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



Joined: 14 May 2004
Posts: 330

View user's profile Send private message

Data tables
PostPosted: Fri May 21, 2004 9:44 pm     Reply with quote

I'm new to C and coming from picbasic.

I want to know how do you work with tables, like fixed 256bytes tables that are used to do data conversion and tables frequently changed, like user configs etc.

I saw that byte const table [] {} are easy to access, but they are fixed.

I'm looking for a way that is as easy as the above but with changeable data.
PCM programmer



Joined: 06 Sep 2003
Posts: 21708

View user's profile Send private message

PostPosted: Mon May 24, 2004 3:00 pm     Reply with quote

Quote:
I want to know how do you work with tables, like fixed 256 bytes tables
that are used to do data conversion and tables frequently changed, like
user configs etc.
I saw that byte const table [] {} are easy to access, but they are fixed.
I'm looking for a way that is as easy as the above but with changeable data.


Just leave off the "const" keywork. Then the table will be in RAM.

But for a ram table of that size (256 bytes), you need to use an
18F-series PIC, such as the 18F452.
future



Joined: 14 May 2004
Posts: 330

View user's profile Send private message

PostPosted: Mon May 24, 2004 6:49 pm     Reply with quote

Thank you for the reply, but I'm looking for a way to save configs when the circuit is powered off.

I am using a 18f PIC.

There are 4 big tables (256bytes) that are never changed, but I need another 150bytes to hold the program configuration modified with a windows program via serial port.

Using defines and read_eeprom(); would eat a lot of code space.

Other questions, is there a way to define the starting address of a byte const table?
PCM programmer



Joined: 06 Sep 2003
Posts: 21708

View user's profile Send private message

PostPosted: Mon May 24, 2004 7:11 pm     Reply with quote

Quote:
Using defines and read_eeprom(); would eat a lot of code space.

See the last post in this thread, for a way to minimize the ROM used
by repeated calls to read_eeprom().
http://www.ccsinfo.com/forum/viewtopic.php?t=19221&highlight=myreadeeprom

Quote:
Other questions, is there a way to define the starting address of a byte const table?

Put an #org statement right above the line which defines the const array.
Use it to set the range of ROM addresses which will hold the array.
Be sure to allow a few additional ROM words to hold the array access
code, which is inserted by the compiler.
future



Joined: 14 May 2004
Posts: 330

View user's profile Send private message

PostPosted: Tue May 25, 2004 12:30 pm     Reply with quote

How do you work with tables that you can modify via serial port?

Like a section in int_rx that gets the offset and data to store in the table.
Neutone



Joined: 08 Sep 2003
Posts: 839
Location: Houston

View user's profile Send private message

PostPosted: Tue May 25, 2004 1:16 pm     Reply with quote

When I think of a table I usualy think of an array stored in program memory though it is posiable to have a table stored in RAM or EEPROM. What I would suggest is that you have your table of constants stored in program memory using the const keyword. Store your configuration paramaters in an array in RAM that is saved to EEPROM in bulk when it is changed and loaded from EEPROM in bulk to RAM on powerup. You need to figure out what kind of memory everything is going to reside in.
future



Joined: 14 May 2004
Posts: 330

View user's profile Send private message

PostPosted: Tue May 25, 2004 1:56 pm     Reply with quote

The eeprom does not have sufficient space.

I have 4 256bytes tables to do data conversion, in the moment they are fixed and any change would require program recompilation and a pic flash.

I´m looking for a way to update these tables via serial port.
Neutone



Joined: 08 Sep 2003
Posts: 839
Location: Houston

View user's profile Send private message

PostPosted: Tue May 25, 2004 2:33 pm     Reply with quote

So when you said

future wrote:
There are 4 big tables (256bytes) that are never changed.


What did you mean?
Guest








PostPosted: Tue May 25, 2004 2:59 pm     Reply with quote

Ok, I use 4 a/d channels and 4 tables 256bytes each to convert a/d values to real world units.

Using CONST DATA, they will be hard coded into the program and changing them would require a recompilation.

Being 1k of data they will not fit in eeprom.
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