29.4.5.1 Using the Loop Counter as a Block Loop Counter

The PTGJMPCx (Jump Conditional) command uses one of the loop counters to keep track of the number of times the PTGJMPCx command is executed, and can therefore be used to create code block loops. This is useful in applications where a sequence of peripheral events needs to be repeated several times. The PTGJMPCx command allows the user to create code loops and use fewer step commands.

Each time the PTGJMPCx command is executed, the corresponding internal loop counter is compared to its limit value. If the loop counter has not reached the limit value, the jump location is loaded into the PTGQPTR register and the loop counter is incremented by one. The next command will be fetched from the new queue location. If the counter has reached the limit, the sequencer proceeds to the next command (i.e., increments the Queue Pointer). While preparing for the next PTGJMPCx command loop execution, the corresponding loop counter is cleared (see Figure 29-2).

Note: The loop counter value can be modified (via the PTGADD or PTGCOPY command) prior to execution of the first iteration of the command loop.

The provision for two separate loop counters and associated PTGJMPCx commands allows for the nested loops to be supported (one-level deep). There are no restrictions with regard to which PTGJMPCx command resides in the inner or outer loops.

Figure 29-2. Implementing Block Loop Diagram