Skip to main content
Visitor II
May 3, 2013
Question

Instruction Trap 0x83

  • May 3, 2013
  • 2 replies
  • 693 views
Posted on May 03, 2013 at 18:38

Hi.

I have a program in STM8L152R8, my firmware has a size of 0xEFE1.

I want to prevent that for any reason my microcontroller work bad. So, I want to fill  the rest of the hex file (0x901E) with 0x83 (interrup trap).

in my programm I have the next code (main.c):

void vFill_Trap(void)

{

  &sharpasm

     switch .text

     dcb.b 36894, $83    ; allocate trap bytes

                                       ; all initialized to $83

     &sharpendasm

}

I need the main.c file be the last to compile.

How I can do this?

I use the STVD and Cosmic.

Thanks.

#trap-interrup-0x83-fill-hex
    This topic has been closed for replies.

    2 replies

    Visitor II
    May 7, 2013
    Posted on May 07, 2013 at 14:36

    I'm not sure what you are really trying to do but if you just want to specify the compile order, you can do that very simply. The order in which the source files are compiled is the order in which they appear in your ''workspace project'' folder. Follow the directions outlined in the STVD help manual in section 3.6 ''Ordering source files before assembly.'' Here is what it says:

    1. Add the source files to your project (

      Project > Insert Files Into Project

      )
    2. Right-click on the project in the Workspace window and disable the

      Add Sorted Elements

      option in the project contextual menu.
    3. Drag and drop the source files into the correct order. The first file to be assembled in at the top, the last is at the bottom.
    4. Right-click on the project in the Workspace window and reactivate the

      Add Sorted Elements

      option in the project contextual menu.
    I hope this helps.

    Visitor II
    May 13, 2013
    Posted on May 13, 2013 at 10:26

    Hello,

    if your purpose is to fill all unused bytes with the opcode 0x83 (or any other), the best solution if to use the -f option in the linker command file, as in the following example

    +seg .text -b 0x8080 -m 0x7F80 -f 0x83 -n .text   

    Assuming a flash size of 32k (from 0x8000 to 0xFFFF) and no special segments (a standard, basic configuration) the line above will place your code starting at 0x8080 and fill all unused bytes up to 0xffff with the values 0x83.

    Regards.