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 CCS Technical Support

Reading rom memory address

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



Joined: 05 Jan 2012
Posts: 7

View user's profile Send private message

Reading rom memory address
PostPosted: Thu Jan 05, 2012 1:15 pm     Reply with quote

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

View user's profile Send private message

PostPosted: Thu Jan 05, 2012 1:25 pm     Reply with quote

See this thread:
http://www.ccsinfo.com/forum/viewtopic.php?t=33198
ancient_one



Joined: 05 Jan 2012
Posts: 7

View user's profile Send private message

PostPosted: Thu Jan 05, 2012 2:30 pm     Reply with quote

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

View user's profile Send private message

PostPosted: Thu Jan 05, 2012 2:43 pm     Reply with quote

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

View user's profile Send private message

PostPosted: Thu Jan 05, 2012 2:59 pm     Reply with quote

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

View user's profile Send private message

PostPosted: Thu Jan 05, 2012 4:00 pm     Reply with quote

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