HCS08 C: Filling unused program memory with reset codes

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

HCS08 C: Filling unused program memory with reset codes

3,376 Views
BasePointer
Contributor II
Hi,
 
I want to fill unused program memory with opcode of asm("dcb 0x8D" ) .
How can I do this?
 
Regards,
BP.


Message Edited by BasePointer on 2008-02-26 11:33 AM
Labels (1)
Tags (1)
0 Kudos
6 Replies

653 Views
colinh
Contributor I
Have a look at FILL in the Codewarrior help, this extract is from the Help under the S12 but I think it should be the same for the 08, and should work for Code space as well:

Code:
SEGMENTS     RAM_1  = READ_WRITE 0x800 TO 0x8FF              FILL 0xAA 0x55; END

 


0 Kudos

653 Views
BasePointer
Contributor II
Code:
MY_STK =  NO_INIT      0x0C60 TO 0x105F FILL 0x55;  // 1024 byte

 
Hi,
 
I tried it to initialize my stack area to help me to understand stack size used.
But it doesn't fill the area. So I used that
Code:
  // initialize stack with 0x55 "U"  memset((void*)0x0C60, 0x55, 0x3E0);

 

I think FILL command is not working for my project. I'm not sure.

Regards,

BP.


 
 
 
 
0 Kudos

653 Views
CompilerGuru
NXP Employee
NXP Employee
>MY_STK =  NO_INIT      0x0C60 TO 0x105F FILL 0x55;

NO_INIT : do not init.
FILL: do init with FF.

Basically that does not work together. FILL only works with segments which are actually containing content.
So to fill the stack, you have to use runtime code as you did.
Using memset on the whole stack except the last 0x10 bytes is a bit problematic too,
as this will suddenly start to fail as soon as main and memset together use more memmory.
Daniel

0 Kudos

653 Views
BasePointer
Contributor II
Hi again,
 
When I check the codes, I saw FILL Command doesn't fill my ROM1 segment.
"ROM1                     =  READ_ONLY    0x1400 TO 0x17FF FILL 0x8D;"
 
This segment is not used by my codes and still seems as 0xFF although fill command.
ROM and other filled segment are filled properly. What may cause this?
 
10x.
BP.
0 Kudos

653 Views
CrasyCat
Specialist III
Hello
 
In order for the FILL attribute to work, there should be at least 1 byte allocated in the specified memory area.
A memory area which is not used at all will not be filled with the fill pattern.
 
CrasyCat
0 Kudos

653 Views
BasePointer
Contributor II
Daniel,
 
>>MY_STK =  READ_WRITE      0x0C60 TO 0x105F FILL 0x55;
I had also tried read_write instead of no_init. The result was same.
My total stack size is 0x400. And I only set first 0x3E0 bytes of it.
I don't touch last 32bytes at all. Can this cause any problem?
Code:
void main(void){  __RESET_WATCHDOG();    // initialize stack with 0x55 "U"  memset((void*)0x0C60, 0x55, 0x3E0);...

 

Here is my prm file to fill unused program memory with illegal opcode (0x8D):

Code:
SEGMENTS /* Here all RAM/ROM areas of the device are listed. Used in PLACEMENT below. */        Z_RAM                    =  READ_WRITE   0x0060 TO 0x00FF;  // 160 byte    RAM                      =  READ_WRITE   0x0100 TO 0x085F;  // 1888 byte    NO_INIT_RAM_SEG          =  NO_INIT      0x0860 TO 0x0C5F;  // 1024 byte    MY_STK                   =  NO_INIT      0x0C60 TO 0x105F;  // 1024 byte    NV_SAVE_SEG              =  READ_ONLY    0x1060 TO 0x13FF;  // reserve 928 (512) byte for NV    ROM1                     =  READ_ONLY    0x1400 TO 0x17FF FILL 0x8D;    ROM                      =  READ_ONLY    0x1870 TO 0xFEAF FILL 0x8D;    FLASH_ROUTINE_SEG        =  READ_ONLY    0xFEB0 TO 0xFFAF FILL 0x8D;    ROM2                     =  READ_ONLY    0xFFC0 TO 0xFFD1 FILL 0x8D;/*  INTVECT                  =  READ_ONLY    0xFFD2 TO 0xFFFF; Reserved for Int. Vectors*/END

and it seems working.

Thanks.

BP.

0 Kudos