Place own binary code in program memory TWRK60N512

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

Place own binary code in program memory TWRK60N512

681 Views
Thommi_Tulpe
Contributor IV

Hello,

i have to place my own assembled binary code into the

program memory (RAM) e. g. at the address 0x70000.

My code is very small only a few 32 bit arm instructions.

At the end of the code I jump back to the main programm.

(mov pc, r14)

 

How can I place my binary code at address 0x70000 in RAM.

I will place my 32 bit instructions in a array.  The first member of the array must placed at 0x70000,

the second at 0x70004, and so on.

I using the CodeWarrior 10.1

 

 

 

Best Regards

Thomas

0 Kudos
2 Replies

437 Views
mjbcswitzerland
Specialist V

Thomas

 

Presumably you will need to have the small code stored in Flash memory and copy it to RAM when the processor starts.

I assume that simply memcpy((void *)0x70000, code_array, sizeof(code_array)); will be adequate, where code_array[] is your code in flash.

 

Regards

 

Mark

 

0 Kudos

437 Views
Thommi_Tulpe
Contributor IV

Hello Marc,

i made an mistake.

I don't want to place my binary code at 0x70000, because its Flash.

 

I want to place my binary code in RAM Memory. (eg. 0x1fff000-0x1fff800)

I use the default lcf-file.(MK60N512VMD100_flash.lcf)

Do I have to change the Linker Command File ?

 

I want to have my main code in flash and my selfmade binary code in RAM.

 

 

This is what I want:

 

code_array[0] = 0xE3A00000;      // MOV r0, #0
code_array[1] = 0xE2800001;      // ADD r0, #1
code_array[2] = 0xE340000A;     // CMP r0, #10 
code_array[3] = 0x1AFFFFFE;
code_array[4] = 0xE1AEF000;   // MOV pc, r14 (return to flash-program)

        
 memcpy((void *)0x1FFF0000, code_array, sizeof(code_array));   // copy binary code in RAM

 

asm{
        MOV r14, pc
        MOV pc, #0x1FFF0000        
    };       //jump to binary code in RAM

 

 

Thanks

0 Kudos