A typical CLA initialization sequence
is performed by the main CPU as described in this section.
- Copy CLA code into the CLA
program RAM: The source for the CLA code can initially reside in the
Flash or a data stream from a communications peripheral or anywhere the main CPU
can access. The debugger can also be used to load code directly to the CLA
program RAM during development.
- Initialize CLA data RAM, if
necessary: Populate the CLA data RAM with any required data coefficients
or constants.
- Configure the CLA registers:
Configure the CLA registers, but keep interrupts disabled until later (leave
MIER = 0):
- Enable the CLA
peripheral clock using the assigned PCLKCRn register: The
peripheral clock control (PCLKCRn) registers are defined in the
System Control and Interrupts chapter.
- Populate the CLA task
interrupt vectors:
- Select the task
interrupt sources: For each task select the interrupt source in
the CLA1TASKSRCSELx register. If a task is software triggered, select no
interrupt. Since the background task takes the place of Task 8, the task uses
the same peripheral trigger source as task 8.
- Enable IACK to start a
task from software, if desired: To enable the IACK instruction
to start a task set the MCTL[IACKE] bit. Using the IACK instruction
avoids having to set and clear the EALLOW bit. If the background task is enabled, the IACK bit for task 8 is
ignored; the user must, instead, write to the BGSTART bit of the
MCTLBGRND register to start the background task (TRIGEN can be 0 to
avoid a peripheral trigger from causing an overflow, for example,
MSTSBGRND.BGOVF is set to 1).
- Map CLA data RAM to
CLA space, if necessary: Map the data RAM to the CLA space by first, assigning ownership of
the memory block to the CLA by writing a 1 to the memory block’s
MemCfgRegs.LSxMSEL[MSEL_LSx] bit, and then specifying the memory
block as a CLA data block by writing a 0 to the
MemCfgRegs.LSxCLAPGM[CLAPGM_LSx] bit. When an LSx memory is
configured as a CLA data memory, the CLA read/write accesses are
arbitrated along with CPU accesses. The user has the option of
turning on CPU fetch or write protection to the memory by writing to
the appropriate bits of the MemCfgRegs.LSxACCPROTx registers.
- Map CLA program RAM to
CLA space: Map the CLA program RAM to CLA space by first assigning ownership
of the memory block to the CLA by writing a 1 to the memory block’s
MemCfgRegs.LSxMSEL[MSEL_LSx] bit, and then specifying the memory
block as CLA code memory by writing a 1 to the
MemCfgRegs.LSxCLAPGM[CLAPGM_LSx] bit. When an LSx memory is
configured as CLA program memory, only debug accesses are allowed on
cycles in which the CLA is not fetching a new instruction.
- Initialize the PIE vector
table and registers: When a CLA task completes, the associated interrupt
in the PIE is flagged. The CLA overflow and underflow flags also have associated
interrupts within the PIE.
- Enable CLA tasks/interrupts:
Set appropriate bits in the interrupt enable register (MIER) to allow the
CLA to service interrupts. Note that a CLA task only triggers on a level
transition (a falling edge) of the configured interrupt source. If a peripheral
is enabled and an interrupt fires before the CLA is configured, then the CLA
does not recognize the interrupt edge and does not respond. To avoid this,
configure the CLA before the peripherals or clear any pending peripheral
interrupts before setting bits in the MIER register.
- Initialize other peripherals:
Initialize any peripherals (such as ePWM, ADC, and others) that generate
interrupt triggers for enabled CLA tasks.
The CLA is now ready to
service interrupts and the message RAMs can be used to pass data between the
CPU and the CLA. Mapping of the CLA program and data RAMs typically occurs
only during the initialization process. If the RAM mapping needs to be
changed after initialization, the CLA interrupts must be disabled and all
tasks must be completed (by checking the MIRUN register) prior to modifying
the RAM ownership.