Control Law Accelerator (CLA)
10 - 12 C2000 Microcontroller Workshop - Control Law Accelerator
CLA Compiler Scratchpad Memory Area
For local and compiler temporary variables
Static allocation, used instead of a stack
Defined in linker command file
CLA_SCRATCHPAD_SIZE = 0x100;
--undef_sym=__cla_scratchpad_end
--undef_sym=__cla_scratchpad_start
MEMORY
{
}
SECTIONS
{
Cla1Prog :> L3DPSARAM, PAGE = 0
RUN_START(_Cla1Prog_Start)
CLAscratch :{*.obj(CLAscratch
. += CLA_SCRATCHPAD_SIZE;
*.obj(CLAscratch_end)
} > L2DPSARAM, PAGE = 1
}
Lab.cmd
Linker defined symbol
specifies size for
scratchpad area
Scratchpad area
accessed directly
using symbols
All CLA C code will be
placed in the section
Cla1Prog
Symbol used to define
the start of CLA
program memory
Must allocate to
memory section that
CLA has write access
CLA Task C Code Example
#include "Lab.h"
;-------------------------------------
interrupt void Cla1Task1 (void)
{
__mdebugstop();
xDelay[0] = (float32)AdcResult.ADCRESULT0;
Y = coeffs[4] * xDelay[4];
xDelay[4] = xDelay[3];
xDelay[1] = xDelay[0];
Y = Y + coeffs[0] * xDelay[0];
ClaFilteredOutput = (Uint16)Y;
}
;-------------------------------------
interrupt void Cla1Task2 (void)
{
}
;-------------------------------------
ClaTasks_C.cla
.cla extension causes
the c2000 compiler to
invoke the CLA
compiler
All code within this
file is placed in the
section “Cla1Prog”
C Peripheral Register
Header File references
can be used in CLA C
and assembly code
Closing braces are
replaced with MSTOP
instructions when
compiled