cancel
Showing results for 
Search instead for 
Did you mean: 

Executing independently compiled code in RAM.

VNilo
Associate

I have a device that must execute precompiled functions which are copied to a place in RAM.

Function calling:

PLC_main = (pFunc_main) 0x30000001; 
PLC_main();

Compied function:

    PLC_1
        0x30000000:    4811        .H      LDR      r0,[pc,#68] ; [0x30000048] = 0x30020004
        0x30000002:    6800        .h      LDR      r0,[r0,#0]
        0x30000004:    1c80        ..      ADDS     r0,r0,#2
        0x30000006:    4910        .I      LDR      r1,[pc,#64] ; [0x30000048] = 0x30020004
        0x30000008:    6008        .`      STR      r0,[r1,#0]
        0x3000000a:    4608        .F      MOV      r0,r1
        0x3000000c:    6800        .h      LDR      r0,[r0,#0]
        0x3000000e:    4770        pG      BX       lr

But after calling this function, program jumps to some place in flash and runs from there.

Is it possible to make a precompiled function to return to a place where it is called ?

2 REPLIES 2

What MCU?

You should be able to step into the RAM code and return via BX​ LR

Try 0x20000000 SRAM

Tips, Buy me a coffee, or three.. PayPal Venmo
Up vote any posts that you find helpful, it shows what's working..
VNilo
Associate

STM32H743 mcu. Keil cannot run by step since function called, it begins to run, but if i stop it manually, i see code execution from flash. Not a code that placed after a function call, because i have a breakpoint there. It looks like this function returns but not to a place where it was called.