View previous topic :: View next topic |
Author |
Message |
future
Joined: 14 May 2004 Posts: 330
|
Data tables |
Posted: Fri May 21, 2004 9:44 pm |
|
|
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
|
|
Posted: Mon May 24, 2004 3:00 pm |
|
|
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
|
|
Posted: Mon May 24, 2004 6:49 pm |
|
|
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
|
|
Posted: Mon May 24, 2004 7:11 pm |
|
|
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
|
|
Posted: Tue May 25, 2004 12:30 pm |
|
|
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
|
|
Posted: Tue May 25, 2004 1:16 pm |
|
|
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
|
|
Posted: Tue May 25, 2004 1:56 pm |
|
|
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
|
|
Posted: Tue May 25, 2004 2:33 pm |
|
|
So when you said
future wrote: | There are 4 big tables (256bytes) that are never changed. |
What did you mean? |
|
|
Guest
|
|
Posted: Tue May 25, 2004 2:59 pm |
|
|
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. |
|
|
|