 |
|
 |
MAEC TOOL NEWS:
MAECT-M3T-NC308WA_1-011116D
M3T-NC308WA and M3T-NC30WA Precautions (IMPORTANT)
|
NOTICE:
This news describes how to use compilers correctly to develop your target programs. So, please don't neglect reading this to prevent your programs from involving serious errors. Be aware that the problem explained below arises as the optimizing functions of the compilers concerned have been significantly enhanced.
Please take note of the problem explained below in using C compilers (with an assembler and integrated development environment) M3T-NC308WA and M3T-NC30WA.
- Products and Versions Concerned
| M3T-NC308WA | : V.3.10 Release 1 -- V.3.10 Release 2 |
| M3T-NC30WA | : V.4.00 Release 2 |
- Problem
When any of the -O, -O3, -O4, -O5, -OR, and -OS optimizing options is used, the compiler generates in some cases BTSTC or BTSTS bit manipulation instructions. In M16C, the BTSTC and BTSTS bit manipulation instructions are prohibited from rewriting the contents of the interrupt control registers. However, the compiler does not recognize the type of any register, so, should BTSTC or BTSTS instructions be generated for interrupt control registers,
the assembled program will be different from the one you intend to develop. For detailed information about this, see Section 5 and 6.
When using any of the products concerned, ensure that no incorrect code is generated.
- Note:
- In the products other than those concerned, this problem does not occur because BTSTC and BTSTS instructions are not generated if any of the above-mentioned optimizing options is used.
- Workaround
This problem will be circumvented in either of the following ways:
Make sure that no BTSTC and BTSTS instructions are generated after these side-steppings.
- Example
When any of the -O, -O3, -O4, -O5, -OR, and -OS optimizing options is used in the program shown below, a BTSTC instruction is generated at compilation, which prevents an interrupt request bit from being processed correctly, resulting in the assembled program performing improper operations.
-------------------------------------------------------------------------
#pragma ADDRESS TA0IC 0055h /* M16C/62 MCU's Timer A0 interrupt
control register */
struct {
char ILVL : 3;
char IR : 1; /* An interrupt request bit */
char dmy : 4;
} TA0IC;
void wait_until_IR_is_ON(void)
{
while (TA0IC.IR == 0) /* Waits for TA0IC.IR to become 1 */
{
;
}
TA0IC.IR = 0; /* Returns 0 to TA0IC.IR
when it becomes 1 */
}
-------------------------------------------------------------------------
- "Precautions for Interrupts" Described in Related Documents for Microcomputer (Excerpts)
The excerpts of the descriptions on "Precautions for Interrupts" in data sheets and User's Manuals of M16C MCUs are shown below.
[Precautions for Interrupts]
When a instruction to rewrite the interrupt control register is executed but the interrupt is disabled, the interrupt request bit is not set sometimes even if the interrupt request for that register has been generated. This will depend on the instruction. If this creates problems, use the below instructions to change the register.
Instructions: AND, OR, BCLR, BSET
- Precautions on writing to or reading a register in the SFR area -Described in Related Documents for Compiler (Excerpts)
The following is described in the document of each compiler.
When writing to or reading a register in the SFR area, it may sometimes be necessary to use a specific instruction. Because this specific instruction varies with each type of MCU, consult the user's manual of your MCU for details.
In this case, write the instruction directly in the program using the ASM function.
When accessing registers in the SFR area in C language, make sure that the same correct instructions are generated as done by using asm functions, regardless of the compiler's version and of whether optimizing options are used or not.
- [Related Documents]
| NC308 User's Manual: | 3.1.2 Notes about the M16C's Type Dependent Part |
| NC30 User's Manual: | 3.1.2 Notes about the M16C's Type Dependent Part |
| M3T-NC308WA Release Note: | Precaution M16C Family-Dependent Code |
| M3T-NC30WA Release Note: | Precaution M16C Family-Dependent Code |
- Note: Although the above descriptions are not found in several documents released before 2000, the same cautions should be observed in those cases.
|
 |