K60N512: junp from code in Flash to code in RAM

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

K60N512: junp from code in Flash to code in RAM

Jump to solution
1,531 Views
Thommi_Tulpe
Contributor IV

Hello,

I want to jump from code in flash to code in RAM.

I have changed the Linker Comannd file,so that i have two code segments,

one in Flash and one in RAM:

 

MEMORY {
m_interrupts  (RX) : ORIGIN = 0x00000000, LENGTH = 0x000001E0
m_text        (RX) : ORIGIN = 0x00000800, LENGTH = 0x00080000-0x00000800
m_text2 (RWX) : ORIGIN = 0x1FFF0000, LENGTH = 0x00001000
m_data        (RW) : ORIGIN = 0x1FFF1000, LENGTH = 0x00020000-0x00001000
m_cfmprotrom  (RX) : ORIGIN = 0x00000400, LENGTH = 0x00000010
}

.....

 

with the Inline assembler I want to set the pc to 1FFF0000.

 

First I saved the pc in r14(link register).

 

asm{
     
        MOV r14, pc
        // MOV pc 0x1FFF0000   ???????    I Want to jump to binary code in flash which starts ai address 0x1FFF0000


    }

 

Does someone know how I can jump from a address which is lower than 0x80000   to address 0x1FFF0000 ?

 

Thanks

Thomas

 

 

 

0 Kudos
Reply
1 Solution
1,168 Views
MarkP_
Contributor V

Hi,

try this:

void (*fcn_ram_call)(void);

...

fcn_thumb_flag = 0x01;

fcn_ram_call = (void (*)(void))(0x1fff0000 | fcn_thumb_flag);

fcn_ram_call();

 

~Mark

 

View solution in original post

0 Kudos
Reply
4 Replies
1,168 Views
MarkP_
Contributor V

Hi Thomas,

one example of initializing and running code in RAM is:

bsp_twrk60n512_pe -> twrk60n512 BSP Files -> init_hw.c -> function: pll_init()

(directory ...\Freescale\Freescale MQX 3.7\mqx\source\bsp\twrk60n512)

 

fcn_thumb_flag = (uint_32)set_sys_dividers & 0x01;
fcn_rom_addr = (uint_32)set_sys_dividers & ~(uint_32)0x01;
fcn_ram_addr = (uint_32)fcn_ram_copy | (fcn_rom_addr & 0x02);
...

 

Does your linker generate the code which copies/initializes the RAM code?

 

~Mark

 

0 Kudos
Reply
1,168 Views
Thommi_Tulpe
Contributor IV

Hello Mark,

thank you for the answer.

I have a bare metal project. I have one code section in Flash memory which is (RX).

In the program i made binary code which I load in RAM (at adress 0x1FFF0000) with memcpy.

The code section in RAM is RWX. After the code section in RAM I have a data section (RW).

After that I will run the  binary code. For that I only need an assembler instruction which set

the programcounter to 0x1FFF0000.

 

My project is a console (LCD-Display with touchscreen) on which the user can write assembler code.

The program converts the assembler code in binary code and copys the binary code at adress 0x1FFF0000.

After that, when the user wants to run his code, the program counter must set to 0x1fff000.

I cant set the pc to 0x1fff0000.

 

 

Thanks

Thomas

 

0 Kudos
Reply
1,169 Views
MarkP_
Contributor V

Hi,

try this:

void (*fcn_ram_call)(void);

...

fcn_thumb_flag = 0x01;

fcn_ram_call = (void (*)(void))(0x1fff0000 | fcn_thumb_flag);

fcn_ram_call();

 

~Mark

 

0 Kudos
Reply
1,168 Views
Thommi_Tulpe
Contributor IV

Hello Mark,

thank you.

 

Best Regards

Thomas

0 Kudos
Reply