12 Programming Model
12 – 12
The subroutine begins by loading the counter register (CNTR). The new
sample is read from SPORT0’s receive data register, RX0, into the SI
register; the choice of SI is of no particular significance. Then, the data is
written into the data buffer. Because of the automatic circular buffer
addressing, the new data overwrites the oldest sample. The N-most recent
samples are always in the buffer.
The fourth instruction of the routine,
MR=0, MY0=PM(I4,M4),
MX0=DM(I0,M0)
, zeroes the multiplier result register (MR) and fetches
the first two operands. This instruction accesses both program and data
memory but still executes in a single cycle because of the processor’s
architecture.
The convolution label identifies the loop itself, consisting of only two
instructions, one setting up the loop (DO UNTIL) and one “inside” the
loop. The MAC instruction multiplies and accumulates the previous set of
operands while fetching the next ones from each memory. This instruction
also accesses both memories.
The final value is transferred back to SPORT0, to the transmit data register
TX0, to be sent to the communicating device.