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

Memory Location with #locate

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



Joined: 20 Nov 2004
Posts: 12
Location: Austria

View user's profile Send private message Send e-mail

Memory Location with #locate
PostPosted: Thu Nov 25, 2004 3:03 am     Reply with quote

Is this correct to place an area with Datas (Bytes) in the rom of the PIC16F684 at Position 0x0100 ?
In which output file of the compiler can I see the Position of the Datas,
Because in the PICkit Classic the data�s are on the beginning of the Programm Memory.

[/code]
BYTE const table[50]={0xAA, 0xBB, 0xCC, 0xDD, 0xFF,
0xAA, 0xBB, 0xCC, 0xDD, 0xFF, 0xAA, 0xBB, 0xCC, 0xDD, 0xFF, 0xAA, 0xBB, 0xCC, 0xDD, 0xFF,
0xAA, 0xBB, 0xCC, 0xDD, 0xFF,
0xAA, 0xBB, 0xCC, 0xDD, 0xFF, 0xAA, 0xBB, 0xCC, 0xDD, 0xFF, 0xAA, 0xBB, 0xCC, 0xDD, 0xFF, 0xAA, 0xBB, 0xCC, 0xDD, 0xFF, 0xAA, 0xBB, 0xCC, 0xDD, 0xFF,
};

#locate table = 0x0100
Quote:
ckielstra



Joined: 18 Mar 2004
Posts: 3680
Location: The Netherlands

View user's profile Send private message

PostPosted: Thu Nov 25, 2004 3:48 am     Reply with quote

Quote:
In which output file of the compiler can I see the Position of the Datas

In the symbol file: *.sym
Ttelmah
Guest







PostPosted: Thu Nov 25, 2004 4:15 am     Reply with quote

Key problem here, is that what is put at 0x100, won't just be the table. If you define a 'const' table, then the compiler places the code to access it, followed by the data table, at the address. In the case of a chip like the 688 (which supports direct reading of the flash), the data following the program, will be as expected. In the case of older chips without these instructions, the program will be followed by a series of 'retlw' instructions to return the data. If you require actual data to sit at a specific location, then use the #rom directive instead, and access the data using the read_program_memory instruction on chips supporting this (on chips that don't support this, you cannot directly 'read' an address in the ROM.
You can't have 'data' at the start of program memory, in any PIC, since the first instruction, is where the processor goes on boot (you can have it immediately after this, if you are not using interrupts - otherwse a few more instruction have to be missed to allow for the interrupt vectors.


Best Wishes
UKH2
Guest







Table at ROM
PostPosted: Fri Mar 11, 2005 1:49 am     Reply with quote

What can I do to build at table of bytes in FLASH-ROM. For my application it's senseless where this table will be located, BUT I would like to know where it is placed because I want to read and write it with read_/write_program_memory.

In older applications in which such functionallity was needed too I've used
the #ROM directive with a fixed-address, so read_ or write to programm-memory was easy because of the known address. But this solution isn't nice in each case.

Has someone made any experiences with another solution.
Thanks in advance.

UKH.
PCM programmer



Joined: 06 Sep 2003
Posts: 21708

View user's profile Send private message

PostPosted: Fri Mar 11, 2005 2:12 am     Reply with quote

If you have a modern version of the compiler, you can use the
label_address() function to get the address of the data in a const array.
See the example near the start of this thread:
http://www.ccsinfo.com/forum/viewtopic.php?t=22070
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