View previous topic :: View next topic |
Author |
Message |
ancient_one
Joined: 05 Jan 2012 Posts: 7
|
Reading rom memory address |
Posted: Thu Jan 05, 2012 1:15 pm |
|
|
I need to put during compile time some bytes into a particular rom address, such as 0x100,0x001, and read them later using the address.
If I use:
Code: | #ORG 0x100
int8 const stuff = 0xA;
#ORG 0x101
int8 const stuff2 = 0xB;
#ORG 0x102
int8 const stuff3 = 0xC; |
How can i read this values using rom address instead of variable names?
I do not need:
Code: | int8 value = stuff;
int8 value2 = stuff2;
int8 value3 = stuff3; |
but something like:
Code: | int8 address = 0x100;
int8 value;
value = read_eeprom(address);
address++;
value = read_eeprom(address);
address++;
value = read_eeprom(address);
|
How can i do this? |
|
|
PCM programmer
Joined: 06 Sep 2003 Posts: 21708
|
|
|
ancient_one
Joined: 05 Jan 2012 Posts: 7
|
|
Posted: Thu Jan 05, 2012 2:30 pm |
|
|
That is exactly what i need, thanks.
Another thing, about:
Code: | #define DATA_ADDRESS 0x1000 // Start address for data
#define DATA_SIZE 20 // in bytes |
What is the minimun address i can use? is 0x00 writable?
And how much data can i store in rom in this way?
I'm using pic16f88. |
|
|
PCM programmer
Joined: 06 Sep 2003 Posts: 21708
|
|
Posted: Thu Jan 05, 2012 2:43 pm |
|
|
Normally your program goes in low memory. There are hardware
address vectors in that area, such as the Reset Vector and various
interrupt vectors. I would not casually try to alter that area.
I don't know what your overall purpose is. If you are trying to control
compiler behavior with respect to code placement, there are other tools
such as #build, #org, etc. See the manual and search for sample code
in the forum archives. |
|
|
ancient_one
Joined: 05 Jan 2012 Posts: 7
|
|
Posted: Thu Jan 05, 2012 2:59 pm |
|
|
I'm writing a firmware that control a led matrix 7x100 (20 letters).
Each letter is 5x7 pixel and i need to store in rom (compile time) each letter scheme.
Example for letter A:
So for the uppercase alphabet i need 25 (24 plus blank) * 5 byte in rom.
I want to use the ascii code of the single character as address offset to make the print function simpler.
I can't usa a full switch/case because the compiler told me that "the code segment is too large for the pic".
So your example is perfect for my project, but I neet to write at least 25*5=125bytes in rom. For example from 0x1000 to 0x007D.
Is it possibile or i'll overwrite some hardware address vector? |
|
|
PCM programmer
Joined: 06 Sep 2003 Posts: 21708
|
|
Posted: Thu Jan 05, 2012 4:00 pm |
|
|
CCS has examples of how to store Font tables in ROM. You don't have to
use the complex direct reading of Program Memory. You can just tell the
compiler to put a Font Table array in ROM by using the 'const' qualifier
in the array declaration. See this CCS driver file for an example:
Quote: |
c:\program files\picc\drivers\glcd.c |
|
|
|
|