From an experienced programmer perspective, the following notes taken from a real project using Renesas SH7047 will help you grasp the most important aspects in the use of Renesas microcontroller development tool HEW, the High-performance Embedded Workshop V4. 1. Create Organized Project Structure
It is a good practice to have a well-organized project structure rather than a flat structure. The project structure within HEW does not have to be the same as the project folder structure on your local drive, although it might be better that way.
Here is an example of my project structure in HEW.

Here is the project folder structure on my local drive

2. Add Project Files to Project Structure
Click menu Proejct->Add Files, browse to the files in the folders on your local drive, the assembly files and C files are added to the default folder Assembly source file and C source file under your HEW project respectively. Now drag-n-drop the files to the project subfolders as appropriate. Doing so does not change the location property of the files.
Note: Don’t create a header folder in your project and add the header files into it. The compiler will check the file dependencies and add them to the default Dependencies folder.
3. Toolchain Setting All compiler and linker settings are done through the toolchain dialog, which is accessed through the menu Build->SuperH RISC Engine Standard Toolchain. 3.1 Setting Include File Path
You must set all include file path correctly otherwise the compiler will emit “couldn’t find file” error. When specify include file path as well as module path, use relative path instead of absolute path, which facilitates project relocation. Mostly relative to project directory is a good choice. An example is shown below.

3.2 Execution Start Address
Only if the execution start address is an externally defined symbol such as from library file or an absolute address, the start address needs specified. If it is a symbol in your file, the reset vector shall point to the symbol. Therefore, it is not necessary to specify the execution start address.
There are two methods to specify the start address when it is needed.
One method is use ENTRY command in a source file. Example: Entry = _crt0 Entry = 100
Another method is use the toolchain setting option. Example:

3.3 Linker Section Command
Similar to a linker command file except some limitation, HEW uses a dialog for programmer to specify program sections. To set a code section into a specific memory area, you need to do two things. First, define a code section name by using #pragma directive.
Example:
#pragma section DUPVECT
void *Duplicate_RESET_Vectors[] = { PowerON_Reset_PC, // Power On Reset PC
__secend("S"), // Power On Reset SP
Manual_Reset_PC, // Manual Reset PC
__secend("S") // Manual Reset SP };
#pragma section ResetPRG
void PowerON_Reset_PC(void) { //set the vector base register to the relocated address set_vbr((char *)&Duplicate_RESET_Vectors); //initialize B section to 0 and copies D section in ROM to R section in RAM _INITSCT(); HardwareSetup(); set_cr(SR_INIT);
main(); //call C code entry }
Secondly, specify the start address in the Section setting.
Note: after switching section, data section name becomes D<section name>, e.g., DDUPVECT, program section name becomes P<section name>, e.g., PResetPRG, as shown in the example below. 
3.4 Build Path
If the option “Generate map file” under Output category in the Link/Library tab is checked, the build files will be put in a subdirectory named “1st” under the build configuration directory, instead of the build configuration directory itself. But the MAP command looks for the map file under the build configuration directory, where it can not be found, therefore, neither section nor symbol information can be found. This behaviour seems a bug in the version 4.02.00.022.
If the option “Generate map file” is unchecked, the build files will be saved in the build configuration directory, and if the option “Generate list file” in the List category is checked, the map file is also generated there, hence, clicking MAP icon shows correct section and symbol information. Below are the correct settings.

3.5 ROM Support Function
A mapping RAM area must be reserved for the initialized variables and defined symbols in ROM. It is done through the Show entry for “ROM to RAM mapped section” in the Output category on Link/Library tab. An example is shown below.

3.6 Standard Library
It is not necessary to include standard library files into a project; library modules are built for the project according to option selection. Select the header files that are needed by checking them in the following tab.
 Tip: Select “Build a library file (option changed)” mode, so that the standard library won’t be built every time unless any option has been changed.

4 The Cause of “Can’t Open Internal File”
If Windows 2000 Indexing service (cisvc.exe) is running, it may open a file when the compiler also tries to write to it, then “Can’t open internal file” error will occur. So in Windows 2000, stop the service and change its startup type to manual so that it won’t be started automatically when the computer boots up. This issue does not occur in Windows XP though.
 |