How to Define a Custom INIT Section in Softune V3 for 16FX – KBA219887
- Subscribe to RSS Feed
- Mark as New
- Mark as Read
- Bookmark
- Subscribe
- Printer Friendly Page
- Report Inappropriate Content
Version: **
Translation - Japanese: Softune V3 for 16FXでカスタムINITセクションを定義する方法 – KBA219887 - Community Translated (JA)
Question:
Variables with initial value is expected to be located in a specific area of RAM. How do I define a custom INIT section for this in Softune for 16FX?
Answer:
In Softune V3 for 16-bit MCU, do the following to define a custom INIT section to store initialized variables in a specific RAM area:
1. Define the RAM area and custom section in Softune project setup.
In Softune, click Project > Setup Project and select the Linker tab. Then select Category: Disposition/Connection to define the RAM area and section name.
Figure 1. Steps to Define RAM Area and Section Name in Softune
Here, set the RAM area 0x7000~0x7FFF for _INRAM02 to store variables with an initial value. Define the TESTINIT section in the _INRAM02 area. The section name can also be defined by adding “-sc TESTINIT/Data/BYTE=_INRAM02” in the Option window directly as displayed in Figure 2.
Figure 2. Add Command to Option Window to Define Section Name
2. Modify the start.asm file to initialize the variables defined in the TESTINIT section during startup. Follow the steps shown in Figure 3
Figure 3. Steps to Modify start.asm
3. Define initialized variables in the custom section with the #pragma segment.
//Eg. Test.c
#pragma segment DCONST=TESTDCONST,attr=CONST
#pragma segment INIT=TESTINIT,attr=DATA
unsigned char test1=0x1;
unsigned char test2=0x2;
4. Build the Softune project and check the address of the variables in the map file (.mp1). Variable test1 and test2 are located in the _INRAM02 area.
Figure 4. Results in map file (.mp1)
For information about default section of Softune compiler, refer to F2MC-16 Family SOFTUNE™ C Compiler Manual.