
10. CAUTIONS FOR CODING B-63322EN-2/01
- 42 -
10.1 OVERVIEW
When creating application programs, observe the following cautions:
1. Do not perform division by zero.
2. When using data of type float or double, do not perform an
arithmetic operation on that data with NaN (nonnumeric) held.
3. Before converting data from type float or double to an integral
type, make sure that the resulting data will not fall outside the
valid data range of the target integral type.
4. The following restrictions are imposed on the alignment of
variables to be placed.
One-byte variable : No restriction
Two-byte variable : The least significant digit of the address
must be 0, 2, 4, 8, a, c, or e.
Four-byte variable : The least significant digit of the address
must be 0, 4, 8, or c.
Eight-byte variable : The least significant digit of the address
must be 0 or 8.
5. Stack area size
When switching tasks, the system software saves contexts into the
stack for the task that is currently being executed. The stack size
used for the saved data is about 1 Kbyte.
Therefore, the stack must be large enough to hold these contexts.
6. If more than 500 updates are performed on the same variable in an
area accessed from the CNC side, it may lower the processing
speed of the CNC side or lead to a system alarm condition.
Therefore, issue the sc_access_wait system call at least once
every 500 updates.
(Example) In the following example, variable count is updated
more than 500 times.
extern int count;
for ( ; ; ) {
count ++;
if ( count > 100000 ) break;
}