TC1796
System Units (Vol. 1 of 2)
Peripheral Control Processor (PCP)
User’s Manual
11-113
V2.0, 2007-07
PCP, V2.0
11.12.1.2 Channel Resume
When PCP_CS.RCB = 0, the program counter of the PCP is vectored to the address that
is restored from the channel program’s context. This means that before exiting, a
channel program must itself arrange for where it will resume execution by configuring the
value of its PC in its saved context so that it restarts at the desired location.
In this way, arbitrarily complex interrupt-driven state machines can be created as
individual channel programs. Channel programs can be constructed that always start at
their beginning, pick up where they left off, or pick up elsewhere, or have a mix of these
approaches.
An example of a restarting channel program is shown below. Before exiting, the channel
branches back to the address of the START label minus 1 (note that START – 1 = CH16)
and then exits. This will leave the next value of the PC in the channel program’s context
as the address of the START label.
CH16:
;channel program 16
EXIT EC=1 ST=0 INT=0 EP=1 cc_UC
;exit, no intr., leave PC @ next
START:
;nominal channel start address
ST.IF base #0x8 SIZE=32
;output note from R0
JC
CH16, cc_UC
;loop back before exit
Note that when the channel program is originally configured by the programmer, the PC
field in the R7 context of this channel program should also be set to the address of the
START label.
Similarly, an interrupt-driven state machine can be created by exiting with the next PC
value pointing to the start of the next state in a state machine implemented by the
channel program. The next example below shows a program starting at the address to
the STATE0 label. It proceeds after the first interrupt to STATE1 - 1, where the channel
program is left ready for the next state, STATE1 in the state machine. After the next
interrupt, it executes to address STATE2 - 1 and the channel program is left ready for
the next state, STATE2. After another interrupt, it proceeds through STATE2. The
channel program jumps back to START, which is STATE0 - 1. The state machine has
gone through one cycle and it is ready to restart in STATE0.
;This program is intended to test the sequence of exit/operate
;just as if you were implementing an interrupt driven state
;machine.
;It requires a periodic sequence of interrupts.
START:
EXIT EC=1,ST=0,INT=0,EP=1,cc_UC
;begin exit
STATE0:
COMP.I
R5,#0x0
;compare to interrupt number it
;should be