4 programming precautions, Programming language – Toshiba T2N User Manual

Page 237

Advertising
background image

5. Programming Language

224

PROSEC T2N

The T2N supports multi-task functions. When interrupt programs are
used there is the possibility of the main program being interrupted by an
interrupt program. Precautionary notes arising from this are given below,
and should be taken into account when creating programs.

(1)

Avoid using the same sub-routine in the main program and an
interrupt program. When the main program exection is interrupted
during a sub-routine is being executed and the same sub-routine
is executed in that state, the results after re-starting are
sometimes not as expected.

(2)

There is no classification of user data (register/device) by
program type. Therefore, take thorough precautions over
individual data do that there is no erroneous mixed use between
program types.

Example)

(3)

Try to execute the exchange of data between main and interrupt
programs by 1 instruction, such as the data transfer instruction
(MOV) or the table transfer instruction (TMOV) or by using the
interrupt disble (DI) and the interrupt enable (EI) instruction
Otherwise, the same thing as in (2) above may happen.

Example)

Composition of the main program when transferring
the three data, D1000, D1001 and D1002, from an
interrupt program to the main program.

In the above program, when an interrupt occurs between
instructions, synchronisation between D2000, D2001 and D2002
cannot be guaranteed. In this case, make 1 instruction by using
the table transfer instruction, as follows.

|–[

D1000

TMOV

(3)

D2000

]––––––|

5.4

Programming

Precautions

interrupt

Interrupt occurs through the timing in the above diagram. And when the content of R0 is
modified in the interrupt, the simultaneous ON (or the simultaneous OFF) of Y0 and Y1,
which normally could not occur, happens.

Advertising