C equivalent of ORG?

cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 

C equivalent of ORG?

1,601 Views
DSbob
Contributor III
I've spent years programming HC05 in asm.  New to C and Flash, using S08QG8.  I need to store a calibration value in flash.
 
With help from this forum, I have it written to second to last page, 0xFC00.
 
Memory write protection starts at last page and works toward lower pages, right?  So with a flash writer in my application, I sure want to protect program memory! 
 
I want to write the calibration value at 0xE000, and make sure the complier/linker starts the application program at 0xE200, the second page of flash.  I've studied Segments and Sections in the linker prm file but don't see how to force that.  Any suggestions?
 
Writing this, I've come to realize each debug session will probably overwrite the calibration value through mass erase.  I think that can be delt with, have used command files.  Will a w(rite bytes, words, etc) post load command actually write to flash, so I can debug normal operation? 
Labels (1)
0 Kudos
Reply
4 Replies

424 Views
DSbob
Contributor III
Thanks peg and Alban.
 
I searched at 8 bit CW as peg suggested, and reposted there with my analysis of what Alban suggested.  Not much progress with the search, so far.
0 Kudos
Reply

424 Views
CrasyCat
Specialist III
Hello
 
I assume you want to define a constant and allocate it at an absolute address.
Am I right?
 
If you are using CodeWarrior compiler you can use the @ operator in this purpose.
For example following instruction will allocate a 2 byte object at address 0xFFA0 and initialize it with 0x10.
 
   const int toto @0xFFA0 = 0x10 ;
 
If you are using another compiler than CodeWarrior, please check with your compiler vendor how you are supposed to solve that.
 
CrasyCat
0 Kudos
Reply

424 Views
Alban
Senior Contributor II
Hello,

The most clever way I see is to change the PRM file:

- break the exisiting second FlashC000 emplacement into Flash2a C000-DFEF and Flash2b E000-FFFF,
- change the "INTO" to go to Flash2b instead of Flash C000.
- create a new INTO: CALIBDATA INTO Flash2a
- in your software put #pragma CONST_SEG CALIBDATA and #pragma CONST_SEG DEFAULT around the constants declared as CONST you want to be in the Flash2a area.

Cheers,
Alban.
0 Kudos
Reply

424 Views
peg
Senior Contributor IV
Hi and welcome to the forums,
It is not the job of C to do this kind of stuff.
It will be tool specific.
What compiler are you using?
If it is Codewarrior then this question would best be put in the 8-bit Codewarrior forum.
A search in there will also turn up your answer.
 
0 Kudos
Reply