Click here to Skip to main content
15,889,335 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
I am using Kinetis Design Studio IDE and the Processor on which am programming is MKE02Z64VLD2 (Kinetis E series). The Flash memory area of this processor is 0X0000_0000 to 0X07FF_FFFF . My code is in C language. I need to put a piece of code into the flash memory space of this processor. If its Assembly, then we use

.org 0X0000_0000 {CODE} 


where 0X0000_0000 is the starting address of the flash space. So the code written after the .org statement will be written to memory space whose starting address is 0X00000000.

What is its equivalent statement in C ?

What I have tried:

I tried using PRAGMA tags but I dont know whether it is working.
main()
{
#pragma section 0X00000000;
sample code;
}
Will pragma tags work for the IDE which I use ?
Posted
Updated 17-Feb-16 23:27pm

1 solution

A compiler generates relocatable object files which are then linked. While there might be an option for the C compiler (check the manual for your compiler), it is more probable that a fixed start address is passed to the linker or defined in some configuration file (probably a processor specific config file). There may be also an option in the project settings of the IDE.

If the used compiler is GCC and there is an option to specify the address it would not use a pragma statement but an __attribute__() statement. A quick web research found Defining Variables at Absolute Addresses with gcc | MCU on Eclipse[^] describing how to store variables at fixed addresses. So there should be a similar way for functions.

You might get better help asking in a related forum like Space: Kinetis Design Studio | NXP Community[^].
 
Share this answer
 
Comments
GaneshRfromSpace 19-Feb-16 0:38am    
Hey the link which you gave explains, how to place a variable in a specific address. My doubt is how to place a piece of code in a specific address. Anyways Good Answer. Thanks.
Jochen Arndt 19-Feb-16 2:48am    
Thank you for your feedback.

Your question was very specific and there are probably only a few (if any) here at CP that know the IDE and the processors. I just tried to point you into some direction with my knowledge of other micro processor IDEs and compilers.

GaneshRfromSpace 19-Feb-16 2:56am    
You are awesome Jochen. Thanks alot for helping me out.

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900