A similar concern is the reuse of the same variable in multiple tasks. Without
some sort of messaging between the two tasks placed into the CRBasic program,
unpredictable results are likely to occur. The SemaphoreGet() and
SemaphoreRelease() instruction pair provide a tool to prevent unwanted access
of an object (variable, COM port, etc.) by another task while the object is in use.
Consult CRBasic Editor Help for information on using SemaphoreGet() and
SemaphoreRelease().
7.8.4.12 Execution Timing
Timing of program execution is regulated by timing instructions listed in the
following table.
Table 19. Program Timing Instructions
Instructions General Guidelines Syntax Form
Scan() / NextScan
Use in most programs. Begins
/ ends the main scan.
BeginProg
Scan()
'.
'.
'.
NextScan
SlowSequence /
EndSequence
Use when measurements or
processing must run at slower
frequencies than that of the
main program.
BeginProg
Scan()
'.
'.
'.
NextScan
SlowSequence
Scan()
'.
'.
'.
NextScan
EndSequence
SubScan / NextSubScan
Use when measurements or
processing must run at faster
frequencies than that of the
main program.
BeginProg
Scan()
'.
'.
'.
SubScan()
'.
'.
'.
NextSubScan
NextScan
7.8.4.12.1 Scan() / NextScan
Simple CR1000 programs are often built entirely within a single Scan() /
NextScan structure, with only variable and data-table declarations outside the
scan. Scan() / NextScan creates an infinite loop; each periodic pass through the
loop is synchronized to the CR1000 clock. Scan() parameters allow modification
154