Update repo
This commit is contained in:
1 parent
749dab5721
commit
ce65a0f59a
14950 files changed
+4408250
-1
No files matched your search
@@ -0,0 +1,13 @@
|
||||
/* f280013x_link.cmd */
|
||||
|
||||
SECTIONS
|
||||
{
|
||||
dclfuncs : > RAMLS0, align(2)
|
||||
|
||||
PDataLogSection : >> RAMLS0, align(4)
|
||||
QDataLogSection : >> RAMLS0, align(4)
|
||||
RDataLogSection : >> RAMLS1, align(4)
|
||||
SDataLogSection : >> RAMLS1, align(4)
|
||||
}
|
||||
|
||||
/* end of file */
|
||||
@@ -0,0 +1,13 @@
|
||||
/* f280015x_link.cmd */
|
||||
|
||||
SECTIONS
|
||||
{
|
||||
dclfuncs : > RAMLS0, align(2)
|
||||
|
||||
PDataLogSection : >> RAMLS0, align(4)
|
||||
QDataLogSection : >> RAMLS0, align(4)
|
||||
RDataLogSection : >> RAMLS1, align(4)
|
||||
SDataLogSection : >> RAMLS1, align(4)
|
||||
}
|
||||
|
||||
/* end of file */
|
||||
@@ -0,0 +1,37 @@
|
||||
/* f280025_link.cmd */
|
||||
|
||||
SECTIONS
|
||||
{
|
||||
codestart : > BEGIN, PAGE = 0
|
||||
.TI.ramfunc : > RAMM0 PAGE = 0
|
||||
/* .text : >> FLASH_BANK0_SEC0 | FLASH_BANK0_SEC1, PAGE = 0 */
|
||||
.text : > RAMLS456 PAGE = 0
|
||||
.cinit : > RAMM0, PAGE = 0
|
||||
.switch : > RAMM0, PAGE = 0
|
||||
.reset : > RESET, PAGE = 0, TYPE = DSECT
|
||||
.stack : > RAMM1, PAGE = 1
|
||||
|
||||
#if defined(__TI_EABI__)
|
||||
.bss : > RAMGS0b
|
||||
.bss:output : > RAMGS0b
|
||||
.bss:cio : > RAMGS0b
|
||||
.init_array : > RAMGS0b
|
||||
.const : > RAMGS0b, PAGE = 1
|
||||
.data : > RAMGS0b, PAGE = 1
|
||||
.sysmem : > RAMGS0b, PAGE = 1
|
||||
#else
|
||||
.pinit : > RAMM0, PAGE = 0
|
||||
.ebss : > RAMGS0b, PAGE = 1
|
||||
.econst : > RAMGS0b, PAGE = 1
|
||||
.esysmem : > RAMGS0b, PAGE = 1
|
||||
.cio : > RAMLS0, PAGE = 0
|
||||
#endif
|
||||
|
||||
dclfuncs : > RAMM0, PAGE = 0 align(2)
|
||||
|
||||
pDataLogSection : >> RAMLS7a, PAGE = 1 align(4)
|
||||
qDataLogSection : >> RAMLS7b, PAGE = 1 align(4)
|
||||
sDataLogSection : >> RAMGS0a, PAGE = 1 align(4)
|
||||
}
|
||||
|
||||
/* end of file */
|
||||
@@ -0,0 +1,57 @@
|
||||
/* f280025_stdmem.cmd */
|
||||
|
||||
MEMORY
|
||||
{
|
||||
PAGE 0 :
|
||||
BEGIN : origin = 0x000000, length = 0x000002
|
||||
RAMM0 : origin = 0x0000F5, length = 0x00030B
|
||||
RAMLS456 : origin = 0x00A000, length = 0x001800
|
||||
RESET : origin = 0x3FFFC0, length = 0x000002
|
||||
|
||||
/* BANK 0 */
|
||||
FLASH_BANK0_SEC0 : origin = 0x080000, length = 0x001000
|
||||
FLASH_BANK0_SEC1 : origin = 0x081000, length = 0x001000
|
||||
FLASH_BANK0_SEC2 : origin = 0x082000, length = 0x001000
|
||||
FLASH_BANK0_SEC3 : origin = 0x083000, length = 0x001000
|
||||
FLASH_BANK0_SEC4 : origin = 0x084000, length = 0x001000
|
||||
FLASH_BANK0_SEC5 : origin = 0x085000, length = 0x001000
|
||||
FLASH_BANK0_SEC6 : origin = 0x086000, length = 0x001000
|
||||
FLASH_BANK0_SEC7 : origin = 0x087000, length = 0x001000
|
||||
FLASH_BANK0_SEC8 : origin = 0x088000, length = 0x001000
|
||||
FLASH_BANK0_SEC9 : origin = 0x089000, length = 0x001000
|
||||
FLASH_BANK0_SEC10 : origin = 0x08A000, length = 0x001000
|
||||
FLASH_BANK0_SEC11 : origin = 0x08B000, length = 0x001000
|
||||
FLASH_BANK0_SEC12 : origin = 0x08C000, length = 0x001000
|
||||
FLASH_BANK0_SEC13 : origin = 0x08D000, length = 0x001000
|
||||
FLASH_BANK0_SEC14 : origin = 0x08E000, length = 0x001000
|
||||
FLASH_BANK0_SEC15 : origin = 0x08F000, length = 0x001000
|
||||
|
||||
/* BANK 1 */
|
||||
FLASH_BANK1_SEC0 : origin = 0x090000, length = 0x001000
|
||||
FLASH_BANK1_SEC1 : origin = 0x091000, length = 0x001000
|
||||
FLASH_BANK1_SEC2 : origin = 0x092000, length = 0x001000
|
||||
FLASH_BANK1_SEC3 : origin = 0x093000, length = 0x001000
|
||||
FLASH_BANK1_SEC4 : origin = 0x094000, length = 0x001000
|
||||
FLASH_BANK1_SEC5 : origin = 0x095000, length = 0x001000
|
||||
FLASH_BANK1_SEC6 : origin = 0x096000, length = 0x001000
|
||||
FLASH_BANK1_SEC7 : origin = 0x097000, length = 0x001000
|
||||
FLASH_BANK1_SEC8 : origin = 0x098000, length = 0x001000
|
||||
FLASH_BANK1_SEC9 : origin = 0x099000, length = 0x001000
|
||||
FLASH_BANK1_SEC10 : origin = 0x09A000, length = 0x001000
|
||||
FLASH_BANK1_SEC11 : origin = 0x09B000, length = 0x001000
|
||||
FLASH_BANK1_SEC12 : origin = 0x09C000, length = 0x001000
|
||||
FLASH_BANK1_SEC13 : origin = 0x09D000, length = 0x001000
|
||||
FLASH_BANK1_SEC14 : origin = 0x09E000, length = 0x001000
|
||||
FLASH_BANK1_SEC15 : origin = 0x09F000, length = 0x001000
|
||||
|
||||
PAGE 1 :
|
||||
BOOT_RSVD : origin = 0x000002, length = 0x0000F3
|
||||
RAMM1 : origin = 0x000400, length = 0x000400
|
||||
RAMLS7a : origin = 0x00B800, length = 0x000400
|
||||
RAMLS7b : origin = 0x00BC00, length = 0x000400
|
||||
RAMGS0a : origin = 0x00C000, length = 0x000400
|
||||
RAMGS0b : origin = 0x00C400, length = 0x000400
|
||||
|
||||
}
|
||||
|
||||
/* end of file */
|
||||
@@ -0,0 +1,12 @@
|
||||
/* f280039c_link.cmd */
|
||||
|
||||
SECTIONS
|
||||
{
|
||||
dclfuncs : > RAMLS3, align(2)
|
||||
|
||||
pDataLogSection : >> RAMLS6_7, align(4)
|
||||
qDataLogSection : >> RAMLS6_7, align(4)
|
||||
sDataLogSection : >> RAMGS0, align(4)
|
||||
}
|
||||
|
||||
/* end of file */
|
||||
@@ -0,0 +1,51 @@
|
||||
/* F280049_DCL.cmd
|
||||
*
|
||||
* Copyright (C) 2020 Texas Instruments Incorporated - http://www.ti.com/
|
||||
* ALL RIGHTS RESERVED
|
||||
*
|
||||
*/
|
||||
|
||||
SECTIONS
|
||||
{
|
||||
/* 22-bit program sections */
|
||||
.reset : load = RESET, type = DSECT, PAGE = 0 /* reset vector in internal boot ROM */
|
||||
codestart : > BEGIN, PAGE = 0
|
||||
|
||||
/* program sections */
|
||||
.text : > RAMLS02, PAGE = 0 /* default code section */
|
||||
.code : > RAMLS02, PAGE = 0 /* assembly code section */
|
||||
|
||||
.pinit : > RAMLS4, PAGE = 0 /* global constructor table */
|
||||
.cinit : > RAMLS4, PAGE = 0 /* initialised variables */
|
||||
.data : > RAMLS4, PAGE = 0 /* constant data */
|
||||
.switch : > RAMLS4, PAGE = 0 /* switch tables */
|
||||
.init_array : > RAMLS4, PAGE = 0 /* for EABI */
|
||||
|
||||
/* 16-Bit data sections */
|
||||
.const : > RAMLS5, PAGE = 1 /* near constants */
|
||||
.bss : > RAMLS5, PAGE = 1 /* near variables */
|
||||
.stack : > RAMM1, PAGE = 1 align(2) /* stack: even word alignment */
|
||||
.sysmem : > RAMLS6, PAGE = 1 /* near dynamic memory */
|
||||
.cio : > RAMLS6, PAGE = 1 /* string constants */
|
||||
|
||||
/* 32-bit data sections */
|
||||
.ebss : > RAMLS5, PAGE = 1 /* far variables [RAMM0] */
|
||||
.econst : > RAMLS7, PAGE = 1 /* far constants [RAMM0] */
|
||||
.esysmem : > RAMLS7, PAGE = 1 /* far dynamic memory [RAMM0] */
|
||||
|
||||
/* DCL functions */
|
||||
dclfuncs : > RAMLS02 PAGE = 0
|
||||
dcl32funcs : > RAMLS02 PAGE = 0
|
||||
.TI.ramfunc : > RAMLS02 PAGE = 0
|
||||
|
||||
/* data buffers */
|
||||
pDataLogSection : > RAMGS0, PAGE = 1 align(2)
|
||||
qDataLogSection : > RAMGS1, PAGE = 1 align(2)
|
||||
rDataLogSection : > RAMGS2, PAGE = 1 align(2)
|
||||
sDataLogSection : > RAMGS3, PAGE = 1 align(2)
|
||||
|
||||
interruptSection : > RAMLS3, PAGE = 0
|
||||
|
||||
}
|
||||
|
||||
/* end of file */
|
||||
@@ -0,0 +1,51 @@
|
||||
/* F280049_ERAD.cmd
|
||||
*
|
||||
* Copyright (C) 2020 Texas Instruments Incorporated - http://www.ti.com/
|
||||
* ALL RIGHTS RESERVED
|
||||
*
|
||||
*/
|
||||
|
||||
SECTIONS
|
||||
{
|
||||
/* 22-bit program sections */
|
||||
.reset : load = RESET, type = DSECT, PAGE = 0 /* reset vector in internal boot ROM */
|
||||
codestart : > BEGIN, PAGE = 0
|
||||
|
||||
/* program sections */
|
||||
.text : > RAMLS02, PAGE = 0 /* default code section */
|
||||
.code : > RAMLS02, PAGE = 0 /* assembly code section */
|
||||
|
||||
.pinit : > RAMLS4, PAGE = 0 /* global constructor table */
|
||||
.cinit : > RAMLS4, PAGE = 0 /* initialised variables */
|
||||
.data : > RAMLS4, PAGE = 0 /* constant data */
|
||||
.switch : > RAMLS4, PAGE = 0 /* switch tables */
|
||||
.init_array : > RAMLS4, PAGE = 0 /* for EABI */
|
||||
|
||||
/* 16-Bit data sections */
|
||||
.const : > RAMLS5, PAGE = 1 /* near constants */
|
||||
.bss : > RAMLS5, PAGE = 1 /* near variables */
|
||||
.stack : > RAMM1, PAGE = 1 align(2) /* stack: even word alignment */
|
||||
.sysmem : > RAMLS6, PAGE = 1 /* near dynamic memory */
|
||||
.cio : > RAMLS6, PAGE = 1 /* string constants */
|
||||
|
||||
/* 32-bit data sections */
|
||||
.ebss : > RAMLS5, PAGE = 1 /* far variables [RAMM0] */
|
||||
.econst : > RAMLS7, PAGE = 1 /* far constants [RAMM0] */
|
||||
.esysmem : > RAMLS7, PAGE = 1 /* far dynamic memory [RAMM0] */
|
||||
|
||||
/* DCL functions */
|
||||
dclfuncs : > RAMLS02 PAGE = 0
|
||||
dcl32funcs : > RAMLS02 PAGE = 0
|
||||
.TI.ramfunc : > RAMLS02 PAGE = 0
|
||||
|
||||
/* data buffers */
|
||||
pDataLogSection : > RAMGS0, PAGE = 1 align(2)
|
||||
qDataLogSection : > RAMGS1, PAGE = 1 align(2)
|
||||
rDataLogSection : > RAMGS2, PAGE = 1 align(2)
|
||||
sDataLogSection : > RAMGS3, PAGE = 1 align(2)
|
||||
|
||||
interruptSection : > RAMLS3, PAGE = 0
|
||||
|
||||
}
|
||||
|
||||
/* end of file */
|
||||
@@ -0,0 +1,36 @@
|
||||
/* F280049_stdmem.cmd
|
||||
*
|
||||
* Copyright (C) 2020 Texas Instruments Incorporated - http://www.ti.com/
|
||||
* ALL RIGHTS RESERVED
|
||||
*
|
||||
*/
|
||||
|
||||
MEMORY
|
||||
{
|
||||
PAGE 0 :
|
||||
/* BEGIN is used for the "boot to SARAM" bootloader mode */
|
||||
|
||||
BEGIN : origin = 0x000000, length = 0x000002
|
||||
RAMM0 : origin = 0x0000F5, length = 0x00030B
|
||||
|
||||
RAMLS02 : origin = 0x008000, length = 0x001800
|
||||
RAMLS3 : origin = 0x009800, length = 0x000800
|
||||
RAMLS4 : origin = 0x00A000, length = 0x000800
|
||||
RESET : origin = 0x3FFFC0, length = 0x000002
|
||||
|
||||
PAGE 1 :
|
||||
|
||||
BOOT_RSVD : origin = 0x000002, length = 0x0000F3 /* Part of M0, BOOT rom will use this for stack */
|
||||
RAMM1 : origin = 0x000400, length = 0x000400 /* on-chip RAM block M1 */
|
||||
|
||||
RAMLS5 : origin = 0x00A800, length = 0x000800
|
||||
RAMLS6 : origin = 0x00B000, length = 0x000800
|
||||
RAMLS7 : origin = 0x00B800, length = 0x000800
|
||||
|
||||
RAMGS0 : origin = 0x00C000, length = 0x002000
|
||||
RAMGS1 : origin = 0x00E000, length = 0x002000
|
||||
RAMGS2 : origin = 0x010000, length = 0x002000
|
||||
RAMGS3 : origin = 0x012000, length = 0x002000
|
||||
}
|
||||
|
||||
/* end of file */
|
||||
@@ -0,0 +1,98 @@
|
||||
/* F28069_DCL.cmd
|
||||
*
|
||||
* Copyright (C) 2020 Texas Instruments Incorporated - http://www.ti.com/
|
||||
* ALL RIGHTS RESERVED
|
||||
*
|
||||
*/
|
||||
|
||||
SECTIONS
|
||||
{
|
||||
/* 22-bit program sections */
|
||||
.reset : load = RESET, type = DSECT, PAGE = 0 /* reset vector in internal boot ROM */
|
||||
vectors : load = VECTORS, type = DSECT, PAGE = 0 /* internal ROM vector table */
|
||||
codestart : > BOOTM0, PAGE = 0
|
||||
|
||||
/* RAML4 for all program sections */
|
||||
.text : > RAML4L, PAGE = 0 /* default code section */
|
||||
.pinit : > RAML4L, PAGE = 0 /* global constructor table */
|
||||
.cinit : > RAML3, PAGE = 0 /* initialised variables */
|
||||
.code : > RAML4L, PAGE = 0 /* assembly code section */
|
||||
.data : > RAML4L, PAGE = 0 /* constant data */
|
||||
.switch : > RAML4L, PAGE = 0 /* switch tables */
|
||||
.init_array : > RAML4L, PAGE = 0 /* for EABI */
|
||||
|
||||
/* 16-Bit data sections */
|
||||
.const : > RAMM0, PAGE = 1 /* near constants */
|
||||
.bss : > RAMM0, PAGE = 1 /* near variables */
|
||||
RUN_START(_bss_start),
|
||||
RUN_SIZE(_bss_size)
|
||||
|
||||
.stack : > RAMM1, PAGE = 1 align(2) /* stack: even word alignment */
|
||||
.sysmem : > RAMM0, PAGE = 1 /* near dynamic memory */
|
||||
.cio : > RAMM0, PAGE = 1 /* string constants */
|
||||
|
||||
/* 32-bit data sections */
|
||||
.ebss : > RAML4H, PAGE = 1 /* far variables */
|
||||
RUN_START(_ebss_start),
|
||||
RUN_SIZE(_ebss_size)
|
||||
|
||||
.econst : > RAML4H, PAGE = 1 /* far constants */
|
||||
.esysmem : > RAML4H, PAGE = 1 /* far dynamic memory */
|
||||
|
||||
/* csmpasswds : > CSM_PWL_P0 PAGE = 0 */
|
||||
/* csm_rsvd : > CSM_RSVD PAGE = 0 */
|
||||
|
||||
/* Digital Controller Library functions */
|
||||
dclfuncs : > RAML4L, PAGE = 0
|
||||
dcl32funcs : > RAML4L, PAGE = 0
|
||||
|
||||
ramfuncs : > RAML4L, PAGE = 0
|
||||
LOAD_START(_RamfuncsLoadStart),
|
||||
LOAD_END(_RamfuncsLoadEnd),
|
||||
RUN_START(_RamfuncsRunStart),
|
||||
RUN_SIZE(_RamfuncsRUNSize)
|
||||
|
||||
/* data buffers */
|
||||
PDataLogSection : > RAML5, PAGE = 1 align(2)
|
||||
QDataLogSection : > RAML6, PAGE = 1 align(2)
|
||||
RDataLogSection : > RAML7, PAGE = 1 align(2)
|
||||
SDataLogSection : > RAML8, PAGE = 1 align(2)
|
||||
|
||||
/* IQ math sections */
|
||||
IQmath : > RAML4L, PAGE = 0
|
||||
IQmathTables : > IQTABLES, PAGE = 0, TYPE = NOLOAD
|
||||
|
||||
|
||||
.scratchpad : > CLARAM0, PAGE = 1
|
||||
.bss_cla : > CLARAM0, PAGE = 1
|
||||
.const_cla : > CLARAM0, PAGE = 1
|
||||
|
||||
Cla1Prog : > RAML3,
|
||||
LOAD_START(_Cla1funcsLoadStart),
|
||||
LOAD_END(_Cla1funcsLoadEnd),
|
||||
LOAD_SIZE(_Cla1funcsLoadSize),
|
||||
RUN_START(_Cla1funcsRunStart),
|
||||
PAGE = 0
|
||||
|
||||
Cla1ToCpuMsgRAM : > CLA1_MSGRAMLOW, PAGE = 1
|
||||
CpuToCla1MsgRAM : > CLA1_MSGRAMHIGH, PAGE = 1
|
||||
Cla1DataRam0 : > CLARAM0, PAGE = 1
|
||||
Cla1DataRam1 : > CLARAM1, PAGE = 1
|
||||
Cla1DataRam2 : > CLARAM2, PAGE = 1
|
||||
|
||||
CLA1mathTables : > CLARAM1,
|
||||
LOAD_START(_Cla1mathTablesLoadStart),
|
||||
LOAD_END(_Cla1mathTablesLoadEnd),
|
||||
LOAD_SIZE(_Cla1mathTablesLoadSize),
|
||||
RUN_START(_Cla1mathTablesRunStart),
|
||||
PAGE = 1
|
||||
|
||||
CLAscratch :
|
||||
{ *.obj(CLAscratch)
|
||||
. += CLA_SCRATCHPAD_SIZE;
|
||||
*.obj(CLAscratch_end) } > CLARAM0,
|
||||
PAGE = 1
|
||||
|
||||
}
|
||||
|
||||
/* end of file */
|
||||
@@ -0,0 +1,66 @@
|
||||
/* F28069_stdmem.cmd - standard memory linker command file for F28069
|
||||
*
|
||||
* Copyright (C) 2020 Texas Instruments Incorporated - http://www.ti.com/
|
||||
* ALL RIGHTS RESERVED
|
||||
*
|
||||
*/
|
||||
|
||||
_Cla1Prog_Start = _Cla1funcsRunStart;
|
||||
|
||||
CLA_SCRATCHPAD_SIZE = 0x100;
|
||||
--undef_sym=__cla_scratchpad_end
|
||||
--undef_sym=__cla_scratchpad_start
|
||||
|
||||
MEMORY
|
||||
{
|
||||
|
||||
PAGE 0: /* Program Memory */
|
||||
|
||||
BOOTM0 : origin = 0x000000, length = 0x000002 /* boot vector */
|
||||
RAML3 : origin = 0x009000, length = 0x001000 /* CLA program RAM */
|
||||
RAML4L : origin = 0x00A000, length = 0x001C00 /* on-chip RAM block L4 */
|
||||
|
||||
OTP : origin = 0x3D7800, length = 0x000400 /* on-chip OTP */
|
||||
FLASHH : origin = 0x3D8000, length = 0x004000 /* on-chip FLASH */
|
||||
FLASHG : origin = 0x3DC000, length = 0x004000 /* on-chip FLASH */
|
||||
FLASHF : origin = 0x3E0000, length = 0x004000 /* on-chip FLASH */
|
||||
FLASHE : origin = 0x3E4000, length = 0x004000 /* on-chip FLASH */
|
||||
FLASHD : origin = 0x3E8000, length = 0x004000 /* on-chip FLASH */
|
||||
FLASHC : origin = 0x3EC000, length = 0x004000 /* on-chip FLASH */
|
||||
FLASHA : origin = 0x3F4000, length = 0x003F80 /* on-chip FLASH */
|
||||
CSM_RSVD : origin = 0x3F7F80, length = 0x000076 /* Part of FLASHA. Program with all 0x0000 when CSM is in use. */
|
||||
BEGIN : origin = 0x3F7FF6, length = 0x000002 /* Part of FLASHA. Used for "boot to Flash" bootloader mode. */
|
||||
CSM_PWL_P0 : origin = 0x3F7FF8, length = 0x000008 /* Part of FLASHA. CSM password locations in FLASHA */
|
||||
|
||||
FPUTABLES : origin = 0x3FD860, length = 0x0006A0 /* FPU Tables in Boot ROM */
|
||||
IQTABLES : origin = 0x3FDF00, length = 0x000B50 /* IQ Math Tables in Boot ROM */
|
||||
IQTABLES2 : origin = 0x3FEA50, length = 0x00008C /* IQ Math Tables in Boot ROM */
|
||||
IQTABLES3 : origin = 0x3FEADC, length = 0x0000AA /* IQ Math Tables in Boot ROM */
|
||||
|
||||
ROM : origin = 0x3FF3B0, length = 0x000C10 /* Boot ROM */
|
||||
RESET : origin = 0x3FFFC0, length = 0x000002 /* part of boot ROM */
|
||||
VECTORS : origin = 0x3FFFC2, length = 0x00003E /* part of boot ROM */
|
||||
|
||||
|
||||
PAGE 1 : /* Data Memory */
|
||||
|
||||
BOOT_RSVD : origin = 0x000002, length = 0x00004E /* Part of M0, BOOT rom will use this for stack */
|
||||
RAMM0 : origin = 0x000050, length = 0x0003B0 /* on-chip RAM block M0 */
|
||||
RAMM1 : origin = 0x000400, length = 0x000400 /* on-chip RAM block M1 */
|
||||
CLARAM2 : origin = 0x008000, length = 0x000800 /* on-chip RAM block L0 */
|
||||
CLARAM0 : origin = 0x008800, length = 0x000400 /* on-chip RAM block L1 */
|
||||
CLARAM1 : origin = 0x008C00, length = 0x000400 /* on-chip RAM block L1 */
|
||||
RAML4H : origin = 0x00B800, length = 0x000400 /* on-chip RAM block L4 */
|
||||
RAML5 : origin = 0x00C000, length = 0x002000 /* on-chip RAM block L5 */
|
||||
RAML6 : origin = 0x00E000, length = 0x002000 /* on-chip RAM block L6 */
|
||||
RAML7 : origin = 0x010000, length = 0x002000 /* on-chip RAM block L7 */
|
||||
RAML8 : origin = 0x012000, length = 0x002000 /* on-chip RAM block L8 */
|
||||
USB_RAM : origin = 0x040000, length = 0x000800 /* USB RAM */
|
||||
FLASHB : origin = 0x3F0000, length = 0x004000 /* on-chip FLASH */
|
||||
|
||||
CLA1_MSGRAMLOW : origin = 0x001480, length = 0x000080
|
||||
CLA1_MSGRAMHIGH : origin = 0x001500, length = 0x000080
|
||||
|
||||
}
|
||||
|
||||
/* end of file */
|
||||
@@ -0,0 +1,67 @@
|
||||
/* F28388D_DCL.cmd
|
||||
*
|
||||
* Copyright (C) 2020 Texas Instruments Incorporated - http://www.ti.com/
|
||||
* ALL RIGHTS RESERVED
|
||||
*
|
||||
*/
|
||||
|
||||
SECTIONS
|
||||
{
|
||||
codestart : > BEGIN
|
||||
.text : >> RAMD0 | RAMD1 | RAMLS0 | RAMLS1 | RAMLS2 | RAMLS3
|
||||
.cinit : > RAMM0
|
||||
.switch : > RAMM0
|
||||
.reset : > RESET, TYPE = DSECT /* not used, */
|
||||
|
||||
.stack : > RAMM1
|
||||
#if defined(__TI_EABI__)
|
||||
.bss : > RAMLS5
|
||||
.bss:output : > RAMLS3
|
||||
.init_array : > RAMM0
|
||||
.const : > RAMLS5
|
||||
.data : > RAMLS5
|
||||
.sysmem : > RAMLS4
|
||||
#else
|
||||
.pinit : > RAMM0
|
||||
.ebss : >> RAMLS5 | RAMLS6
|
||||
.econst : > RAMLS5
|
||||
.esysmem : > RAMLS5
|
||||
#endif
|
||||
|
||||
ramgs0 : > RAMGS0
|
||||
ramgs1 : > RAMGS1
|
||||
|
||||
MSGRAM_CPU1_TO_CPU2 > CPU1TOCPU2RAM
|
||||
MSGRAM_CPU2_TO_CPU1 > CPU2TOCPU1RAM
|
||||
MSGRAM_CPU_TO_CM > CPUTOCMRAM
|
||||
MSGRAM_CM_TO_CPU > CMTOCPURAM
|
||||
|
||||
#ifdef __TI_COMPILER_VERSION__
|
||||
#if __TI_COMPILER_VERSION__ >= 15009000
|
||||
.TI.ramfunc : {} > RAMM0
|
||||
#else
|
||||
ramfuncs : > RAMM0
|
||||
#endif
|
||||
#endif
|
||||
|
||||
dclfuncs : > RAMGS2, align(2)
|
||||
PDataLogSection : > RAMGS12, align(4)
|
||||
LOAD_START(pData_start),
|
||||
LOAD_SIZE(pData_size)
|
||||
|
||||
QDataLogSection : > RAMGS13, align(4)
|
||||
LOAD_START(qData_start),
|
||||
LOAD_SIZE(qData_size)
|
||||
|
||||
|
||||
RDataLogSection : > RAMGS14, align(4)
|
||||
LOAD_START(rData_start),
|
||||
LOAD_SIZE(rData_size)
|
||||
|
||||
SDataLogSection : > RAMGS15, align(4)
|
||||
LOAD_START(sData_start),
|
||||
LOAD_SIZE(sData_size)
|
||||
|
||||
}
|
||||
|
||||
/* end of file */
|
||||
@@ -0,0 +1,68 @@
|
||||
/* F28388D_stdmem_cpu1.cmd
|
||||
*
|
||||
* Copyright (C) 2020 Texas Instruments Incorporated - http://www.ti.com/
|
||||
* ALL RIGHTS RESERVED
|
||||
*
|
||||
*/
|
||||
|
||||
MEMORY
|
||||
{
|
||||
/* BEGIN is used for the "boot to SARAM" bootloader mode */
|
||||
BEGIN : origin = 0x000000, length = 0x000002
|
||||
BOOT_RSVD : origin = 0x000002, length = 0x0001AE /* Part of M0, BOOT rom will use this for stack */
|
||||
RAMM0 : origin = 0x0001B0, length = 0x000250
|
||||
RAMM1 : origin = 0x000400, length = 0x000400 /* on-chip RAM block M1 */
|
||||
RAMD0 : origin = 0x00C000, length = 0x000800
|
||||
RAMD1 : origin = 0x00C800, length = 0x000800
|
||||
RAMLS0 : origin = 0x008000, length = 0x000800
|
||||
RAMLS1 : origin = 0x008800, length = 0x000800
|
||||
RAMLS2 : origin = 0x009000, length = 0x000800
|
||||
RAMLS3 : origin = 0x009800, length = 0x000800
|
||||
RAMLS4 : origin = 0x00A000, length = 0x000800
|
||||
RAMLS5 : origin = 0x00A800, length = 0x000800
|
||||
RAMLS6 : origin = 0x00B000, length = 0x000800
|
||||
RAMLS7 : origin = 0x00B800, length = 0x000800
|
||||
RAMGS0 : origin = 0x00D000, length = 0x001000
|
||||
RAMGS1 : origin = 0x00E000, length = 0x001000
|
||||
RAMGS2 : origin = 0x00F000, length = 0x001000
|
||||
RAMGS3 : origin = 0x010000, length = 0x001000
|
||||
RAMGS4 : origin = 0x011000, length = 0x001000
|
||||
RAMGS5 : origin = 0x012000, length = 0x001000
|
||||
RAMGS6 : origin = 0x013000, length = 0x001000
|
||||
RAMGS7 : origin = 0x014000, length = 0x001000
|
||||
RAMGS8 : origin = 0x015000, length = 0x001000
|
||||
RAMGS9 : origin = 0x016000, length = 0x001000
|
||||
RAMGS10 : origin = 0x017000, length = 0x001000
|
||||
RAMGS11 : origin = 0x018000, length = 0x001000
|
||||
RAMGS12 : origin = 0x019000, length = 0x001000
|
||||
RAMGS13 : origin = 0x01A000, length = 0x001000
|
||||
RAMGS14 : origin = 0x01B000, length = 0x001000
|
||||
RAMGS15 : origin = 0x01C000, length = 0x001000
|
||||
|
||||
/* Flash sectors */
|
||||
FLASH0 : origin = 0x080000, length = 0x002000 /* on-chip Flash */
|
||||
FLASH1 : origin = 0x082000, length = 0x002000 /* on-chip Flash */
|
||||
FLASH2 : origin = 0x084000, length = 0x002000 /* on-chip Flash */
|
||||
FLASH3 : origin = 0x086000, length = 0x002000 /* on-chip Flash */
|
||||
FLASH4 : origin = 0x088000, length = 0x008000 /* on-chip Flash */
|
||||
FLASH5 : origin = 0x090000, length = 0x008000 /* on-chip Flash */
|
||||
FLASH6 : origin = 0x098000, length = 0x008000 /* on-chip Flash */
|
||||
FLASH7 : origin = 0x0A0000, length = 0x008000 /* on-chip Flash */
|
||||
FLASH8 : origin = 0x0A8000, length = 0x008000 /* on-chip Flash */
|
||||
FLASH9 : origin = 0x0B0000, length = 0x008000 /* on-chip Flash */
|
||||
FLASH10 : origin = 0x0B8000, length = 0x002000 /* on-chip Flash */
|
||||
FLASH11 : origin = 0x0BA000, length = 0x002000 /* on-chip Flash */
|
||||
FLASH12 : origin = 0x0BC000, length = 0x002000 /* on-chip Flash */
|
||||
FLASH13 : origin = 0x0BE000, length = 0x002000 /* on-chip Flash */
|
||||
CPU1TOCPU2RAM : origin = 0x03A000, length = 0x000800
|
||||
CPU2TOCPU1RAM : origin = 0x03B000, length = 0x000800
|
||||
|
||||
CPUTOCMRAM : origin = 0x039000, length = 0x000800
|
||||
CMTOCPURAM : origin = 0x038000, length = 0x000800
|
||||
|
||||
CANA_MSG_RAM : origin = 0x049000, length = 0x000800
|
||||
CANB_MSG_RAM : origin = 0x04B000, length = 0x000800
|
||||
RESET : origin = 0x3FFFC0, length = 0x000002
|
||||
}
|
||||
|
||||
/* end of file */
|
||||
@@ -0,0 +1,13 @@
|
||||
/* f28p55x_link.cmd */
|
||||
|
||||
SECTIONS
|
||||
{
|
||||
dclfuncs : > RAMLS0, align(2)
|
||||
|
||||
PDataLogSection : >> RAMLS8, align(4)
|
||||
QDataLogSection : >> RAMLS8, align(4)
|
||||
RDataLogSection : >> RAMLS9, align(4)
|
||||
SDataLogSection : >> RAMLS9, align(4)
|
||||
}
|
||||
|
||||
/* end of file */
|
||||
@@ -0,0 +1,13 @@
|
||||
/* f28p65x_link.cmd */
|
||||
|
||||
SECTIONS
|
||||
{
|
||||
dclfuncs : > RAMLS0, align(2)
|
||||
|
||||
PDataLogSection : >> RAMLS8, align(4)
|
||||
QDataLogSection : >> RAMLS8, align(4)
|
||||
RDataLogSection : >> RAMLS9, align(4)
|
||||
SDataLogSection : >> RAMLS9, align(4)
|
||||
}
|
||||
|
||||
/* end of file */
|
||||
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
+29
@@ -0,0 +1,29 @@
|
||||
<projectSpec>
|
||||
<project
|
||||
name="F280013x_DF22"
|
||||
device="TMS320F2800137"
|
||||
cgtVersion="22.6.0.LTS"
|
||||
outputFormat="ELF"
|
||||
launchWizard="False"
|
||||
linkerCommandFile=""
|
||||
>
|
||||
<configuration name="CPU1_RAM" compilerBuildOptions="--opt_level=2 -I${PROJECT_ROOT}/device -I${C2000WARE_DLIB_ROOT} -I${DCL_INCLUDE} -v28 -ml -mt --float_support=fpu32 --tmu_support=tmu0 --define=DEBUG --define RAM --diag_warning=225 --diag_suppress=10063" linkerBuildOptions="--entry_point code_start --stack_size=0x200 --heap_size=0x100 "/>
|
||||
<pathVariable name="C2000WARE_DLIB_ROOT" path="../../../../../../../driverlib/f280013x/driverlib/" scope="project"/>
|
||||
<pathVariable name="DCL_INCLUDE" path="../../../include" scope="project"/>
|
||||
<pathVariable name="C2000WARE_DEVICE_SUPPORT" path="../../../../../../../device_support" scope="project"/>
|
||||
<file action="copy" path="C2000WARE_DEVICE_SUPPORT/f280013x/common/include/driverlib.h" targetDirectory="device"/>
|
||||
<file action="copy" path="C2000WARE_DEVICE_SUPPORT/f280013x/common/include/device.h" targetDirectory="device"/>
|
||||
<file action="copy" path="C2000WARE_DEVICE_SUPPORT/f280013x/common/source/device.c" targetDirectory="device"/>
|
||||
<file action="copy" path="C2000WARE_DEVICE_SUPPORT/f280013x/common/source/f280013x_codestartbranch.asm" targetDirectory="device"/>
|
||||
<file action="copy" path="C2000WARE_DEVICE_SUPPORT/f280013x/common/targetConfigs/TMS320F2800137.ccxml" targetDirectory="targetConfigs"/>
|
||||
<file action="link" path="C2000WARE_DLIB_ROOT/ccs/Debug/driverlib.lib" targetDirectory=""/>
|
||||
<file action="copy" path="../Example_DF22.c" targetDirectory=""/>
|
||||
<file action="copy" path="../../../source/DCL_error.c" targetDirectory=""/>
|
||||
<file action="copy" path="../../../source/DCL_clamp_C1.asm" targetDirectory="" />
|
||||
<file action="copy" path="../../../source/DCL_DF22_C1.asm" targetDirectory="" />
|
||||
<file action="copy" path="../../../source/DCL_DF22_C2C3.asm" targetDirectory="" />
|
||||
<file action="copy" path="../DF22_edata.dat" targetDirectory="" />
|
||||
<file action="copy" path="C2000WARE_DEVICE_SUPPORT/f280013x/common/cmd/280013x_generic_ram_lnk.cmd" targetDirectory=""/>
|
||||
<file action="copy" path="../../../cmd/F280013x_DCL.cmd" targetDirectory=""/>
|
||||
</project>
|
||||
</projectSpec>
|
||||
File diff suppressed because it is too large.
Load diff
@@ -0,0 +1,168 @@
|
||||
/* Example_DF22.c
|
||||
*
|
||||
* Copyright (C) 2020 Texas Instruments Incorporated - http://www.ti.com/
|
||||
* ALL RIGHTS RESERVED
|
||||
*
|
||||
*/
|
||||
|
||||
#include "driverlib.h"
|
||||
#include "device.h"
|
||||
#include "DCLF32.h"
|
||||
#include "DCL_fdlog.h"
|
||||
|
||||
#define DATA_LENGTH 1601
|
||||
|
||||
// input data
|
||||
#pragma DATA_SECTION(e_array, "PDataLogSection")
|
||||
float e_array[DATA_LENGTH];
|
||||
FDLOG eBuf = FDLOG_DEFAULTS;
|
||||
|
||||
// full controller results
|
||||
#pragma DATA_SECTION(u1_array, "QDataLogSection")
|
||||
float u1_array[DATA_LENGTH];
|
||||
FDLOG u1Buf = FDLOG_DEFAULTS;
|
||||
|
||||
// pre-computed controller results
|
||||
#pragma DATA_SECTION(u2_array, "RDataLogSection")
|
||||
float u2_array[DATA_LENGTH];
|
||||
FDLOG u2Buf = FDLOG_DEFAULTS;
|
||||
|
||||
// controller difference data
|
||||
#pragma DATA_SECTION(d_array, "SDataLogSection")
|
||||
float d_array[DATA_LENGTH];
|
||||
FDLOG dBuf = FDLOG_DEFAULTS;
|
||||
|
||||
// function prototypes
|
||||
void initCPUTimer0(float freq, float period);
|
||||
extern interrupt void control_Isr(void);
|
||||
|
||||
// global variables
|
||||
long IdleLoopCount = 0;
|
||||
long IsrCount = 0;
|
||||
int complete = 0;
|
||||
float ek;
|
||||
float u1k;
|
||||
float u2k;
|
||||
float dk;
|
||||
float upperLim;
|
||||
float lowerLim;
|
||||
uint16_t v;
|
||||
DCL_DF22 controller1 = DF22_DEFAULTS;
|
||||
DCL_DF22 controller2 = DF22_DEFAULTS;
|
||||
|
||||
|
||||
/* main */
|
||||
main()
|
||||
{
|
||||
// device initialization
|
||||
Device_init();
|
||||
Interrupt_initModule();
|
||||
Interrupt_initVectorTable();
|
||||
|
||||
// initialize CPU timer0 & interrupt
|
||||
Interrupt_register(INT_TIMER0, &control_Isr);
|
||||
initCPUTimer0( DEVICE_SYSCLK_FREQ, 1000);
|
||||
CPUTimer_enableInterrupt(CPUTIMER0_BASE);
|
||||
Interrupt_enable(INT_TIMER0);
|
||||
|
||||
// initialise data arrays
|
||||
DCL_initLog(&eBuf, e_array, DATA_LENGTH);
|
||||
DCL_initLog(&u1Buf, u1_array, DATA_LENGTH);
|
||||
DCL_initLog(&u2Buf, u2_array, DATA_LENGTH);
|
||||
DCL_initLog(&dBuf, d_array, DATA_LENGTH);
|
||||
DCL_clearLog(&u1Buf);
|
||||
DCL_clearLog(&u2Buf);
|
||||
DCL_fillLog(&dBuf, 1.234567f);
|
||||
|
||||
// initialise full controller
|
||||
controller1.a1 = -1.9417f;
|
||||
controller1.a2 = 0.9417f;
|
||||
controller1.b0 = 9.8549f;
|
||||
controller1.b1 = -19.4165f;
|
||||
controller1.b2 = 9.5636f;
|
||||
|
||||
// initialise pre-computed controller
|
||||
controller2.a1 = controller1.a1;
|
||||
controller2.a2 = controller1.a2;
|
||||
controller2.b0 = controller1.b0;
|
||||
controller2.b1 = controller1.b1;
|
||||
controller2.b2 = controller1.b2;
|
||||
|
||||
// clamp limits
|
||||
upperLim = 1000.0f;
|
||||
lowerLim = -1000.0f;
|
||||
|
||||
// enable global interrupts
|
||||
EINT;
|
||||
ERTM;
|
||||
CPUTimer_startTimer(CPUTIMER0_BASE);
|
||||
|
||||
while(1)
|
||||
{
|
||||
IdleLoopCount++;
|
||||
|
||||
if (complete == 1)
|
||||
{
|
||||
DCL_BREAK_POINT;
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
// initialize CPU timer0
|
||||
void initCPUTimer0(float freq, float period)
|
||||
{
|
||||
uint32_t temp;
|
||||
|
||||
temp = (uint32_t)(freq / 1000000 * period);
|
||||
CPUTimer_setPeriod(CPUTIMER0_BASE, temp);
|
||||
CPUTimer_setPreScaler(CPUTIMER0_BASE, 0);
|
||||
CPUTimer_stopTimer(CPUTIMER0_BASE);
|
||||
CPUTimer_reloadTimerCounter(CPUTIMER0_BASE);
|
||||
CPUTimer_setEmulationMode(CPUTIMER0_BASE,
|
||||
CPUTIMER_EMULATIONMODE_STOPAFTERNEXTDECREMENT);
|
||||
CPUTimer_enableInterrupt(CPUTIMER0_BASE);
|
||||
}
|
||||
|
||||
/* control ISR: triggered by CPU timer 0 */
|
||||
interrupt void control_Isr(void)
|
||||
{
|
||||
|
||||
// read data & run controllers
|
||||
if (complete == 0)
|
||||
{
|
||||
// read input data
|
||||
ek = DCL_readLog(&eBuf);
|
||||
|
||||
// run full controller
|
||||
u1k = DCL_runDF22_C1(&controller1, ek);
|
||||
|
||||
// run pre-computed controller
|
||||
u2k = DCL_runDF22_C2(&controller2, ek);
|
||||
v = DCL_runClamp_C1(&u2k, upperLim, lowerLim);
|
||||
if (0U == v)
|
||||
{
|
||||
DCL_runDF22_C3(&controller2, ek, u2k);
|
||||
}
|
||||
|
||||
// compute difference
|
||||
dk = u1k - u2k;
|
||||
|
||||
// store results
|
||||
DCL_writeLog(&u1Buf, u1k);
|
||||
DCL_writeLog(&u2Buf, u2k);
|
||||
DCL_writeLog(&dBuf, dk);
|
||||
|
||||
// check if data log is full
|
||||
if FDLOG_START(&dBuf)
|
||||
{
|
||||
complete = 1;
|
||||
}
|
||||
}
|
||||
|
||||
IsrCount++;
|
||||
Interrupt_clearACKGroup(INTERRUPT_ACK_GROUP1);
|
||||
}
|
||||
|
||||
|
||||
/* end of file */
|
||||
+29
@@ -0,0 +1,29 @@
|
||||
<projectSpec>
|
||||
<project
|
||||
name="F280015x_DF22"
|
||||
device="TMS320F2800157"
|
||||
cgtVersion="22.6.0.LTS"
|
||||
outputFormat="ELF"
|
||||
launchWizard="False"
|
||||
linkerCommandFile=""
|
||||
>
|
||||
<configuration name="CPU1_RAM" compilerBuildOptions="--opt_level=2 -I${PROJECT_ROOT}/device -I${C2000WARE_DLIB_ROOT} -I${DCL_INCLUDE} -v28 -ml -mt --float_support=fpu32 --tmu_support=tmu0 --define=DEBUG --define RAM --diag_warning=225 --diag_suppress=10063" linkerBuildOptions="--entry_point code_start --stack_size=0x200 --heap_size=0x100 "/>
|
||||
<pathVariable name="C2000WARE_DLIB_ROOT" path="../../../../../../../driverlib/f280015x/driverlib/" scope="project"/>
|
||||
<pathVariable name="DCL_INCLUDE" path="../../../include" scope="project"/>
|
||||
<pathVariable name="C2000WARE_DEVICE_SUPPORT" path="../../../../../../../device_support" scope="project"/>
|
||||
<file action="copy" path="C2000WARE_DEVICE_SUPPORT/f280015x/common/include/driverlib.h" targetDirectory="device"/>
|
||||
<file action="copy" path="C2000WARE_DEVICE_SUPPORT/f280015x/common/include/device.h" targetDirectory="device"/>
|
||||
<file action="copy" path="C2000WARE_DEVICE_SUPPORT/f280015x/common/source/device.c" targetDirectory="device"/>
|
||||
<file action="copy" path="C2000WARE_DEVICE_SUPPORT/f280015x/common/source/f280015x_codestartbranch.asm" targetDirectory="device"/>
|
||||
<file action="copy" path="C2000WARE_DEVICE_SUPPORT/f280015x/common/targetConfigs/TMS320F2800157.ccxml" targetDirectory="targetConfigs"/>
|
||||
<file action="link" path="C2000WARE_DLIB_ROOT/ccs/Debug/driverlib.lib" targetDirectory=""/>
|
||||
<file action="copy" path="../Example_DF22.c" targetDirectory=""/>
|
||||
<file action="copy" path="../../../source/DCL_error.c" targetDirectory=""/>
|
||||
<file action="copy" path="../../../source/DCL_clamp_C1.asm" targetDirectory="" />
|
||||
<file action="copy" path="../../../source/DCL_DF22_C1.asm" targetDirectory="" />
|
||||
<file action="copy" path="../../../source/DCL_DF22_C2C3.asm" targetDirectory="" />
|
||||
<file action="copy" path="../DF22_edata.dat" targetDirectory="" />
|
||||
<file action="copy" path="C2000WARE_DEVICE_SUPPORT/f280015x/common/cmd/280015x_generic_ram_lnk.cmd" targetDirectory=""/>
|
||||
<file action="copy" path="../../../cmd/F280015x_DCL.cmd" targetDirectory=""/>
|
||||
</project>
|
||||
</projectSpec>
|
||||
File diff suppressed because it is too large.
Load diff
@@ -0,0 +1,168 @@
|
||||
/* Example_DF22.c
|
||||
*
|
||||
* Copyright (C) 2020 Texas Instruments Incorporated - http://www.ti.com/
|
||||
* ALL RIGHTS RESERVED
|
||||
*
|
||||
*/
|
||||
|
||||
#include "driverlib.h"
|
||||
#include "device.h"
|
||||
#include "DCLF32.h"
|
||||
#include "DCL_fdlog.h"
|
||||
|
||||
#define DATA_LENGTH 1601
|
||||
|
||||
// input data
|
||||
#pragma DATA_SECTION(e_array, "PDataLogSection")
|
||||
float e_array[DATA_LENGTH];
|
||||
FDLOG eBuf = FDLOG_DEFAULTS;
|
||||
|
||||
// full controller results
|
||||
#pragma DATA_SECTION(u1_array, "QDataLogSection")
|
||||
float u1_array[DATA_LENGTH];
|
||||
FDLOG u1Buf = FDLOG_DEFAULTS;
|
||||
|
||||
// pre-computed controller results
|
||||
#pragma DATA_SECTION(u2_array, "RDataLogSection")
|
||||
float u2_array[DATA_LENGTH];
|
||||
FDLOG u2Buf = FDLOG_DEFAULTS;
|
||||
|
||||
// controller difference data
|
||||
#pragma DATA_SECTION(d_array, "SDataLogSection")
|
||||
float d_array[DATA_LENGTH];
|
||||
FDLOG dBuf = FDLOG_DEFAULTS;
|
||||
|
||||
// function prototypes
|
||||
void initCPUTimer0(float freq, float period);
|
||||
extern interrupt void control_Isr(void);
|
||||
|
||||
// global variables
|
||||
long IdleLoopCount = 0;
|
||||
long IsrCount = 0;
|
||||
int complete = 0;
|
||||
float ek;
|
||||
float u1k;
|
||||
float u2k;
|
||||
float dk;
|
||||
float upperLim;
|
||||
float lowerLim;
|
||||
uint16_t v;
|
||||
DCL_DF22 controller1 = DF22_DEFAULTS;
|
||||
DCL_DF22 controller2 = DF22_DEFAULTS;
|
||||
|
||||
|
||||
/* main */
|
||||
main()
|
||||
{
|
||||
// device initialization
|
||||
Device_init();
|
||||
Interrupt_initModule();
|
||||
Interrupt_initVectorTable();
|
||||
|
||||
// initialize CPU timer0 & interrupt
|
||||
Interrupt_register(INT_TIMER0, &control_Isr);
|
||||
initCPUTimer0( DEVICE_SYSCLK_FREQ, 1000);
|
||||
CPUTimer_enableInterrupt(CPUTIMER0_BASE);
|
||||
Interrupt_enable(INT_TIMER0);
|
||||
|
||||
// initialise data arrays
|
||||
DCL_initLog(&eBuf, e_array, DATA_LENGTH);
|
||||
DCL_initLog(&u1Buf, u1_array, DATA_LENGTH);
|
||||
DCL_initLog(&u2Buf, u2_array, DATA_LENGTH);
|
||||
DCL_initLog(&dBuf, d_array, DATA_LENGTH);
|
||||
DCL_clearLog(&u1Buf);
|
||||
DCL_clearLog(&u2Buf);
|
||||
DCL_fillLog(&dBuf, 1.234567f);
|
||||
|
||||
// initialise full controller
|
||||
controller1.a1 = -1.9417f;
|
||||
controller1.a2 = 0.9417f;
|
||||
controller1.b0 = 9.8549f;
|
||||
controller1.b1 = -19.4165f;
|
||||
controller1.b2 = 9.5636f;
|
||||
|
||||
// initialise pre-computed controller
|
||||
controller2.a1 = controller1.a1;
|
||||
controller2.a2 = controller1.a2;
|
||||
controller2.b0 = controller1.b0;
|
||||
controller2.b1 = controller1.b1;
|
||||
controller2.b2 = controller1.b2;
|
||||
|
||||
// clamp limits
|
||||
upperLim = 1000.0f;
|
||||
lowerLim = -1000.0f;
|
||||
|
||||
// enable global interrupts
|
||||
EINT;
|
||||
ERTM;
|
||||
CPUTimer_startTimer(CPUTIMER0_BASE);
|
||||
|
||||
while(1)
|
||||
{
|
||||
IdleLoopCount++;
|
||||
|
||||
if (complete == 1)
|
||||
{
|
||||
DCL_BREAK_POINT;
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
// initialize CPU timer0
|
||||
void initCPUTimer0(float freq, float period)
|
||||
{
|
||||
uint32_t temp;
|
||||
|
||||
temp = (uint32_t)(freq / 1000000 * period);
|
||||
CPUTimer_setPeriod(CPUTIMER0_BASE, temp);
|
||||
CPUTimer_setPreScaler(CPUTIMER0_BASE, 0);
|
||||
CPUTimer_stopTimer(CPUTIMER0_BASE);
|
||||
CPUTimer_reloadTimerCounter(CPUTIMER0_BASE);
|
||||
CPUTimer_setEmulationMode(CPUTIMER0_BASE,
|
||||
CPUTIMER_EMULATIONMODE_STOPAFTERNEXTDECREMENT);
|
||||
CPUTimer_enableInterrupt(CPUTIMER0_BASE);
|
||||
}
|
||||
|
||||
/* control ISR: triggered by CPU timer 0 */
|
||||
interrupt void control_Isr(void)
|
||||
{
|
||||
|
||||
// read data & run controllers
|
||||
if (complete == 0)
|
||||
{
|
||||
// read input data
|
||||
ek = DCL_readLog(&eBuf);
|
||||
|
||||
// run full controller
|
||||
u1k = DCL_runDF22_C1(&controller1, ek);
|
||||
|
||||
// run pre-computed controller
|
||||
u2k = DCL_runDF22_C2(&controller2, ek);
|
||||
v = DCL_runClamp_C1(&u2k, upperLim, lowerLim);
|
||||
if (0U == v)
|
||||
{
|
||||
DCL_runDF22_C3(&controller2, ek, u2k);
|
||||
}
|
||||
|
||||
// compute difference
|
||||
dk = u1k - u2k;
|
||||
|
||||
// store results
|
||||
DCL_writeLog(&u1Buf, u1k);
|
||||
DCL_writeLog(&u2Buf, u2k);
|
||||
DCL_writeLog(&dBuf, dk);
|
||||
|
||||
// check if data log is full
|
||||
if FDLOG_START(&dBuf)
|
||||
{
|
||||
complete = 1;
|
||||
}
|
||||
}
|
||||
|
||||
IsrCount++;
|
||||
Interrupt_clearACKGroup(INTERRUPT_ACK_GROUP1);
|
||||
}
|
||||
|
||||
|
||||
/* end of file */
|
||||
+32
@@ -0,0 +1,32 @@
|
||||
<projectSpec>
|
||||
<project
|
||||
name="F280049_ERAD"
|
||||
device="TMS320F280049"
|
||||
configurations="DEBUG"
|
||||
launchWizard="False"
|
||||
linkerCommandFile=""
|
||||
compilerBuildOptions="--opt_level=off -I${C2000WARE_F28004X_ROOT1} -I${C2000WARE_F28004X_ROOT2} -I${C2000WARE_DCL_INCLUDE_ROOT} -I${C2000WARE_F28004X_ERAD_INCLUDE} -v28 -ml -mt --float_support=fpu32 --define=DEBUG --diag_warning=225 --diag_suppress=10063 --display_error_number"
|
||||
linkerBuildOptions="--stack_size=0x400 --heap_size=0x200 --define RAM"
|
||||
>
|
||||
<pathVariable name="C2000WARE_F28004X_ROOT1" path="../../../../../../../device_support/f28004x/headers/include" scope="project" />
|
||||
<pathVariable name="C2000WARE_F28004X_ROOT2" path="../../../../../../../device_support/f28004x/common/include" scope="project" />
|
||||
<pathVariable name="C2000WARE_F28004X_ERAD_INCLUDE" path="../" scope="project" />
|
||||
<pathVariable name="C2000WARE_DCL_INCLUDE_ROOT" path="../../../include" scope="project" />
|
||||
<file action="copy" path="../../../../../../../device_support/f28004x/common/source/f28004x_codestartbranch.asm" targetDirectory="" />
|
||||
<file action="copy" path="../../../../../../../device_support/f28004x/common/source/f28004x_cputimers.c" targetDirectory="" />
|
||||
<file action="copy" path="../../../../../../../device_support/f28004x/common/source/f28004x_defaultisr.c" targetDirectory="" />
|
||||
<file action="copy" path="../../../../../../../device_support/f28004x/headers/source/f28004x_globalvariabledefs.c" targetDirectory="" />
|
||||
<file action="copy" path="../../../../../../../device_support/f28004x/common/source/f28004x_gpio.c" targetDirectory="" />
|
||||
<file action="copy" path="../../../../../../../device_support/f28004x/common/source/f28004x_piectrl.c" targetDirectory="" />
|
||||
<file action="copy" path="../../../../../../../device_support/f28004x/common/source/f28004x_pievect.c" targetDirectory="" />
|
||||
<file action="copy" path="../../../../../../../device_support/f28004x/common/source/f28004x_sysctrl.c" targetDirectory="" />
|
||||
<file action="copy" path="../../../../../../../device_support/f28004x/common/source/f28004x_usdelay.asm" targetDirectory="" />
|
||||
<file action="copy" path="../../../../../../../device_support/f28004x/headers/cmd/f28004x_headers_nonbios.cmd" targetDirectory="" />
|
||||
<file action="copy" path="../../../cmd/F280049_stdmem.cmd" targetDirectory="" />
|
||||
<file action="copy" path="../../../cmd/F280049_ERAD.cmd" targetDirectory="" />
|
||||
<file action="copy" path="../f28004x_usdelay_erad.asm" targetDirectory="" />
|
||||
<file action="copy" path="../Example_F280049_erad.c" targetDirectory="" />
|
||||
<file action="copy" path="../f28004x_dcl_erad.c" targetDirectory="" />
|
||||
<file action="copy" path="../../../source/DCL_error.c" targetDirectory="" />
|
||||
</project>
|
||||
</projectSpec>
|
||||
@@ -0,0 +1,317 @@
|
||||
// main.c
|
||||
|
||||
#include "F28x_Project.h"
|
||||
#include "DCLF32.h"
|
||||
#include "f28004x_erad.h"
|
||||
#include "f28004x_dcl_erad.h"
|
||||
|
||||
// controllers
|
||||
DCL_PID F1 = PID_DEFAULTS;
|
||||
DCL_PI F2 = PI_DEFAULTS;
|
||||
DCL_PI F3 = PI_DEFAULTS;
|
||||
DCL_GSM F4 = GSM_DEFAULTS;
|
||||
DCL_DF11 F5 = DF11_DEFAULTS;
|
||||
DCL_DF22 F6 = DF22_DEFAULTS;
|
||||
DCL_DF23 F7 = DF23_DEFAULTS;
|
||||
DCL_DF23_SPS F7sps = DF23_SPS_DEFAULTS;
|
||||
DCL_CSS F7css = DCL_CSS_DEFAULTS;
|
||||
|
||||
// program constants
|
||||
#define DECIM_F1 10
|
||||
#define DECIM_F6 3
|
||||
#define DECIM_F7 9
|
||||
#define PAYLOAD_F7 2000
|
||||
|
||||
// variables
|
||||
uint16_t i = 0;
|
||||
uint32_t IdleLoopCount = 0UL;
|
||||
uint16_t IsraCount = 0;
|
||||
uint16_t IsrbCount = 0;
|
||||
uint16_t IsrcCount = 0;
|
||||
int16_t DecimF1 = DECIM_F1;
|
||||
int16_t DecimF6 = DECIM_F6;
|
||||
volatile float32_t r1, y1, u1;
|
||||
volatile float32_t y2, u2;
|
||||
volatile float32_t r3, y3, u3;
|
||||
volatile float32_t r4, y4, u4;
|
||||
volatile float32_t u5;
|
||||
volatile float32_t r6, u6;
|
||||
volatile float32_t r7, y7, u7;
|
||||
float32_t x = 0.0f;
|
||||
|
||||
// ISR declarations
|
||||
interrupt void ISRa(void);
|
||||
interrupt void ISRb(void);
|
||||
interrupt void ISRc(void);
|
||||
|
||||
void func_label(void);
|
||||
|
||||
void F28x_usDelayErad(long LoopCount);
|
||||
|
||||
void EradConfig(void);
|
||||
|
||||
uint32_t MaxWindowCycles = 0;
|
||||
uint32_t MaxISRCycles = 0;
|
||||
|
||||
void main(void)
|
||||
{
|
||||
InitSysCtrl();
|
||||
InitGpio();
|
||||
|
||||
// interrupt configuration
|
||||
DINT;
|
||||
InitPieCtrl();
|
||||
IER = 0x0000;
|
||||
IFR = 0x0000;
|
||||
InitPieVectTable();
|
||||
EALLOW;
|
||||
PieVectTable.TIMER0_INT = &ISRa;
|
||||
PieVectTable.TIMER1_INT = &ISRb;
|
||||
PieVectTable.TIMER2_INT = &ISRc;
|
||||
|
||||
// configure CPU timers
|
||||
InitCpuTimers();
|
||||
ConfigCpuTimer(&CpuTimer0, 100.0f, 100.0f);
|
||||
ConfigCpuTimer(&CpuTimer1, 100.0f, 3.952f);
|
||||
ConfigCpuTimer(&CpuTimer2, 100.0f, 16.67f);
|
||||
|
||||
// controller initialization
|
||||
// PID controller (F1)
|
||||
F1.Kp = 9.0623f;
|
||||
F1.Ki = 0.012f;
|
||||
F1.Kd = 3.5f;
|
||||
F1.c1 = 0.99f;
|
||||
F1.c2 = 0.1221f;
|
||||
F1.Umax = 15.4665f;
|
||||
F1.Umin = -16.22f;
|
||||
r1 = 0.754f;
|
||||
y1 = 0.0f;
|
||||
u1 = 0.0f;
|
||||
|
||||
// PI controller (F2)
|
||||
F2.Kp = 0.1234f;
|
||||
F2.Ki = 0.02389f;
|
||||
F2.Umax = 15.4665f;
|
||||
F2.Umin = -16.22f;
|
||||
F2.Imax = 1.465f;
|
||||
F2.Imin = -1.2f;
|
||||
y2 = 0.0f;
|
||||
|
||||
// PI controller (F3)
|
||||
F3.Kp = 0.1234f;
|
||||
F3.Ki = 0.02389f;
|
||||
F3.Umax = 15.4665f;
|
||||
F3.Umin = -16.22f;
|
||||
F3.Imax = 1.465f;
|
||||
F3.Imin = -1.2f;
|
||||
r3 = -0.125f;
|
||||
y3 = 0.0f;
|
||||
|
||||
// GSM (F4)
|
||||
for (i=1; i<=GSM_N; i++)
|
||||
{
|
||||
x += F4.h;
|
||||
F4.sps->c[i] = x*x;
|
||||
}
|
||||
DCL_loadGSMgains(&F4);
|
||||
DCL_REQUEST_UPDATE(&F4);
|
||||
DCL_updateGSM(&F4);
|
||||
r4 = 0.0899f;
|
||||
y4 = -0.106f;
|
||||
|
||||
// DF11 (F5)
|
||||
F5.b0 = 5.106;
|
||||
F5.b1 = -5.094;
|
||||
F5.a1 = -1;
|
||||
|
||||
// DF22 (F6)
|
||||
F6.b0 = 9.8549f;
|
||||
F6.b1 = -19.4165f;
|
||||
F6.b2 = 9.5636f;
|
||||
F6.a1 = -1.9417f;
|
||||
F6.a2 = 0.9417f;
|
||||
r6 = 0.95f;
|
||||
|
||||
// DF23 (F7)
|
||||
F7.sps = &F7sps;
|
||||
F7.css = &F7css;
|
||||
F7.sps->b0 = 9.658f;
|
||||
F7.sps->b1 = -9.158f;
|
||||
F7.sps->b2 = -9.6521f;
|
||||
F7.sps->b3 = 9.1639f;
|
||||
F7.sps->a1 = -2.128f;
|
||||
F7.sps->a2 = 1.3968f;
|
||||
F7.sps->a3 = -0.2689f;
|
||||
DCL_REQUEST_UPDATE(&F7);
|
||||
DCL_updateDF23(&F7);
|
||||
r7 = 0.5f;
|
||||
y7 = 0.0f;
|
||||
|
||||
// enable interrupts
|
||||
PieCtrlRegs.PIEIER1.bit.INTx7 = 1;
|
||||
IER |= M_INT1;
|
||||
IER |= M_INT13;
|
||||
IER |= M_INT14;
|
||||
ERTM;
|
||||
EINT;
|
||||
|
||||
// Configure ERAD for profiling
|
||||
EradConfig();
|
||||
|
||||
// start CPU timers
|
||||
StartCpuTimer1();
|
||||
StartCpuTimer2();
|
||||
StartCpuTimer0();
|
||||
|
||||
while(1)
|
||||
{
|
||||
DCL_REQUEST_UPDATE(&F7);
|
||||
DCL_updateDF23(&F7);
|
||||
|
||||
asm(" NOP");
|
||||
IdleLoopCount++;
|
||||
|
||||
if(IdleLoopCount == 1000)
|
||||
{
|
||||
CpuTimer0Regs.TCR.bit.TSS = 1;
|
||||
CpuTimer1Regs.TCR.bit.TSS = 1;
|
||||
CpuTimer2Regs.TCR.bit.TSS = 1;
|
||||
|
||||
ERAD_setGlobalCTMDisable(CTM1_INST | CTM2_INST);
|
||||
ERAD_globalHWBPDisable(HWBP1_INST | HWBP2_INST | HWBP3_INST);
|
||||
|
||||
MaxWindowCycles = ERAD_counterGetMaxCount(CTM2_INST);
|
||||
MaxISRCycles = ERAD_counterGetMaxCount(CTM1_INST);
|
||||
|
||||
while(1);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/* control loop (a) - CPU timer 0 @ 10 kHz */
|
||||
#pragma CODE_SECTION(ISRa, "interruptSection")
|
||||
interrupt void ISRa(void)
|
||||
{
|
||||
CpuTimer0Regs.TCR.bit.TIF = 1;
|
||||
PieCtrlRegs.PIEACK.all = PIEACK_GROUP1;
|
||||
EINT;
|
||||
|
||||
if (0 > --DecimF1)
|
||||
{
|
||||
u1 = DCL_runPID_C2(&F1, r1, y1, 1.0f);
|
||||
DecimF1 = DECIM_F1;
|
||||
}
|
||||
|
||||
u2 = DCL_runPI_C2(&F2, u1, y2);
|
||||
u3 = DCL_runPI_C2(&F3, r3, y3);
|
||||
|
||||
IsraCount++;
|
||||
DINT;
|
||||
}
|
||||
|
||||
/* control loop (b) - CPU timer 1 @ 253 kHz */
|
||||
#pragma CODE_SECTION(ISRb, "interruptSection")
|
||||
interrupt void ISRb(void)
|
||||
{
|
||||
CpuTimer1Regs.TCR.bit.TIF = 1;
|
||||
|
||||
u4 = DCL_runGSM_C1(&F4, r4 - y4);
|
||||
u5 = DCL_runDF11_C2(&F5, u4);
|
||||
|
||||
if (0 > --DecimF6)
|
||||
{
|
||||
u6 = DCL_runDF22_C4(&F6, r6);
|
||||
DecimF6 = DECIM_F6;
|
||||
}
|
||||
|
||||
IsrbCount++;
|
||||
}
|
||||
|
||||
/* control loop (c) - CPU timer 2 @ 60 kHz */
|
||||
#pragma CODE_SECTION(ISRc, "interruptSection")
|
||||
interrupt void ISRc(void)
|
||||
{
|
||||
CpuTimer2Regs.TCR.bit.TIF = 1;
|
||||
|
||||
u7 = DCL_runDF23_C4(&F7, r7 - y7);
|
||||
|
||||
IsrcCount++;
|
||||
|
||||
if (0 == (IsrcCount + IsrbCount) % DECIM_F7)
|
||||
{
|
||||
F28x_usDelayErad(PAYLOAD_F7);
|
||||
}
|
||||
}
|
||||
|
||||
/* ERAD configuration */
|
||||
void EradConfig()
|
||||
{
|
||||
hwbpConfig hwbpConfig1,hwbpConfig2,hwbpConfig3;
|
||||
counterConfig counterConfig1,counterConfig2;
|
||||
|
||||
// Disable all comparator and counter units
|
||||
ERAD_setGlobalCTMDisable(CTM1_INST | CTM2_INST);
|
||||
ERAD_globalHWBPDisable(HWBP1_INST | HWBP2_INST | HWBP3_INST);
|
||||
|
||||
// Setup BC-1 for VPC Match when code is executing interrupts
|
||||
// Configure BC-1 for tracing any match for the following "0x9800 - 0x9FFF" i.e. LS3
|
||||
hwbpConfig1.BUS_SEL = VPC;
|
||||
hwbpConfig1.COMP_MODE = EQ;
|
||||
hwbpConfig1.DBGEVT = DISABLED;
|
||||
hwbpConfig1.MASK = 0x000007FF;
|
||||
hwbpConfig1.REF = 0x00009800;
|
||||
hwbpConfig1.RTOSINT = DISABLED;
|
||||
ERAD_HWBPConfig(HWBP1_INST,hwbpConfig1);
|
||||
|
||||
// Setup BC-2 for VPC Match when ISR + 2 instruction start
|
||||
hwbpConfig2.BUS_SEL = VPC;
|
||||
hwbpConfig2.COMP_MODE = EQ;
|
||||
hwbpConfig2.DBGEVT = DISABLED;
|
||||
hwbpConfig2.MASK = 0x00000000;
|
||||
hwbpConfig2.REF = ((uint32_t)&(ISRa)) + 0x1;
|
||||
hwbpConfig2.RTOSINT = DISABLED;
|
||||
ERAD_HWBPConfig(HWBP2_INST,hwbpConfig2);
|
||||
|
||||
// Setup BC-3 for VPC Match when ISRa starts
|
||||
hwbpConfig3.BUS_SEL = VPC;
|
||||
hwbpConfig3.COMP_MODE = EQ;
|
||||
hwbpConfig3.DBGEVT = DISABLED;
|
||||
hwbpConfig3.MASK = 0x00000000;
|
||||
hwbpConfig3.REF = (uint32_t)&(ISRa);
|
||||
hwbpConfig3.RTOSINT = DISABLED;
|
||||
ERAD_HWBPConfig(HWBP3_INST,hwbpConfig3);
|
||||
|
||||
// Setup CNT-1 in START STOP mode with START = BC-2, STOP=BC-3, COUNTER ENABLE = BC-1
|
||||
counterConfig1.RTOSINT = DISABLED;
|
||||
counterConfig1.DBGEVT = DISABLED;
|
||||
counterConfig1.EDGE_LEVEL_CFG = LEVEL;
|
||||
counterConfig1.START_STOP_MODE = ENABLED;
|
||||
counterConfig1.START_INP_SEL = BUS_COMP2_EVENT;
|
||||
counterConfig1.STOP_INP_SEL = BUS_COMP3_EVENT;
|
||||
counterConfig1.CNT_INP_SEL_EN = ENABLED;
|
||||
counterConfig1.CNT_INP_SEL = BUS_COMP1_EVENT;
|
||||
counterConfig1.HW_CNT_RST = DISABLED;
|
||||
counterConfig1.RST_INP_SEL = BUS_COMP1_EVENT; // This is don't care since HW_CNT_RST is Disabled
|
||||
counterConfig1.RST_ON_MATCH = DISABLED;
|
||||
ERAD_counterConfig(CTM1_INST,counterConfig1);
|
||||
|
||||
// Setup CNT-2 in START STOP mode with START = BC-2, STOP=BC-3, COUNTER ENABLE = Always / CPU_CYCLES
|
||||
counterConfig2.RTOSINT = DISABLED;
|
||||
counterConfig2.DBGEVT = DISABLED;
|
||||
counterConfig2.EDGE_LEVEL_CFG = LEVEL;
|
||||
counterConfig2.START_STOP_MODE = ENABLED;
|
||||
counterConfig2.START_INP_SEL = BUS_COMP2_EVENT;
|
||||
counterConfig2.STOP_INP_SEL = BUS_COMP3_EVENT;
|
||||
counterConfig2.CNT_INP_SEL_EN = DISABLED;
|
||||
counterConfig2.CNT_INP_SEL = BUS_COMP1_EVENT; //T his is don't care since CNT_INP_SEL_EN is Disabled
|
||||
counterConfig2.HW_CNT_RST = DISABLED;
|
||||
counterConfig2.RST_INP_SEL = BUS_COMP1_EVENT; // This is don't care since HW_CNT_RST is Disabled
|
||||
counterConfig2.RST_ON_MATCH = DISABLED;
|
||||
ERAD_counterConfig(CTM2_INST,counterConfig2);
|
||||
|
||||
// Enable all comparator and counter units
|
||||
ERAD_setGlobalCTMEnable(CTM1_INST | CTM2_INST);
|
||||
ERAD_globalHWBPEnable(HWBP1_INST | HWBP2_INST | HWBP3_INST);
|
||||
}
|
||||
|
||||
/* end of file */
|
||||
@@ -0,0 +1,665 @@
|
||||
//###########################################################################
|
||||
//
|
||||
// FILE: f28004x_dcl_erad.c
|
||||
//
|
||||
// TITLE: ERAD driver functions for DCL suite.
|
||||
//
|
||||
//###########################################################################
|
||||
// $TI Release: $
|
||||
// $Release Date: $
|
||||
// $Copyright:
|
||||
// Copyright (C) 2018 Texas Instruments Incorporated - http://www.ti.com/
|
||||
//
|
||||
// Redistribution and use in source and binary forms, with or without
|
||||
// modification, are permitted provided that the following conditions
|
||||
// are met:
|
||||
//
|
||||
// Redistributions of source code must retain the above copyright
|
||||
// notice, this list of conditions and the following disclaimer.
|
||||
//
|
||||
// Redistributions in binary form must reproduce the above copyright
|
||||
// notice, this list of conditions and the following disclaimer in the
|
||||
// documentation and/or other materials provided with the
|
||||
// distribution.
|
||||
//
|
||||
// Neither the name of Texas Instruments Incorporated nor the names of
|
||||
// its contributors may be used to endorse or promote products derived
|
||||
// from this software without specific prior written permission.
|
||||
//
|
||||
// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
|
||||
// "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
|
||||
// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
|
||||
// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
|
||||
// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
|
||||
// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
|
||||
// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
|
||||
// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
|
||||
// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
||||
// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
|
||||
// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
// $
|
||||
//###########################################################################
|
||||
|
||||
//***********************************************************************************
|
||||
//
|
||||
// Included Files
|
||||
//
|
||||
//***********************************************************************************
|
||||
#include "f28004x_dcl_erad.h"
|
||||
#include "f28004x_erad.h"
|
||||
|
||||
//***********************************************************************************
|
||||
//
|
||||
//ERAD_setGlobalCTMEnable - This function is used to enable the Counters.
|
||||
// Inputs can be CTM1_INST,CTM2_INST etc.
|
||||
// Returns false if the unit is not owned by Application.
|
||||
//
|
||||
//***********************************************************************************
|
||||
bool ERAD_setGlobalCTMEnable(Uint16 counterInstances)
|
||||
{
|
||||
|
||||
//Check if Application owns the ERAD, else return false
|
||||
if(EradGlobalRegs.GLBL_OWNER.bit.OWNER == DEBUGGER)
|
||||
{
|
||||
return false;
|
||||
}else
|
||||
{
|
||||
Uint16 shiftedCounterInstance,temp;
|
||||
|
||||
shiftedCounterInstance = counterInstances << 8;
|
||||
EALLOW;
|
||||
temp = (EradGlobalRegs.GLBL_ENABLE.all) | shiftedCounterInstance;
|
||||
EradGlobalRegs.GLBL_ENABLE.all = temp;
|
||||
EDIS;
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
//***********************************************************************************
|
||||
//
|
||||
//ERAD_setGlobalCTMDisable -This function is used to disable the Counters.
|
||||
// Inputs can be CTM1_INST,CTM2_INST etc.
|
||||
// Returns false if the unit is not owned by Application.
|
||||
//
|
||||
//***********************************************************************************
|
||||
bool ERAD_setGlobalCTMDisable(Uint16 counterInstances)
|
||||
{
|
||||
//Check if Application owns the ERAD, else return false
|
||||
if(EradGlobalRegs.GLBL_OWNER.bit.OWNER == DEBUGGER)
|
||||
{
|
||||
return false;
|
||||
}else
|
||||
{
|
||||
Uint16 shiftedCounterInstance,temp;
|
||||
|
||||
shiftedCounterInstance = counterInstances << 8;
|
||||
EALLOW;
|
||||
temp = (EradGlobalRegs.GLBL_ENABLE.all) & (~shiftedCounterInstance);
|
||||
EradGlobalRegs.GLBL_ENABLE.all = temp;
|
||||
EDIS;
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
//***********************************************************************************
|
||||
//
|
||||
//ERAD_setGlobalCTMReset - This function is used to reset the Counters.
|
||||
// Inputs can be CTM1_INST,CTM2_INST etc.
|
||||
//***********************************************************************************
|
||||
void ERAD_setGlobalCTMReset(Uint16 counterInstances)
|
||||
{
|
||||
EALLOW;
|
||||
EradGlobalRegs.GLBL_CTM_RESET.all = counterInstances;
|
||||
EDIS;
|
||||
}
|
||||
|
||||
//***********************************************************************************
|
||||
//
|
||||
//ERAD_getCTMEventStat - This function is used to read the Counter event stats.
|
||||
// Outputs can be checked against CTM1_INST,CTM2_INST etc.
|
||||
//
|
||||
//***********************************************************************************
|
||||
Uint16 ERAD_getCTMEventStat()
|
||||
{
|
||||
Uint16 shiftedCounterInstance;
|
||||
shiftedCounterInstance = ((EradGlobalRegs.GLBL_EVENT_STAT.all) & 0xF00)>>8;
|
||||
return(shiftedCounterInstance);
|
||||
}
|
||||
|
||||
//***********************************************************************************
|
||||
//
|
||||
//ERAD_getCTMHaltStat - This function is used to read the Counter halt stats.
|
||||
// Outputs can be checked against CTM1_INST,CTM2_INST etc.
|
||||
//
|
||||
//***********************************************************************************
|
||||
Uint16 ERAD_getCTMHaltStat()
|
||||
{
|
||||
Uint16 shiftedCounterInstance;
|
||||
shiftedCounterInstance = ((EradGlobalRegs.GLBL_HALT_STAT.all) & 0xF00)>>8;
|
||||
return(shiftedCounterInstance);
|
||||
}
|
||||
|
||||
//***********************************************************************************
|
||||
//
|
||||
//ERAD_globalHWBPEnable - This function is used to enable the Enhanced Bus Comparator
|
||||
// units.
|
||||
// Inputs can be HWBP1_INST,HWBP2_INST etc.
|
||||
// Returns false if the unit is not owned by Application.
|
||||
//
|
||||
//***********************************************************************************
|
||||
bool ERAD_globalHWBPEnable(Uint16 hwbpInstances)
|
||||
{
|
||||
//Check if Application owns the ERAD, else return false
|
||||
if(EradGlobalRegs.GLBL_OWNER.bit.OWNER == DEBUGGER)
|
||||
{
|
||||
return false;
|
||||
}else
|
||||
{
|
||||
Uint16 temp;
|
||||
EALLOW;
|
||||
temp = (EradGlobalRegs.GLBL_ENABLE.all) | hwbpInstances;
|
||||
EradGlobalRegs.GLBL_ENABLE.all = temp;
|
||||
EDIS;
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
//***********************************************************************************
|
||||
//
|
||||
//ERAD_globalHWBPDisable - This function is used to disable the Enhanced Bus comparator
|
||||
// units.
|
||||
// Inputs can be HWBP1_INST,HWBP2_INST etc.
|
||||
// Returns false if the unit is not owned by Application.
|
||||
//
|
||||
//***********************************************************************************
|
||||
bool ERAD_globalHWBPDisable(Uint16 hwbpInstances)
|
||||
{
|
||||
//Check if Application owns the ERAD, else return false
|
||||
if(EradGlobalRegs.GLBL_OWNER.bit.OWNER == DEBUGGER)
|
||||
{
|
||||
return false;
|
||||
}else
|
||||
{
|
||||
Uint16 temp;
|
||||
EALLOW;
|
||||
temp = (EradGlobalRegs.GLBL_ENABLE.all) & (~hwbpInstances);
|
||||
EradGlobalRegs.GLBL_ENABLE.all = temp;
|
||||
EDIS;
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
//***********************************************************************************
|
||||
//
|
||||
//ERAD_getHWBPEventStat - This function is used to get the Enhanced Bus comparator
|
||||
// event stats
|
||||
// Outputs can be checked against HWBP1_INST,HWBP2_INST etc.
|
||||
//
|
||||
//***********************************************************************************
|
||||
Uint16 ERAD_getHWBPEventStat()
|
||||
{
|
||||
Uint16 shiftedCounterInstance;
|
||||
shiftedCounterInstance = ((EradGlobalRegs.GLBL_EVENT_STAT.all) & 0x00FF);
|
||||
return(shiftedCounterInstance);
|
||||
}
|
||||
|
||||
//***********************************************************************************
|
||||
//
|
||||
//ERAD_getHWBPHaltStat - This function is used to get the Enhanced Bus comparator
|
||||
// halt stats
|
||||
// Outputs can be checked against HWBP1_INST,HWBP2_INST etc.
|
||||
//
|
||||
//***********************************************************************************
|
||||
Uint16 ERAD_getHWBPHaltStat()
|
||||
{
|
||||
Uint16 shiftedCounterInstance;
|
||||
shiftedCounterInstance = ((EradGlobalRegs.GLBL_HALT_STAT.all) & 0x00FF);
|
||||
return(shiftedCounterInstance);
|
||||
}
|
||||
|
||||
//***********************************************************************************
|
||||
//
|
||||
//ERAD_counterSetRef - This function is used to set the reference match count for the
|
||||
// counter.
|
||||
// Inputs can be CTM1_INST,CTM2_INST etc and the
|
||||
// counter reference count.
|
||||
//
|
||||
//***********************************************************************************
|
||||
void ERAD_counterSetRef(Uint16 counterInstance,Uint32 referenceCount)
|
||||
{
|
||||
EALLOW;
|
||||
if(counterInstance == CTM1_INST)
|
||||
{
|
||||
EradCounter1Regs.CTM_REF = referenceCount;
|
||||
}else if(counterInstance == CTM2_INST)
|
||||
{
|
||||
EradCounter2Regs.CTM_REF = referenceCount;
|
||||
}else if(counterInstance == CTM3_INST)
|
||||
{
|
||||
EradCounter3Regs.CTM_REF = referenceCount;
|
||||
}else if(counterInstance == CTM4_INST)
|
||||
{
|
||||
EradCounter4Regs.CTM_REF = referenceCount;
|
||||
}
|
||||
EDIS;
|
||||
}
|
||||
|
||||
//***********************************************************************************
|
||||
//
|
||||
//ERAD_counterSetCurCount - This function is used to set the current count for the
|
||||
// counter to a predetermined value.
|
||||
// Inputs can be CTM1_INST,CTM2_INST etc and the current
|
||||
// counter count.
|
||||
//
|
||||
//***********************************************************************************
|
||||
void ERAD_counterSetCurCount(Uint16 counterInstance,Uint32 currentCount)
|
||||
{
|
||||
EALLOW;
|
||||
if(counterInstance == CTM1_INST)
|
||||
{
|
||||
EradCounter1Regs.CTM_COUNT = currentCount;
|
||||
}else if(counterInstance == CTM2_INST)
|
||||
{
|
||||
EradCounter2Regs.CTM_COUNT = currentCount;
|
||||
}else if(counterInstance == CTM3_INST)
|
||||
{
|
||||
EradCounter3Regs.CTM_COUNT = currentCount;
|
||||
}else if(counterInstance == CTM4_INST)
|
||||
{
|
||||
EradCounter4Regs.CTM_COUNT = currentCount;
|
||||
}
|
||||
EDIS;
|
||||
}
|
||||
|
||||
//***********************************************************************************
|
||||
//
|
||||
//ERAD_counterSetMaxCount - This function is used to set the max count for the
|
||||
// counter to a predetermined value.
|
||||
// Inputs can be CTM1_INST,CTM2_INST etc and the counter
|
||||
// max count.
|
||||
//
|
||||
//***********************************************************************************
|
||||
void ERAD_counterSetMaxCount(Uint16 counterInstance,Uint32 maxCount)
|
||||
{
|
||||
EALLOW;
|
||||
if(counterInstance == CTM1_INST)
|
||||
{
|
||||
EradCounter1Regs.CTM_MAX_COUNT = maxCount;
|
||||
}else if(counterInstance == CTM2_INST)
|
||||
{
|
||||
EradCounter2Regs.CTM_MAX_COUNT = maxCount;
|
||||
}else if(counterInstance == CTM3_INST)
|
||||
{
|
||||
EradCounter3Regs.CTM_MAX_COUNT = maxCount;
|
||||
}else if(counterInstance == CTM4_INST)
|
||||
{
|
||||
EradCounter4Regs.CTM_MAX_COUNT = maxCount;
|
||||
}
|
||||
EDIS;
|
||||
}
|
||||
|
||||
//***********************************************************************************
|
||||
//
|
||||
//ERAD_counterGetCurCount - This function is used to get the current count for
|
||||
// the counter.
|
||||
// Inputs can be CTM1_INST,CTM2_INST etc.
|
||||
// Returns the current count value.
|
||||
//
|
||||
//***********************************************************************************
|
||||
Uint32 ERAD_counterGetCurCount(Uint16 counterInstance)
|
||||
{
|
||||
Uint32 currentCount;
|
||||
if(counterInstance == CTM1_INST)
|
||||
{
|
||||
currentCount = EradCounter1Regs.CTM_COUNT;
|
||||
}else if(counterInstance == CTM2_INST)
|
||||
{
|
||||
currentCount = EradCounter2Regs.CTM_COUNT ;
|
||||
}else if(counterInstance == CTM3_INST)
|
||||
{
|
||||
currentCount = EradCounter3Regs.CTM_COUNT ;
|
||||
}else if(counterInstance == CTM4_INST)
|
||||
{
|
||||
currentCount = EradCounter4Regs.CTM_COUNT ;
|
||||
}
|
||||
return(currentCount);
|
||||
}
|
||||
|
||||
//***********************************************************************************
|
||||
//
|
||||
//ERAD_counterGetMaxCount - This function is used to get the max count for the
|
||||
// counter.
|
||||
// Inputs can be CTM1_INST,CTM2_INST etc.
|
||||
// Returns the count max value.
|
||||
//
|
||||
//***********************************************************************************
|
||||
Uint32 ERAD_counterGetMaxCount(Uint16 counterInstance)
|
||||
{
|
||||
Uint32 maxCount;
|
||||
if(counterInstance == CTM1_INST)
|
||||
{
|
||||
maxCount = EradCounter1Regs.CTM_MAX_COUNT;
|
||||
}else if(counterInstance == CTM2_INST)
|
||||
{
|
||||
maxCount = EradCounter2Regs.CTM_MAX_COUNT ;
|
||||
}else if(counterInstance == CTM3_INST)
|
||||
{
|
||||
maxCount = EradCounter3Regs.CTM_MAX_COUNT ;
|
||||
}else if(counterInstance == CTM4_INST)
|
||||
{
|
||||
maxCount = EradCounter4Regs.CTM_MAX_COUNT ;
|
||||
}
|
||||
return(maxCount);
|
||||
}
|
||||
|
||||
//***********************************************************************************
|
||||
//
|
||||
//ERAD_counterGetStatus - This function is used to get the current status for the
|
||||
// counter.
|
||||
// Inputs can be CTM1_INST,CTM2_INST etc.
|
||||
// Returns CTM_EVENT_FIRED or CTM_EVENT_OVERFLOW or both.
|
||||
//
|
||||
//***********************************************************************************
|
||||
Uint16 ERAD_counterGetStatus(Uint16 counterInstance)
|
||||
{
|
||||
if(counterInstance == CTM1_INST)
|
||||
{
|
||||
return( ( (EradCounter1Regs.CTM_STATUS.bit.OVERFLOW << 1) | EradCounter1Regs.CTM_STATUS.bit.EVENT_FIRED) );
|
||||
}else if(counterInstance == CTM2_INST)
|
||||
{
|
||||
return( ( (EradCounter2Regs.CTM_STATUS.bit.OVERFLOW << 1) | EradCounter2Regs.CTM_STATUS.bit.EVENT_FIRED) );
|
||||
}else if(counterInstance == CTM3_INST)
|
||||
{
|
||||
return( ( (EradCounter3Regs.CTM_STATUS.bit.OVERFLOW << 1) | EradCounter3Regs.CTM_STATUS.bit.EVENT_FIRED) );
|
||||
}else if(counterInstance == CTM4_INST)
|
||||
{
|
||||
return( ( (EradCounter4Regs.CTM_STATUS.bit.OVERFLOW << 1) | EradCounter4Regs.CTM_STATUS.bit.EVENT_FIRED) );
|
||||
}else
|
||||
{
|
||||
return(0);
|
||||
}
|
||||
}
|
||||
|
||||
//***********************************************************************************
|
||||
//
|
||||
//ERAD_counterClearStatus - This function is used to clear the current status for the
|
||||
// counter.
|
||||
// Inputs can be CTM1_INST,CTM2_INST etc and the event
|
||||
// to clear(CTM_EVENT_FIRED or CTM_EVENT_OVERFLOW or both).
|
||||
//
|
||||
//***********************************************************************************
|
||||
void ERAD_counterClearStatus(Uint16 counterInstance,Uint16 clearFlags)
|
||||
{
|
||||
EALLOW;
|
||||
if(counterInstance == CTM1_INST)
|
||||
{
|
||||
if(clearFlags && CTM_EVENT_FIRED == 0x1)
|
||||
{
|
||||
EradCounter1Regs.CTM_CLEAR.bit.EVENT_CLEAR = 1;
|
||||
}
|
||||
if(clearFlags && CTM_EVENT_FIRED == 0x2)
|
||||
{
|
||||
EradCounter1Regs.CTM_CLEAR.bit.OVERFLOW_CLEAR = 1;
|
||||
}
|
||||
}else if(counterInstance == CTM2_INST)
|
||||
{
|
||||
if(clearFlags && CTM_EVENT_FIRED == 0x1)
|
||||
{
|
||||
EradCounter2Regs.CTM_CLEAR.bit.EVENT_CLEAR = 1;
|
||||
}
|
||||
if(clearFlags && CTM_EVENT_FIRED == 0x2)
|
||||
{
|
||||
EradCounter2Regs.CTM_CLEAR.bit.OVERFLOW_CLEAR = 1;
|
||||
}
|
||||
}else if(counterInstance == CTM3_INST)
|
||||
{
|
||||
if(clearFlags && CTM_EVENT_FIRED == 0x1)
|
||||
{
|
||||
EradCounter3Regs.CTM_CLEAR.bit.EVENT_CLEAR = 1;
|
||||
}
|
||||
if(clearFlags && CTM_EVENT_FIRED == 0x2)
|
||||
{
|
||||
EradCounter3Regs.CTM_CLEAR.bit.OVERFLOW_CLEAR = 1;
|
||||
}
|
||||
}else if(counterInstance == CTM4_INST)
|
||||
{
|
||||
if(clearFlags && CTM_EVENT_FIRED == 0x1)
|
||||
{
|
||||
EradCounter4Regs.CTM_CLEAR.bit.EVENT_CLEAR = 1;
|
||||
}
|
||||
if(clearFlags && CTM_EVENT_FIRED == 0x2)
|
||||
{
|
||||
EradCounter4Regs.CTM_CLEAR.bit.OVERFLOW_CLEAR = 1;
|
||||
}
|
||||
}
|
||||
EDIS;
|
||||
}
|
||||
|
||||
//***********************************************************************************
|
||||
//
|
||||
//ERAD_counterConfig - This function is used to configure the counter.
|
||||
// Inputs can be CTM1_INST,CTM2_INST etc and
|
||||
// configurations can be passed via a structure of type counterConfig.
|
||||
//
|
||||
//***********************************************************************************
|
||||
void ERAD_counterConfig(Uint16 counterInstance,counterConfig counterCfg)
|
||||
{
|
||||
EALLOW;
|
||||
if(counterInstance == CTM1_INST)
|
||||
{
|
||||
EradCounter1Regs.CTM_CNTL.bit.START_STOP_MODE = counterCfg.START_STOP_MODE;
|
||||
EradCounter1Regs.CTM_CNTL.bit.EVENT_MODE = counterCfg.EDGE_LEVEL_CFG;
|
||||
EradCounter1Regs.CTM_CNTL.bit.RST_ON_MATCH = counterCfg.RST_ON_MATCH;
|
||||
EradCounter1Regs.CTM_CNTL.bit.STOP = counterCfg.DBGEVT;
|
||||
EradCounter1Regs.CTM_CNTL.bit.RTOSINT = counterCfg.RTOSINT;
|
||||
EradCounter1Regs.CTM_CNTL.bit.RST_EN = counterCfg.HW_CNT_RST;
|
||||
EradCounter1Regs.CTM_CNTL.bit.RST_INP_SEL = counterCfg.RST_INP_SEL;
|
||||
EradCounter1Regs.CTM_INPUT_SEL.bit.CNT_INP_SEL = counterCfg.CNT_INP_SEL;
|
||||
EradCounter1Regs.CTM_INPUT_SEL.bit.STA_INP_SEL = counterCfg.START_INP_SEL;
|
||||
EradCounter1Regs.CTM_INPUT_SEL.bit.STO_INP_SEL = counterCfg.STOP_INP_SEL;
|
||||
EradCounter1Regs.CTM_INPUT_SEL.bit.CTM_INP_SEL_EN = counterCfg.CNT_INP_SEL_EN;
|
||||
}else if(counterInstance == CTM2_INST)
|
||||
{
|
||||
EradCounter2Regs.CTM_CNTL.bit.START_STOP_MODE = counterCfg.START_STOP_MODE;
|
||||
EradCounter2Regs.CTM_CNTL.bit.EVENT_MODE = counterCfg.EDGE_LEVEL_CFG;
|
||||
EradCounter2Regs.CTM_CNTL.bit.RST_ON_MATCH = counterCfg.RST_ON_MATCH;
|
||||
EradCounter2Regs.CTM_CNTL.bit.STOP = counterCfg.DBGEVT;
|
||||
EradCounter2Regs.CTM_CNTL.bit.RTOSINT = counterCfg.RTOSINT;
|
||||
EradCounter2Regs.CTM_CNTL.bit.RST_EN = counterCfg.HW_CNT_RST;
|
||||
EradCounter2Regs.CTM_CNTL.bit.RST_INP_SEL = counterCfg.RST_INP_SEL;
|
||||
EradCounter2Regs.CTM_INPUT_SEL.bit.CNT_INP_SEL = counterCfg.CNT_INP_SEL;
|
||||
EradCounter2Regs.CTM_INPUT_SEL.bit.STA_INP_SEL = counterCfg.START_INP_SEL;
|
||||
EradCounter2Regs.CTM_INPUT_SEL.bit.STO_INP_SEL = counterCfg.STOP_INP_SEL;
|
||||
EradCounter2Regs.CTM_INPUT_SEL.bit.CTM_INP_SEL_EN = counterCfg.CNT_INP_SEL_EN;
|
||||
|
||||
}else if(counterInstance == CTM3_INST)
|
||||
{
|
||||
EradCounter3Regs.CTM_CNTL.bit.START_STOP_MODE = counterCfg.START_STOP_MODE;
|
||||
EradCounter3Regs.CTM_CNTL.bit.EVENT_MODE = counterCfg.EDGE_LEVEL_CFG;
|
||||
EradCounter3Regs.CTM_CNTL.bit.RST_ON_MATCH = counterCfg.RST_ON_MATCH;
|
||||
EradCounter3Regs.CTM_CNTL.bit.STOP = counterCfg.DBGEVT;
|
||||
EradCounter3Regs.CTM_CNTL.bit.RTOSINT = counterCfg.RTOSINT;
|
||||
EradCounter3Regs.CTM_CNTL.bit.RST_EN = counterCfg.HW_CNT_RST;
|
||||
EradCounter3Regs.CTM_CNTL.bit.RST_INP_SEL = counterCfg.RST_INP_SEL;
|
||||
EradCounter3Regs.CTM_INPUT_SEL.bit.CNT_INP_SEL = counterCfg.CNT_INP_SEL;
|
||||
EradCounter3Regs.CTM_INPUT_SEL.bit.STA_INP_SEL = counterCfg.START_INP_SEL;
|
||||
EradCounter3Regs.CTM_INPUT_SEL.bit.STO_INP_SEL = counterCfg.STOP_INP_SEL;
|
||||
EradCounter3Regs.CTM_INPUT_SEL.bit.CTM_INP_SEL_EN = counterCfg.CNT_INP_SEL_EN;
|
||||
|
||||
}else if(counterInstance == CTM4_INST)
|
||||
{
|
||||
EradCounter4Regs.CTM_CNTL.bit.START_STOP_MODE = counterCfg.START_STOP_MODE;
|
||||
EradCounter4Regs.CTM_CNTL.bit.EVENT_MODE = counterCfg.EDGE_LEVEL_CFG;
|
||||
EradCounter4Regs.CTM_CNTL.bit.RST_ON_MATCH = counterCfg.RST_ON_MATCH;
|
||||
EradCounter4Regs.CTM_CNTL.bit.STOP = counterCfg.DBGEVT;
|
||||
EradCounter4Regs.CTM_CNTL.bit.RTOSINT = counterCfg.RTOSINT;
|
||||
EradCounter4Regs.CTM_CNTL.bit.RST_EN = counterCfg.HW_CNT_RST;
|
||||
EradCounter4Regs.CTM_CNTL.bit.RST_INP_SEL = counterCfg.RST_INP_SEL;
|
||||
EradCounter4Regs.CTM_INPUT_SEL.bit.CNT_INP_SEL = counterCfg.CNT_INP_SEL;
|
||||
EradCounter4Regs.CTM_INPUT_SEL.bit.STA_INP_SEL = counterCfg.START_INP_SEL;
|
||||
EradCounter4Regs.CTM_INPUT_SEL.bit.STO_INP_SEL = counterCfg.STOP_INP_SEL;
|
||||
EradCounter4Regs.CTM_INPUT_SEL.bit.CTM_INP_SEL_EN = counterCfg.CNT_INP_SEL_EN;
|
||||
}
|
||||
EDIS;
|
||||
}
|
||||
|
||||
//***********************************************************************************
|
||||
//
|
||||
//ERAD_HWBPGetStatus - This function is used to get the current status for the
|
||||
// Enhanced Bus comparator unit.
|
||||
// Inputs can be HWBP1_INST, HWBP2_INST etc.
|
||||
// Returns HWBP_EVENT_FIRED, if fired.
|
||||
//
|
||||
//***********************************************************************************
|
||||
Uint16 ERAD_HWBPGetStatus(Uint16 hwbpInstance)
|
||||
{
|
||||
if(hwbpInstance == HWBP1_INST)
|
||||
{
|
||||
return (EradHWBP1Regs.HWBP_STATUS.bit.EVENT_FIRED);
|
||||
}else if(hwbpInstance == HWBP2_INST)
|
||||
{
|
||||
return (EradHWBP2Regs.HWBP_STATUS.bit.EVENT_FIRED);
|
||||
}else if(hwbpInstance == HWBP3_INST)
|
||||
{
|
||||
return (EradHWBP3Regs.HWBP_STATUS.bit.EVENT_FIRED);
|
||||
}else if(hwbpInstance == HWBP4_INST)
|
||||
{
|
||||
return (EradHWBP4Regs.HWBP_STATUS.bit.EVENT_FIRED);
|
||||
}else if(hwbpInstance == HWBP5_INST)
|
||||
{
|
||||
return (EradHWBP5Regs.HWBP_STATUS.bit.EVENT_FIRED);
|
||||
}else if(hwbpInstance == HWBP6_INST)
|
||||
{
|
||||
return (EradHWBP6Regs.HWBP_STATUS.bit.EVENT_FIRED);
|
||||
}else if(hwbpInstance == HWBP7_INST)
|
||||
{
|
||||
return (EradHWBP7Regs.HWBP_STATUS.bit.EVENT_FIRED);
|
||||
}else if(hwbpInstance == HWBP8_INST)
|
||||
{
|
||||
return (EradHWBP8Regs.HWBP_STATUS.bit.EVENT_FIRED);
|
||||
}else
|
||||
{
|
||||
return (0);
|
||||
}
|
||||
}
|
||||
|
||||
//***********************************************************************************
|
||||
//
|
||||
//ERAD_HWBPClearStatus - This function is used to clear the current status for the
|
||||
// Enhanced Bus comparator unit.
|
||||
// Inputs can be HWBP1_INST, HWBP2_INST etc and the event to
|
||||
// clear(HWBP_EVENT_FIRED).
|
||||
//
|
||||
//***********************************************************************************
|
||||
void ERAD_HWBPClearStatus(Uint16 hwbpInstance,Uint16 clearFlags)
|
||||
{
|
||||
EALLOW;
|
||||
if(clearFlags == HWBP_EVENT_FIRED)
|
||||
{
|
||||
if(hwbpInstance == HWBP1_INST)
|
||||
{
|
||||
EradHWBP1Regs.HWBP_CLEAR.bit.EVENT_CLR = 1;
|
||||
}else if(hwbpInstance == HWBP2_INST)
|
||||
{
|
||||
EradHWBP2Regs.HWBP_CLEAR.bit.EVENT_CLR = 1;
|
||||
}else if(hwbpInstance == HWBP3_INST)
|
||||
{
|
||||
EradHWBP3Regs.HWBP_CLEAR.bit.EVENT_CLR = 1;
|
||||
}else if(hwbpInstance == HWBP4_INST)
|
||||
{
|
||||
EradHWBP4Regs.HWBP_CLEAR.bit.EVENT_CLR = 1;
|
||||
}else if(hwbpInstance == HWBP5_INST)
|
||||
{
|
||||
EradHWBP5Regs.HWBP_CLEAR.bit.EVENT_CLR = 1;
|
||||
}else if(hwbpInstance == HWBP6_INST)
|
||||
{
|
||||
EradHWBP6Regs.HWBP_CLEAR.bit.EVENT_CLR = 1;
|
||||
}else if(hwbpInstance == HWBP7_INST)
|
||||
{
|
||||
EradHWBP7Regs.HWBP_CLEAR.bit.EVENT_CLR = 1;
|
||||
}else if(hwbpInstance == HWBP8_INST)
|
||||
{
|
||||
EradHWBP8Regs.HWBP_CLEAR.bit.EVENT_CLR = 1;
|
||||
}
|
||||
}
|
||||
EDIS;
|
||||
}
|
||||
|
||||
//***********************************************************************************
|
||||
//
|
||||
//ERAD_HWBPConfig - This function is used to configure the Enhanced Bus comparator unit.
|
||||
// Inputs can be HWBP1_INST, HWBP2_INST etc and the
|
||||
// configurations can be passed via a structure of type hwbpConfig.
|
||||
//
|
||||
//***********************************************************************************
|
||||
void ERAD_HWBPConfig(Uint16 hwbpInstance,hwbpConfig hwbpCfg)
|
||||
{
|
||||
EALLOW;
|
||||
if(hwbpInstance == HWBP1_INST)
|
||||
{
|
||||
EradHWBP1Regs.HWBP_CNTL.bit.BUS_SEL = hwbpCfg.BUS_SEL;
|
||||
EradHWBP1Regs.HWBP_CNTL.bit.COMP_MODE = hwbpCfg.COMP_MODE;
|
||||
EradHWBP1Regs.HWBP_REF = hwbpCfg.REF;
|
||||
EradHWBP1Regs.HWBP_MASK = hwbpCfg.MASK;
|
||||
EradHWBP1Regs.HWBP_CNTL.bit.STOP = hwbpCfg.DBGEVT;
|
||||
EradHWBP1Regs.HWBP_CNTL.bit.RTOSINT = hwbpCfg.RTOSINT;
|
||||
}else if(hwbpInstance == HWBP2_INST)
|
||||
{
|
||||
EradHWBP2Regs.HWBP_CNTL.bit.BUS_SEL = hwbpCfg.BUS_SEL;
|
||||
EradHWBP2Regs.HWBP_CNTL.bit.COMP_MODE = hwbpCfg.COMP_MODE;
|
||||
EradHWBP2Regs.HWBP_REF = hwbpCfg.REF;
|
||||
EradHWBP2Regs.HWBP_MASK = hwbpCfg.MASK;
|
||||
EradHWBP2Regs.HWBP_CNTL.bit.STOP = hwbpCfg.DBGEVT;
|
||||
EradHWBP2Regs.HWBP_CNTL.bit.RTOSINT = hwbpCfg.RTOSINT;
|
||||
}else if(hwbpInstance == HWBP3_INST)
|
||||
{
|
||||
EradHWBP3Regs.HWBP_CNTL.bit.BUS_SEL = hwbpCfg.BUS_SEL;
|
||||
EradHWBP3Regs.HWBP_CNTL.bit.COMP_MODE = hwbpCfg.COMP_MODE;
|
||||
EradHWBP3Regs.HWBP_REF = hwbpCfg.REF;
|
||||
EradHWBP3Regs.HWBP_MASK = hwbpCfg.MASK;
|
||||
EradHWBP3Regs.HWBP_CNTL.bit.STOP = hwbpCfg.DBGEVT;
|
||||
EradHWBP3Regs.HWBP_CNTL.bit.RTOSINT = hwbpCfg.RTOSINT;
|
||||
}else if(hwbpInstance == HWBP4_INST)
|
||||
{
|
||||
EradHWBP4Regs.HWBP_CNTL.bit.BUS_SEL = hwbpCfg.BUS_SEL;
|
||||
EradHWBP4Regs.HWBP_CNTL.bit.COMP_MODE = hwbpCfg.COMP_MODE;
|
||||
EradHWBP4Regs.HWBP_REF = hwbpCfg.REF;
|
||||
EradHWBP4Regs.HWBP_MASK = hwbpCfg.MASK;
|
||||
EradHWBP4Regs.HWBP_CNTL.bit.STOP = hwbpCfg.DBGEVT;
|
||||
EradHWBP4Regs.HWBP_CNTL.bit.RTOSINT = hwbpCfg.RTOSINT;
|
||||
}else if(hwbpInstance == HWBP5_INST)
|
||||
{
|
||||
EradHWBP5Regs.HWBP_CNTL.bit.BUS_SEL = hwbpCfg.BUS_SEL;
|
||||
EradHWBP5Regs.HWBP_CNTL.bit.COMP_MODE = hwbpCfg.COMP_MODE;
|
||||
EradHWBP5Regs.HWBP_REF = hwbpCfg.REF;
|
||||
EradHWBP5Regs.HWBP_MASK = hwbpCfg.MASK;
|
||||
EradHWBP5Regs.HWBP_CNTL.bit.STOP = hwbpCfg.DBGEVT;
|
||||
EradHWBP5Regs.HWBP_CNTL.bit.RTOSINT = hwbpCfg.RTOSINT;
|
||||
}else if(hwbpInstance == HWBP6_INST)
|
||||
{
|
||||
EradHWBP6Regs.HWBP_CNTL.bit.BUS_SEL = hwbpCfg.BUS_SEL;
|
||||
EradHWBP6Regs.HWBP_CNTL.bit.COMP_MODE = hwbpCfg.COMP_MODE;
|
||||
EradHWBP6Regs.HWBP_REF = hwbpCfg.REF;
|
||||
EradHWBP6Regs.HWBP_MASK = hwbpCfg.MASK;
|
||||
EradHWBP6Regs.HWBP_CNTL.bit.STOP = hwbpCfg.DBGEVT;
|
||||
EradHWBP6Regs.HWBP_CNTL.bit.RTOSINT = hwbpCfg.RTOSINT;
|
||||
}else if(hwbpInstance == HWBP7_INST)
|
||||
{
|
||||
EradHWBP7Regs.HWBP_CNTL.bit.BUS_SEL = hwbpCfg.BUS_SEL;
|
||||
EradHWBP7Regs.HWBP_CNTL.bit.COMP_MODE = hwbpCfg.COMP_MODE;
|
||||
EradHWBP7Regs.HWBP_REF = hwbpCfg.REF;
|
||||
EradHWBP7Regs.HWBP_MASK = hwbpCfg.MASK;
|
||||
EradHWBP7Regs.HWBP_CNTL.bit.STOP = hwbpCfg.DBGEVT;
|
||||
EradHWBP7Regs.HWBP_CNTL.bit.RTOSINT = hwbpCfg.RTOSINT;
|
||||
}else if(hwbpInstance == HWBP8_INST)
|
||||
{
|
||||
EradHWBP8Regs.HWBP_CNTL.bit.BUS_SEL = hwbpCfg.BUS_SEL;
|
||||
EradHWBP8Regs.HWBP_CNTL.bit.COMP_MODE = hwbpCfg.COMP_MODE;
|
||||
EradHWBP8Regs.HWBP_REF = hwbpCfg.REF;
|
||||
EradHWBP8Regs.HWBP_MASK = hwbpCfg.MASK;
|
||||
EradHWBP8Regs.HWBP_CNTL.bit.STOP = hwbpCfg.DBGEVT;
|
||||
EradHWBP8Regs.HWBP_CNTL.bit.RTOSINT = hwbpCfg.RTOSINT;
|
||||
}
|
||||
EDIS;
|
||||
}
|
||||
|
||||
@@ -0,0 +1,656 @@
|
||||
//###########################################################################
|
||||
//
|
||||
// FILE: f28004x_dcl_erad.h
|
||||
//
|
||||
// TITLE: ERAD driver header file for DCL suite.
|
||||
//
|
||||
//###########################################################################
|
||||
// $TI Release: $
|
||||
// $Release Date: $
|
||||
// $Copyright:
|
||||
// Copyright (C) 2018 Texas Instruments Incorporated - http://www.ti.com/
|
||||
//
|
||||
// Redistribution and use in source and binary forms, with or without
|
||||
// modification, are permitted provided that the following conditions
|
||||
// are met:
|
||||
//
|
||||
// Redistributions of source code must retain the above copyright
|
||||
// notice, this list of conditions and the following disclaimer.
|
||||
//
|
||||
// Redistributions in binary form must reproduce the above copyright
|
||||
// notice, this list of conditions and the following disclaimer in the
|
||||
// documentation and/or other materials provided with the
|
||||
// distribution.
|
||||
//
|
||||
// Neither the name of Texas Instruments Incorporated nor the names of
|
||||
// its contributors may be used to endorse or promote products derived
|
||||
// from this software without specific prior written permission.
|
||||
//
|
||||
// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
|
||||
// "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
|
||||
// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
|
||||
// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
|
||||
// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
|
||||
// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
|
||||
// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
|
||||
// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
|
||||
// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
||||
// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
|
||||
// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
// $
|
||||
//###########################################################################
|
||||
|
||||
#ifndef F28004x_DCL_ERAD_DEFINES_H
|
||||
#define F28004x_DCL_ERAD_DEFINES_H
|
||||
|
||||
//*****************************************************************************
|
||||
//
|
||||
// If building with a C++ compiler, make all of the definitions in this header
|
||||
// have a C binding.
|
||||
//
|
||||
//*****************************************************************************
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
//*****************************************************************************
|
||||
//
|
||||
//! \addtogroup f28004x_dcl_erad_api F28004x_DCL_ERAD
|
||||
//! @{
|
||||
//
|
||||
//*****************************************************************************
|
||||
|
||||
#include "f28004x_device.h"
|
||||
|
||||
//*****************************************************************************
|
||||
//
|
||||
// The following defines are used by the Counter, Enhanced bus comparator APIs
|
||||
// to configure the corresponding instances.
|
||||
//
|
||||
//*****************************************************************************
|
||||
#define CTM1_INST 0x00000001
|
||||
#define CTM2_INST 0x00000002
|
||||
#define CTM3_INST 0x00000004
|
||||
#define CTM4_INST 0x00000008
|
||||
#define HWBP1_INST 0x00000001
|
||||
#define HWBP2_INST 0x00000002
|
||||
#define HWBP3_INST 0x00000004
|
||||
#define HWBP4_INST 0x00000008
|
||||
#define HWBP5_INST 0x00000010
|
||||
#define HWBP6_INST 0x00000020
|
||||
#define HWBP7_INST 0x00000040
|
||||
#define HWBP8_INST 0x00000080
|
||||
|
||||
//*****************************************************************************
|
||||
//
|
||||
// The following defines are used by the Counter APIs
|
||||
// ERAD_counterClearStatus and ERAD_counterGetStatus.
|
||||
//
|
||||
//*****************************************************************************
|
||||
#define CTM_EVENT_FIRED 0x1
|
||||
#define CTM_EVENT_OVERFLOW 0x2
|
||||
|
||||
//*****************************************************************************
|
||||
//
|
||||
// The following defines are used by the Enhanced bus comparator APIs
|
||||
// ERAD_HWBPClearStatus and ERAD_HWBPGetStatus.
|
||||
//
|
||||
//*****************************************************************************
|
||||
#define HWBP_EVENT_FIRED 0x1
|
||||
|
||||
//*****************************************************************************
|
||||
//
|
||||
//! Values passed onto counterConfig and and hwbpConfig structs
|
||||
//! to enable/disable the selected features.
|
||||
//
|
||||
//*****************************************************************************
|
||||
typedef enum {
|
||||
ENABLED=1,
|
||||
DISABLED=0
|
||||
}modeConfig;
|
||||
|
||||
//*****************************************************************************
|
||||
//
|
||||
//! Values passed onto ERAD_setGlobalOwner() or returned from ERAD_getGlobalOwner API
|
||||
//! These values are used to select the owner or return the owner
|
||||
//
|
||||
//*****************************************************************************
|
||||
typedef enum{
|
||||
NO_OWNER=0,
|
||||
APPLICATION=1,
|
||||
DEBUGGER=2
|
||||
}globalOwner;
|
||||
|
||||
//*****************************************************************************
|
||||
//
|
||||
//! Values passed onto counterConfig struct
|
||||
//! These values are used to select the event on which the counter will
|
||||
//! start,stop,reset,count.
|
||||
//
|
||||
//*****************************************************************************
|
||||
typedef enum {
|
||||
BUS_COMP1_EVENT=0,
|
||||
BUS_COMP2_EVENT=1,
|
||||
BUS_COMP3_EVENT=2,
|
||||
BUS_COMP4_EVENT=3,
|
||||
BUS_COMP5_EVENT=4,
|
||||
BUS_COMP6_EVENT=5,
|
||||
BUS_COMP7_EVENT=6,
|
||||
BUS_COMP8_EVENT=7,
|
||||
COUNTER1_EVENT=8,
|
||||
COUNTER2_EVENT=9,
|
||||
COUNTER3_EVENT=10,
|
||||
COUNTER4_EVENT=11,
|
||||
PIE_INT1=12,
|
||||
PIE_INT2=13,
|
||||
PIE_INT3=14,
|
||||
PIE_INT4=15,
|
||||
PIE_INT5=16,
|
||||
PIE_INT6=17,
|
||||
PIE_INT7=18,
|
||||
PIE_INT8=19,
|
||||
PIE_INT9=20,
|
||||
PIE_INT10=21,
|
||||
PIE_INT11=22,
|
||||
PIE_INT12=23,
|
||||
TIMER1_TINT1=24,
|
||||
TIMER2_TINT2=25,
|
||||
CLA_INTERRUPT1=26,
|
||||
CLA_INTERRUPT2=27,
|
||||
CLA_INTERRUPT3=28,
|
||||
CLA_INTERRUPT4=29,
|
||||
CLA_INTERRUPT5=30,
|
||||
CLA_INTERRUPT8=31
|
||||
}eventInputs;
|
||||
|
||||
//*****************************************************************************
|
||||
//
|
||||
//! Values passed onto hwbpConfig struct.
|
||||
//! These values are used to select which CPU buses will be used for
|
||||
//! comparison to generate the match events.
|
||||
//
|
||||
//*****************************************************************************
|
||||
typedef enum{
|
||||
PAB=0,
|
||||
DRAB=3,
|
||||
DWAB=2,
|
||||
VPC=1,
|
||||
DWDB=4
|
||||
}busSel;
|
||||
|
||||
//*****************************************************************************
|
||||
//
|
||||
//! Values passed onto hwbpConfig struct.
|
||||
//! These values are used to select the comparison Mode of the bus that is
|
||||
//! selected.
|
||||
//
|
||||
//*****************************************************************************
|
||||
typedef enum{
|
||||
GT=4,
|
||||
GE=5,
|
||||
LT=6,
|
||||
LE=7,
|
||||
EQ=0
|
||||
}compMode;
|
||||
|
||||
//*****************************************************************************
|
||||
//
|
||||
//! Values that can be passed onto counterConfig struct.
|
||||
//! These values are used to configure the counter to count on the edge
|
||||
//! or level event.
|
||||
//
|
||||
//*****************************************************************************
|
||||
typedef enum
|
||||
{
|
||||
LEVEL=0,
|
||||
EDGE=1
|
||||
}edgeLevel;
|
||||
|
||||
//*****************************************************************************
|
||||
//
|
||||
//! Data structure that can be passed onto ERAD_counterConfig API.
|
||||
//! The structure is used to configure the counter to count on
|
||||
//! the required event.
|
||||
//
|
||||
//*****************************************************************************
|
||||
typedef struct
|
||||
{
|
||||
modeConfig HW_CNT_RST;
|
||||
eventInputs RST_INP_SEL;
|
||||
modeConfig RTOSINT;
|
||||
modeConfig DBGEVT;
|
||||
modeConfig RST_ON_MATCH;
|
||||
edgeLevel EDGE_LEVEL_CFG;
|
||||
modeConfig START_STOP_MODE;
|
||||
eventInputs START_INP_SEL;
|
||||
eventInputs STOP_INP_SEL;
|
||||
modeConfig CNT_INP_SEL_EN;
|
||||
eventInputs CNT_INP_SEL;
|
||||
}counterConfig;
|
||||
|
||||
//*****************************************************************************
|
||||
//
|
||||
//! Data structure that can be passed onto ERAD_HWBPConfig API.
|
||||
//! The structure is used to configure the Enhanced Bus Comparator unit.
|
||||
//
|
||||
//*****************************************************************************
|
||||
typedef struct
|
||||
{
|
||||
busSel BUS_SEL;
|
||||
compMode COMP_MODE;
|
||||
Uint32 REF;
|
||||
Uint32 MASK;
|
||||
modeConfig RTOSINT;
|
||||
modeConfig DBGEVT;
|
||||
}hwbpConfig;
|
||||
|
||||
|
||||
//*****************************************************************************
|
||||
//
|
||||
// Prototypes for the APIs.
|
||||
//
|
||||
//*****************************************************************************
|
||||
|
||||
//*****************************************************************************
|
||||
//
|
||||
//! This function is used to enable the Counter unit(s).
|
||||
//!
|
||||
//! \param counterInstances is the counter instance to be enabled.
|
||||
//!
|
||||
//! The \e counterInstances parameter is the logical OR of any of the following:
|
||||
//! - \b CTM1_INST - Counter unit1
|
||||
//! - \b CTM2_INST - Counter unit2
|
||||
//! - \b CTM3_INST - Counter unit3
|
||||
//! - \b CTM4_INST - Counter unit4
|
||||
//!
|
||||
//! \return Returns \b true if the ERAD is owned by Application.Returns
|
||||
//! \b false if the ERAD is owned by Debugger.
|
||||
//
|
||||
//*****************************************************************************
|
||||
extern bool ERAD_setGlobalCTMEnable(Uint16 counterInstances);
|
||||
|
||||
//*****************************************************************************
|
||||
//
|
||||
//! This function is used to disable the Counter unit(s).
|
||||
//!
|
||||
//! \param counterInstances is the counter instance to be disabled.
|
||||
//!
|
||||
//! The \e counterInstances parameter is the logical OR of any of the following:
|
||||
//! - \b CTM1_INST - Counter unit1
|
||||
//! - \b CTM2_INST - Counter unit2
|
||||
//! - \b CTM3_INST - Counter unit3
|
||||
//! - \b CTM4_INST - Counter unit4
|
||||
//!
|
||||
//! \return Returns \b true if the ERAD is owned by Application.Returns
|
||||
//! \b false if the ERAD is owned by Debugger.
|
||||
//
|
||||
//*****************************************************************************
|
||||
extern bool ERAD_setGlobalCTMDisable(Uint16 counterInstances);
|
||||
|
||||
//*****************************************************************************
|
||||
//
|
||||
//! This function is used to reset the Counter unit(s).
|
||||
//!
|
||||
//! \param counterInstances is the counter instance to be reset.
|
||||
//!
|
||||
//! The \e counterInstances parameter is the logical OR of any of the following:
|
||||
//! - \b CTM1_INST - Counter unit1
|
||||
//! - \b CTM2_INST - Counter unit2
|
||||
//! - \b CTM3_INST - Counter unit3
|
||||
//! - \b CTM4_INST - Counter unit4
|
||||
//!
|
||||
//! \return None.
|
||||
//
|
||||
//*****************************************************************************
|
||||
extern void ERAD_setGlobalCTMReset(Uint16 counterInstances);
|
||||
|
||||
//*****************************************************************************
|
||||
//
|
||||
//! This function is used to read the Global Counter event stats.
|
||||
//!
|
||||
//! \param None.
|
||||
//!
|
||||
//! \return Returns
|
||||
//! -\b CTM1_INST if the event is fired from Counter1.
|
||||
//! -\b CTM2_INST if the event is fired from Counter2.
|
||||
//! -\b CTM3_INST if the event is fired from Counter3.
|
||||
//! -\b CTM4_INST if the event is fired from Counter4.
|
||||
//
|
||||
//*****************************************************************************
|
||||
extern Uint16 ERAD_getCTMEventStat();
|
||||
|
||||
//*****************************************************************************
|
||||
//
|
||||
//! This function is used to read the Global Counter halt stats.
|
||||
//!
|
||||
//! \param None.
|
||||
//!
|
||||
//! \return Returns
|
||||
//! -\b CTM1_INST if the count event of Counter1 is generated.
|
||||
//! -\b CTM2_INST if the count event of Counter2 is generated.
|
||||
//! -\b CTM3_INST if the count event of Counter3 is generated.
|
||||
//! -\b CTM4_INST if the count event of Counter4 is generated.
|
||||
//
|
||||
//*****************************************************************************
|
||||
extern Uint16 ERAD_getCTMHaltStat();
|
||||
|
||||
//*****************************************************************************
|
||||
//
|
||||
//! This function is used to enable the Enhanced Bus Comparator unit(s).
|
||||
//!
|
||||
//! \param hwbpInstances is the Enhanced Bus Comparator instance to be enabled.
|
||||
//!
|
||||
//! The \e hwbpInstances parameter is the logical OR of any of the following:
|
||||
//! - \b HWBP1_INST - Enhanced Bus Comparator unit1
|
||||
//! - \b HWBP2_INST - Enhanced Bus Comparator unit2
|
||||
//! - \b HWBP3_INST - Enhanced Bus Comparator unit3
|
||||
//! - \b HWBP4_INST - Enhanced Bus Comparator unit4
|
||||
//! - \b HWBP5_INST - Enhanced Bus Comparator unit5
|
||||
//! - \b HWBP6_INST - Enhanced Bus Comparator unit6
|
||||
//! - \b HWBP7_INST - Enhanced Bus Comparator unit7
|
||||
//! - \b HWBP8_INST - Enhanced Bus Comparator unit8
|
||||
//!
|
||||
//! \return Returns \b true if the ERAD is owned by Application.Returns
|
||||
//! \b false if the ERAD is owned by Debugger.
|
||||
//
|
||||
//*****************************************************************************
|
||||
extern bool ERAD_globalHWBPEnable(Uint16 hwbpInstances);
|
||||
|
||||
//*****************************************************************************
|
||||
//
|
||||
//! This function is used to disable the Enhanced Bus Comparator unit(s).
|
||||
//!
|
||||
//! \param hwbpInstances is the Enhanced Bus Comparator instance to be disabled.
|
||||
//!
|
||||
//! The \e hwbpInstances parameter is the logical OR of any of the following:
|
||||
//! - \b HWBP1_INST - Enhanced Bus Comparator unit1
|
||||
//! - \b HWBP2_INST - Enhanced Bus Comparator unit2
|
||||
//! - \b HWBP3_INST - Enhanced Bus Comparator unit3
|
||||
//! - \b HWBP4_INST - Enhanced Bus Comparator unit4
|
||||
//! - \b HWBP5_INST - Enhanced Bus Comparator unit5
|
||||
//! - \b HWBP6_INST - Enhanced Bus Comparator unit6
|
||||
//! - \b HWBP7_INST - Enhanced Bus Comparator unit7
|
||||
//! - \b HWBP8_INST - Enhanced Bus Comparator unit8
|
||||
//!
|
||||
//! \return Returns \b true if the ERAD is owned by Application.Returns
|
||||
//! \b false if the ERAD is owned by Debugger.
|
||||
//
|
||||
//*****************************************************************************
|
||||
extern bool ERAD_globalHWBPDisable(Uint16 hwbpInstances);
|
||||
|
||||
//*****************************************************************************
|
||||
//
|
||||
//! This function is used to read the Global Enhanced Bus Comparator event stats.
|
||||
//!
|
||||
//! \param None.
|
||||
//!
|
||||
//! \return Returns
|
||||
//! -\b HWBP1_INST if the event is fired from Enhanced Bus Comparator unit1.
|
||||
//! -\b HWBP2_INST if the event is fired from Enhanced Bus Comparator unit2.
|
||||
//! -\b HWBP3_INST if the event is fired from Enhanced Bus Comparator unit3.
|
||||
//! -\b HWBP4_INST if the event is fired from Enhanced Bus Comparator unit4.
|
||||
//! -\b HWBP5_INST if the event is fired from Enhanced Bus Comparator unit5.
|
||||
//! -\b HWBP6_INST if the event is fired from Enhanced Bus Comparator unit6.
|
||||
//! -\b HWBP7_INST if the event is fired from Enhanced Bus Comparator unit7.
|
||||
//! -\b HWBP8_INST if the event is fired from Enhanced Bus Comparator unit8.
|
||||
//
|
||||
//*****************************************************************************
|
||||
extern Uint16 ERAD_getHWBPEventStat();
|
||||
|
||||
//*****************************************************************************
|
||||
//
|
||||
//! This function is used to read the Global Enhanced Bus Comparator halt stats.
|
||||
//!
|
||||
//! \param None.
|
||||
//!
|
||||
//! \return Returns
|
||||
//! -\b HWBP1_INST if the Enhanced Bus Comparator unit1 is completed.
|
||||
//! -\b HWBP2_INST if the Enhanced Bus Comparator unit2 is completed.
|
||||
//! -\b HWBP3_INST if the Enhanced Bus Comparator unit3 is completed.
|
||||
//! -\b HWBP4_INST if the Enhanced Bus Comparator unit4 is completed.
|
||||
//! -\b HWBP5_INST if the Enhanced Bus Comparator unit5 is completed.
|
||||
//! -\b HWBP6_INST if the Enhanced Bus Comparator unit6 is completed.
|
||||
//! -\b HWBP7_INST if the Enhanced Bus Comparator unit7 is completed.
|
||||
//! -\b HWBP8_INST if the Enhanced Bus Comparator unit8 is completed.
|
||||
//
|
||||
//*****************************************************************************
|
||||
extern Uint16 ERAD_getHWBPHaltStat();
|
||||
|
||||
//*****************************************************************************
|
||||
//
|
||||
//! This function is used to set the reference match count for the counter to
|
||||
//! a predetermined value.
|
||||
//!
|
||||
//! \param counterInstances is the counter instance.
|
||||
//! \param referenceCount is the counter reference for comparison
|
||||
//!
|
||||
//! The \e counterInstances parameter is one of the following:
|
||||
//! - \b CTM1_INST - Counter unit1
|
||||
//! - \b CTM2_INST - Counter unit2
|
||||
//! - \b CTM3_INST - Counter unit3
|
||||
//! - \b CTM4_INST - Counter unit4
|
||||
//!
|
||||
//! \return None.
|
||||
//
|
||||
//*****************************************************************************
|
||||
extern void ERAD_counterSetRef(Uint16 counterInstance,Uint32 referenceCount);
|
||||
|
||||
//*****************************************************************************
|
||||
//
|
||||
//! This function is used to set the current count for the counter to
|
||||
//! a predetermined value.
|
||||
//!
|
||||
//! \param counterInstances is the counter instance.
|
||||
//! \param currentCount is the current counter value to be set.
|
||||
//!
|
||||
//! The \e counterInstances parameter is one of the following:
|
||||
//! - \b CTM1_INST - Counter unit1
|
||||
//! - \b CTM2_INST - Counter unit2
|
||||
//! - \b CTM3_INST - Counter unit3
|
||||
//! - \b CTM4_INST - Counter unit4
|
||||
//!
|
||||
//! \return None.
|
||||
//
|
||||
//*****************************************************************************
|
||||
extern void ERAD_counterSetCurCount(Uint16 counterInstance,Uint32 currentCount);
|
||||
|
||||
//*****************************************************************************
|
||||
//
|
||||
//! This function is used to set the maximum count for the counter to
|
||||
//! a predetermined value.
|
||||
//!
|
||||
//! \param counterInstances is the counter instance.
|
||||
//! \param maxCount is the maximum counter value to be set.
|
||||
//!
|
||||
//! The \e counterInstances parameter is one of the following:
|
||||
//! - \b CTM1_INST - Counter unit1
|
||||
//! - \b CTM2_INST - Counter unit2
|
||||
//! - \b CTM3_INST - Counter unit3
|
||||
//! - \b CTM4_INST - Counter unit4
|
||||
//!
|
||||
//! \return None.
|
||||
//
|
||||
//*****************************************************************************
|
||||
extern void ERAD_counterSetMaxCount(Uint16 counterInstance,Uint32 maxCount);
|
||||
|
||||
//*****************************************************************************
|
||||
//
|
||||
//! This function is used to get the current count of the counter.
|
||||
//!
|
||||
//! \param counterInstances is the counter instance.
|
||||
//!
|
||||
//! The \e counterInstances parameter is one of the following:
|
||||
//! - \b CTM1_INST - Counter unit1
|
||||
//! - \b CTM2_INST - Counter unit2
|
||||
//! - \b CTM3_INST - Counter unit3
|
||||
//! - \b CTM4_INST - Counter unit4
|
||||
//!
|
||||
//! \return Returns the current counter value.
|
||||
//
|
||||
//*****************************************************************************
|
||||
extern Uint32 ERAD_counterGetCurCount(Uint16 counterInstance);
|
||||
|
||||
//*****************************************************************************
|
||||
//
|
||||
//! This function is used to get the maximum count of the counter.
|
||||
//!
|
||||
//! \param counterInstances is the counter instance.
|
||||
//!
|
||||
//! The \e counterInstances parameter is one of the following:
|
||||
//! - \b CTM1_INST - Counter unit1
|
||||
//! - \b CTM2_INST - Counter unit2
|
||||
//! - \b CTM3_INST - Counter unit3
|
||||
//! - \b CTM4_INST - Counter unit4
|
||||
//!
|
||||
//! \return Returns the Max count value.
|
||||
//
|
||||
//*****************************************************************************
|
||||
extern Uint32 ERAD_counterGetMaxCount(Uint16 counterInstance);
|
||||
|
||||
//*****************************************************************************
|
||||
//
|
||||
//! This function is used to get the current status for the counter.
|
||||
//!
|
||||
//! \param counterInstances is the counter instance.
|
||||
//!
|
||||
//! The \e counterInstances parameter is one of the following:
|
||||
//! - \b CTM1_INST - Counter unit1
|
||||
//! - \b CTM2_INST - Counter unit2
|
||||
//! - \b CTM3_INST - Counter unit3
|
||||
//! - \b CTM4_INST - Counter unit4
|
||||
//!
|
||||
//! \return Returns
|
||||
//! -\b CTM_EVENT_FIRED if the event is fired.
|
||||
//! -\b CTM_EVENT_OVERFLOW if the counter has overflown.
|
||||
//
|
||||
//*****************************************************************************
|
||||
extern Uint16 ERAD_counterGetStatus(Uint16 counterInstance);
|
||||
|
||||
//*****************************************************************************
|
||||
//
|
||||
//! This function is used to clear the current status for the counter.
|
||||
//!
|
||||
//! \param counterInstances is the counter instance.
|
||||
//! \param clearFlags is the flag to be cleared
|
||||
//!
|
||||
//! The \e counterInstances parameter is one of the following:
|
||||
//! - \b CTM1_INST - Counter unit1
|
||||
//! - \b CTM2_INST - Counter unit2
|
||||
//! - \b CTM3_INST - Counter unit3
|
||||
//! - \b CTM4_INST - Counter unit4
|
||||
//!
|
||||
//! The \e clearFlags parameter is the one of the following:
|
||||
//! - \b CTM_EVENT_FIRED - To clear the event fired status
|
||||
//! - \b CTM_EVENT_OVERFLOW - To clear the event overflow status
|
||||
//!
|
||||
//! \return None.
|
||||
//
|
||||
//*****************************************************************************
|
||||
extern void ERAD_counterClearStatus(Uint16 counterInstance,Uint16 clearFlags);
|
||||
|
||||
//*****************************************************************************
|
||||
//
|
||||
//! This function is used to configure the counter to count on certain event.
|
||||
//!
|
||||
//! \param counterInstances is the counter instance.
|
||||
//! \param counterCfg is the data struture that is used to configure
|
||||
//! the counter to count on
|
||||
//!
|
||||
//! The \e counterInstances parameter is one of the following:
|
||||
//! - \b CTM1_INST - Counter unit1
|
||||
//! - \b CTM2_INST - Counter unit2
|
||||
//! - \b CTM3_INST - Counter unit3
|
||||
//! - \b CTM4_INST - Counter unit4
|
||||
//!
|
||||
//! \return None.
|
||||
//
|
||||
//*****************************************************************************
|
||||
extern void ERAD_counterConfig(Uint16 counterInstance,counterConfig counterCfg);
|
||||
|
||||
//*****************************************************************************
|
||||
//
|
||||
//! This function is used to get the current status for the Enhanced Bus Comparator unit.
|
||||
//!
|
||||
//! \param hwbpInstance is the Enhanced Bus Comparator instance.
|
||||
//!
|
||||
//! The \e hwbpInstance parameter is one of the following:
|
||||
//! - \b HWBP1_INST - Enhanced Bus Comparator unit1
|
||||
//! - \b HWBP2_INST - Enhanced Bus Comparator unit2
|
||||
//! - \b HWBP3_INST - Enhanced Bus Comparator unit3
|
||||
//! - \b HWBP4_INST - Enhanced Bus Comparator unit4
|
||||
//! - \b HWBP5_INST - Enhanced Bus Comparator unit5
|
||||
//! - \b HWBP6_INST - Enhanced Bus Comparator unit6
|
||||
//! - \b HWBP7_INST - Enhanced Bus Comparator unit7
|
||||
//! - \b HWBP8_INST - Enhanced Bus Comparator unit8
|
||||
//!
|
||||
//! \return Returns
|
||||
//! -\b HWBP_EVENT_FIRED if the event is fired.
|
||||
//
|
||||
//*****************************************************************************
|
||||
extern Uint16 ERAD_HWBPGetStatus(Uint16 hwbpInstance);
|
||||
|
||||
//*****************************************************************************
|
||||
//
|
||||
//! This function is used to clear the status for the Enhanced Bus Comparator unit.
|
||||
//!
|
||||
//! \param hwbpInstance is the Enhanced Bus Comparator instance.
|
||||
//! \param clearFlags is the flag to be cleared
|
||||
//!
|
||||
//! The \e hwbpInstance parameter is one of the following:
|
||||
//! - \b HWBP1_INST - Enhanced Bus Comparator unit1
|
||||
//! - \b HWBP2_INST - Enhanced Bus Comparator unit2
|
||||
//! - \b HWBP3_INST - Enhanced Bus Comparator unit3
|
||||
//! - \b HWBP4_INST - Enhanced Bus Comparator unit4
|
||||
//! - \b HWBP5_INST - Enhanced Bus Comparator unit5
|
||||
//! - \b HWBP6_INST - Enhanced Bus Comparator unit6
|
||||
//! - \b HWBP7_INST - Enhanced Bus Comparator unit7
|
||||
//! - \b HWBP8_INST - Enhanced Bus Comparator unit8
|
||||
//!
|
||||
//! The \e clearFlags parameter is the one of the following:
|
||||
//! -\b HWBP_EVENT_FIRED - To clear the event fired status.
|
||||
//!
|
||||
//! \return None.
|
||||
//
|
||||
//*****************************************************************************
|
||||
extern void ERAD_HWBPClearStatus(Uint16 hwbpInstance,Uint16 clearFlags);
|
||||
|
||||
//*****************************************************************************
|
||||
//
|
||||
//! This function is used to configure the Enhanced Bus Comparator unit.
|
||||
//!
|
||||
//! \param hwbpInstance is the Enhanced Bus Comparator unit instance.
|
||||
//! \param hwbpCfg is the data struture that is used to configure
|
||||
//! the Enhanced Bus Comparator unit.
|
||||
//!
|
||||
//! The \e hwbpInstance parameter is one of the following:
|
||||
//! - \b HWBP1_INST - Enhanced Bus Comparator unit1
|
||||
//! - \b HWBP2_INST - Enhanced Bus Comparator unit2
|
||||
//! - \b HWBP3_INST - Enhanced Bus Comparator unit3
|
||||
//! - \b HWBP4_INST - Enhanced Bus Comparator unit4
|
||||
//! - \b HWBP5_INST - Enhanced Bus Comparator unit5
|
||||
//! - \b HWBP6_INST - Enhanced Bus Comparator unit6
|
||||
//! - \b HWBP7_INST - Enhanced Bus Comparator unit7
|
||||
//! - \b HWBP8_INST - Enhanced Bus Comparator unit8
|
||||
//!
|
||||
//! \return None.
|
||||
//
|
||||
//*****************************************************************************
|
||||
extern void ERAD_HWBPConfig(Uint16 hwbpInstance,hwbpConfig hwbpCfg);
|
||||
|
||||
//*****************************************************************************
|
||||
//
|
||||
// Close the Doxygen group.
|
||||
//! @}
|
||||
//
|
||||
//*****************************************************************************
|
||||
|
||||
//*****************************************************************************
|
||||
//
|
||||
// Mark the end of the C bindings section for C++ compilers.
|
||||
//
|
||||
//*****************************************************************************
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
||||
#endif // - end of F28004x_DCL_ERAD_DEFINES_H
|
||||
@@ -0,0 +1,92 @@
|
||||
;;#############################################################################
|
||||
;;
|
||||
;; FILE: f28004x_usdelay.asm
|
||||
;;
|
||||
;; TITLE: Simple Delay Function
|
||||
;;
|
||||
;; DESCRIPTION:
|
||||
;;
|
||||
;; This is a simple delay function that can be used to insert a specified
|
||||
;; delay into code.
|
||||
;; This function is only accurate if executed from internal zero-waitstate
|
||||
;; SARAM. If it is executed from waitstate memory then the delay will be
|
||||
;; longer then specified.
|
||||
;; To use this function:
|
||||
;; 1 - update the CPU clock speed in the f28004x_examples.h
|
||||
;; file.
|
||||
;; 2 - Call this function by using the DELAY_US(A) macro
|
||||
;; that is defined in the f28004x_device.h file. This macro
|
||||
;; will convert the number of microseconds specified
|
||||
;; into a loop count for use with this function.
|
||||
;; This count will be based on the CPU frequency you specify.
|
||||
;; 3 - For the most accurate delay
|
||||
;; - Execute this function in 0 waitstate RAM.
|
||||
;; - Disable interrupts before calling the function
|
||||
;; If you do not disable interrupts, then think of
|
||||
;; this as an "at least" delay function as the actual
|
||||
;; delay may be longer.
|
||||
;; The C assembly call from the DELAY_US(time) macro will
|
||||
;; look as follows:
|
||||
;; extern void Delay(long LoopCount);
|
||||
;; MOV AL,#LowLoopCount
|
||||
;; MOV AH,#HighLoopCount
|
||||
;; LCR _Delay
|
||||
;; Or as follows (if count is less then 16-bits):
|
||||
;; MOV ACC,#LoopCount
|
||||
;; LCR _Delay
|
||||
;;#############################################################################
|
||||
;; $TI Release: F28004x Support Library v1.03.00.00 $
|
||||
;; $Release Date: Thu Dec 7 18:46:47 CST 2017 $
|
||||
;; $Copyright:
|
||||
;// Copyright (C) 2017 Texas Instruments Incorporated - http://www.ti.com/
|
||||
;//
|
||||
;// Redistribution and use in source and binary forms, with or without
|
||||
;// modification, are permitted provided that the following conditions
|
||||
;// are met:
|
||||
;//
|
||||
;// Redistributions of source code must retain the above copyright
|
||||
;// notice, this list of conditions and the following disclaimer.
|
||||
;//
|
||||
;// Redistributions in binary form must reproduce the above copyright
|
||||
;// notice, this list of conditions and the following disclaimer in the
|
||||
;// documentation and/or other materials provided with the
|
||||
;// distribution.
|
||||
;//
|
||||
;// Neither the name of Texas Instruments Incorporated nor the names of
|
||||
;// its contributors may be used to endorse or promote products derived
|
||||
;// from this software without specific prior written permission.
|
||||
;//
|
||||
;// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
|
||||
;// "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
|
||||
;// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
|
||||
;// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
|
||||
;// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
|
||||
;// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
|
||||
;// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
|
||||
;// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
|
||||
;// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
||||
;// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
|
||||
;// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
;// $
|
||||
;;#############################################################################
|
||||
|
||||
.def _F28x_usDelayErad
|
||||
.sect "interruptSection"
|
||||
|
||||
.global __F28x_usDelayErad
|
||||
_F28x_usDelayErad:
|
||||
SUB ACC,#1
|
||||
BF _F28x_usDelayErad,GEQ ;; Loop if ACC >= 0
|
||||
LRETR
|
||||
|
||||
;There is a 9/10 cycle overhead and each loop
|
||||
;takes five cycles. The LoopCount is given by
|
||||
;the following formula:
|
||||
; DELAY_CPU_CYCLES = 9 + 5*LoopCount
|
||||
; LoopCount = (DELAY_CPU_CYCLES - 9) / 5
|
||||
; The macro DELAY_US(A) performs this calculation for you
|
||||
|
||||
;;#############################################################################
|
||||
;; End of file
|
||||
;;#############################################################################
|
||||
|
||||
@@ -0,0 +1,31 @@
|
||||
<projectSpec>
|
||||
<project
|
||||
name="F28069_DF22"
|
||||
device="TMS320F28069"
|
||||
configurations="DEBUG"
|
||||
launchWizard="False"
|
||||
linkerCommandFile=""
|
||||
compilerBuildOptions="--opt_level=off -I${C2000WARE_F2806X_ROOT1} -I${C2000WARE_F2806X_ROOT2} -I${C2000WARE_DCL_INCLUDE_ROOT} -v28 -ml -mt --float_support=fpu32 --define=DEBUG --diag_warning=225 --diag_suppress=10063 --display_error_number"
|
||||
linkerBuildOptions="--stack_size=0x400 --heap_size=0x200 --define RAM"
|
||||
>
|
||||
<pathVariable name="C2000WARE_F2806X_ROOT1" path="../../../../../../../device_support/f2806x/headers/include" scope="project" />
|
||||
<pathVariable name="C2000WARE_F2806X_ROOT2" path="../../../../../../../device_support/f2806x/common/include" scope="project" />
|
||||
<pathVariable name="C2000WARE_DCL_INCLUDE_ROOT" path="../../../include" scope="project" />
|
||||
<file action="copy" path="../../../../../../../device_support/f2806x/common/source/F2806x_CpuTimers.c" targetDirectory="" />
|
||||
<file action="copy" path="../../../../../../../device_support/f2806x/common/source/F2806x_DefaultIsr.c" targetDirectory="" />
|
||||
<file action="copy" path="../../../../../../../device_support/f2806x/headers/source/F2806x_GlobalVariableDefs.c" targetDirectory="" />
|
||||
<file action="copy" path="../../../../../../../device_support/f2806x/common/source/F2806x_PieCtrl.c" targetDirectory="" />
|
||||
<file action="copy" path="../../../../../../../device_support/f2806x/common/source/F2806x_PieVect.c" targetDirectory="" />
|
||||
<file action="copy" path="../../../../../../../device_support/f2806x/common/source/F2806x_SysCtrl.c" targetDirectory="" />
|
||||
<file action="copy" path="../../../../../../../device_support/f2806x/common/source/F2806x_DisInt.asm" targetDirectory="" />
|
||||
<file action="copy" path="../../../../../../../device_support/f2806x/common/source/F2806x_usDelay.asm" targetDirectory="" />
|
||||
<file action="copy" path="../../../../../../../device_support/f2806x/headers/cmd/F2806x_Headers_nonBIOS.cmd" targetDirectory="" />
|
||||
<file action="copy" path="../../../cmd/F28069_stdmem.cmd" targetDirectory="" />
|
||||
<file action="copy" path="../../../cmd/F28069_DCL.cmd" targetDirectory="" />
|
||||
<file action="copy" path="../../../source/DCL_clamp_C1.asm" targetDirectory="" />
|
||||
<file action="copy" path="../../../source/DCL_DF22_C1.asm" targetDirectory="" />
|
||||
<file action="copy" path="../../../source/DCL_DF22_C2C3.asm" targetDirectory="" />
|
||||
<file action="copy" path="../Example_F28069_DF22.c" targetDirectory="" />
|
||||
<file action="copy" path="../DF22_edata.dat" targetDirectory="" />
|
||||
</project>
|
||||
</projectSpec>
|
||||
File diff suppressed because it is too large.
Load diff
@@ -0,0 +1,154 @@
|
||||
/* Example_F28069_DF22.c
|
||||
*
|
||||
* Copyright (C) 2020 Texas Instruments Incorporated - http://www.ti.com/
|
||||
* ALL RIGHTS RESERVED
|
||||
*
|
||||
*/
|
||||
|
||||
#include "F2806x_Device.h"
|
||||
#include "F2806x_Examples.h"
|
||||
#include "F2806x_GlobalPrototypes.h"
|
||||
#include "DCLF32.h"
|
||||
#include "DCL_fdlog.h"
|
||||
|
||||
#define DATA_LENGTH 1601
|
||||
|
||||
// input data
|
||||
#pragma DATA_SECTION(e_array, "PDataLogSection")
|
||||
float e_array[DATA_LENGTH];
|
||||
FDLOG eBuf = FDLOG_DEFAULTS;
|
||||
|
||||
// full controller results
|
||||
#pragma DATA_SECTION(u1_array, "QDataLogSection")
|
||||
float u1_array[DATA_LENGTH];
|
||||
FDLOG u1Buf = FDLOG_DEFAULTS;
|
||||
|
||||
// pre-computed controller results
|
||||
#pragma DATA_SECTION(u2_array, "RDataLogSection")
|
||||
float u2_array[DATA_LENGTH];
|
||||
FDLOG u2Buf = FDLOG_DEFAULTS;
|
||||
|
||||
// controller difference data
|
||||
#pragma DATA_SECTION(d_array, "SDataLogSection")
|
||||
float d_array[DATA_LENGTH];
|
||||
FDLOG dBuf = FDLOG_DEFAULTS;
|
||||
|
||||
extern interrupt void control_Isr(void);
|
||||
|
||||
// global variables
|
||||
long IdleLoopCount = 0;
|
||||
long IsrCount = 0;
|
||||
float ek;
|
||||
float u1k;
|
||||
float u2k;
|
||||
float dk;
|
||||
float upperLim;
|
||||
float lowerLim;
|
||||
uint16_t v;
|
||||
DCL_DF22 controller1 = DF22_DEFAULTS;
|
||||
DCL_DF22 controller2 = DF22_DEFAULTS;
|
||||
|
||||
|
||||
/* main */
|
||||
main()
|
||||
{
|
||||
// initialise system
|
||||
InitSysCtrl();
|
||||
DINT;
|
||||
IER = 0x0000;
|
||||
IFR = 0x0000;
|
||||
InitPieCtrl();
|
||||
InitPieVectTable();
|
||||
EALLOW;
|
||||
PieVectTable.TINT0 = &control_Isr;
|
||||
EDIS;
|
||||
|
||||
// configure CPU timer 0
|
||||
InitCpuTimers();
|
||||
ConfigCpuTimer(&CpuTimer0, 90.0, 1.0e+03);
|
||||
|
||||
// initialise data arrays
|
||||
DCL_initLog(&eBuf, e_array, DATA_LENGTH);
|
||||
DCL_initLog(&u1Buf, u1_array, DATA_LENGTH);
|
||||
DCL_initLog(&u2Buf, u2_array, DATA_LENGTH);
|
||||
DCL_initLog(&dBuf, d_array, DATA_LENGTH);
|
||||
DCL_clearLog(&u1Buf);
|
||||
DCL_clearLog(&u2Buf);
|
||||
DCL_fillLog(&dBuf, 1.234567f);
|
||||
|
||||
// initialise full controller
|
||||
controller1.a1 = -1.9417f;
|
||||
controller1.a2 = 0.9417f;
|
||||
controller1.b0 = 9.8549f;
|
||||
controller1.b1 = -19.4165f;
|
||||
controller1.b2 = 9.5636f;
|
||||
|
||||
// initialise pre-computed controller
|
||||
controller2.a1 = controller1.a1;
|
||||
controller2.a2 = controller1.a2;
|
||||
controller2.b0 = controller1.b0;
|
||||
controller2.b1 = controller1.b1;
|
||||
controller2.b2 = controller1.b2;
|
||||
|
||||
// clamp limits
|
||||
upperLim = 1000.0f;
|
||||
lowerLim = -1000.0f;
|
||||
|
||||
// enable interrupts
|
||||
PieCtrlRegs.PIEIER1.bit.INTx7 = 1;
|
||||
IER |= M_INT1;
|
||||
EINT;
|
||||
StartCpuTimer0();
|
||||
|
||||
// idle loop
|
||||
while(1)
|
||||
{
|
||||
IdleLoopCount++;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
||||
/* control ISR: triggered by CPU timer 0 */
|
||||
interrupt void control_Isr(void)
|
||||
{
|
||||
// clear timer flag & acknowledge interrupt
|
||||
CpuTimer0Regs.TCR.bit.TIF = 1;
|
||||
PieCtrlRegs.PIEACK.all = PIEACK_GROUP1;
|
||||
|
||||
// read data & run controllers
|
||||
if (eBuf.dptr < eBuf.lptr)
|
||||
{
|
||||
// read input data
|
||||
ek = DCL_readLog(&eBuf);
|
||||
|
||||
// run full controller
|
||||
u1k = DCL_runDF22_C1(&controller1, ek);
|
||||
|
||||
// run pre-computed controller
|
||||
u2k = DCL_runDF22_C2(&controller2, ek);
|
||||
v = DCL_runClamp_C1(&u2k, upperLim, lowerLim);
|
||||
if (0U == v)
|
||||
{
|
||||
DCL_runDF22_C3(&controller2, ek, u2k);
|
||||
}
|
||||
|
||||
// compute difference
|
||||
dk = u1k - u2k;
|
||||
|
||||
// store results
|
||||
DCL_writeLog(&u1Buf, u1k);
|
||||
DCL_writeLog(&u2Buf, u2k);
|
||||
DCL_writeLog(&dBuf, dk);
|
||||
}
|
||||
else
|
||||
{
|
||||
// place break-point here
|
||||
asm(" NOP");
|
||||
}
|
||||
|
||||
IsrCount++;
|
||||
}
|
||||
|
||||
|
||||
/* end of file */
|
||||
+33
@@ -0,0 +1,33 @@
|
||||
<projectSpec>
|
||||
<project
|
||||
name="F28069_DF23"
|
||||
device="TMS320F28069"
|
||||
configurations="DEBUG"
|
||||
launchWizard="False"
|
||||
linkerCommandFile=""
|
||||
compilerBuildOptions="--opt_level=off -I${C2000WARE_F2806X_ROOT1} -I${C2000WARE_F2806X_ROOT2} -I${C2000WARE_DCL_INCLUDE_ROOT} -I${PROJECT_INCLUDE_ROOT} -v28 -ml -mt --float_support=fpu32 --define=DEBUG --diag_warning=225 --diag_suppress=10063,303 --display_error_number"
|
||||
linkerBuildOptions="--stack_size=0x400 --heap_size=0x200 --define RAM"
|
||||
>
|
||||
<pathVariable name="C2000WARE_F2806X_ROOT1" path="../../../../../../../device_support/f2806x/headers/include" scope="project" />
|
||||
<pathVariable name="C2000WARE_F2806X_ROOT2" path="../../../../../../../device_support/f2806x/common/include" scope="project" />
|
||||
<pathVariable name="C2000WARE_DCL_INCLUDE_ROOT" path="../../../include" scope="project" />
|
||||
<pathVariable name="PROJECT_INCLUDE_ROOT" path="../" scope="project" />
|
||||
<file action="copy" path="../../../../../../../device_support/f2806x/common/source/F2806x_CpuTimers.c" targetDirectory="" />
|
||||
<file action="copy" path="../../../../../../../device_support/f2806x/common/source/F2806x_DefaultIsr.c" targetDirectory="" />
|
||||
<file action="copy" path="../../../../../../../device_support/f2806x/headers/source/F2806x_GlobalVariableDefs.c" targetDirectory="" />
|
||||
<file action="copy" path="../../../../../../../device_support/f2806x/common/source/F2806x_PieCtrl.c" targetDirectory="" />
|
||||
<file action="copy" path="../../../../../../../device_support/f2806x/common/source/F2806x_PieVect.c" targetDirectory="" />
|
||||
<file action="copy" path="../../../../../../../device_support/f2806x/common/source/F2806x_SysCtrl.c" targetDirectory="" />
|
||||
<file action="copy" path="../../../../../../../device_support/f2806x/common/source/F2806x_DisInt.asm" targetDirectory="" />
|
||||
<file action="copy" path="../../../../../../../device_support/f2806x/common/source/F2806x_usDelay.asm" targetDirectory="" />
|
||||
<file action="copy" path="../../../../../../../device_support/f2806x/headers/cmd/F2806x_Headers_nonBIOS.cmd" targetDirectory="" />
|
||||
<file action="copy" path="../../../cmd/F28069_stdmem.cmd" targetDirectory="" />
|
||||
<file action="copy" path="../../../cmd/F28069_DCL.cmd" targetDirectory="" />
|
||||
<file action="copy" path="../../../source/DCL_clamp_L1.asm" targetDirectory="" />
|
||||
<file action="copy" path="../../../source/DCL_DF23_L1.asm" targetDirectory="" />
|
||||
<file action="copy" path="../../../source/DCL_DF23_L2L3.asm" targetDirectory="" />
|
||||
<file action="copy" path="../Example_F28069_DF23.c" targetDirectory="" />
|
||||
<file action="copy" path="../F28069_DF23_CLA.cla" targetDirectory="" />
|
||||
<file action="copy" path="../DF23_edata.dat" targetDirectory="" />
|
||||
</project>
|
||||
</projectSpec>
|
||||
@@ -0,0 +1,47 @@
|
||||
/* CLA_shared.h */
|
||||
|
||||
#ifndef _C_CLA_SHARED_H
|
||||
#define _C_CLA_SHARED_H
|
||||
|
||||
#include "DCLCLA.h"
|
||||
#include "F2806x_Cla_typedefs.h"
|
||||
|
||||
#define CLA_PROG_ENABLE 0x0001
|
||||
#define CLARAM0_ENABLE 0x0010
|
||||
#define CLARAM1_ENABLE 0x0020
|
||||
#define CLARAM2_ENABLE 0x0040
|
||||
#define CLA_RAM0CPUE 0x0100
|
||||
#define CLA_RAM1CPUE 0x0200
|
||||
#define CLA_RAM2CPUE 0x0400
|
||||
|
||||
/* shared CLA vars */
|
||||
extern float ek;
|
||||
extern float u1k;
|
||||
extern float u2k;
|
||||
|
||||
// CLA memory address symbols
|
||||
extern Uint16 Cla1funcsLoadStart;
|
||||
extern Uint16 Cla1funcsLoadEnd;
|
||||
extern Uint16 Cla1funcsLoadSize;
|
||||
extern Uint16 Cla1funcsRunStart;
|
||||
extern Uint16 Cla1Prog_Start;
|
||||
|
||||
// CLA math table symbols
|
||||
extern Uint16 Cla1mathTablesLoadStart;
|
||||
extern Uint16 Cla1mathTablesLoadEnd;
|
||||
extern Uint16 Cla1mathTablesLoadSize;
|
||||
extern Uint16 Cla1mathTablesRunStart;
|
||||
|
||||
// CLA C Tasks
|
||||
__interrupt void Cla1Task1();
|
||||
__interrupt void Cla1Task2();
|
||||
__interrupt void Cla1Task3();
|
||||
__interrupt void Cla1Task4();
|
||||
__interrupt void Cla1Task5();
|
||||
__interrupt void Cla1Task6();
|
||||
__interrupt void Cla1Task7();
|
||||
__interrupt void Cla1Task8();
|
||||
|
||||
#endif // _C_CLA_SHARED_H
|
||||
|
||||
/* end of file */
|
||||
File diff suppressed because it is too large.
Load diff
@@ -0,0 +1,171 @@
|
||||
/* Example_F28069_DF23.c
|
||||
*
|
||||
* Copyright (C) 2020 Texas Instruments Incorporated - http://www.ti.com/
|
||||
* ALL RIGHTS RESERVED
|
||||
*
|
||||
*/
|
||||
|
||||
// header files
|
||||
#include "F2806x_Device.h"
|
||||
#include "F2806x_Examples.h"
|
||||
#include "F2806x_GlobalPrototypes.h"
|
||||
#include "DCLCLA.h"
|
||||
#include "DCL_fdlog.h"
|
||||
#include "CLA_shared.h"
|
||||
|
||||
#define DATA_LENGTH 1601
|
||||
|
||||
// input data
|
||||
#pragma DATA_SECTION(e_array, "PDataLogSection")
|
||||
float e_array[DATA_LENGTH];
|
||||
FDLOG eBuf = FDLOG_DEFAULTS;
|
||||
|
||||
// full controller results
|
||||
#pragma DATA_SECTION(u1_array, "QDataLogSection")
|
||||
float u1_array[DATA_LENGTH];
|
||||
FDLOG u1Buf = FDLOG_DEFAULTS;
|
||||
|
||||
// pre-computed controller results
|
||||
#pragma DATA_SECTION(u2_array, "RDataLogSection")
|
||||
float u2_array[DATA_LENGTH];
|
||||
FDLOG u2Buf = FDLOG_DEFAULTS;
|
||||
|
||||
// controller difference data
|
||||
#pragma DATA_SECTION(d_array, "SDataLogSection")
|
||||
float d_array[DATA_LENGTH];
|
||||
FDLOG dBuf = FDLOG_DEFAULTS;
|
||||
|
||||
// function prototypes
|
||||
interrupt void control_Isr(void);
|
||||
|
||||
// shared variables
|
||||
#pragma DATA_SECTION(ek, "CpuToCla1MsgRAM")
|
||||
#pragma DATA_SECTION(u1k, "Cla1ToCpuMsgRAM")
|
||||
#pragma DATA_SECTION(u2k, "Cla1ToCpuMsgRAM")
|
||||
float ek;
|
||||
float u1k;
|
||||
float u2k;
|
||||
|
||||
// global variables
|
||||
long IdleLoopCount = 0;
|
||||
long IsrCount = 0;
|
||||
float dk;
|
||||
|
||||
|
||||
main()
|
||||
{
|
||||
// initialise system
|
||||
InitSysCtrl();
|
||||
DINT;
|
||||
IER = 0x0000;
|
||||
IFR = 0x0000;
|
||||
InitPieCtrl();
|
||||
InitPieVectTable();
|
||||
EALLOW;
|
||||
PieVectTable.TINT0 = &control_Isr;
|
||||
EDIS;
|
||||
|
||||
// configure CPU timer 0
|
||||
InitCpuTimers();
|
||||
ConfigCpuTimer(&CpuTimer0, 90.0, 1.0e+03);
|
||||
|
||||
// initialise data arrays
|
||||
DCL_initLog(&eBuf, e_array, DATA_LENGTH);
|
||||
DCL_initLog(&u1Buf, u1_array, DATA_LENGTH);
|
||||
DCL_initLog(&u2Buf, u2_array, DATA_LENGTH);
|
||||
DCL_initLog(&dBuf, d_array, DATA_LENGTH);
|
||||
DCL_clearLog(&u1Buf);
|
||||
DCL_clearLog(&u2Buf);
|
||||
DCL_fillLog(&dBuf, 1.234567f);
|
||||
|
||||
// compute CLA task vectors
|
||||
EALLOW;
|
||||
Cla1Regs.MVECT1 = (Uint16)((Uint32)&Cla1Task1 -(Uint32)&Cla1Prog_Start);
|
||||
Cla1Regs.MVECT2 = (Uint16)((Uint32)&Cla1Task2 -(Uint32)&Cla1Prog_Start);
|
||||
Cla1Regs.MVECT3 = (Uint16)((Uint32)&Cla1Task3 -(Uint32)&Cla1Prog_Start);
|
||||
Cla1Regs.MVECT4 = (Uint16)((Uint32)&Cla1Task4 -(Uint32)&Cla1Prog_Start);
|
||||
Cla1Regs.MVECT5 = (Uint16)((Uint32)&Cla1Task5 -(Uint32)&Cla1Prog_Start);
|
||||
Cla1Regs.MVECT6 = (Uint16)((Uint32)&Cla1Task6 -(Uint32)&Cla1Prog_Start);
|
||||
Cla1Regs.MVECT7 = (Uint16)((Uint32)&Cla1Task7 -(Uint32)&Cla1Prog_Start);
|
||||
Cla1Regs.MVECT8 = (Uint16)((Uint32)&Cla1Task8 -(Uint32)&Cla1Prog_Start);
|
||||
|
||||
// CLA task triggers
|
||||
Cla1Regs.MPISRCSEL1.bit.PERINT1SEL = CLA_INT1_NONE;
|
||||
Cla1Regs.MPISRCSEL1.bit.PERINT2SEL = CLA_INT2_NONE;
|
||||
Cla1Regs.MPISRCSEL1.bit.PERINT3SEL = CLA_INT3_NONE;
|
||||
Cla1Regs.MPISRCSEL1.bit.PERINT4SEL = CLA_INT4_NONE;
|
||||
Cla1Regs.MPISRCSEL1.bit.PERINT5SEL = CLA_INT5_NONE;
|
||||
Cla1Regs.MPISRCSEL1.bit.PERINT6SEL = CLA_INT6_NONE;
|
||||
Cla1Regs.MPISRCSEL1.bit.PERINT7SEL = CLA_INT7_NONE;
|
||||
Cla1Regs.MPISRCSEL1.bit.PERINT8SEL = CLA_INT8_NONE;
|
||||
Cla1Regs.MIER.all = 0x00FF;
|
||||
|
||||
/* Switch the CLA program space to the CLA and enable software forcing
|
||||
* Also switch over CLA data ram 0,1 and 2
|
||||
* CAUTION: The RAMxCPUE bits can only be enabled by writing to the register
|
||||
* and not the individual bit field. Furthermore, the status of these bitfields
|
||||
* is not reflected in either the watch or register views - they always read as
|
||||
* zeros. This is a known bug and the user is advised to test CPU accessibilty
|
||||
* first before proceeding
|
||||
*/
|
||||
Cla1Regs.MMEMCFG.all = CLA_PROG_ENABLE|CLARAM0_ENABLE|CLARAM1_ENABLE|CLARAM2_ENABLE|CLA_RAM1CPUE;
|
||||
Cla1Regs.MCTL.bit.IACKE = 1;
|
||||
EDIS;
|
||||
|
||||
// enable CLA interrupts and run task 8
|
||||
Cla1Regs.MIER.bit.INT3 = 1;
|
||||
Cla1Regs.MIER.bit.INT8 = 1;
|
||||
Cla1ForceTask8andWait();
|
||||
|
||||
// enable CPU interrupts & start timer 0
|
||||
PieCtrlRegs.PIEIER1.bit.INTx7 = 1;
|
||||
IER |= M_INT1;
|
||||
EINT;
|
||||
StartCpuTimer0();
|
||||
|
||||
// idle loop
|
||||
while(1)
|
||||
{
|
||||
IdleLoopCount++;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
||||
/* control ISR: triggered by timer 0 */
|
||||
interrupt void control_Isr(void)
|
||||
{
|
||||
// clear timer flag & acknowledge interrupt
|
||||
CpuTimer0Regs.TCR.bit.TIF = 1;
|
||||
PieCtrlRegs.PIEACK.all = PIEACK_GROUP1;
|
||||
|
||||
// read data & run controllers
|
||||
if (eBuf.dptr < eBuf.lptr)
|
||||
{
|
||||
// read input data
|
||||
ek = DCL_readLog(&eBuf);
|
||||
|
||||
// run DF23 controllers on CLA
|
||||
EALLOW;
|
||||
Cla1ForceTask3andWait();
|
||||
EDIS;
|
||||
|
||||
// compute difference in controller results
|
||||
dk = u1k - u2k;
|
||||
|
||||
// store results
|
||||
DCL_writeLog(&u1Buf, u1k);
|
||||
DCL_writeLog(&u2Buf, u2k);
|
||||
DCL_writeLog(&dBuf, dk);
|
||||
}
|
||||
else
|
||||
{
|
||||
// place break-point here
|
||||
asm(" NOP");
|
||||
}
|
||||
|
||||
IsrCount++;
|
||||
}
|
||||
|
||||
|
||||
/* end of file */
|
||||
@@ -0,0 +1,106 @@
|
||||
/* control_F28069_DF23_CLA.cla
|
||||
*
|
||||
* Copyright (C) 2020 Texas Instruments Incorporated - http://www.ti.com/
|
||||
* ALL RIGHTS RESERVED
|
||||
*
|
||||
*/
|
||||
|
||||
#include "CLA_shared.h"
|
||||
#include "F2806x_Cla_typedefs.h"
|
||||
#include "F2806x_Device.h"
|
||||
|
||||
// CLA variables
|
||||
DCL_DF23_CLA ctrl1;
|
||||
DCL_DF23_CLA ctrl2;
|
||||
float vk;
|
||||
float upperLim;
|
||||
float lowerLim;
|
||||
|
||||
|
||||
__interrupt void Cla1Task1 ( void )
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
__interrupt void Cla1Task2 ( void )
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
// task 3 contains the DF23 controller
|
||||
__interrupt void Cla1Task3 ( void )
|
||||
{
|
||||
// __mdebugstop();
|
||||
|
||||
// run the full DF23 controller
|
||||
u1k = DCL_runDF23_L1(&ctrl1, ek);
|
||||
|
||||
// run the pre-computed DF23 controller with clamp
|
||||
u2k = DCL_runDF23_L2(&ctrl2, ek);
|
||||
vk = DCL_runClamp_L1(&u2k, upperLim, lowerLim);
|
||||
if (0.5f > vk)
|
||||
{
|
||||
DCL_runDF23_L3(&ctrl2, ek, u2k);
|
||||
}
|
||||
|
||||
__mnop();
|
||||
__mnop();
|
||||
__mnop();
|
||||
}
|
||||
|
||||
__interrupt void Cla1Task4 ( void )
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
__interrupt void Cla1Task5 ( void )
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
__interrupt void Cla1Task6 ( void )
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
__interrupt void Cla1Task7 ( void )
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
//Task 8 will initialize the variables used in Task 3
|
||||
__interrupt void Cla1Task8 ( void )
|
||||
{
|
||||
// __mdebugstop();
|
||||
|
||||
// initialise DF23 controller coefficients
|
||||
ctrl1.a1 = -2.1280f;
|
||||
ctrl1.a2 = 1.3968f;
|
||||
ctrl1.a3 = -0.2689f;
|
||||
ctrl1.b0 = 9.6580f;
|
||||
ctrl1.b1 = -9.1580f;
|
||||
ctrl1.b2 = -9.6521f;
|
||||
ctrl1.b3 = 9.1639f;
|
||||
ctrl1.x1 = 0.0f;
|
||||
ctrl1.x2 = 0.0f;
|
||||
ctrl1.x3 = 0.0f;
|
||||
|
||||
ctrl2.a1 = ctrl1.a1;
|
||||
ctrl2.a2 = ctrl1.a2;
|
||||
ctrl2.a3 = ctrl1.a3;
|
||||
ctrl2.b0 = ctrl1.b0;
|
||||
ctrl2.b1 = ctrl1.b1;
|
||||
ctrl2.b2 = ctrl1.b2;
|
||||
ctrl2.b3 = ctrl1.b3;
|
||||
ctrl2.x1 = ctrl1.x1;
|
||||
ctrl2.x2 = ctrl1.x2;
|
||||
ctrl2.x3 = ctrl1.x3;
|
||||
|
||||
// clamp limits
|
||||
upperLim = 1001.0f;
|
||||
lowerLim = -1001.0f;
|
||||
|
||||
}
|
||||
|
||||
// end of file
|
||||
|
||||
@@ -0,0 +1,23 @@
|
||||
<projectSpec>
|
||||
<project
|
||||
name="F28069_GSM"
|
||||
device="TMS320F28069"
|
||||
configurations="DEBUG"
|
||||
launchWizard="False"
|
||||
linkerCommandFile=""
|
||||
compilerBuildOptions="--opt_level=off -I${C2000WARE_F2806X_ROOT1} -I${C2000WARE_F2806X_ROOT2} -I${C2000WARE_DCL_INCLUDE_ROOT} -v28 -ml -mt --float_support=fpu32 --define=DEBUG --diag_warning=225 --diag_suppress=10063 --display_error_number"
|
||||
linkerBuildOptions="--stack_size=0x400 --heap_size=0x200 --define RAM"
|
||||
>
|
||||
<pathVariable name="C2000WARE_F2806X_ROOT1" path="../../../../../../../device_support/f2806x/headers/include" scope="project" />
|
||||
<pathVariable name="C2000WARE_F2806X_ROOT2" path="../../../../../../../device_support/f2806x/common/include" scope="project" />
|
||||
<pathVariable name="C2000WARE_DCL_INCLUDE_ROOT" path="../../../include" scope="project" />
|
||||
<file action="copy" path="../../../../../../../device_support/f2806x/common/source/F2806x_DefaultIsr.c" targetDirectory="" />
|
||||
<file action="copy" path="../../../../../../../device_support/f2806x/headers/source/F2806x_GlobalVariableDefs.c" targetDirectory="" />
|
||||
<file action="copy" path="../../../../../../../device_support/f2806x/common/source/F2806x_SysCtrl.c" targetDirectory="" />
|
||||
<file action="copy" path="../../../../../../../device_support/f2806x/common/source/F2806x_usDelay.asm" targetDirectory="" />
|
||||
<file action="copy" path="../../../../../../../device_support/f2806x/headers/cmd/F2806x_Headers_nonBIOS.cmd" targetDirectory="" />
|
||||
<file action="copy" path="../../../cmd/F28069_stdmem.cmd" targetDirectory="" />
|
||||
<file action="copy" path="../../../cmd/F28069_DCL.cmd" targetDirectory="" />
|
||||
<file action="copy" path="../Example_F28069_GSM.c" targetDirectory="" />
|
||||
</project>
|
||||
</projectSpec>
|
||||
@@ -0,0 +1,87 @@
|
||||
/* Example_F28069_GSM.c
|
||||
*
|
||||
* Copyright (C) 2020 Texas Instruments Incorporated - http://www.ti.com/
|
||||
* ALL RIGHTS RESERVED
|
||||
*
|
||||
*/
|
||||
|
||||
// header files
|
||||
#include "F2806x_Device.h"
|
||||
#include "F2806x_Examples.h"
|
||||
#include "F2806x_GlobalPrototypes.h"
|
||||
#include "DCLF32.h"
|
||||
#include "DCL_fdlog.h"
|
||||
|
||||
// function prototypes
|
||||
float32_t GSM_target_fcn(float32_t x);
|
||||
|
||||
// global variables
|
||||
uint16_t i = 0;
|
||||
float32_t dx, xk, yk;
|
||||
|
||||
// controller
|
||||
DCL_GSM F = GSM_DEFAULTS;
|
||||
DCL_CSS Fcss = DCL_CSS_DEFAULTS;
|
||||
DCL_GSM_SPS Fsps = GSM_SPS_DEFAULTS;
|
||||
|
||||
// result buffer
|
||||
#pragma DATA_SECTION(s_array, "SDataLogSection")
|
||||
float32_t s_array[FDLOG_DEFAULT_SIZE];
|
||||
FDLOG sBuf = FDLOG_DEFAULTS;
|
||||
|
||||
|
||||
/* main */
|
||||
main()
|
||||
{
|
||||
/* initialise system */
|
||||
InitSysCtrl(); // [F2806x_SysCtrl.c]
|
||||
DINT; // disable interrupts
|
||||
|
||||
/* result buffer initialization */
|
||||
DCL_initLog(&sBuf, s_array, FDLOG_DEFAULT_SIZE);
|
||||
DCL_clearLog(&sBuf);
|
||||
|
||||
/* initialize GSM support structures */
|
||||
F.sps = &Fsps;
|
||||
F.css = &Fcss;
|
||||
|
||||
/* load GSM offset coefficients */
|
||||
xk = 0;
|
||||
for (i=1; i<=GSM_N; i++)
|
||||
{
|
||||
xk += F.h;
|
||||
F.sps->c[i] = GSM_target_fcn(xk);
|
||||
}
|
||||
|
||||
/* load GSM gain table */
|
||||
DCL_loadGSMgains(&F);
|
||||
|
||||
/* load active GSM */
|
||||
DCL_REQUEST_UPDATE(&F);
|
||||
DCL_updateGSM(&F);
|
||||
|
||||
/* load input-output curve */
|
||||
dx = 2.2f / FDLOG_DEFAULT_SIZE;
|
||||
for (xk=-1.1f; xk<1.1f; xk+=dx)
|
||||
{
|
||||
yk = DCL_runGSM_C1(&F, xk);
|
||||
DCL_writeLog(&sBuf, yk);
|
||||
}
|
||||
|
||||
/* infinite loop */
|
||||
while(1)
|
||||
{
|
||||
asm(" NOP");
|
||||
} // while
|
||||
|
||||
} // main
|
||||
|
||||
|
||||
/* target function for gain scheduler profile */
|
||||
float32_t GSM_target_fcn(float32_t x)
|
||||
{
|
||||
return(x*x);
|
||||
}
|
||||
|
||||
|
||||
/* end of file */
|
||||
+33
@@ -0,0 +1,33 @@
|
||||
<projectSpec>
|
||||
<project
|
||||
name="F28069_NLPID"
|
||||
device="TMS320F28069"
|
||||
configurations="DEBUG"
|
||||
launchWizard="False"
|
||||
linkerCommandFile=""
|
||||
compilerBuildOptions="--opt_level=off -I${C2000WARE_F2806X_ROOT1} -I${C2000WARE_F2806X_ROOT2} -I${C2000WARE_DCL_INCLUDE_ROOT} -v28 -ml -mt --float_support=fpu32 --define=DEBUG --diag_warning=225 --diag_suppress=10063 --display_error_number"
|
||||
linkerBuildOptions="--stack_size=0x400 --heap_size=0x200 --define RAM"
|
||||
>
|
||||
<pathVariable name="C2000WARE_F2806X_ROOT1" path="../../../../../../../device_support/f2806x/headers/include" scope="project" />
|
||||
<pathVariable name="C2000WARE_F2806X_ROOT2" path="../../../../../../../device_support/f2806x/common/include" scope="project" />
|
||||
<pathVariable name="C2000WARE_DCL_INCLUDE_ROOT" path="../../../include" scope="project" />
|
||||
<file action="copy" path="../../../../../../../device_support/f2806x/common/source/F2806x_Adc.c" targetDirectory="" />
|
||||
<file action="copy" path="../../../../../../../device_support/f2806x/common/source/F2806x_CpuTimers.c" targetDirectory="" />
|
||||
<file action="copy" path="../../../../../../../device_support/f2806x/common/source/F2806x_DefaultIsr.c" targetDirectory="" />
|
||||
<file action="copy" path="../../../../../../../device_support/f2806x/common/source/F2806x_EPwm.c" targetDirectory="" />
|
||||
<file action="copy" path="../../../../../../../device_support/f2806x/headers/source/F2806x_GlobalVariableDefs.c" targetDirectory="" />
|
||||
<file action="copy" path="../../../../../../../device_support/f2806x/common/source/F2806x_Gpio.c" targetDirectory="" />
|
||||
<file action="copy" path="../../../../../../../device_support/f2806x/common/source/F2806x_PieCtrl.c" targetDirectory="" />
|
||||
<file action="copy" path="../../../../../../../device_support/f2806x/common/source/F2806x_PieVect.c" targetDirectory="" />
|
||||
<file action="copy" path="../../../../../../../device_support/f2806x/common/source/F2806x_SysCtrl.c" targetDirectory="" />
|
||||
<file action="copy" path="../../../../../../../device_support/f2806x/common/source/F2806x_DBGIER.asm" targetDirectory="" />
|
||||
<file action="copy" path="../../../../../../../device_support/f2806x/common/source/F2806x_DisInt.asm" targetDirectory="" />
|
||||
<file action="copy" path="../../../../../../../device_support/f2806x/common/source/F2806x_usDelay.asm" targetDirectory="" />
|
||||
<file action="copy" path="../../../../../../../device_support/f2806x/headers/cmd/F2806x_Headers_nonBIOS.cmd" targetDirectory="" />
|
||||
<file action="copy" path="../../../cmd/F28069_stdmem.cmd" targetDirectory="" />
|
||||
<file action="copy" path="../../../cmd/F28069_DCL.cmd" targetDirectory="" />
|
||||
<file action="copy" path="../Example_F28069_NLPID.c" targetDirectory="" />
|
||||
<file action="copy" path="../../../source/DCL_error.c" targetDirectory="" />
|
||||
</project>
|
||||
</projectSpec>
|
||||
|
||||
@@ -0,0 +1,182 @@
|
||||
/* Example_F28069_PID.c
|
||||
*
|
||||
* Copyright (C) 2020 Texas Instruments Incorporated - http://www.ti.com/
|
||||
* ALL RIGHTS RESERVED
|
||||
*
|
||||
*/
|
||||
|
||||
// header files
|
||||
#include "F2806x_Device.h"
|
||||
#include "F2806x_Examples.h"
|
||||
#include "F2806x_GlobalPrototypes.h"
|
||||
#include "DCLF32.h"
|
||||
#include "DCL_NLPID.h"
|
||||
|
||||
// function prototypes
|
||||
extern interrupt void control_Isr(void);
|
||||
|
||||
// global variables
|
||||
long IdleLoopCount = 0;
|
||||
long IsrCount = 0;
|
||||
float rk = 0.25f;
|
||||
float yk;
|
||||
float lk;
|
||||
float uk;
|
||||
DCL_NLPID nlpid1 = NLPID_DEFAULTS;
|
||||
DCL_NLPID_SPS sps1 = NLPID_SPS_DEFAULTS;
|
||||
DCL_CSS css1 = DCL_CSS_DEFAULTS;
|
||||
float Duty;
|
||||
volatile uint16_t calFlag = 0;
|
||||
float upperlim = 0.95f;
|
||||
float lowerlim = 0.05f;
|
||||
unsigned int clampactive;
|
||||
|
||||
|
||||
/* main */
|
||||
main()
|
||||
{
|
||||
/* initialise system */
|
||||
InitSysCtrl(); // [F2806x_SysCtrl.c]
|
||||
DINT; // disable interrupts
|
||||
IER = 0x0000;
|
||||
IFR = 0x0000;
|
||||
InitPieCtrl(); // initialise PIE control registers [F2806x_PieCtrl.c]
|
||||
InitPieVectTable(); // initialise PIE vector table [F2806x_PieVect.c]
|
||||
EALLOW;
|
||||
PieVectTable.ADCINT1 = &control_Isr; // [F28069_PID_cisr.c]
|
||||
EDIS;
|
||||
|
||||
/* configure ePWM1 */
|
||||
EALLOW;
|
||||
SysCtrlRegs.PCLKCR0.bit.TBCLKSYNC = 0;
|
||||
EDIS;
|
||||
InitEPwm(); // [F2806x_EPwm.c]
|
||||
EPwm1Regs.TBCTL.bit.CTRMODE = 3; // freeze TB counter
|
||||
EPwm1Regs.TBCTL.bit.PRDLD = 1; // immediate load
|
||||
EPwm1Regs.TBCTL.bit.PHSEN = 0; // disable phase loading
|
||||
EPwm1Regs.TBCTL.bit.SYNCOSEL = 3; // disable SYNCOUT signal
|
||||
EPwm1Regs.TBCTL.bit.HSPCLKDIV = 0; // TBCLK = SYSCLKOUT
|
||||
EPwm1Regs.TBCTL.bit.CLKDIV = 0; // clock divider = /1
|
||||
EPwm1Regs.TBCTL.bit.FREE_SOFT = 2; // free run on emulation suspend
|
||||
EPwm1Regs.TBPRD = 0x2328; // set period for ePWM1 (0x2328 = 10kHz)
|
||||
EPwm1Regs.TBPHS.all = 0; // time-base Phase Register
|
||||
EPwm1Regs.TBCTR = 0; // time-base Counter Register
|
||||
EPwm1Regs.ETSEL.bit.SOCAEN = 1; // enable SOC on A group
|
||||
EPwm1Regs.ETSEL.bit.SOCASEL = 1; // select SOC from zero match
|
||||
EPwm1Regs.ETPS.bit.SOCAPRD = 1; // generate pulse on 1st event
|
||||
EPwm1Regs.CMPCTL.bit.SHDWAMODE = 0; // enable shadow mode
|
||||
EPwm1Regs.CMPCTL.bit.LOADAMODE = 2; // reload on CTR=zero
|
||||
EPwm1Regs.CMPA.half.CMPA = 0x0080; // set compare A value
|
||||
EPwm1Regs.AQCTLA.bit.CAU = AQ_SET; // HIGH on CMPA up match
|
||||
EPwm1Regs.AQCTLA.bit.ZRO = AQ_CLEAR; // LOW on zero match
|
||||
EALLOW;
|
||||
SysCtrlRegs.PCLKCR0.bit.TBCLKSYNC = 1;
|
||||
EDIS;
|
||||
|
||||
/* configure ADC */
|
||||
InitAdc(); // [F2806x_Adc.c]
|
||||
EALLOW;
|
||||
AdcRegs.ADCCTL1.bit.INTPULSEPOS = 0; // early interrupt generation
|
||||
AdcRegs.INTSEL1N2.bit.INT1E = 1; // enabled ADCINT1
|
||||
AdcRegs.INTSEL1N2.bit.INT1CONT = 0; // disable ADCINT1 continuous mode
|
||||
AdcRegs.INTSEL1N2.bit.INT1SEL = 1; // setup EOC1 to trigger ADCINT1
|
||||
AdcRegs.INTSEL1N2.bit.INT2E = 0; // enable ADCINT2
|
||||
AdcRegs.INTSEL1N2.bit.INT2CONT = 0; // disable ADCINT1 continuous mode
|
||||
AdcRegs.INTSEL1N2.bit.INT2SEL = 0; // setup EOC1 to trigger ADCINT2
|
||||
AdcRegs.ADCSOC0CTL.bit.CHSEL = 0; // set SOC0 channel select to ADCINA0
|
||||
AdcRegs.ADCSOC1CTL.bit.CHSEL = 8; // set SOC1 channel select to ADCINB0
|
||||
AdcRegs.ADCSOC0CTL.bit.TRIGSEL = 5; // set SOC0 start trigger on EPWM1A, due to round-robin SOC0 converts first then SOC1
|
||||
AdcRegs.ADCSOC1CTL.bit.TRIGSEL = 5; // set SOC1 start trigger on EPWM1A, due to round-robin SOC0 converts first then SOC1
|
||||
AdcRegs.ADCSOC0CTL.bit.ACQPS = 6; // set SOC0 S/H Window to 7 ADC Clock Cycles, (6 ACQPS plus 1)
|
||||
AdcRegs.ADCSOC1CTL.bit.ACQPS = 6; // set SOC1 S/H Window to 7 ADC Clock Cycles, (6 ACQPS plus 1)
|
||||
EDIS;
|
||||
|
||||
/* configure GPIO */
|
||||
InitGpio(); // [F2806x_Gpio.c]
|
||||
EALLOW;
|
||||
GpioCtrlRegs.GPBMUX1.bit.GPIO34 = 0; // GPIO34 = I/O pin
|
||||
GpioCtrlRegs.GPBDIR.bit.GPIO34 = 1; // GPIO34 = output
|
||||
GpioDataRegs.GPBSET.bit.GPIO34 = 1; // GPIO34 = 1
|
||||
GpioCtrlRegs.GPBMUX1.bit.GPIO39 = 0; // GPIO39 = I/O pin
|
||||
GpioCtrlRegs.GPBDIR.bit.GPIO39 = 1; // GPIO39 = output
|
||||
GpioDataRegs.GPBCLEAR.bit.GPIO39 = 1; // GPIO39 = 0
|
||||
EDIS;
|
||||
|
||||
/* initialise controller variables */
|
||||
nlpid1.sps = &sps1;
|
||||
nlpid1.css = &css1;
|
||||
|
||||
nlpid1.sps->Kp = 3.5f;
|
||||
nlpid1.sps->Ki = 0.004f;
|
||||
nlpid1.sps->Kd = 0.35f;
|
||||
nlpid1.sps->alpha_p = 0.8f;
|
||||
nlpid1.sps->alpha_i = 0.95f;
|
||||
nlpid1.sps->alpha_d = 1.0f;
|
||||
nlpid1.sps->delta_p = 0.15f;
|
||||
nlpid1.sps->delta_i = 0.15f;
|
||||
nlpid1.sps->delta_d = 0.15f;
|
||||
nlpid1.i7 = 0.0f;
|
||||
nlpid1.i16 = 0.0f;
|
||||
nlpid1.d2 = 0.0f;
|
||||
nlpid1.d3 = 0.0f;
|
||||
nlpid1.sps->c1 = 151.7093985989552f;
|
||||
nlpid1.sps->c2 = 0.517093985989552f;
|
||||
nlpid1.sps->Umax = 0.31f;
|
||||
nlpid1.sps->Umin = -0.27f;
|
||||
|
||||
// set the gamma variables from the SPS
|
||||
DCL_setNLPIDgamma(&nlpid1);
|
||||
DCL_REQUEST_UPDATE(&nlpid1);
|
||||
DCL_updateNLPID(&nlpid1);
|
||||
|
||||
rk = 0.25f; // initial value for control reference
|
||||
lk = 1.0f; // control loop initially not saturated
|
||||
|
||||
/* enable interrupts */
|
||||
PieCtrlRegs.PIEIER1.bit.INTx1 = 1; // enable PIE INT 1.1 (ADCINT1) - [adcisr]
|
||||
IER |= M_INT1; // enable core interrupt 1 (ADC) - [control_isr]
|
||||
SetDBGIER(0x0001); // enable real-time debug interupts
|
||||
EINT; // enable global interrupt mask
|
||||
|
||||
EALLOW;
|
||||
EPwm1Regs.TBCTL.bit.CTRMODE = 0; // PWM1 timer: count up and start
|
||||
EDIS;
|
||||
|
||||
/* idle loop */
|
||||
while(1)
|
||||
{
|
||||
// update linear gains if new NL parameters
|
||||
DCL_updateNLPID(&nlpid1);
|
||||
|
||||
IdleLoopCount++; // increment loop counter
|
||||
asm(" NOP");
|
||||
} // while
|
||||
|
||||
} // main
|
||||
|
||||
|
||||
/* control ISR: triggered by ADC EOC */
|
||||
interrupt void control_Isr(void)
|
||||
{
|
||||
PieCtrlRegs.PIEACK.all = PIEACK_GROUP1;
|
||||
AdcRegs.ADCINTFLGCLR.bit.ADCINT1 = 1;
|
||||
|
||||
// read ADC channel
|
||||
yk = ((float) AdcResult.ADCRESULT0 - 2048.0f) / 2047.0f;
|
||||
|
||||
// run non-linear PID controller
|
||||
uk = DCL_runNLPID_C1(&nlpid1, rk, yk, lk);
|
||||
|
||||
// external clamp for anti-windup reset
|
||||
clampactive = DCL_runClamp_C2(&uk, upperlim, lowerlim);
|
||||
lk = (clampactive == 0U) ? 1.0f : 0.0f;
|
||||
|
||||
// write u(k) to PWM
|
||||
Duty = (uk / 2.0f + 0.5f) * (float) EPwm1Regs.TBPRD;
|
||||
EPwm1Regs.CMPA.half.CMPA = (Uint16) Duty;
|
||||
|
||||
IsrCount++;
|
||||
}
|
||||
|
||||
|
||||
/* end of file */
|
||||
@@ -0,0 +1,33 @@
|
||||
<projectSpec>
|
||||
<project
|
||||
name="F28069_PID"
|
||||
device="TMS320F28069"
|
||||
configurations="DEBUG"
|
||||
launchWizard="False"
|
||||
linkerCommandFile=""
|
||||
compilerBuildOptions="--opt_level=off -I${C2000WARE_F2806X_ROOT1} -I${C2000WARE_F2806X_ROOT2} -I${C2000WARE_DCL_INCLUDE_ROOT} -v28 -ml -mt --float_support=fpu32 --define=DEBUG --diag_warning=225 --diag_suppress=10063 --display_error_number"
|
||||
linkerBuildOptions="--stack_size=0x400 --heap_size=0x200 --define RAM"
|
||||
>
|
||||
<pathVariable name="C2000WARE_F2806X_ROOT1" path="../../../../../../../device_support/f2806x/headers/include" scope="project" />
|
||||
<pathVariable name="C2000WARE_F2806X_ROOT2" path="../../../../../../../device_support/f2806x/common/include" scope="project" />
|
||||
<pathVariable name="C2000WARE_DCL_INCLUDE_ROOT" path="../../../include" scope="project" />
|
||||
<file action="copy" path="../../../../../../../device_support/f2806x/common/source/F2806x_Adc.c" targetDirectory="" />
|
||||
<file action="copy" path="../../../../../../../device_support/f2806x/common/source/F2806x_CpuTimers.c" targetDirectory="" />
|
||||
<file action="copy" path="../../../../../../../device_support/f2806x/common/source/F2806x_DefaultIsr.c" targetDirectory="" />
|
||||
<file action="copy" path="../../../../../../../device_support/f2806x/common/source/F2806x_EPwm.c" targetDirectory="" />
|
||||
<file action="copy" path="../../../../../../../device_support/f2806x/headers/source/F2806x_GlobalVariableDefs.c" targetDirectory="" />
|
||||
<file action="copy" path="../../../../../../../device_support/f2806x/common/source/F2806x_Gpio.c" targetDirectory="" />
|
||||
<file action="copy" path="../../../../../../../device_support/f2806x/common/source/F2806x_PieCtrl.c" targetDirectory="" />
|
||||
<file action="copy" path="../../../../../../../device_support/f2806x/common/source/F2806x_PieVect.c" targetDirectory="" />
|
||||
<file action="copy" path="../../../../../../../device_support/f2806x/common/source/F2806x_SysCtrl.c" targetDirectory="" />
|
||||
<file action="copy" path="../../../../../../../device_support/f2806x/common/source/F2806x_DBGIER.asm" targetDirectory="" />
|
||||
<file action="copy" path="../../../../../../../device_support/f2806x/common/source/F2806x_DisInt.asm" targetDirectory="" />
|
||||
<file action="copy" path="../../../../../../../device_support/f2806x/common/source/F2806x_usDelay.asm" targetDirectory="" />
|
||||
<file action="copy" path="../../../../../../../device_support/f2806x/headers/cmd/F2806x_Headers_nonBIOS.cmd" targetDirectory="" />
|
||||
<file action="copy" path="../../../cmd/F28069_stdmem.cmd" targetDirectory="" />
|
||||
<file action="copy" path="../../../cmd/F28069_DCL.cmd" targetDirectory="" />
|
||||
<file action="copy" path="../../../source/DCL_clamp_C1.asm" targetDirectory="" />
|
||||
<file action="copy" path="../../../source/DCL_PID_C4.asm" targetDirectory="" />
|
||||
<file action="copy" path="../Example_F28069_PID.c" targetDirectory="" />
|
||||
</project>
|
||||
</projectSpec>
|
||||
@@ -0,0 +1,162 @@
|
||||
/* Example_F28069_PID.c
|
||||
*
|
||||
* Copyright (C) 2020 Texas Instruments Incorporated - http://www.ti.com/
|
||||
* ALL RIGHTS RESERVED
|
||||
*
|
||||
*/
|
||||
|
||||
// header files
|
||||
#include "F2806x_Device.h"
|
||||
#include "F2806x_Examples.h"
|
||||
#include "F2806x_GlobalPrototypes.h"
|
||||
#include "DCLF32.h"
|
||||
|
||||
// function prototypes
|
||||
extern interrupt void control_Isr(void);
|
||||
|
||||
// global variables
|
||||
long IdleLoopCount = 0;
|
||||
long IsrCount = 0;
|
||||
float rk = 0.25f;
|
||||
float yk;
|
||||
float lk;
|
||||
float uk;
|
||||
DCL_PID pid1 = PID_DEFAULTS;
|
||||
float Duty;
|
||||
float upperlim = 0.95f;
|
||||
float lowerlim = 0.05f;
|
||||
unsigned int clampactive;
|
||||
|
||||
|
||||
/* main */
|
||||
main()
|
||||
{
|
||||
/* initialise system */
|
||||
InitSysCtrl(); // [F2806x_SysCtrl.c]
|
||||
DINT; // disable interrupts
|
||||
IER = 0x0000;
|
||||
IFR = 0x0000;
|
||||
InitPieCtrl(); // initialise PIE control registers [F2806x_PieCtrl.c]
|
||||
InitPieVectTable(); // initialise PIE vector table [F2806x_PieVect.c]
|
||||
EALLOW;
|
||||
PieVectTable.ADCINT1 = &control_Isr; // [F28069_PID_cisr.c]
|
||||
EDIS;
|
||||
|
||||
/* configure ePWM1 */
|
||||
EALLOW;
|
||||
SysCtrlRegs.PCLKCR0.bit.TBCLKSYNC = 0;
|
||||
EDIS;
|
||||
InitEPwm(); // [F2806x_EPwm.c]
|
||||
EPwm1Regs.TBCTL.bit.CTRMODE = 3; // freeze TB counter
|
||||
EPwm1Regs.TBCTL.bit.PRDLD = 1; // immediate load
|
||||
EPwm1Regs.TBCTL.bit.PHSEN = 0; // disable phase loading
|
||||
EPwm1Regs.TBCTL.bit.SYNCOSEL = 3; // disable SYNCOUT signal
|
||||
EPwm1Regs.TBCTL.bit.HSPCLKDIV = 0; // TBCLK = SYSCLKOUT
|
||||
EPwm1Regs.TBCTL.bit.CLKDIV = 0; // clock divider = /1
|
||||
EPwm1Regs.TBCTL.bit.FREE_SOFT = 2; // free run on emulation suspend
|
||||
EPwm1Regs.TBPRD = 0x2328; // set period for ePWM1 (0x2328 = 10kHz)
|
||||
EPwm1Regs.TBPHS.all = 0; // time-base Phase Register
|
||||
EPwm1Regs.TBCTR = 0; // time-base Counter Register
|
||||
EPwm1Regs.ETSEL.bit.SOCAEN = 1; // enable SOC on A group
|
||||
EPwm1Regs.ETSEL.bit.SOCASEL = 1; // select SOC from zero match
|
||||
EPwm1Regs.ETPS.bit.SOCAPRD = 1; // generate pulse on 1st event
|
||||
EPwm1Regs.CMPCTL.bit.SHDWAMODE = 0; // enable shadow mode
|
||||
EPwm1Regs.CMPCTL.bit.LOADAMODE = 2; // reload on CTR=zero
|
||||
EPwm1Regs.CMPA.half.CMPA = 0x0080; // set compare A value
|
||||
EPwm1Regs.AQCTLA.bit.CAU = AQ_SET; // HIGH on CMPA up match
|
||||
EPwm1Regs.AQCTLA.bit.ZRO = AQ_CLEAR; // LOW on zero match
|
||||
EALLOW;
|
||||
SysCtrlRegs.PCLKCR0.bit.TBCLKSYNC = 1;
|
||||
EDIS;
|
||||
|
||||
/* configure ADC */
|
||||
InitAdc(); // [F2806x_Adc.c]
|
||||
EALLOW;
|
||||
AdcRegs.ADCCTL1.bit.INTPULSEPOS = 0; // early interrupt generation
|
||||
AdcRegs.INTSEL1N2.bit.INT1E = 1; // enabled ADCINT1
|
||||
AdcRegs.INTSEL1N2.bit.INT1CONT = 0; // disable ADCINT1 continuous mode
|
||||
AdcRegs.INTSEL1N2.bit.INT1SEL = 1; // setup EOC1 to trigger ADCINT1
|
||||
AdcRegs.INTSEL1N2.bit.INT2E = 0; // enable ADCINT2
|
||||
AdcRegs.INTSEL1N2.bit.INT2CONT = 0; // disable ADCINT1 continuous mode
|
||||
AdcRegs.INTSEL1N2.bit.INT2SEL = 0; // setup EOC1 to trigger ADCINT2
|
||||
AdcRegs.ADCSOC0CTL.bit.CHSEL = 0; // set SOC0 channel select to ADCINA0
|
||||
AdcRegs.ADCSOC1CTL.bit.CHSEL = 8; // set SOC1 channel select to ADCINB0
|
||||
AdcRegs.ADCSOC0CTL.bit.TRIGSEL = 5; // set SOC0 start trigger on EPWM1A, due to round-robin SOC0 converts first then SOC1
|
||||
AdcRegs.ADCSOC1CTL.bit.TRIGSEL = 5; // set SOC1 start trigger on EPWM1A, due to round-robin SOC0 converts first then SOC1
|
||||
AdcRegs.ADCSOC0CTL.bit.ACQPS = 6; // set SOC0 S/H Window to 7 ADC Clock Cycles, (6 ACQPS plus 1)
|
||||
AdcRegs.ADCSOC1CTL.bit.ACQPS = 6; // set SOC1 S/H Window to 7 ADC Clock Cycles, (6 ACQPS plus 1)
|
||||
EDIS;
|
||||
|
||||
/* configure GPIO */
|
||||
InitGpio(); // [F2806x_Gpio.c]
|
||||
EALLOW;
|
||||
GpioCtrlRegs.GPBMUX1.bit.GPIO34 = 0; // GPIO34 = I/O pin
|
||||
GpioCtrlRegs.GPBDIR.bit.GPIO34 = 1; // GPIO34 = output
|
||||
GpioDataRegs.GPBSET.bit.GPIO34 = 1; // GPIO34 = 1
|
||||
GpioCtrlRegs.GPBMUX1.bit.GPIO39 = 0; // GPIO39 = I/O pin
|
||||
GpioCtrlRegs.GPBDIR.bit.GPIO39 = 1; // GPIO39 = output
|
||||
GpioDataRegs.GPBCLEAR.bit.GPIO39 = 1; // GPIO39 = 0
|
||||
EDIS;
|
||||
|
||||
/* initialise controller variables */
|
||||
pid1.Kp = 9.0f;
|
||||
pid1.Ki = 0.015f;
|
||||
pid1.Kd = 0.35f;
|
||||
pid1.Kr = 1.0f;
|
||||
pid1.c1 = 188.0296600613396f;
|
||||
pid1.c2 = 0.880296600613396f;
|
||||
pid1.d2 = 0.0f;
|
||||
pid1.d3 = 0.0f;
|
||||
pid1.i10 = 0.0f;
|
||||
pid1.i14 = 1.0f;
|
||||
pid1.Umax = 1.0f;
|
||||
pid1.Umin = -1.0f;
|
||||
|
||||
rk = 0.25f; // initial value for control reference
|
||||
lk = 1.0f; // control loop not saturated
|
||||
|
||||
/* enable interrupts */
|
||||
PieCtrlRegs.PIEIER1.bit.INTx1 = 1; // enable PIE INT 1.1 (ADCINT1) - [adcisr]
|
||||
IER |= M_INT1; // enable core interrupt 1 (ADC) - [control_isr]
|
||||
SetDBGIER(0x0001); // enable real-time debug interupts
|
||||
EINT; // enable global interrupt mask
|
||||
|
||||
EALLOW;
|
||||
EPwm1Regs.TBCTL.bit.CTRMODE = 0; // PWM1 timer: count up and start
|
||||
EDIS;
|
||||
|
||||
/* idle loop */
|
||||
while(1)
|
||||
{
|
||||
IdleLoopCount++; // increment loop counter
|
||||
asm(" NOP");
|
||||
} // while
|
||||
|
||||
} // main
|
||||
|
||||
|
||||
/* control ISR: triggered by ADC EOC */
|
||||
interrupt void control_Isr(void)
|
||||
{
|
||||
PieCtrlRegs.PIEACK.all = PIEACK_GROUP1;
|
||||
AdcRegs.ADCINTFLGCLR.bit.ADCINT1 = 1;
|
||||
|
||||
// read ADC channel
|
||||
yk = ((float) AdcResult.ADCRESULT0 - 2048.0f) / 2047.0f;
|
||||
|
||||
// run PID controller
|
||||
uk = DCL_runPID_C4(&pid1, rk, yk, lk);
|
||||
|
||||
// external clamp for anti-windup reset
|
||||
clampactive = DCL_runClamp_C1(&uk, upperlim, lowerlim);
|
||||
lk = (clampactive == 0U) ? 1.0f : 0.0f;
|
||||
|
||||
// write u(k) to PWM
|
||||
Duty = (uk / 2.0f + 0.5f) * (float) EPwm1Regs.TBPRD;
|
||||
EPwm1Regs.CMPA.half.CMPA = (Uint16) Duty;
|
||||
|
||||
IsrCount++;
|
||||
}
|
||||
|
||||
|
||||
/* end of file */
|
||||
@@ -0,0 +1,33 @@
|
||||
<projectSpec>
|
||||
<project
|
||||
name="F28069_PI"
|
||||
device="TMS320F28069"
|
||||
configurations="DEBUG"
|
||||
launchWizard="False"
|
||||
linkerCommandFile=""
|
||||
compilerBuildOptions="--opt_level=off -I${C2000WARE_F2806X_ROOT1} -I${C2000WARE_F2806X_ROOT2} -I${C2000WARE_DCL_INCLUDE_ROOT} -I${PROJECT_INCLUDE_ROOT} -v28 -ml -mt --float_support=fpu32 --define=DEBUG --diag_warning=225 --diag_suppress=10063,303 --display_error_number"
|
||||
linkerBuildOptions="--stack_size=0x400 --heap_size=0x200 --define RAM"
|
||||
>
|
||||
<pathVariable name="C2000WARE_F2806X_ROOT1" path="../../../../../../../device_support/f2806x/headers/include" scope="project" />
|
||||
<pathVariable name="C2000WARE_F2806X_ROOT2" path="../../../../../../../device_support/f2806x/common/include" scope="project" />
|
||||
<pathVariable name="C2000WARE_DCL_INCLUDE_ROOT" path="../../../include" scope="project" />
|
||||
<pathVariable name="PROJECT_INCLUDE_ROOT" path="../" scope="project" />
|
||||
<file action="copy" path="../../../../../../../device_support/f2806x/common/source/F2806x_Adc.c" targetDirectory="" />
|
||||
<file action="copy" path="../../../../../../../device_support/f2806x/common/source/F2806x_CpuTimers.c" targetDirectory="" />
|
||||
<file action="copy" path="../../../../../../../device_support/f2806x/common/source/F2806x_DefaultIsr.c" targetDirectory="" />
|
||||
<file action="copy" path="../../../../../../../device_support/f2806x/common/source/F2806x_EPwm.c" targetDirectory="" />
|
||||
<file action="copy" path="../../../../../../../device_support/f2806x/headers/source/F2806x_GlobalVariableDefs.c" targetDirectory="" />
|
||||
<file action="copy" path="../../../../../../../device_support/f2806x/common/source/F2806x_Gpio.c" targetDirectory="" />
|
||||
<file action="copy" path="../../../../../../../device_support/f2806x/common/source/F2806x_PieCtrl.c" targetDirectory="" />
|
||||
<file action="copy" path="../../../../../../../device_support/f2806x/common/source/F2806x_PieVect.c" targetDirectory="" />
|
||||
<file action="copy" path="../../../../../../../device_support/f2806x/common/source/F2806x_SysCtrl.c" targetDirectory="" />
|
||||
<file action="copy" path="../../../../../../../device_support/f2806x/common/source/F2806x_DisInt.asm" targetDirectory="" />
|
||||
<file action="copy" path="../../../../../../../device_support/f2806x/common/source/F2806x_usDelay.asm" targetDirectory="" />
|
||||
<file action="copy" path="../../../../../../../device_support/f2806x/headers/cmd/F2806x_Headers_nonBIOS.cmd" targetDirectory="" />
|
||||
<file action="copy" path="../../../cmd/F28069_stdmem.cmd" targetDirectory="" />
|
||||
<file action="copy" path="../../../cmd/F28069_DCL.cmd" targetDirectory="" />
|
||||
<file action="copy" path="../../../source/DCL_PI_L1.asm" targetDirectory="" />
|
||||
<file action="copy" path="../Example_F28069_PI.c" targetDirectory="" />
|
||||
<file action="copy" path="../F28069_PI_CLA.cla" targetDirectory="" />
|
||||
</project>
|
||||
</projectSpec>
|
||||
@@ -0,0 +1,50 @@
|
||||
/* CLA_shared.h */
|
||||
|
||||
#ifndef _C_CLA_SHARED_H
|
||||
#define _C_CLA_SHARED_H
|
||||
|
||||
#include "DCLCLA.h"
|
||||
#include "F2806x_Cla_typedefs.h"
|
||||
|
||||
#define CLA_PROG_ENABLE 0x0001
|
||||
#define CLARAM0_ENABLE 0x0010
|
||||
#define CLARAM1_ENABLE 0x0020
|
||||
#define CLARAM2_ENABLE 0x0040
|
||||
#define CLA_RAM0CPUE 0x0100
|
||||
#define CLA_RAM1CPUE 0x0200
|
||||
#define CLA_RAM2CPUE 0x0400
|
||||
|
||||
/* shared controller data */
|
||||
extern float rk;
|
||||
extern float yk;
|
||||
extern float uk;
|
||||
extern DCL_PI_CLA pi1;
|
||||
|
||||
// CLA memory address symbols
|
||||
extern Uint16 Cla1funcsLoadStart;
|
||||
extern Uint16 Cla1funcsLoadEnd;
|
||||
extern Uint16 Cla1funcsLoadSize;
|
||||
extern Uint16 Cla1funcsRunStart;
|
||||
extern Uint16 Cla1Prog_Start;
|
||||
|
||||
// CLA math table symbols
|
||||
extern Uint16 Cla1mathTablesLoadStart;
|
||||
extern Uint16 Cla1mathTablesLoadEnd;
|
||||
extern Uint16 Cla1mathTablesLoadSize;
|
||||
extern Uint16 Cla1mathTablesRunStart;
|
||||
|
||||
// CLA C Tasks
|
||||
__interrupt void Cla1Task1();
|
||||
__interrupt void Cla1Task2();
|
||||
__interrupt void Cla1Task3();
|
||||
__interrupt void Cla1Task4();
|
||||
__interrupt void Cla1Task5();
|
||||
__interrupt void Cla1Task6();
|
||||
__interrupt void Cla1Task7();
|
||||
__interrupt void Cla1Task8();
|
||||
|
||||
|
||||
|
||||
#endif // _C_CLA_SHARED_H
|
||||
|
||||
/* end of file */
|
||||
@@ -0,0 +1,187 @@
|
||||
/* Example_F28069_PI.c
|
||||
*
|
||||
* Copyright (C) 2020 Texas Instruments Incorporated - http://www.ti.com/
|
||||
* ALL RIGHTS RESERVED
|
||||
*
|
||||
*/
|
||||
|
||||
// header files
|
||||
#include "F2806x_Device.h"
|
||||
#include "F2806x_Examples.h"
|
||||
#include "F2806x_GlobalPrototypes.h"
|
||||
#include "DCLCLA.h"
|
||||
#include "CLA_shared.h"
|
||||
|
||||
// function prototypes
|
||||
interrupt void control_Isr(void);
|
||||
|
||||
// global variables
|
||||
long IdleLoopCount = 0;
|
||||
long IsrCount = 0;
|
||||
float Duty;
|
||||
|
||||
// shared variables
|
||||
#pragma DATA_SECTION(rk, "CpuToCla1MsgRAM")
|
||||
#pragma DATA_SECTION(yk, "CpuToCla1MsgRAM")
|
||||
#pragma DATA_SECTION(uk, "Cla1ToCpuMsgRAM")
|
||||
float rk = 0.25f;
|
||||
float yk;
|
||||
float uk;
|
||||
|
||||
#pragma DATA_SECTION(pi1, "Cla1DataRam1")
|
||||
DCL_PI_CLA pi1 = PI_CLA_DEFAULTS;
|
||||
|
||||
|
||||
main()
|
||||
{
|
||||
/* initialise system */
|
||||
InitSysCtrl(); // [F2806x_SysCtrl.c]
|
||||
DINT; // disable interrupts
|
||||
IER = 0x0000;
|
||||
IFR = 0x0000;
|
||||
InitPieCtrl(); // initialise PIE control registers [F2806x_PieCtrl.c]
|
||||
InitPieVectTable(); // initialise PIE vector table [F2806x_PieVect.c]
|
||||
EALLOW;
|
||||
PieVectTable.ADCINT1 = &control_Isr;
|
||||
EDIS;
|
||||
|
||||
/* initialise PI controller */
|
||||
pi1.Kp = 5.5f;
|
||||
pi1.Ki = 0.015f;
|
||||
pi1.i10 = 0.0f;
|
||||
pi1.i6 = 1.0f;
|
||||
pi1.Umax = 10.2f;
|
||||
pi1.Umin = -10.2f;
|
||||
|
||||
/* compute CLA task vectors */
|
||||
EALLOW;
|
||||
Cla1Regs.MVECT1 = (Uint16)((Uint32)&Cla1Task1 -(Uint32)&Cla1Prog_Start);
|
||||
Cla1Regs.MVECT2 = (Uint16)((Uint32)&Cla1Task2 -(Uint32)&Cla1Prog_Start);
|
||||
Cla1Regs.MVECT3 = (Uint16)((Uint32)&Cla1Task3 -(Uint32)&Cla1Prog_Start);
|
||||
Cla1Regs.MVECT4 = (Uint16)((Uint32)&Cla1Task4 -(Uint32)&Cla1Prog_Start);
|
||||
Cla1Regs.MVECT5 = (Uint16)((Uint32)&Cla1Task5 -(Uint32)&Cla1Prog_Start);
|
||||
Cla1Regs.MVECT6 = (Uint16)((Uint32)&Cla1Task6 -(Uint32)&Cla1Prog_Start);
|
||||
Cla1Regs.MVECT7 = (Uint16)((Uint32)&Cla1Task7 -(Uint32)&Cla1Prog_Start);
|
||||
Cla1Regs.MVECT8 = (Uint16)((Uint32)&Cla1Task8 -(Uint32)&Cla1Prog_Start);
|
||||
|
||||
/* CLA task triggers */
|
||||
Cla1Regs.MPISRCSEL1.bit.PERINT1SEL = CLA_INT1_NONE;
|
||||
Cla1Regs.MPISRCSEL1.bit.PERINT2SEL = CLA_INT2_NONE;
|
||||
Cla1Regs.MPISRCSEL1.bit.PERINT3SEL = CLA_INT3_NONE;
|
||||
Cla1Regs.MPISRCSEL1.bit.PERINT4SEL = CLA_INT4_NONE;
|
||||
Cla1Regs.MPISRCSEL1.bit.PERINT5SEL = CLA_INT5_NONE;
|
||||
Cla1Regs.MPISRCSEL1.bit.PERINT6SEL = CLA_INT6_NONE;
|
||||
Cla1Regs.MPISRCSEL1.bit.PERINT7SEL = CLA_INT7_NONE;
|
||||
Cla1Regs.MPISRCSEL1.bit.PERINT8SEL = CLA_INT8_NONE;
|
||||
Cla1Regs.MIER.all = 0x00FF;
|
||||
|
||||
/* Switch the CLA program space to the CLA and enable software forcing
|
||||
* Also switch over CLA data ram 0,1 and 2
|
||||
* CAUTION: The RAMxCPUE bits can only be enabled by writing to the register
|
||||
* and not the individual bit field. Furthermore, the status of these bitfields
|
||||
* is not reflected in either the watch or register views - they always read as
|
||||
* zeros. This is a known bug and the user is advised to test CPU accessibilty
|
||||
* first before proceeding
|
||||
*/
|
||||
Cla1Regs.MMEMCFG.all = CLA_PROG_ENABLE|CLARAM0_ENABLE|CLARAM1_ENABLE|CLARAM2_ENABLE|CLA_RAM1CPUE;
|
||||
Cla1Regs.MCTL.bit.IACKE = 1;
|
||||
EDIS;
|
||||
|
||||
/* configure ePWM1 */
|
||||
EALLOW;
|
||||
SysCtrlRegs.PCLKCR0.bit.TBCLKSYNC = 0;
|
||||
EDIS;
|
||||
InitEPwm(); // [F2806x_EPwm.c]
|
||||
EPwm1Regs.TBCTL.bit.CTRMODE = 3; // freeze TB counter
|
||||
EPwm1Regs.TBCTL.bit.PRDLD = 1; // immediate load
|
||||
EPwm1Regs.TBCTL.bit.PHSEN = 0; // disable phase loading
|
||||
EPwm1Regs.TBCTL.bit.SYNCOSEL = 3; // disable SYNCOUT signal
|
||||
EPwm1Regs.TBCTL.bit.HSPCLKDIV = 0; // TBCLK = SYSCLKOUT
|
||||
EPwm1Regs.TBCTL.bit.CLKDIV = 0; // clock divider = /1
|
||||
EPwm1Regs.TBCTL.bit.FREE_SOFT = 2; // free run on emulation suspend
|
||||
EPwm1Regs.TBPRD = 0x2328; // set period for ePWM1 (0x2328 = 10kHz)
|
||||
EPwm1Regs.TBPHS.all = 0; // time-base Phase Register
|
||||
EPwm1Regs.TBCTR = 0; // time-base Counter Register
|
||||
EPwm1Regs.ETSEL.bit.SOCAEN = 1; // enable SOC on A group
|
||||
EPwm1Regs.ETSEL.bit.SOCASEL = 1; // select SOC from zero match
|
||||
EPwm1Regs.ETPS.bit.SOCAPRD = 1; // generate pulse on 1st event
|
||||
EPwm1Regs.CMPCTL.bit.SHDWAMODE = 0; // enable shadow mode
|
||||
EPwm1Regs.CMPCTL.bit.LOADAMODE = 2; // reload on CTR=zero
|
||||
EPwm1Regs.CMPA.half.CMPA = 0x0080; // set compare A value
|
||||
EPwm1Regs.AQCTLA.bit.CAU = AQ_SET; // HIGH on CMPA up match
|
||||
EPwm1Regs.AQCTLA.bit.ZRO = AQ_CLEAR; // LOW on zero match
|
||||
EALLOW;
|
||||
SysCtrlRegs.PCLKCR0.bit.TBCLKSYNC = 1;
|
||||
EDIS;
|
||||
|
||||
/* configure ADC */
|
||||
InitAdc(); // [F2806x_Adc.c]
|
||||
EALLOW;
|
||||
AdcRegs.ADCCTL1.bit.INTPULSEPOS = 0; // early interrupt generation
|
||||
AdcRegs.INTSEL1N2.bit.INT1E = 1; // enabled ADCINT1
|
||||
AdcRegs.INTSEL1N2.bit.INT1CONT = 0; // disable ADCINT1 continuous mode
|
||||
AdcRegs.INTSEL1N2.bit.INT1SEL = 1; // setup EOC1 to trigger ADCINT1
|
||||
AdcRegs.INTSEL1N2.bit.INT2E = 0; // enable ADCINT2
|
||||
AdcRegs.INTSEL1N2.bit.INT2CONT = 0; // disable ADCINT1 continuous mode
|
||||
AdcRegs.INTSEL1N2.bit.INT2SEL = 0; // setup EOC1 to trigger ADCINT2
|
||||
AdcRegs.ADCSOC0CTL.bit.CHSEL = 0; // set SOC0 channel select to ADCINA0
|
||||
AdcRegs.ADCSOC1CTL.bit.CHSEL = 8; // set SOC1 channel select to ADCINB0
|
||||
AdcRegs.ADCSOC0CTL.bit.TRIGSEL = 5; // set SOC0 start trigger on EPWM1A, due to round-robin SOC0 converts first then SOC1
|
||||
AdcRegs.ADCSOC1CTL.bit.TRIGSEL = 5; // set SOC1 start trigger on EPWM1A, due to round-robin SOC0 converts first then SOC1
|
||||
AdcRegs.ADCSOC0CTL.bit.ACQPS = 6; // set SOC0 S/H Window to 7 ADC Clock Cycles, (6 ACQPS plus 1)
|
||||
AdcRegs.ADCSOC1CTL.bit.ACQPS = 6; // set SOC1 S/H Window to 7 ADC Clock Cycles, (6 ACQPS plus 1)
|
||||
EDIS;
|
||||
|
||||
/* configure GPIO */
|
||||
InitGpio(); // [F2806x_Gpio.c]
|
||||
EALLOW;
|
||||
GpioCtrlRegs.GPBMUX1.bit.GPIO34 = 0; // GPIO34 = I/O pin
|
||||
GpioCtrlRegs.GPBDIR.bit.GPIO34 = 1; // GPIO34 = output
|
||||
GpioDataRegs.GPBSET.bit.GPIO34 = 1; // GPIO34 = 1
|
||||
GpioCtrlRegs.GPBMUX1.bit.GPIO39 = 0; // GPIO39 = I/O pin
|
||||
GpioCtrlRegs.GPBDIR.bit.GPIO39 = 1; // GPIO39 = output
|
||||
GpioDataRegs.GPBCLEAR.bit.GPIO39 = 1; // GPIO39 = 0
|
||||
|
||||
/* CLA setup */
|
||||
Cla1Regs.MIER.bit.INT3 = 1;
|
||||
Cla1Regs.MIER.bit.INT8 = 1;
|
||||
Cla1ForceTask8andWait();
|
||||
|
||||
/* enable interrupts */
|
||||
PieCtrlRegs.PIEIER1.bit.INTx1 = 1; // enable PIE INT 1.1 (ADCINT1) - [adcisr]
|
||||
IER |= M_INT1; // enable CPU Interrupt 1 (TINT0)
|
||||
EINT; // enable global interrupt mask
|
||||
EPwm1Regs.TBCTL.bit.CTRMODE = 0; // PWM1 timer: count up and start
|
||||
EDIS;
|
||||
|
||||
/* idle loop */
|
||||
while(1)
|
||||
{
|
||||
IdleLoopCount++;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
||||
/* control ISR: triggered by ADC EOC */
|
||||
interrupt void control_Isr(void)
|
||||
{
|
||||
PieCtrlRegs.PIEACK.all = PIEACK_GROUP1;
|
||||
AdcRegs.ADCINTFLGCLR.bit.ADCINT1 = 1;
|
||||
|
||||
// read ADC channel
|
||||
yk = ((float) AdcResult.ADCRESULT0 - 2048.0f) / 2047.0f;
|
||||
|
||||
// trigger PI controller on CLA
|
||||
EALLOW;
|
||||
Cla1ForceTask3andWait();
|
||||
|
||||
// write u(k) to PWM
|
||||
Duty = (uk / 2.0f + 0.5f) * (float) EPwm1Regs.TBPRD;
|
||||
EPwm1Regs.CMPA.half.CMPA = (Uint16) Duty;
|
||||
|
||||
IsrCount++;
|
||||
}
|
||||
|
||||
|
||||
/* end of file */
|
||||
@@ -0,0 +1,62 @@
|
||||
/* control_F28069_CLA.cla
|
||||
*
|
||||
* Copyright (C) 2020 Texas Instruments Incorporated - http://www.ti.com/
|
||||
* ALL RIGHTS RESERVED
|
||||
*
|
||||
*/
|
||||
|
||||
#include "CLA_shared.h"
|
||||
#include "F2806x_Cla_typedefs.h"
|
||||
#include "F2806x_Device.h"
|
||||
|
||||
|
||||
__interrupt void Cla1Task1 ( void )
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
__interrupt void Cla1Task2 ( void )
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
// task 3 contains the PI controller
|
||||
__interrupt void Cla1Task3 ( void )
|
||||
{
|
||||
// __mdebugstop();
|
||||
|
||||
// run the PI controller
|
||||
uk = DCL_runPI_L1(&pi1, rk, yk);
|
||||
|
||||
__mnop();
|
||||
__mnop();
|
||||
__mnop();
|
||||
}
|
||||
|
||||
__interrupt void Cla1Task4 ( void )
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
__interrupt void Cla1Task5 ( void )
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
__interrupt void Cla1Task6 ( void )
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
__interrupt void Cla1Task7 ( void )
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
__interrupt void Cla1Task8 ( void )
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
// end of file
|
||||
|
||||
+31
@@ -0,0 +1,31 @@
|
||||
<projectSpec>
|
||||
<project
|
||||
name="F28069_SMITH"
|
||||
device="TMS320F28069"
|
||||
configurations="DEBUG"
|
||||
launchWizard="False"
|
||||
linkerCommandFile=""
|
||||
compilerBuildOptions="--opt_level=off -I${C2000WARE_F2806X_ROOT1} -I${C2000WARE_F2806X_ROOT2} -I${C2000WARE_DCL_INCLUDE_ROOT} -v28 -ml -mt --float_support=fpu32 --define=DEBUG --diag_warning=225 --diag_suppress=10063 --display_error_number"
|
||||
linkerBuildOptions="--stack_size=0x400 --heap_size=0x200 --define RAM"
|
||||
>
|
||||
<pathVariable name="C2000WARE_F2806X_ROOT1" path="../../../../../../../device_support/f2806x/headers/include" scope="project" />
|
||||
<pathVariable name="C2000WARE_F2806X_ROOT2" path="../../../../../../../device_support/f2806x/common/include" scope="project" />
|
||||
<pathVariable name="C2000WARE_DCL_INCLUDE_ROOT" path="../../../include" scope="project" />
|
||||
<file action="copy" path="../../../../../../../device_support/f2806x/common/source/F2806x_Adc.c" targetDirectory="" />
|
||||
<file action="copy" path="../../../../../../../device_support/f2806x/common/source/F2806x_CpuTimers.c" targetDirectory="" />
|
||||
<file action="copy" path="../../../../../../../device_support/f2806x/common/source/F2806x_DefaultIsr.c" targetDirectory="" />
|
||||
<file action="copy" path="../../../../../../../device_support/f2806x/common/source/F2806x_EPwm.c" targetDirectory="" />
|
||||
<file action="copy" path="../../../../../../../device_support/f2806x/headers/source/F2806x_GlobalVariableDefs.c" targetDirectory="" />
|
||||
<file action="copy" path="../../../../../../../device_support/f2806x/common/source/F2806x_Gpio.c" targetDirectory="" />
|
||||
<file action="copy" path="../../../../../../../device_support/f2806x/common/source/F2806x_PieCtrl.c" targetDirectory="" />
|
||||
<file action="copy" path="../../../../../../../device_support/f2806x/common/source/F2806x_PieVect.c" targetDirectory="" />
|
||||
<file action="copy" path="../../../../../../../device_support/f2806x/common/source/F2806x_SysCtrl.c" targetDirectory="" />
|
||||
<file action="copy" path="../../../../../../../device_support/f2806x/common/source/F2806x_DBGIER.asm" targetDirectory="" />
|
||||
<file action="copy" path="../../../../../../../device_support/f2806x/common/source/F2806x_DisInt.asm" targetDirectory="" />
|
||||
<file action="copy" path="../../../../../../../device_support/f2806x/common/source/F2806x_usDelay.asm" targetDirectory="" />
|
||||
<file action="copy" path="../../../../../../../device_support/f2806x/headers/cmd/F2806x_Headers_nonBIOS.cmd" targetDirectory="" />
|
||||
<file action="copy" path="../../../cmd/F28069_stdmem.cmd" targetDirectory="" />
|
||||
<file action="copy" path="../../../cmd/F28069_DCL.cmd" targetDirectory="" />
|
||||
<file action="copy" path="../Example_F28069_Smith.c" targetDirectory="" />
|
||||
</project>
|
||||
</projectSpec>
|
||||
@@ -0,0 +1,171 @@
|
||||
/* Example_F28069_Smith.c
|
||||
*
|
||||
* Copyright (C) 2020 Texas Instruments Incorporated - http://www.ti.com/
|
||||
* ALL RIGHTS RESERVED
|
||||
*
|
||||
*/
|
||||
|
||||
// header files
|
||||
#include "F2806x_Device.h"
|
||||
#include "F2806x_Examples.h"
|
||||
#include "F2806x_GlobalPrototypes.h"
|
||||
#include "DCLF32.h"
|
||||
#include "DCL_fdlog.h"
|
||||
|
||||
// function prototypes
|
||||
extern interrupt void control_Isr(void);
|
||||
|
||||
// global variables
|
||||
uint32_t IdleLoopCount = 0;
|
||||
uint32_t IsrCount = 0;
|
||||
float32_t rk = 0.25f, yk, uk;
|
||||
float32_t Duty;
|
||||
|
||||
// controller
|
||||
DCL_DF23 F = DF23_DEFAULTS;
|
||||
DCL_CSS Fcss = DCL_CSS_DEFAULTS;
|
||||
DCL_DF23_SPS Fsps = DF23_SPS_DEFAULTS;
|
||||
float32_t v3, v5 = 0.0f, v6 = 0.0f;
|
||||
|
||||
// plant model
|
||||
DCL_DF13 GH = DF13_DEFAULTS;
|
||||
|
||||
// modelled delay
|
||||
#define GH_DELAY_LINE_LENGTH 13
|
||||
#pragma DATA_SECTION(p_array, "PDataLogSection")
|
||||
float32_t p_array[GH_DELAY_LINE_LENGTH];
|
||||
FDLOG pBuf = FDLOG_DEFAULTS;
|
||||
|
||||
|
||||
/* main */
|
||||
main()
|
||||
{
|
||||
/* initialise system */
|
||||
InitSysCtrl(); // [F2806x_SysCtrl.c]
|
||||
DINT; // disable interrupts
|
||||
IER = 0x0000;
|
||||
IFR = 0x0000;
|
||||
InitPieCtrl(); // initialise PIE control registers [F2806x_PieCtrl.c]
|
||||
InitPieVectTable(); // initialise PIE vector table [F2806x_PieVect.c]
|
||||
|
||||
EALLOW;
|
||||
PieVectTable.ADCINT1 = &control_Isr; // load interrupt vector
|
||||
EDIS;
|
||||
|
||||
/* configure ePWM1 */
|
||||
EALLOW;
|
||||
SysCtrlRegs.PCLKCR0.bit.TBCLKSYNC = 0;
|
||||
EDIS;
|
||||
InitEPwm(); // [F2806x_EPwm.c]
|
||||
EPwm1Regs.TBCTL.bit.CTRMODE = 3; // freeze TB counter
|
||||
EPwm1Regs.TBCTL.bit.PRDLD = 1; // immediate load
|
||||
EPwm1Regs.TBCTL.bit.PHSEN = 0; // disable phase loading
|
||||
EPwm1Regs.TBCTL.bit.SYNCOSEL = 3; // disable SYNCOUT signal
|
||||
EPwm1Regs.TBCTL.bit.HSPCLKDIV = 0; // TBCLK = SYSCLKOUT
|
||||
EPwm1Regs.TBCTL.bit.CLKDIV = 0; // clock divider = /1
|
||||
EPwm1Regs.TBCTL.bit.FREE_SOFT = 2; // free run on emulation suspend
|
||||
EPwm1Regs.TBPRD = 0x2328; // set period for ePWM1 (0x2328 = 10kHz)
|
||||
EPwm1Regs.TBPHS.all = 0; // time-base Phase Register
|
||||
EPwm1Regs.TBCTR = 0; // time-base Counter Register
|
||||
EPwm1Regs.ETSEL.bit.SOCAEN = 1; // enable SOC on A group
|
||||
EPwm1Regs.ETSEL.bit.SOCASEL = 1; // select SOC from zero match
|
||||
EPwm1Regs.ETPS.bit.SOCAPRD = 1; // generate pulse on 1st event
|
||||
EPwm1Regs.CMPCTL.bit.SHDWAMODE = 0; // enable shadow mode
|
||||
EPwm1Regs.CMPCTL.bit.LOADAMODE = 2; // reload on CTR=zero
|
||||
EPwm1Regs.CMPA.half.CMPA = 0x0080; // set compare A value
|
||||
EPwm1Regs.AQCTLA.bit.CAU = AQ_SET; // HIGH on CMPA up match
|
||||
EPwm1Regs.AQCTLA.bit.ZRO = AQ_CLEAR; // LOW on zero match
|
||||
EALLOW;
|
||||
SysCtrlRegs.PCLKCR0.bit.TBCLKSYNC = 1;
|
||||
EDIS;
|
||||
|
||||
/* configure ADC */
|
||||
InitAdc(); // [F2806x_Adc.c]
|
||||
EALLOW;
|
||||
AdcRegs.ADCCTL1.bit.INTPULSEPOS = 0; // early interrupt generation
|
||||
AdcRegs.INTSEL1N2.bit.INT1E = 1; // enable ADCINT1
|
||||
AdcRegs.INTSEL1N2.bit.INT1CONT = 0; // disable ADCINT1 continuous mode
|
||||
AdcRegs.INTSEL1N2.bit.INT1SEL = 1; // setup EOC1 to trigger ADCINT1
|
||||
AdcRegs.INTSEL1N2.bit.INT2E = 0; // disable ADCINT2
|
||||
AdcRegs.INTSEL1N2.bit.INT2CONT = 0; // disable ADCINT1 continuous mode
|
||||
AdcRegs.INTSEL1N2.bit.INT2SEL = 0; // no trigger to ADCINT2
|
||||
AdcRegs.ADCSOC0CTL.bit.CHSEL = 0; // set SOC0 channel select to ADCINA0
|
||||
AdcRegs.ADCSOC1CTL.bit.CHSEL = 8; // set SOC1 channel select to ADCINB0
|
||||
AdcRegs.ADCSOC0CTL.bit.TRIGSEL = 5; // set SOC0 start trigger on EPWM1A, due to round-robin SOC0 converts first then SOC1
|
||||
AdcRegs.ADCSOC1CTL.bit.TRIGSEL = 5; // set SOC1 start trigger on EPWM1A, due to round-robin SOC0 converts first then SOC1
|
||||
AdcRegs.ADCSOC0CTL.bit.ACQPS = 6; // set SOC0 S/H Window to 7 ADC Clock Cycles, (6 ACQPS plus 1)
|
||||
AdcRegs.ADCSOC1CTL.bit.ACQPS = 6; // set SOC1 S/H Window to 7 ADC Clock Cycles, (6 ACQPS plus 1)
|
||||
AdcRegs.ADCINTFLGCLR.bit.ADCINT1 = 1;
|
||||
EDIS;
|
||||
|
||||
/* delay line initialization */
|
||||
DCL_initLog(&pBuf, p_array, GH_DELAY_LINE_LENGTH);
|
||||
DCL_clearLog(&pBuf);
|
||||
|
||||
/* initialize plant model */
|
||||
// 4.95e-05 z^2 + 4.926e-07 z - 4.901e-05
|
||||
// GH(z) = --------------------------------------
|
||||
// z^3 - 2.97 z^2 + 2.94 z - 0.9704
|
||||
|
||||
GH.b0 = 0.0f;
|
||||
GH.b1 = 4.95e-05f;
|
||||
GH.b2 = 4.926e-07f;
|
||||
GH.b3 = -4.901e-05f;
|
||||
GH.a0 = 1.0f;
|
||||
GH.a1 = -2.97f;
|
||||
GH.a2 = 2.94f;
|
||||
GH.a3 = -0.9704f;
|
||||
|
||||
/* initalize controller */
|
||||
F.b0 = 9.6580f;
|
||||
F.b1 = -9.1580f;
|
||||
F.b2 = -9.6521f;
|
||||
F.b3 = 9.1639f;
|
||||
F.a1 = -2.1280f;
|
||||
F.a2 = 1.3968f;
|
||||
F.a3 = -0.2689f;
|
||||
|
||||
/* enable interrupts */
|
||||
PieCtrlRegs.PIEIER1.bit.INTx1 = 1; // enable PIE INT 1.1 (ADCINT1) - [adcisr]
|
||||
IER |= M_INT1; // enable core interrupt 1 (ADC) - [control_isr]
|
||||
SetDBGIER(0x0001); // enable real-time debug interrupts
|
||||
EINT; // enable global interrupt mask
|
||||
|
||||
EALLOW;
|
||||
EPwm1Regs.TBCTL.bit.CTRMODE = 0; // PWM1 timer: count up and start
|
||||
EDIS;
|
||||
|
||||
/* idle loop */
|
||||
while(1)
|
||||
{
|
||||
IdleLoopCount++; // increment loop counter
|
||||
asm(" NOP");
|
||||
} // while
|
||||
|
||||
} // main
|
||||
|
||||
|
||||
/* control ISR: triggered by ADC EOC */
|
||||
interrupt void control_Isr(void)
|
||||
{
|
||||
PieCtrlRegs.PIEACK.all = PIEACK_GROUP1;
|
||||
AdcRegs.ADCINTFLGCLR.bit.ADCINT1 = 1;
|
||||
|
||||
// read feedback
|
||||
yk = ((float) AdcResult.ADCRESULT0 - 2048.0f) / 2047.0f;
|
||||
|
||||
// run controller
|
||||
v3 = rk - yk + v6 - v5;
|
||||
uk = DCL_runDF23_C4(&F, v3); // control effort
|
||||
v5 = DCL_runDF13_C4(&GH, uk); // plant model
|
||||
v6 = DCL_writeLog(&pBuf, v5); // delay line
|
||||
|
||||
// write u(k) to PWM
|
||||
Duty = (uk / 2.0f + 0.5f) * (float) EPwm1Regs.TBPRD;
|
||||
EPwm1Regs.CMPA.half.CMPA = (Uint16) Duty;
|
||||
|
||||
IsrCount++;
|
||||
}
|
||||
|
||||
|
||||
/* end of file */
|
||||
@@ -0,0 +1,31 @@
|
||||
<projectSpec>
|
||||
<project
|
||||
name="F28069_TCM"
|
||||
device="TMS320F28069"
|
||||
configurations="DEBUG"
|
||||
launchWizard="False"
|
||||
linkerCommandFile=""
|
||||
compilerBuildOptions="--opt_level=off -I${C2000WARE_F2806X_ROOT1} -I${C2000WARE_F2806X_ROOT2} -I${C2000WARE_DCL_INCLUDE_ROOT} -v28 -ml -mt --float_support=fpu32 --define=DEBUG --diag_warning=225 --diag_suppress=10063 --display_error_number"
|
||||
linkerBuildOptions="--stack_size=0x400 --heap_size=0x200 --define RAM"
|
||||
>
|
||||
<pathVariable name="C2000WARE_F2806X_ROOT1" path="../../../../../../../device_support/f2806x/headers/include" scope="project" />
|
||||
<pathVariable name="C2000WARE_F2806X_ROOT2" path="../../../../../../../device_support/f2806x/common/include" scope="project" />
|
||||
<pathVariable name="C2000WARE_DCL_INCLUDE_ROOT" path="../../../include" scope="project" />
|
||||
<file action="copy" path="../../../../../../../device_support/f2806x/common/source/F2806x_CpuTimers.c" targetDirectory="" />
|
||||
<file action="copy" path="../../../../../../../device_support/f2806x/common/source/F2806x_DefaultIsr.c" targetDirectory="" />
|
||||
<file action="copy" path="../../../../../../../device_support/f2806x/headers/source/F2806x_GlobalVariableDefs.c" targetDirectory="" />
|
||||
<file action="copy" path="../../../../../../../device_support/f2806x/common/source/F2806x_PieCtrl.c" targetDirectory="" />
|
||||
<file action="copy" path="../../../../../../../device_support/f2806x/common/source/F2806x_PieVect.c" targetDirectory="" />
|
||||
<file action="copy" path="../../../../../../../device_support/f2806x/common/source/F2806x_SysCtrl.c" targetDirectory="" />
|
||||
<file action="copy" path="../../../../../../../device_support/f2806x/common/source/F2806x_DisInt.asm" targetDirectory="" />
|
||||
<file action="copy" path="../../../../../../../device_support/f2806x/common/source/F2806x_usDelay.asm" targetDirectory="" />
|
||||
<file action="copy" path="../../../../../../../device_support/f2806x/headers/cmd/F2806x_Headers_nonBIOS.cmd" targetDirectory="" />
|
||||
<file action="copy" path="../../../cmd/F28069_stdmem.cmd" targetDirectory="" />
|
||||
<file action="copy" path="../../../cmd/F28069_DCL.cmd" targetDirectory="" />
|
||||
<file action="copy" path="../../../source/DCL_index.asm" targetDirectory="" />
|
||||
<file action="copy" path="../../../source/DCL_frwlog.asm" targetDirectory="" />
|
||||
<file action="copy" path="../Example_F28069_TCM.c" targetDirectory="" />
|
||||
<file action="copy" path="../TCM_input.dat" targetDirectory="" />
|
||||
<file action="copy" path="../TCM_response.dat" targetDirectory="" />
|
||||
</project>
|
||||
</projectSpec>
|
||||
@@ -0,0 +1,133 @@
|
||||
/* Example_F28069_TCM.c
|
||||
*
|
||||
* Copyright (C) 2020 Texas Instruments Incorporated - http://www.ti.com/
|
||||
* ALL RIGHTS RESERVED
|
||||
*
|
||||
*/
|
||||
|
||||
#include "F2806x_Device.h"
|
||||
#include "F2806x_Examples.h"
|
||||
#include "F2806x_GlobalPrototypes.h"
|
||||
#include "DCLF32.h"
|
||||
#include "DCL_fdlog.h"
|
||||
#include "DCL_TCM.h"
|
||||
|
||||
#define DATA_LENGTH 1601
|
||||
#define TCM_DATA_LENGTH 350
|
||||
#define ISR_FREQ 10000.0f
|
||||
|
||||
// input reference data
|
||||
#pragma DATA_SECTION(r_array, "PDataLogSection")
|
||||
float r_array[DATA_LENGTH];
|
||||
FDLOG rBuf = FDLOG_DEFAULTS;
|
||||
|
||||
// feedback data
|
||||
#pragma DATA_SECTION(y_array, "QDataLogSection")
|
||||
float y_array[DATA_LENGTH];
|
||||
FDLOG yBuf = FDLOG_DEFAULTS;
|
||||
|
||||
// servo loop error
|
||||
#pragma DATA_SECTION(e_array, "RDataLogSection")
|
||||
float e_array[DATA_LENGTH];
|
||||
FDLOG eBuf = FDLOG_DEFAULTS;
|
||||
|
||||
// transient data
|
||||
#pragma DATA_SECTION(d_array, "SDataLogSection")
|
||||
float d_array[DATA_LENGTH];
|
||||
FDLOG dBuf = FDLOG_DEFAULTS;
|
||||
|
||||
interrupt void control_Isr(void);
|
||||
|
||||
// global variables
|
||||
long IdleLoopCount = 0;
|
||||
long IsrCount = 0;
|
||||
float rk;
|
||||
float yk;
|
||||
float ek;
|
||||
TCM tcm1 = TCM_DEFAULTS;
|
||||
float P1;
|
||||
float P2;
|
||||
float P3;
|
||||
|
||||
|
||||
/* main */
|
||||
main()
|
||||
{
|
||||
// initialise system
|
||||
InitSysCtrl();
|
||||
DINT;
|
||||
IER = 0x0000;
|
||||
IFR = 0x0000;
|
||||
InitPieCtrl();
|
||||
InitPieVectTable();
|
||||
EALLOW;
|
||||
PieVectTable.TINT0 = &control_Isr;
|
||||
EDIS;
|
||||
|
||||
// configure CPU timer 0
|
||||
InitCpuTimers();
|
||||
ConfigCpuTimer(&CpuTimer0, 90.0, ISR_FREQ);
|
||||
|
||||
// initialise data arrays
|
||||
DCL_initLog(&rBuf, r_array, DATA_LENGTH);
|
||||
DCL_initLog(&yBuf, y_array, DATA_LENGTH);
|
||||
DCL_initLog(&eBuf, e_array, DATA_LENGTH);
|
||||
DCL_initLog(&dBuf, d_array, TCM_DATA_LENGTH);
|
||||
DCL_clearLog(&eBuf);
|
||||
|
||||
// initialise TCM
|
||||
DCL_initTCM(&tcm1, dBuf.fptr, TCM_DATA_LENGTH, 25, -0.001f, 0.001f);
|
||||
DCL_armTCM(&tcm1);
|
||||
|
||||
// enable interrupts
|
||||
PieCtrlRegs.PIEIER1.bit.INTx7 = 1;
|
||||
IER |= M_INT1;
|
||||
EINT;
|
||||
StartCpuTimer0();
|
||||
|
||||
// idle loop
|
||||
while(1)
|
||||
{
|
||||
IdleLoopCount++;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
||||
/* control ISR: triggered by CPU timer 0 */
|
||||
interrupt void control_Isr(void)
|
||||
{
|
||||
// clear timer flag & acknowledge interrupt
|
||||
CpuTimer0Regs.TCR.bit.TIF = 1;
|
||||
PieCtrlRegs.PIEACK.all = PIEACK_GROUP1;
|
||||
IsrCount++;
|
||||
|
||||
// read feedback data from log
|
||||
rk = DCL_freadLog(&rBuf);
|
||||
yk = DCL_freadLog(&yBuf);
|
||||
|
||||
// run the TCM
|
||||
DCL_runTCM(&tcm1, yk);
|
||||
|
||||
// log the servo error
|
||||
ek = rk - yk;
|
||||
DCL_fwriteLog(&eBuf, ek);
|
||||
|
||||
// if data read-out complete
|
||||
if FDLOG_START(&rBuf)
|
||||
{
|
||||
// stop interrupt
|
||||
PieCtrlRegs.PIEIER1.bit.INTx7 = 0;
|
||||
|
||||
// compute performance indices
|
||||
P1 = DCL_runITAE_C1(&eBuf, 1/ISR_FREQ);
|
||||
P2 = DCL_runIAE_C1(&eBuf);
|
||||
P3 = DCL_runIES_C1(&eBuf);
|
||||
|
||||
// place preak-point here
|
||||
asm(" NOP");
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/* end of file */
|
||||
File diff suppressed because it is too large.
Load diff
File diff suppressed because it is too large.
Load diff
+27
@@ -0,0 +1,27 @@
|
||||
<projectSpec>
|
||||
<project
|
||||
name="F28388D_PIDF64"
|
||||
device="TMS320F28388D"
|
||||
configurations="DEBUG"
|
||||
cgtVersion="22.6.0.LTS"
|
||||
outputFormat="ELF"
|
||||
launchWizard="False"
|
||||
linkerCommandFile=""
|
||||
compilerBuildOptions="--opt_level=off -I${C2000WARE_DLIB_ROOT} -I${C2000WARE_F2838X_ROOT1} -I${C2000WARE_F2838X_ROOT2} -I${C2000WARE_DCL_INCLUDE_ROOT} -v28 -ml -mt --float_support=fpu64 --define=DEBUG --diag_warning=225 --diag_suppress=10063 --display_error_number --abi=eabi --define=CPU1"
|
||||
linkerBuildOptions="--stack_size=0x400 --heap_size=0x200 --define RAM"
|
||||
>
|
||||
<pathVariable name="C2000WARE_DLIB_ROOT" path="../../../../../../../driverlib/f2838x/driverlib" scope="project" />
|
||||
<pathVariable name="C2000WARE_F2838X_ROOT1" path="../../../../../../../device_support/f2838x/headers/include" scope="project" />
|
||||
<pathVariable name="C2000WARE_F2838X_ROOT2" path="../../../../../../../device_support/f2838x/common/include" scope="project" />
|
||||
<pathVariable name="C2000WARE_DCL_INCLUDE_ROOT" path="../../../include" scope="project" />
|
||||
<file action="copy" path="../../../../../../../device_support/f2838x/common/include/driverlib.h" targetDirectory="" />
|
||||
<file action="copy" path="../../../../../../../device_support/f2838x/common/include/device.h" targetDirectory="" />
|
||||
<file action="copy" path="../../../../../../../device_support/f2838x/common/source/device.c" targetDirectory="" />
|
||||
<file action="copy" path="../../../../../../../device_support/f2838x/common/source/f2838x_codestartbranch.asm" targetDirectory="" />
|
||||
<file action="copy" path="../../../../../../../driverlib/f2838x/driverlib/ccs/Debug/driverlib.lib" targetDirectory="" />
|
||||
<file action="copy" path="../Example_F28388D_PIDF64.c" targetDirectory="" />
|
||||
<file action="copy" path="../../../cmd/F28388D_stdmem_cpu1.cmd" targetDirectory="" />
|
||||
<file action="copy" path="../../../cmd/F28388D_DCL.cmd" targetDirectory="" />
|
||||
<file action="copy" path="../../../source/DCL_error.c" targetDirectory="" />
|
||||
</project>
|
||||
</projectSpec>
|
||||
@@ -0,0 +1,139 @@
|
||||
/* Example_F28388D_PIDF64.c
|
||||
*
|
||||
* Copyright (C) 2020 Texas Instruments Incorporated - http://www.ti.com/
|
||||
* ALL RIGHTS RESERVED
|
||||
*
|
||||
*/
|
||||
|
||||
#include "device.h"
|
||||
#include "DCLF64.h"
|
||||
#include "DCL_fdlog64.h"
|
||||
|
||||
#define ISR_PRD 10000
|
||||
|
||||
// data logs
|
||||
#pragma DATA_SECTION(p_array, "PDataLogSection")
|
||||
#pragma DATA_SECTION(q_array, "QDataLogSection")
|
||||
#pragma DATA_SECTION(r_array, "RDataLogSection")
|
||||
#pragma DATA_SECTION(s_array, "SDataLogSection")
|
||||
|
||||
// section addresses from linker file
|
||||
extern unsigned int pData_start;
|
||||
extern unsigned int qData_start;
|
||||
extern unsigned int rData_start;
|
||||
extern unsigned int sData_start;
|
||||
|
||||
// data arrays
|
||||
float64_t p_array[FDLOG64_DEFAULT_SIZE];
|
||||
float64_t q_array[FDLOG64_DEFAULT_SIZE];
|
||||
float64_t r_array[FDLOG64_DEFAULT_SIZE];
|
||||
float64_t s_array[FDLOG64_DEFAULT_SIZE];
|
||||
|
||||
// data log structs
|
||||
FDLOG64 pBuf = FDLOG64_DEFAULTS;
|
||||
FDLOG64 qBuf = FDLOG64_DEFAULTS;
|
||||
FDLOG64 rBuf = FDLOG64_DEFAULTS;
|
||||
FDLOG64 sBuf = FDLOG64_DEFAULTS;
|
||||
|
||||
// global variables
|
||||
uint32_t IdleLoopCount = 0L;
|
||||
uint32_t IsrCount = 0L;
|
||||
float64_t rk = 0.25f;
|
||||
float64_t yk;
|
||||
float64_t lk;
|
||||
float64_t uk;
|
||||
DCL_PIDF64 pid = PIDF64_DEFAULTS;
|
||||
|
||||
// function prototypes
|
||||
__interrupt void control_isr(void);
|
||||
void configCPUTimer(uint32_t, uint32_t);
|
||||
|
||||
|
||||
void main(void)
|
||||
{
|
||||
// device initialization
|
||||
Device_init();
|
||||
SysCtl_disableWatchdog();
|
||||
Device_initGPIO();
|
||||
Interrupt_initModule();
|
||||
DINT;
|
||||
Interrupt_initVectorTable();
|
||||
|
||||
// configure CPU timer 0 interrupt
|
||||
Interrupt_register(INT_TIMER0, &control_isr);
|
||||
configCPUTimer(CPUTIMER0_BASE, ISR_PRD);
|
||||
CPUTimer_enableInterrupt(CPUTIMER0_BASE);
|
||||
Interrupt_enable(INT_TIMER0);
|
||||
|
||||
// initialize data logs
|
||||
DCL_initLog64(&pBuf, (float64_t *) &pData_start, FDLOG64_DEFAULT_SIZE);
|
||||
DCL_initLog64(&qBuf, (float64_t *) &qData_start, FDLOG64_DEFAULT_SIZE);
|
||||
DCL_initLog64(&rBuf, (float64_t *) &rData_start, FDLOG64_DEFAULT_SIZE);
|
||||
DCL_initLog64(&sBuf, (float64_t *) &sData_start, FDLOG64_DEFAULT_SIZE);
|
||||
DCL_fillLog64(&rBuf, 1.0);
|
||||
DCL_clearLog64(&sBuf);
|
||||
|
||||
// controller initialization
|
||||
pid.Kp = 5.4;
|
||||
pid.Ki = 0.0014;
|
||||
pid.Kd = 0.25;
|
||||
pid.Kr = 1.0;
|
||||
pid.c1 = 628.2199;
|
||||
pid.c2 = -0.9997;
|
||||
pid.c1 = 151.7094;
|
||||
pid.c2 = 0.5171;
|
||||
|
||||
DCL_BREAK_POINT;
|
||||
|
||||
// enable interrupt
|
||||
CPUTimer_startTimer(CPUTIMER0_BASE);
|
||||
EINT;
|
||||
ERTM;
|
||||
|
||||
// idle loop
|
||||
do {
|
||||
if (FDLOG64_END(&sBuf))
|
||||
{
|
||||
DCL_BREAK_POINT;
|
||||
}
|
||||
|
||||
IdleLoopCount++;
|
||||
} while(1);
|
||||
}
|
||||
|
||||
|
||||
// control interrupt service routine
|
||||
__interrupt void control_isr(void)
|
||||
{
|
||||
// read inputs
|
||||
rk = DCL_readLog64(&pBuf);
|
||||
yk = DCL_readLog64(&qBuf);
|
||||
lk = DCL_readLog64(&rBuf);
|
||||
|
||||
// run PIDF64 controller
|
||||
uk = DCL_runPIDF64_S1(&pid, rk, yk, lk);
|
||||
|
||||
// store the control
|
||||
DCL_writeLog64(&sBuf, uk);
|
||||
|
||||
// stop timer at end of buffer
|
||||
if (FDLOG64_END(&sBuf))
|
||||
{
|
||||
CPUTimer_stopTimer(CPUTIMER0_BASE);
|
||||
}
|
||||
|
||||
IsrCount++;
|
||||
Interrupt_clearACKGroup(INTERRUPT_ACK_GROUP1);
|
||||
}
|
||||
|
||||
|
||||
// CPU timer configuration
|
||||
void configCPUTimer(uint32_t cpuTimer, uint32_t period)
|
||||
{
|
||||
CPUTimer_setPeriod(cpuTimer, period);
|
||||
CPUTimer_setPreScaler(cpuTimer, 0);
|
||||
CPUTimer_stopTimer(cpuTimer);
|
||||
CPUTimer_reloadTimerCounter(cpuTimer);
|
||||
}
|
||||
|
||||
/* end of file */
|
||||
File diff suppressed because it is too large.
Load diff
File diff suppressed because it is too large.
Load diff
+29
@@ -0,0 +1,29 @@
|
||||
<projectSpec>
|
||||
<project
|
||||
name="F28P55x_DF22"
|
||||
device="TMS320F28P550SJ9"
|
||||
cgtVersion="22.6.0.LTS"
|
||||
outputFormat="ELF"
|
||||
launchWizard="False"
|
||||
linkerCommandFile=""
|
||||
>
|
||||
<configuration name="CPU1_RAM" compilerBuildOptions="--opt_level=off -I${PROJECT_ROOT}/device -I${C2000WARE_DLIB_ROOT} -I${DCL_INCLUDE} -v28 -ml -mt --float_support=fpu32 --tmu_support=tmu0 --define=CPU1 --define=DEBUG --define RAM --diag_warning=225 --diag_suppress=10063" linkerBuildOptions="--entry_point code_start --stack_size=0x200 --heap_size=0x100 "/>
|
||||
<pathVariable name="C2000WARE_DLIB_ROOT" path="../../../../../../../driverlib/f28p55x/driverlib/" scope="project"/>
|
||||
<pathVariable name="DCL_INCLUDE" path="../../../include" scope="project"/>
|
||||
<pathVariable name="C2000WARE_DEVICE_SUPPORT" path="../../../../../../../device_support" scope="project"/>
|
||||
<file action="copy" path="C2000WARE_DEVICE_SUPPORT/f28p55x/common/include/driverlib.h" targetDirectory="device"/>
|
||||
<file action="copy" path="C2000WARE_DEVICE_SUPPORT/f28p55x/common/include/device.h" targetDirectory="device"/>
|
||||
<file action="copy" path="C2000WARE_DEVICE_SUPPORT/f28p55x/common/source/device.c" targetDirectory="device"/>
|
||||
<file action="copy" path="C2000WARE_DEVICE_SUPPORT/f28p55x/common/source/f28p55x_codestartbranch.asm" targetDirectory="device"/>
|
||||
<file action="copy" path="C2000WARE_DEVICE_SUPPORT/f28p55x/common/targetConfigs/TMS320F28P550SJ9.ccxml" targetDirectory="targetConfigs"/>
|
||||
<file action="link" path="C2000WARE_DLIB_ROOT/ccs/Debug/driverlib.lib" targetDirectory=""/>
|
||||
<file action="copy" path="../Example_DF22.c" targetDirectory=""/>
|
||||
<file action="copy" path="../../../source/DCL_error.c" targetDirectory=""/>
|
||||
<file action="copy" path="../../../source/DCL_clamp_C1.asm" targetDirectory="" />
|
||||
<file action="copy" path="../../../source/DCL_DF22_C1.asm" targetDirectory="" />
|
||||
<file action="copy" path="../../../source/DCL_DF22_C2C3.asm" targetDirectory="" />
|
||||
<file action="copy" path="../DF22_edata.dat" targetDirectory="" />
|
||||
<file action="copy" path="C2000WARE_DEVICE_SUPPORT/f28p55x/common/cmd/28p55x_generic_ram_lnk.cmd" targetDirectory=""/>
|
||||
<file action="copy" path="../../../cmd/F28P55x_DCL.cmd" targetDirectory=""/>
|
||||
</project>
|
||||
</projectSpec>
|
||||
File diff suppressed because it is too large.
Load diff
@@ -0,0 +1,168 @@
|
||||
/* Example_DF22.c
|
||||
*
|
||||
* Copyright (C) 2020 Texas Instruments Incorporated - http://www.ti.com/
|
||||
* ALL RIGHTS RESERVED
|
||||
*
|
||||
*/
|
||||
|
||||
#include "driverlib.h"
|
||||
#include "device.h"
|
||||
#include "DCLF32.h"
|
||||
#include "DCL_fdlog.h"
|
||||
|
||||
#define DATA_LENGTH 1601
|
||||
|
||||
// input data
|
||||
#pragma DATA_SECTION(e_array, "PDataLogSection")
|
||||
float e_array[DATA_LENGTH];
|
||||
FDLOG eBuf = FDLOG_DEFAULTS;
|
||||
|
||||
// full controller results
|
||||
#pragma DATA_SECTION(u1_array, "QDataLogSection")
|
||||
float u1_array[DATA_LENGTH];
|
||||
FDLOG u1Buf = FDLOG_DEFAULTS;
|
||||
|
||||
// pre-computed controller results
|
||||
#pragma DATA_SECTION(u2_array, "RDataLogSection")
|
||||
float u2_array[DATA_LENGTH];
|
||||
FDLOG u2Buf = FDLOG_DEFAULTS;
|
||||
|
||||
// controller difference data
|
||||
#pragma DATA_SECTION(d_array, "SDataLogSection")
|
||||
float d_array[DATA_LENGTH];
|
||||
FDLOG dBuf = FDLOG_DEFAULTS;
|
||||
|
||||
// function prototypes
|
||||
void initCPUTimer0(float freq, float period);
|
||||
extern interrupt void control_Isr(void);
|
||||
|
||||
// global variables
|
||||
long IdleLoopCount = 0;
|
||||
long IsrCount = 0;
|
||||
int complete = 0;
|
||||
float ek;
|
||||
float u1k;
|
||||
float u2k;
|
||||
float dk;
|
||||
float upperLim;
|
||||
float lowerLim;
|
||||
uint16_t v;
|
||||
DCL_DF22 controller1 = DF22_DEFAULTS;
|
||||
DCL_DF22 controller2 = DF22_DEFAULTS;
|
||||
|
||||
|
||||
/* main */
|
||||
main()
|
||||
{
|
||||
// device initialization
|
||||
Device_init();
|
||||
Interrupt_initModule();
|
||||
Interrupt_initVectorTable();
|
||||
|
||||
// initialize CPU timer0 & interrupt
|
||||
Interrupt_register(INT_TIMER0, &control_Isr);
|
||||
initCPUTimer0( DEVICE_SYSCLK_FREQ, 1000);
|
||||
CPUTimer_enableInterrupt(CPUTIMER0_BASE);
|
||||
Interrupt_enable(INT_TIMER0);
|
||||
|
||||
// initialise data arrays
|
||||
DCL_initLog(&eBuf, e_array, DATA_LENGTH);
|
||||
DCL_initLog(&u1Buf, u1_array, DATA_LENGTH);
|
||||
DCL_initLog(&u2Buf, u2_array, DATA_LENGTH);
|
||||
DCL_initLog(&dBuf, d_array, DATA_LENGTH);
|
||||
DCL_clearLog(&u1Buf);
|
||||
DCL_clearLog(&u2Buf);
|
||||
DCL_fillLog(&dBuf, 1.234567f);
|
||||
|
||||
// initialise full controller
|
||||
controller1.a1 = -1.9417f;
|
||||
controller1.a2 = 0.9417f;
|
||||
controller1.b0 = 9.8549f;
|
||||
controller1.b1 = -19.4165f;
|
||||
controller1.b2 = 9.5636f;
|
||||
|
||||
// initialise pre-computed controller
|
||||
controller2.a1 = controller1.a1;
|
||||
controller2.a2 = controller1.a2;
|
||||
controller2.b0 = controller1.b0;
|
||||
controller2.b1 = controller1.b1;
|
||||
controller2.b2 = controller1.b2;
|
||||
|
||||
// clamp limits
|
||||
upperLim = 1000.0f;
|
||||
lowerLim = -1000.0f;
|
||||
|
||||
// enable global interrupts
|
||||
EINT;
|
||||
ERTM;
|
||||
CPUTimer_startTimer(CPUTIMER0_BASE);
|
||||
|
||||
while(1)
|
||||
{
|
||||
IdleLoopCount++;
|
||||
|
||||
if (complete == 1)
|
||||
{
|
||||
DCL_BREAK_POINT;
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
// initialize CPU timer0
|
||||
void initCPUTimer0(float freq, float period)
|
||||
{
|
||||
uint32_t temp;
|
||||
|
||||
temp = (uint32_t)(freq / 1000000 * period);
|
||||
CPUTimer_setPeriod(CPUTIMER0_BASE, temp);
|
||||
CPUTimer_setPreScaler(CPUTIMER0_BASE, 0);
|
||||
CPUTimer_stopTimer(CPUTIMER0_BASE);
|
||||
CPUTimer_reloadTimerCounter(CPUTIMER0_BASE);
|
||||
CPUTimer_setEmulationMode(CPUTIMER0_BASE,
|
||||
CPUTIMER_EMULATIONMODE_STOPAFTERNEXTDECREMENT);
|
||||
CPUTimer_enableInterrupt(CPUTIMER0_BASE);
|
||||
}
|
||||
|
||||
/* control ISR: triggered by CPU timer 0 */
|
||||
interrupt void control_Isr(void)
|
||||
{
|
||||
|
||||
// read data & run controllers
|
||||
if (complete == 0)
|
||||
{
|
||||
// read input data
|
||||
ek = DCL_readLog(&eBuf);
|
||||
|
||||
// run full controller
|
||||
u1k = DCL_runDF22_C1(&controller1, ek);
|
||||
|
||||
// run pre-computed controller
|
||||
u2k = DCL_runDF22_C2(&controller2, ek);
|
||||
v = DCL_runClamp_C1(&u2k, upperLim, lowerLim);
|
||||
if (0U == v)
|
||||
{
|
||||
DCL_runDF22_C3(&controller2, ek, u2k);
|
||||
}
|
||||
|
||||
// compute difference
|
||||
dk = u1k - u2k;
|
||||
|
||||
// store results
|
||||
DCL_writeLog(&u1Buf, u1k);
|
||||
DCL_writeLog(&u2Buf, u2k);
|
||||
DCL_writeLog(&dBuf, dk);
|
||||
|
||||
// check if data log is full
|
||||
if FDLOG_START(&dBuf)
|
||||
{
|
||||
complete = 1;
|
||||
}
|
||||
}
|
||||
|
||||
IsrCount++;
|
||||
Interrupt_clearACKGroup(INTERRUPT_ACK_GROUP1);
|
||||
}
|
||||
|
||||
|
||||
/* end of file */
|
||||
+30
@@ -0,0 +1,30 @@
|
||||
<projectSpec>
|
||||
<project
|
||||
name="F28P55x_PI"
|
||||
device="TMS320F28P550SJ9"
|
||||
cgtVersion="22.6.0.LTS"
|
||||
outputFormat="ELF"
|
||||
launchWizard="False"
|
||||
linkerCommandFile=""
|
||||
enableSysConfigTool="true"
|
||||
sysConfigBuildOptions="--product ${C2000WARE_ROOT}/.metadata/sdk.json --device F28P55x --package 128PDT --part F28P55x_128PDT"
|
||||
>
|
||||
<configuration name="CPU1_RAM" compilerBuildOptions="--opt_level=off -I${C2000WARE_ROOT} -v28 -ml -mt --cla_support=cla2 --float_support=fpu32 --tmu_support=tmu1 --gen_func_subsections=on --define=DEBUG --define=RAM --define=generic_ram_lnk --diag_warning=225 --diag_suppress=10063" linkerBuildOptions="--entry_point code_start --stack_size=0x200 --heap_size=0x100 --define=RAM -i${C2000WARE_ROOT} -i${PROJECT_BUILD_DIR}/syscfg -lc2000ware_libraries.cmd.genlibs -lboard.cmd.genlibs --define=generic_ram_lnk"/>
|
||||
<configuration name="CPU1_FLASH" compilerBuildOptions="--opt_level=off -I${C2000WARE_ROOT} -v28 -ml -mt --cla_support=cla2 --float_support=fpu32 --tmu_support=tmu1 --gen_func_subsections=on --define=DEBUG --define=_FLASH --define=generic_flash_lnk --diag_warning=225 --diag_suppress=10063" linkerBuildOptions="--entry_point code_start --stack_size=0x200 --heap_size=0x100 --define=_FLASH -i${C2000WARE_ROOT} -i${PROJECT_BUILD_DIR}/syscfg -lc2000ware_libraries.cmd.genlibs -lboard.cmd.genlibs -ldevice_cmd.cmd.genlibs --define=generic_flash_lnk"/>
|
||||
|
||||
<pathVariable name="C2000WARE_ROOT" path="../../../../../../../" scope="project" />
|
||||
<pathVariable name="C2000WARE_DLIB_ROOT" path="../../../../../../../driverlib/f28p55x/driverlib/" scope="project"/>
|
||||
<pathVariable name="CLB_SYSCFG_ROOT" path="../../../../../../../utilities/clb_tool/clb_syscfg/" scope="project" />
|
||||
<pathVariable name="SYSTEMC_INSTALL" path="../../../../../../../utilities/clb_tool/clb_syscfg/systemc-2.3.3" scope="project" />
|
||||
<pathVariable name="CLB_SIM_COMPILER" path="C:/TDM-GCC-64/bin" scope="project" />
|
||||
<buildVariable name="CLB_DEBUG" value="0" scope="project" />
|
||||
<buildVariable name="GENERATE_DIAGRAM" value="0" scope="project" />
|
||||
<file action="copy" path="../../../../../../../device_support/f28p55x/common/targetConfigs" targetDirectory="targetConfigs"/>
|
||||
<file action="copy" path="../pi_test.h" targetDirectory=""/>
|
||||
<file action="copy" path="../pi_test.c" targetDirectory=""/>
|
||||
<file action="copy" path="../f28p55x_pi.syscfg" targetDirectory=""/>
|
||||
<file action="copy" path="../data/PI_ctl-1.dat" targetDirectory="data"/>
|
||||
<file action="copy" path="../data/PI_rk-1.dat" targetDirectory="data"/>
|
||||
<file action="copy" path="../data/PI_yk-1.dat" targetDirectory="data"/>
|
||||
</project>
|
||||
</projectSpec>
|
||||
File diff suppressed because it is too large.
Load diff
File diff suppressed because it is too large.
Load diff
File diff suppressed because it is too large.
Load diff
@@ -0,0 +1,81 @@
|
||||
/**
|
||||
* These arguments were used when this file was generated. They will be automatically applied on subsequent loads
|
||||
* via the GUI or CLI. Run CLI with '--help' for additional information on how to override these arguments.
|
||||
* @cliArgs --device "F28P55x" --package "100PZ" --part "F28P55x_100PZ" --context "system" --product "C2000WARE@5.02.00.00"
|
||||
* @versions {"tool":"1.20.0+3514"}
|
||||
*/
|
||||
|
||||
/**
|
||||
* Import the modules used in this configuration.
|
||||
*/
|
||||
const cputimer = scripting.addModule("/driverlib/cputimer.js", {}, false);
|
||||
const cputimer1 = cputimer.addInstance();
|
||||
const device_support = scripting.addModule("/driverlib/device_support.js");
|
||||
const sysctl = scripting.addModule("/driverlib/sysctl.js");
|
||||
const controller = scripting.addModule("/libraries/control/dcl/controller.js", {}, false);
|
||||
const controller1 = controller.addInstance();
|
||||
const logger = scripting.addModule("/libraries/control/dcl/logger.js", {}, false);
|
||||
const logger1 = logger.addInstance();
|
||||
const logger2 = logger.addInstance();
|
||||
const logger3 = logger.addInstance();
|
||||
const logger4 = logger.addInstance();
|
||||
const CMD = scripting.addModule("/utilities/cmd_tool/cmd_syscfg/source/CMD");
|
||||
const CMD1 = CMD.addInstance();
|
||||
|
||||
/**
|
||||
* Write custom configuration values to the imported modules.
|
||||
*/
|
||||
cputimer1.$name = "myCPUTIMER0";
|
||||
cputimer1.enableInterrupt = true;
|
||||
cputimer1.startTimer = true;
|
||||
cputimer1.timerPeriod = 10;
|
||||
cputimer1.registerInterrupts = true;
|
||||
cputimer1.emulationMode = "CPUTIMER_EMULATIONMODE_STOPATZERO";
|
||||
cputimer1.timerInt.$name = "control_Isr";
|
||||
cputimer1.timerInt.interruptHandler = "control_Isr";
|
||||
cputimer1.timerInt.enableInterrupt = true;
|
||||
|
||||
controller1.controllerChoice = "PI";
|
||||
controller1.$name = "myController0";
|
||||
controller1.Kp = "2.5f";
|
||||
controller1.Ki = "0.01f";
|
||||
controller1.Umax = "2.0f";
|
||||
controller1.Umin = "-2.0f";
|
||||
|
||||
logger1.$name = "rkLog";
|
||||
logger1.arrEn = false;
|
||||
logger1.linkerVal = "LoggerDataSection";
|
||||
logger1.logSize = 800;
|
||||
|
||||
logger2.arrEn = false;
|
||||
logger2.$name = "ykLog";
|
||||
logger2.linkerVal = "LoggerDataSection";
|
||||
logger2.logSize = 800;
|
||||
|
||||
logger3.arrEn = false;
|
||||
logger3.$name = "ctlLog";
|
||||
logger3.linkerVal = "LoggerDataSection";
|
||||
logger3.logSize = 800;
|
||||
|
||||
logger4.$name = "outLog";
|
||||
logger4.fillEn = true;
|
||||
logger4.linkerEn = true;
|
||||
logger4.linkerVal = "LoggerDataSection";
|
||||
logger4.logSize = 800;
|
||||
|
||||
CMD1.$name = "generic_ram_lnk";
|
||||
CMD1.sectionMemory_const = ["RAMLS5","RAMLS6"];
|
||||
CMD1.sectionMemory_ramfunc = ["RAMM0"];
|
||||
CMD1.sectionMemory_init_array = ["RAMM0"];
|
||||
CMD1.sectionMemory_switch = ["RAMM0"];
|
||||
CMD1.sectionMemory_sysmem = ["RAMLS4"];
|
||||
CMD1.sectionMemory_stack = ["RAMLS0"];
|
||||
CMD1.sectionMemory_bss = ["RAMGS1","RAMLS3","RAMLS4","RAMLS5"];
|
||||
CMD1.sectionMemory_data = ["RAMGS2","RAMLS5","RAMLS6","RAMLS7","RAMLS8"];
|
||||
CMD1.sectionMemory_cinit = ["RAMGS1"];
|
||||
CMD1.sectionMemory_text = ["RAMLS0","RAMLS1","RAMLS2","RAMLS3","RAMLS4","RAMLS5","RAMLS6","RAMLS7","RAMLS8","RAMLS9"];
|
||||
CMD1.userSection.create(2);
|
||||
CMD1.userSection[0].$name = "LoggerDataSection";
|
||||
CMD1.userSection[0].sectionMemory = ["RAMGS3"];
|
||||
CMD1.userSection[1].sectionMemory = ["RAMM0"];
|
||||
CMD1.userSection[1].$name = "dclfuncs";
|
||||
@@ -0,0 +1,192 @@
|
||||
//#############################################################################
|
||||
//! \file pi_test.c
|
||||
//!
|
||||
//!
|
||||
//! This example demonstrates how to use DCL's PI controller along with SysConfig
|
||||
//! setup
|
||||
//
|
||||
// Group: C2000
|
||||
// Target Family: F28P55X
|
||||
//
|
||||
//#############################################################################
|
||||
//
|
||||
//
|
||||
// $Copyright: Copyright (C) 2024 Texas Instruments Incorporated -
|
||||
// http://www.ti.com/ ALL RIGHTS RESERVED $
|
||||
//#############################################################################
|
||||
|
||||
|
||||
//*****************************************************************************
|
||||
// includes
|
||||
//*****************************************************************************
|
||||
#include "driverlib.h"
|
||||
#include "device.h"
|
||||
#include "board.h"
|
||||
#include "c2000ware_libraries.h"
|
||||
#include "stdio.h"
|
||||
|
||||
#include "pi_test.h"
|
||||
|
||||
//!
|
||||
//! \addtogroup DCL_EXAMPLES PI controller example
|
||||
|
||||
// @{
|
||||
|
||||
|
||||
uint16_t currIdx = 0;
|
||||
uint16_t completed = 0;
|
||||
int16_t errors = -1;
|
||||
|
||||
void Init_DCL_Logger(void)
|
||||
{
|
||||
//
|
||||
// Initialize Log pointers to the data buffer
|
||||
//
|
||||
DCL_initLog(&rkLog, (float32_t*)rkLogArr, DATA_LENGTH);
|
||||
DCL_initLog(&ykLog, (float32_t*)ykLogArr, DATA_LENGTH);
|
||||
DCL_initLog(&ctlLog, (float32_t*)ctlLogArr, DATA_LENGTH);
|
||||
DCL_initLog(&outLog, (float32_t*)outLogArr, DATA_LENGTH);
|
||||
|
||||
// Reset PI controller as well
|
||||
DCL_resetPI(&myController0);
|
||||
}
|
||||
|
||||
int Run_PI_Logger()
|
||||
{
|
||||
|
||||
|
||||
//
|
||||
// rk = Target referenced value
|
||||
// yk = Current feedback value
|
||||
// uk = Output control effort
|
||||
//
|
||||
float32_t rk,yk,uk;
|
||||
|
||||
//
|
||||
// Read the input data buffers
|
||||
//
|
||||
rk = DCL_freadLog(&rkLog);
|
||||
yk = DCL_freadLog(&ykLog);
|
||||
|
||||
//
|
||||
// Run the controller
|
||||
// Equivalent to uk = DCL_runPI_series(ctrl_handle, rk, yk);
|
||||
//
|
||||
uk = DCL_runPI_C1(&myController0, rk, yk);
|
||||
|
||||
//
|
||||
// Write the results to the output buffer
|
||||
//
|
||||
DCL_fwriteLog(&outLog, uk);
|
||||
|
||||
return 1;
|
||||
}
|
||||
|
||||
int Compare_Results()
|
||||
{
|
||||
int i;
|
||||
|
||||
//
|
||||
// Reset the log pointer so it starts from the beginning
|
||||
//
|
||||
DCL_resetLog(&outLog);
|
||||
|
||||
//
|
||||
// Check output against expected output with tolerance (1e-06)
|
||||
//
|
||||
int errors = 0;
|
||||
for (i = 0; i < NUM_ELEMENTS; i++)
|
||||
{
|
||||
float32_t output = DCL_freadLog(&outLog); // outLogArr[i]
|
||||
float32_t expected = DCL_freadLog(&ctlLog); // ctlLogArr[i]
|
||||
float32_t error = fabsf(output - expected);
|
||||
if (error > EPSILON)
|
||||
{
|
||||
errors++;
|
||||
printf("FAIL at sample %d, outputs %f, should be %f\n", i, output, expected);
|
||||
}
|
||||
}
|
||||
|
||||
return errors;
|
||||
}
|
||||
|
||||
//
|
||||
// Main
|
||||
//
|
||||
void main(void)
|
||||
{
|
||||
//
|
||||
// Initialize device clock and peripherals
|
||||
//
|
||||
Device_init();
|
||||
|
||||
//
|
||||
// Disable pin locks and enable internal pull-ups.
|
||||
//
|
||||
Device_initGPIO();
|
||||
|
||||
//
|
||||
// Initialize PIE and clear PIE registers. Disables CPU interrupts.
|
||||
//
|
||||
Interrupt_initModule();
|
||||
|
||||
//
|
||||
// Initialize the PIE vector table with pointers to the shell Interrupt
|
||||
// Service Routines (ISR).
|
||||
//
|
||||
Interrupt_initVectorTable();
|
||||
|
||||
//
|
||||
// PinMux and Peripheral Initialization
|
||||
//
|
||||
Board_init();
|
||||
|
||||
//
|
||||
// C2000Ware Library initialization
|
||||
//
|
||||
C2000Ware_libraries_init();
|
||||
|
||||
//
|
||||
// DCL Logger Initialization
|
||||
//
|
||||
Init_DCL_Logger();
|
||||
|
||||
//
|
||||
// Enable Global Interrupt (INTM) and real time interrupt (DBGM)
|
||||
//
|
||||
EINT;
|
||||
ERTM;
|
||||
|
||||
while(1)
|
||||
{
|
||||
if (completed)
|
||||
{
|
||||
errors = Compare_Results();
|
||||
printf("PI test produced %d error\n",errors);
|
||||
DCL_BREAK_POINT;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// initialize CPU timer0 in sysconfig
|
||||
interrupt void control_Isr(void)
|
||||
{
|
||||
if (currIdx < NUM_ELEMENTS)
|
||||
{
|
||||
Run_PI_Logger();
|
||||
currIdx++;
|
||||
}
|
||||
else
|
||||
{
|
||||
completed = 1;
|
||||
Interrupt_disable(INT_myCPUTIMER0);
|
||||
}
|
||||
|
||||
Interrupt_clearACKGroup(INT_myCPUTIMER0_INTERRUPT_ACK_GROUP);
|
||||
}
|
||||
|
||||
// End of main
|
||||
|
||||
// @} //addtogroup
|
||||
|
||||
// End of file
|
||||
@@ -0,0 +1,88 @@
|
||||
/*
|
||||
* Copyright (C) 2023 Texas Instruments Incorporated - http://www.ti.com/
|
||||
*
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
* modification, are permitted provided that the following conditions
|
||||
* are met:
|
||||
*
|
||||
* * Redistributions of source code must retain the above copyright
|
||||
* notice, this list of conditions and the following disclaimer.
|
||||
*
|
||||
* * Redistributions in binary form must reproduce the above copyright
|
||||
* notice, this list of conditions and the following disclaimer in the
|
||||
* documentation and/or other materials provided with the
|
||||
* distribution.
|
||||
*
|
||||
* * Neither the name of Texas Instruments Incorporated nor the names of
|
||||
* its contributors may be used to endorse or promote products derived
|
||||
* from this software without specific prior written permission.
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
|
||||
* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
|
||||
* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
|
||||
* A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
|
||||
* OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
|
||||
* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
|
||||
* LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
|
||||
* DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
|
||||
* THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
||||
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
|
||||
* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
*/
|
||||
|
||||
#ifndef PI_TEST_H
|
||||
#define PI_TEST_H
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
#include "c2000ware_libraries.h"
|
||||
#include "stdint.h"
|
||||
#include "math.h"
|
||||
#include "stdio.h"
|
||||
|
||||
int PI_test(void);
|
||||
|
||||
//
|
||||
// User configurable values
|
||||
//
|
||||
#define DATA_LENGTH 800 //!< Size of total data inputs
|
||||
#define NUM_ELEMENTS 400 //!< The number of samples ran, cannot exceed DATA_LENGTH
|
||||
#define EPSILON 0.00001f
|
||||
|
||||
//
|
||||
// declared & initialized by sysconfig
|
||||
//
|
||||
extern DCL_PI myController0;
|
||||
extern float32_t outLogArr[DATA_LENGTH];
|
||||
|
||||
//
|
||||
// Allocate data sections and initialize data
|
||||
//
|
||||
#pragma DATA_SECTION(rkLogArr, "LoggerDataSection")
|
||||
float32_t rkLogArr[DATA_LENGTH] =
|
||||
{
|
||||
#include "data/PI_rk-1.dat"
|
||||
};
|
||||
|
||||
#pragma DATA_SECTION(ykLogArr, "LoggerDataSection")
|
||||
float32_t ykLogArr[DATA_LENGTH] =
|
||||
{
|
||||
#include "data/PI_yk-1.dat"
|
||||
};
|
||||
|
||||
#pragma DATA_SECTION(ctlLogArr, "LoggerDataSection")
|
||||
float32_t ctlLogArr[DATA_LENGTH] =
|
||||
{
|
||||
#include "data/PI_ctl-1.dat"
|
||||
};
|
||||
|
||||
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif // extern "C"
|
||||
|
||||
#endif
|
||||
+26
@@ -0,0 +1,26 @@
|
||||
<projectSpec>
|
||||
<project
|
||||
name="F28P55x_PI"
|
||||
device="TMS320F28P550SJ9"
|
||||
cgtVersion="22.6.0.LTS"
|
||||
outputFormat="ELF"
|
||||
launchWizard="False"
|
||||
linkerCommandFile=""
|
||||
enableSysConfigTool="true"
|
||||
sysConfigBuildOptions="--product ${C2000WARE_ROOT}/.metadata/sdk.json --device F28P55x --package 128PDT --part F28P55x_128PDT"
|
||||
>
|
||||
<configuration name="CPU1_RAM" compilerBuildOptions="--opt_level=off -I${C2000WARE_ROOT} -v28 -ml -mt --cla_support=cla2 --float_support=fpu32 --tmu_support=tmu1 --gen_func_subsections=on --define=DEBUG --define=RAM --define=generic_ram_lnk --diag_warning=225 --diag_suppress=10063" linkerBuildOptions="--entry_point code_start --stack_size=0x200 --heap_size=0x100 --define=RAM -i${C2000WARE_ROOT} -i${PROJECT_BUILD_DIR}/syscfg -lc2000ware_libraries.cmd.genlibs -lboard.cmd.genlibs --define=generic_ram_lnk"/>
|
||||
<configuration name="CPU1_FLASH" compilerBuildOptions="--opt_level=off -I${C2000WARE_ROOT} -v28 -ml -mt --cla_support=cla2 --float_support=fpu32 --tmu_support=tmu1 --gen_func_subsections=on --define=DEBUG --define=_FLASH --define=generic_flash_lnk --diag_warning=225 --diag_suppress=10063" linkerBuildOptions="--entry_point code_start --stack_size=0x200 --heap_size=0x100 --define=_FLASH -i${C2000WARE_ROOT} -i${PROJECT_BUILD_DIR}/syscfg -lc2000ware_libraries.cmd.genlibs -lboard.cmd.genlibs -ldevice_cmd.cmd.genlibs --define=generic_flash_lnk"/>
|
||||
|
||||
<pathVariable name="C2000WARE_ROOT" path="../../../../../../../" scope="project" />
|
||||
<pathVariable name="C2000WARE_DLIB_ROOT" path="../../../../../../../driverlib/f28p55x/driverlib/" scope="project"/>
|
||||
<pathVariable name="CLB_SYSCFG_ROOT" path="../../../../../../../utilities/clb_tool/clb_syscfg/" scope="project" />
|
||||
<pathVariable name="SYSTEMC_INSTALL" path="../../../../../../../utilities/clb_tool/clb_syscfg/systemc-2.3.3" scope="project" />
|
||||
<pathVariable name="CLB_SIM_COMPILER" path="C:/TDM-GCC-64/bin" scope="project" />
|
||||
<buildVariable name="CLB_DEBUG" value="0" scope="project" />
|
||||
<buildVariable name="GENERATE_DIAGRAM" value="0" scope="project" />
|
||||
<file action="copy" path="../../../../../../../device_support/f28p55x/common/targetConfigs" targetDirectory="targetConfigs"/>
|
||||
<file action="copy" path="../main.c" targetDirectory=""/>
|
||||
<file action="copy" path="../f28p55x_refgen.syscfg" targetDirectory=""/>
|
||||
</project>
|
||||
</projectSpec>
|
||||
+79
@@ -0,0 +1,79 @@
|
||||
/**
|
||||
* These arguments were used when this file was generated. They will be automatically applied on subsequent loads
|
||||
* via the GUI or CLI. Run CLI with '--help' for additional information on how to override these arguments.
|
||||
* @cliArgs --device "F28P55x" --package "100PZ" --part "F28P55x_100PZ" --context "system" --product "C2000WARE@5.02.00.00"
|
||||
* @versions {"tool":"1.20.0+3514"}
|
||||
*/
|
||||
|
||||
/**
|
||||
* Import the modules used in this configuration.
|
||||
*/
|
||||
const cputimer = scripting.addModule("/driverlib/cputimer.js", {}, false);
|
||||
const cputimer1 = cputimer.addInstance();
|
||||
const device_support = scripting.addModule("/driverlib/device_support.js");
|
||||
const sysctl = scripting.addModule("/driverlib/sysctl.js");
|
||||
const logger = scripting.addModule("/libraries/control/dcl/logger.js", {}, false);
|
||||
const logger1 = logger.addInstance();
|
||||
const logger2 = logger.addInstance();
|
||||
const logger3 = logger.addInstance();
|
||||
const refgen = scripting.addModule("/libraries/control/dcl/refgen.js", {}, false);
|
||||
const refgen1 = refgen.addInstance();
|
||||
const FPUfastRTS = scripting.addModule("/libraries/math/FPUfastRTS/FPUfastRTS.js", {}, false);
|
||||
const FPUfastRTS1 = FPUfastRTS.addInstance();
|
||||
const CMD = scripting.addModule("/utilities/cmd_tool/cmd_syscfg/source/CMD");
|
||||
const CMD1 = CMD.addInstance();
|
||||
|
||||
/**
|
||||
* Write custom configuration values to the imported modules.
|
||||
*/
|
||||
cputimer1.$name = "myCPUTIMER0";
|
||||
cputimer1.timerPeriod = 100;
|
||||
cputimer1.enableInterrupt = true;
|
||||
cputimer1.registerInterrupts = true;
|
||||
cputimer1.startTimer = true;
|
||||
cputimer1.timerInt.enableInterrupt = true;
|
||||
cputimer1.timerInt.$name = "timer_Isr";
|
||||
cputimer1.timerInt.interruptHandler = "timer_Isr";
|
||||
|
||||
logger1.$name = "LoggerSineA";
|
||||
logger1.logSize = 400;
|
||||
logger1.fillEn = true;
|
||||
logger1.linkerEn = true;
|
||||
logger1.linkerVal = "LoggerDataSection";
|
||||
|
||||
logger2.logSize = 400;
|
||||
logger2.fillEn = true;
|
||||
logger2.linkerEn = true;
|
||||
logger2.linkerVal = "LoggerDataSection";
|
||||
logger2.$name = "LoggerSineB";
|
||||
|
||||
logger3.linkerEn = true;
|
||||
logger3.fillEn = true;
|
||||
logger3.linkerVal = "LoggerDataSection";
|
||||
logger3.$name = "LoggerSineC";
|
||||
logger3.logSize = 400;
|
||||
|
||||
refgen1.$name = "myREFGEN0";
|
||||
refgen1.umax = 1;
|
||||
refgen1.umin = -1;
|
||||
refgen1.mode = "SINE3";
|
||||
refgen1.ampl = 2;
|
||||
|
||||
FPUfastRTS1.$name = "myFFR0";
|
||||
|
||||
CMD1.$name = "generic_ram_lnk";
|
||||
CMD1.sectionMemory_const = ["RAMLS5","RAMLS6"];
|
||||
CMD1.sectionMemory_ramfunc = ["RAMM0"];
|
||||
CMD1.sectionMemory_init_array = ["RAMM0"];
|
||||
CMD1.sectionMemory_switch = ["RAMM0"];
|
||||
CMD1.sectionMemory_sysmem = ["RAMLS4"];
|
||||
CMD1.sectionMemory_stack = ["RAMLS0"];
|
||||
CMD1.sectionMemory_bss = ["RAMGS1","RAMLS3","RAMLS4","RAMLS5"];
|
||||
CMD1.sectionMemory_data = ["RAMGS2","RAMLS5","RAMLS6","RAMLS7","RAMLS8"];
|
||||
CMD1.sectionMemory_cinit = ["RAMGS1"];
|
||||
CMD1.sectionMemory_text = ["RAMLS0","RAMLS1","RAMLS2","RAMLS3","RAMLS4","RAMLS5","RAMLS6","RAMLS7","RAMLS8","RAMLS9"];
|
||||
CMD1.userSection.create(2);
|
||||
CMD1.userSection[0].$name = "LoggerDataSection";
|
||||
CMD1.userSection[0].sectionMemory = ["RAMGS3"];
|
||||
CMD1.userSection[1].$name = "dclfuncs";
|
||||
CMD1.userSection[1].sectionMemory = ["RAMGS3"];
|
||||
@@ -0,0 +1,148 @@
|
||||
//#############################################################################
|
||||
//! \file /main.c
|
||||
//!
|
||||
//!
|
||||
//! This example shows how to use SysConfig to setup and run DCL's reference
|
||||
//! generator
|
||||
//
|
||||
// Group: C2000
|
||||
// Target Family: F28P55X
|
||||
//
|
||||
//#############################################################################
|
||||
//
|
||||
//
|
||||
// $Copyright: Copyright (C) 2024 Texas Instruments Incorporated -
|
||||
// http://www.ti.com/ ALL RIGHTS RESERVED $
|
||||
//#############################################################################
|
||||
|
||||
|
||||
//*****************************************************************************
|
||||
// includes
|
||||
//*****************************************************************************
|
||||
#include "driverlib.h"
|
||||
#include "device.h"
|
||||
#include "board.h"
|
||||
#include "c2000ware_libraries.h"
|
||||
#include "stdio.h"
|
||||
|
||||
//!
|
||||
//! \addtogroup DCL_EXAMPLES Ref Gen example
|
||||
|
||||
// @{
|
||||
|
||||
//
|
||||
// declared & initialized by sysconfig
|
||||
//
|
||||
extern DCL_REFGEN myREFGEN0;
|
||||
extern FDLOG LoggerSineA;
|
||||
extern FDLOG LoggerSineB;
|
||||
extern FDLOG LoggerSineC;
|
||||
|
||||
uint16_t isrCnt = 0;
|
||||
uint16_t isrStopCnt = 400;
|
||||
|
||||
uint16_t currIdxA = 0;
|
||||
uint16_t currIdxB = 0;
|
||||
uint16_t currIdxC = 0;
|
||||
|
||||
|
||||
int Run_RefGen_Logger()
|
||||
{
|
||||
|
||||
float32_t sineA, sineB, sineC;
|
||||
|
||||
//
|
||||
// Runs reference generator based on pre-configured settings denoted in sysconfig
|
||||
//
|
||||
DCL_runRefgen(&myREFGEN0);
|
||||
|
||||
//
|
||||
// Save generated phase output to the data logger
|
||||
//
|
||||
sineA = DCL_getRefgenPhaseA(&myREFGEN0);
|
||||
sineB = DCL_getRefgenPhaseB(&myREFGEN0);
|
||||
sineC = DCL_getRefgenPhaseC(&myREFGEN0);
|
||||
DCL_writeLog(&LoggerSineA, sineA);
|
||||
DCL_writeLog(&LoggerSineB, sineB);
|
||||
DCL_writeLog(&LoggerSineC, sineC);
|
||||
|
||||
//
|
||||
// Record the latest index for each data logger for debugging purposes
|
||||
//
|
||||
currIdxA = FDLOG_ELEMENT(&LoggerSineA);
|
||||
currIdxB = FDLOG_ELEMENT(&LoggerSineB);
|
||||
currIdxC = FDLOG_ELEMENT(&LoggerSineC);
|
||||
|
||||
return 1;
|
||||
}
|
||||
|
||||
//
|
||||
// Main
|
||||
//
|
||||
void main(void)
|
||||
{
|
||||
//
|
||||
// Initialize device clock and peripherals
|
||||
//
|
||||
Device_init();
|
||||
|
||||
//
|
||||
// Disable pin locks and enable internal pull-ups.
|
||||
//
|
||||
Device_initGPIO();
|
||||
|
||||
//
|
||||
// Initialize PIE and clear PIE registers. Disables CPU interrupts.
|
||||
//
|
||||
Interrupt_initModule();
|
||||
|
||||
//
|
||||
// Initialize the PIE vector table with pointers to the shell Interrupt
|
||||
// Service Routines (ISR).
|
||||
//
|
||||
Interrupt_initVectorTable();
|
||||
|
||||
//
|
||||
// PinMux and Peripheral Initialization
|
||||
//
|
||||
Board_init();
|
||||
|
||||
//
|
||||
// C2000Ware Library initialization
|
||||
//
|
||||
C2000Ware_libraries_init();
|
||||
|
||||
//
|
||||
// Enable Global Interrupt (INTM) and real time interrupt (DBGM)
|
||||
//
|
||||
EINT;
|
||||
ERTM;
|
||||
|
||||
while(1)
|
||||
{
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
// initialize CPU timer0 in sysconfig
|
||||
interrupt void timer_Isr(void)
|
||||
{
|
||||
if (isrCnt < isrStopCnt)
|
||||
{
|
||||
Run_RefGen_Logger();
|
||||
isrCnt++;
|
||||
}
|
||||
else
|
||||
{
|
||||
Interrupt_disable(INT_myCPUTIMER0);
|
||||
DCL_BREAK_POINT;
|
||||
}
|
||||
|
||||
Interrupt_clearACKGroup(INT_myCPUTIMER0_INTERRUPT_ACK_GROUP);
|
||||
}
|
||||
|
||||
// End of main
|
||||
|
||||
// @} //addtogroup
|
||||
|
||||
// End of file
|
||||
+29
@@ -0,0 +1,29 @@
|
||||
<projectSpec>
|
||||
<project
|
||||
name="F28P65x_DF22"
|
||||
device="TMS320F28P650DK9"
|
||||
cgtVersion="22.6.0.LTS"
|
||||
outputFormat="ELF"
|
||||
launchWizard="False"
|
||||
linkerCommandFile=""
|
||||
>
|
||||
<configuration name="CPU1_RAM" compilerBuildOptions="--opt_level=off -I${PROJECT_ROOT}/device -I${C2000WARE_DLIB_ROOT} -I${DCL_INCLUDE} -v28 -ml -mt --float_support=fpu32 --tmu_support=tmu0 --define=CPU1 --define=DEBUG --define RAM --diag_warning=225 --diag_suppress=10063" linkerBuildOptions="--entry_point code_start --stack_size=0x200 --heap_size=0x100 "/>
|
||||
<pathVariable name="C2000WARE_DLIB_ROOT" path="../../../../../../../driverlib/f28p65x/driverlib/" scope="project"/>
|
||||
<pathVariable name="DCL_INCLUDE" path="../../../include" scope="project"/>
|
||||
<pathVariable name="C2000WARE_DEVICE_SUPPORT" path="../../../../../../../device_support" scope="project"/>
|
||||
<file action="copy" path="C2000WARE_DEVICE_SUPPORT/f28p65x/common/include/driverlib.h" targetDirectory="device"/>
|
||||
<file action="copy" path="C2000WARE_DEVICE_SUPPORT/f28p65x/common/include/device.h" targetDirectory="device"/>
|
||||
<file action="copy" path="C2000WARE_DEVICE_SUPPORT/f28p65x/common/source/device.c" targetDirectory="device"/>
|
||||
<file action="copy" path="C2000WARE_DEVICE_SUPPORT/f28p65x/common/source/f28p65x_codestartbranch.asm" targetDirectory="device"/>
|
||||
<file action="copy" path="C2000WARE_DEVICE_SUPPORT/f28p65x/common/targetConfigs/TMS320F28P650DK9.ccxml" targetDirectory="targetConfigs"/>
|
||||
<file action="link" path="C2000WARE_DLIB_ROOT/ccs/Debug/driverlib.lib" targetDirectory=""/>
|
||||
<file action="copy" path="../Example_DF22.c" targetDirectory=""/>
|
||||
<file action="copy" path="../../../source/DCL_error.c" targetDirectory=""/>
|
||||
<file action="copy" path="../../../source/DCL_clamp_C1.asm" targetDirectory="" />
|
||||
<file action="copy" path="../../../source/DCL_DF22_C1.asm" targetDirectory="" />
|
||||
<file action="copy" path="../../../source/DCL_DF22_C2C3.asm" targetDirectory="" />
|
||||
<file action="copy" path="../DF22_edata.dat" targetDirectory="" />
|
||||
<file action="copy" path="C2000WARE_DEVICE_SUPPORT/f28p65x/common/cmd/28p65x_generic_ram_lnk_cpu1.cmd" targetDirectory=""/>
|
||||
<file action="copy" path="../../../cmd/F28P65x_DCL.cmd" targetDirectory=""/>
|
||||
</project>
|
||||
</projectSpec>
|
||||
File diff suppressed because it is too large.
Load diff
@@ -0,0 +1,168 @@
|
||||
/* Example_DF22.c
|
||||
*
|
||||
* Copyright (C) 2020 Texas Instruments Incorporated - http://www.ti.com/
|
||||
* ALL RIGHTS RESERVED
|
||||
*
|
||||
*/
|
||||
|
||||
#include "driverlib.h"
|
||||
#include "device.h"
|
||||
#include "DCLF32.h"
|
||||
#include "DCL_fdlog.h"
|
||||
|
||||
#define DATA_LENGTH 1601
|
||||
|
||||
// input data
|
||||
#pragma DATA_SECTION(e_array, "PDataLogSection")
|
||||
float e_array[DATA_LENGTH];
|
||||
FDLOG eBuf = FDLOG_DEFAULTS;
|
||||
|
||||
// full controller results
|
||||
#pragma DATA_SECTION(u1_array, "QDataLogSection")
|
||||
float u1_array[DATA_LENGTH];
|
||||
FDLOG u1Buf = FDLOG_DEFAULTS;
|
||||
|
||||
// pre-computed controller results
|
||||
#pragma DATA_SECTION(u2_array, "RDataLogSection")
|
||||
float u2_array[DATA_LENGTH];
|
||||
FDLOG u2Buf = FDLOG_DEFAULTS;
|
||||
|
||||
// controller difference data
|
||||
#pragma DATA_SECTION(d_array, "SDataLogSection")
|
||||
float d_array[DATA_LENGTH];
|
||||
FDLOG dBuf = FDLOG_DEFAULTS;
|
||||
|
||||
// function prototypes
|
||||
void initCPUTimer0(float freq, float period);
|
||||
extern interrupt void control_Isr(void);
|
||||
|
||||
// global variables
|
||||
long IdleLoopCount = 0;
|
||||
long IsrCount = 0;
|
||||
int complete = 0;
|
||||
float ek;
|
||||
float u1k;
|
||||
float u2k;
|
||||
float dk;
|
||||
float upperLim;
|
||||
float lowerLim;
|
||||
uint16_t v;
|
||||
DCL_DF22 controller1 = DF22_DEFAULTS;
|
||||
DCL_DF22 controller2 = DF22_DEFAULTS;
|
||||
|
||||
|
||||
/* main */
|
||||
main()
|
||||
{
|
||||
// device initialization
|
||||
Device_init();
|
||||
Interrupt_initModule();
|
||||
Interrupt_initVectorTable();
|
||||
|
||||
// initialize CPU timer0 & interrupt
|
||||
Interrupt_register(INT_TIMER0, &control_Isr);
|
||||
initCPUTimer0( DEVICE_SYSCLK_FREQ, 1000);
|
||||
CPUTimer_enableInterrupt(CPUTIMER0_BASE);
|
||||
Interrupt_enable(INT_TIMER0);
|
||||
|
||||
// initialise data arrays
|
||||
DCL_initLog(&eBuf, e_array, DATA_LENGTH);
|
||||
DCL_initLog(&u1Buf, u1_array, DATA_LENGTH);
|
||||
DCL_initLog(&u2Buf, u2_array, DATA_LENGTH);
|
||||
DCL_initLog(&dBuf, d_array, DATA_LENGTH);
|
||||
DCL_clearLog(&u1Buf);
|
||||
DCL_clearLog(&u2Buf);
|
||||
DCL_fillLog(&dBuf, 1.234567f);
|
||||
|
||||
// initialise full controller
|
||||
controller1.a1 = -1.9417f;
|
||||
controller1.a2 = 0.9417f;
|
||||
controller1.b0 = 9.8549f;
|
||||
controller1.b1 = -19.4165f;
|
||||
controller1.b2 = 9.5636f;
|
||||
|
||||
// initialise pre-computed controller
|
||||
controller2.a1 = controller1.a1;
|
||||
controller2.a2 = controller1.a2;
|
||||
controller2.b0 = controller1.b0;
|
||||
controller2.b1 = controller1.b1;
|
||||
controller2.b2 = controller1.b2;
|
||||
|
||||
// clamp limits
|
||||
upperLim = 1000.0f;
|
||||
lowerLim = -1000.0f;
|
||||
|
||||
// enable global interrupts
|
||||
EINT;
|
||||
ERTM;
|
||||
CPUTimer_startTimer(CPUTIMER0_BASE);
|
||||
|
||||
while(1)
|
||||
{
|
||||
IdleLoopCount++;
|
||||
|
||||
if (complete == 1)
|
||||
{
|
||||
DCL_BREAK_POINT;
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
// initialize CPU timer0
|
||||
void initCPUTimer0(float freq, float period)
|
||||
{
|
||||
uint32_t temp;
|
||||
|
||||
temp = (uint32_t)(freq / 1000000 * period);
|
||||
CPUTimer_setPeriod(CPUTIMER0_BASE, temp);
|
||||
CPUTimer_setPreScaler(CPUTIMER0_BASE, 0);
|
||||
CPUTimer_stopTimer(CPUTIMER0_BASE);
|
||||
CPUTimer_reloadTimerCounter(CPUTIMER0_BASE);
|
||||
CPUTimer_setEmulationMode(CPUTIMER0_BASE,
|
||||
CPUTIMER_EMULATIONMODE_STOPAFTERNEXTDECREMENT);
|
||||
CPUTimer_enableInterrupt(CPUTIMER0_BASE);
|
||||
}
|
||||
|
||||
/* control ISR: triggered by CPU timer 0 */
|
||||
interrupt void control_Isr(void)
|
||||
{
|
||||
|
||||
// read data & run controllers
|
||||
if (complete == 0)
|
||||
{
|
||||
// read input data
|
||||
ek = DCL_readLog(&eBuf);
|
||||
|
||||
// run full controller
|
||||
u1k = DCL_runDF22_C1(&controller1, ek);
|
||||
|
||||
// run pre-computed controller
|
||||
u2k = DCL_runDF22_C2(&controller2, ek);
|
||||
v = DCL_runClamp_C1(&u2k, upperLim, lowerLim);
|
||||
if (0U == v)
|
||||
{
|
||||
DCL_runDF22_C3(&controller2, ek, u2k);
|
||||
}
|
||||
|
||||
// compute difference
|
||||
dk = u1k - u2k;
|
||||
|
||||
// store results
|
||||
DCL_writeLog(&u1Buf, u1k);
|
||||
DCL_writeLog(&u2Buf, u2k);
|
||||
DCL_writeLog(&dBuf, dk);
|
||||
|
||||
// check if data log is full
|
||||
if FDLOG_START(&dBuf)
|
||||
{
|
||||
complete = 1;
|
||||
}
|
||||
}
|
||||
|
||||
IsrCount++;
|
||||
Interrupt_clearACKGroup(INTERRUPT_ACK_GROUP1);
|
||||
}
|
||||
|
||||
|
||||
/* end of file */
|
||||
@@ -0,0 +1,26 @@
|
||||
<projectSpec>
|
||||
<project
|
||||
name="F280025_NLPID"
|
||||
device="TMS320F280025C"
|
||||
cgtVersion="22.6.0.LTS"
|
||||
outputFormat="ELF"
|
||||
launchWizard="False"
|
||||
linkerCommandFile=""
|
||||
>
|
||||
<configuration name="CPU1_RAM" compilerBuildOptions="--opt_level=off -I${PROJECT_ROOT}/device -I${C2000WARE_DLIB_ROOT} -I${DCL_INCLUDE} -v28 -ml -mt --float_support=fpu32 --tmu_support=tmu1 --define=DEBUG --define RAM --diag_warning=225 --diag_suppress=10063" linkerBuildOptions="--entry_point code_start --stack_size=0x200 --heap_size=0x100 "/>
|
||||
<pathVariable name="C2000WARE_DLIB_ROOT" path="../../../../../../../driverlib/f28002x/driverlib/" scope="project"/>
|
||||
<pathVariable name="DCL_INCLUDE" path="../../../include" scope="project"/>
|
||||
<file action="copy" path="../../../../../../../device_support/f28002x/common/include/driverlib.h" targetDirectory="device"/>
|
||||
<file action="copy" path="../../../../../../../device_support/f28002x/common/include/device.h" targetDirectory="device"/>
|
||||
<file action="copy" path="../../../../../../../device_support/f28002x/common/source/device.c" targetDirectory="device"/>
|
||||
<file action="copy" path="../../../../../../../device_support/f28002x/common/source/f28002x_codestartbranch.asm" targetDirectory="device"/>
|
||||
<file action="copy" path="../../../../../../../device_support/f28002x/common/targetConfigs/TMS320F280025C.ccxml" targetDirectory="targetConfigs"/>
|
||||
<file action="link" path="../../../../../../../driverlib/f28002x/driverlib/ccs/Debug/driverlib.lib" targetDirectory=""/>
|
||||
<file action="copy" path="../../../../../../../driverlib/f28002x/driverlib/" targetDirectory="device" excludeFromBuild="True"/>
|
||||
<file action="copy" path="../Example_NLPID.c" targetDirectory=""/>
|
||||
<file action="copy" path="../../../source/DCL_NLPID_C3.asm" targetDirectory=""/>
|
||||
<file action="copy" path="../../../source/DCL_error.c" targetDirectory=""/>
|
||||
<file action="copy" path="../../../cmd/F280025_stdmem.cmd" targetDirectory=""/>
|
||||
<file action="copy" path="../../../cmd/F280025_DCL.cmd" targetDirectory=""/>
|
||||
</project>
|
||||
</projectSpec>
|
||||
@@ -0,0 +1,26 @@
|
||||
<projectSpec>
|
||||
<project
|
||||
name="F280039_NLPID"
|
||||
device="TMS320F280039C"
|
||||
cgtVersion="22.6.0.LTS"
|
||||
outputFormat="ELF"
|
||||
launchWizard="False"
|
||||
linkerCommandFile=""
|
||||
>
|
||||
<configuration name="CPU1_RAM" compilerBuildOptions="--opt_level=off -I${PROJECT_ROOT}/device -I${C2000WARE_DLIB_ROOT} -I${DCL_INCLUDE} -v28 -ml -mt --float_support=fpu32 --tmu_support=tmu1 --define=DEBUG --define RAM --diag_warning=225 --diag_suppress=10063" linkerBuildOptions="--entry_point code_start --stack_size=0x200 --heap_size=0x100 "/>
|
||||
<pathVariable name="C2000WARE_DLIB_ROOT" path="../../../../../../../driverlib/f28003x/driverlib/" scope="project"/>
|
||||
<pathVariable name="DCL_INCLUDE" path="../../../include" scope="project"/>
|
||||
<file action="copy" path="../../../../../../../device_support/f28003x/common/include/driverlib.h" targetDirectory="device"/>
|
||||
<file action="copy" path="../../../../../../../device_support/f28003x/common/include/device.h" targetDirectory="device"/>
|
||||
<file action="copy" path="../../../../../../../device_support/f28003x/common/source/device.c" targetDirectory="device"/>
|
||||
<file action="copy" path="../../../../../../../device_support/f28003x/common/source/f28003x_codestartbranch.asm" targetDirectory="device"/>
|
||||
<file action="copy" path="../../../../../../../device_support/f28003x/common/targetConfigs/TMS320F280039C.ccxml" targetDirectory="targetConfigs"/>
|
||||
<file action="link" path="../../../../../../../driverlib/f28003x/driverlib/ccs/Debug/driverlib.lib" targetDirectory=""/>
|
||||
<file action="copy" path="../../../../../../../driverlib/f28003x/driverlib/" targetDirectory="device" excludeFromBuild="True"/>
|
||||
<file action="copy" path="../Example_NLPID.c" targetDirectory=""/>
|
||||
<file action="copy" path="../../../source/DCL_NLPID_C3.asm" targetDirectory=""/>
|
||||
<file action="copy" path="../../../source/DCL_error.c" targetDirectory=""/>
|
||||
<file action="copy" path="../../../../../../../device_support/f28003x/common/cmd/28003x_generic_ram_lnk.cmd" targetDirectory=""/>
|
||||
<file action="copy" path="../../../cmd/F280039_DCL.cmd" targetDirectory=""/>
|
||||
</project>
|
||||
</projectSpec>
|
||||
@@ -0,0 +1,153 @@
|
||||
/* Example_NLPID.c
|
||||
*
|
||||
* Copyright (C) 2020 Texas Instruments Incorporated - http://www.ti.com/
|
||||
* ALL RIGHTS RESERVED
|
||||
*
|
||||
*/
|
||||
|
||||
// includes
|
||||
#include "driverlib.h"
|
||||
#include "device.h"
|
||||
#include "DCL_NLPID.h"
|
||||
#include "DCL_fdlog.h"
|
||||
|
||||
#define DATA_LENGTH 501
|
||||
|
||||
// data logs
|
||||
#pragma DATA_SECTION(p_array, "pDataLogSection")
|
||||
#pragma DATA_SECTION(q_array, "qDataLogSection")
|
||||
#pragma DATA_SECTION(s_array, "sDataLogSection")
|
||||
|
||||
// section addresses from linker file
|
||||
extern unsigned int pData_start;
|
||||
extern unsigned int qData_start;
|
||||
extern unsigned int sData_start;
|
||||
|
||||
// data arrays
|
||||
float32_t p_array[DATA_LENGTH];
|
||||
float32_t q_array[DATA_LENGTH];
|
||||
float32_t s_array[DATA_LENGTH];
|
||||
|
||||
// data log structs
|
||||
FDLOG pBuf = FDLOG_DEFAULTS;
|
||||
FDLOG qBuf = FDLOG_DEFAULTS;
|
||||
FDLOG sBuf = FDLOG_DEFAULTS;
|
||||
|
||||
// global variables
|
||||
long IdleLoopCount = 0;
|
||||
long IsrCount = 0;
|
||||
int complete = 0;
|
||||
float32_t rk = 0.25f, yk, uk;
|
||||
DCL_NLPID controller1 = NLPID_DEFAULTS;
|
||||
DCL_NLPID_SPS sps1 = NLPID_SPS_DEFAULTS;
|
||||
DCL_CSS css1 = DCL_CSS_DEFAULTS;
|
||||
|
||||
// function prototypes
|
||||
void initCPUTimer0(float freq, float period);
|
||||
__interrupt void control_isr(void);
|
||||
|
||||
|
||||
void main(void)
|
||||
{
|
||||
// device initialization
|
||||
Device_init();
|
||||
Interrupt_initModule();
|
||||
Interrupt_initVectorTable();
|
||||
|
||||
// initialize CPU timer0 & interrupt
|
||||
Interrupt_register(INT_TIMER0, &control_isr);
|
||||
initCPUTimer0( DEVICE_SYSCLK_FREQ, 1000);
|
||||
CPUTimer_enableInterrupt(CPUTIMER0_BASE);
|
||||
Interrupt_enable(INT_TIMER0);
|
||||
|
||||
// initialize data logs
|
||||
DCL_initLog(&pBuf, (float32_t *) p_array, DATA_LENGTH);
|
||||
DCL_initLog(&qBuf, (float32_t *) q_array, DATA_LENGTH);
|
||||
DCL_initLog(&sBuf, (float32_t *) s_array, DATA_LENGTH);
|
||||
DCL_clearLog(&sBuf);
|
||||
|
||||
// initialize controller
|
||||
DCL_resetNLPID(&controller1);
|
||||
controller1.sps = &sps1;
|
||||
controller1.css = &css1;
|
||||
DCL_SET_CONTROLLER_PERIOD(&controller1, 0.01f);
|
||||
controller1.sps->Kp = 25.0f;
|
||||
controller1.sps->Ki = 0.002f;
|
||||
controller1.sps->Kd = 0.03f;
|
||||
controller1.sps->alpha_p = 1.2f;
|
||||
controller1.sps->alpha_i = 1.05f;
|
||||
controller1.sps->alpha_d = 0.8f;
|
||||
controller1.sps->delta_p = 0.3f;
|
||||
controller1.sps->delta_i = 0.1f;
|
||||
controller1.sps->delta_d = 0.16f;
|
||||
controller1.sps->Umax = 100.0f;
|
||||
controller1.sps->Umin = -100.0f;
|
||||
DCL_setNLPIDfilterBW(&controller1, 4.9f);
|
||||
|
||||
// load gamma from the SPS
|
||||
DCL_setNLPIDgamma(&controller1);
|
||||
DCL_REQUEST_UPDATE(&controller1);
|
||||
DCL_updateNLPID(&controller1);
|
||||
|
||||
// enable global interrupts
|
||||
EINT;
|
||||
ERTM;
|
||||
CPUTimer_startTimer(CPUTIMER0_BASE);
|
||||
|
||||
while(1)
|
||||
{
|
||||
IdleLoopCount++;
|
||||
|
||||
if (complete == 1)
|
||||
{
|
||||
DCL_BREAK_POINT;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
// initialize CPU timer0
|
||||
void initCPUTimer0(float freq, float period)
|
||||
{
|
||||
uint32_t temp;
|
||||
|
||||
temp = (uint32_t)(freq / 1000000 * period);
|
||||
CPUTimer_setPeriod(CPUTIMER0_BASE, temp);
|
||||
CPUTimer_setPreScaler(CPUTIMER0_BASE, 0);
|
||||
CPUTimer_stopTimer(CPUTIMER0_BASE);
|
||||
CPUTimer_reloadTimerCounter(CPUTIMER0_BASE);
|
||||
CPUTimer_setEmulationMode(CPUTIMER0_BASE,
|
||||
CPUTIMER_EMULATIONMODE_STOPAFTERNEXTDECREMENT);
|
||||
CPUTimer_enableInterrupt(CPUTIMER0_BASE);
|
||||
}
|
||||
|
||||
|
||||
// control ISR, triggered by timer0
|
||||
__interrupt void control_isr(void)
|
||||
{
|
||||
|
||||
if (complete == 0)
|
||||
{
|
||||
// read test data
|
||||
rk = DCL_readLog(&pBuf);
|
||||
yk = DCL_readLog(&qBuf);
|
||||
|
||||
// run controller
|
||||
uk = DCL_runNLPID_C3(&controller1, rk, yk, 1.0f);
|
||||
|
||||
// store controller output
|
||||
DCL_writeLog(&sBuf, uk);
|
||||
|
||||
// check if data log is full
|
||||
if FDLOG_START(&sBuf)
|
||||
{
|
||||
complete = 1;
|
||||
}
|
||||
}
|
||||
|
||||
// exit sequence
|
||||
IsrCount++;
|
||||
Interrupt_clearACKGroup(INTERRUPT_ACK_GROUP1);
|
||||
}
|
||||
|
||||
/* end of file */
|
||||
@@ -0,0 +1,501 @@
|
||||
0.00000000e+00
|
||||
0.00000000e+00
|
||||
0.00000000e+00
|
||||
0.00000000e+00
|
||||
0.00000000e+00
|
||||
0.00000000e+00
|
||||
0.00000000e+00
|
||||
0.00000000e+00
|
||||
0.00000000e+00
|
||||
0.00000000e+00
|
||||
0.00000000e+00
|
||||
0.00000000e+00
|
||||
0.00000000e+00
|
||||
0.00000000e+00
|
||||
0.00000000e+00
|
||||
0.00000000e+00
|
||||
0.00000000e+00
|
||||
0.00000000e+00
|
||||
0.00000000e+00
|
||||
0.00000000e+00
|
||||
0.00000000e+00
|
||||
0.00000000e+00
|
||||
0.00000000e+00
|
||||
0.00000000e+00
|
||||
0.00000000e+00
|
||||
0.00000000e+00
|
||||
0.00000000e+00
|
||||
0.00000000e+00
|
||||
0.00000000e+00
|
||||
0.00000000e+00
|
||||
0.00000000e+00
|
||||
0.00000000e+00
|
||||
0.00000000e+00
|
||||
0.00000000e+00
|
||||
0.00000000e+00
|
||||
0.00000000e+00
|
||||
0.00000000e+00
|
||||
0.00000000e+00
|
||||
0.00000000e+00
|
||||
0.00000000e+00
|
||||
0.00000000e+00
|
||||
0.00000000e+00
|
||||
0.00000000e+00
|
||||
0.00000000e+00
|
||||
0.00000000e+00
|
||||
0.00000000e+00
|
||||
0.00000000e+00
|
||||
0.00000000e+00
|
||||
0.00000000e+00
|
||||
0.00000000e+00
|
||||
9.84731999e-01
|
||||
9.85187837e-01
|
||||
9.82450663e-01
|
||||
9.77129538e-01
|
||||
9.69670477e-01
|
||||
9.60399955e-01
|
||||
9.49556796e-01
|
||||
9.37906316e-01
|
||||
9.25458787e-01
|
||||
9.11630488e-01
|
||||
8.97134111e-01
|
||||
8.82532078e-01
|
||||
8.67095198e-01
|
||||
8.50838804e-01
|
||||
8.34955181e-01
|
||||
8.18626679e-01
|
||||
8.01803829e-01
|
||||
7.84449992e-01
|
||||
7.67719546e-01
|
||||
7.50176186e-01
|
||||
7.32458141e-01
|
||||
7.14482677e-01
|
||||
6.96779572e-01
|
||||
6.79186723e-01
|
||||
6.61585011e-01
|
||||
6.43296240e-01
|
||||
6.25554675e-01
|
||||
6.07573916e-01
|
||||
5.89917979e-01
|
||||
5.72450203e-01
|
||||
5.54479204e-01
|
||||
5.37230240e-01
|
||||
5.19909718e-01
|
||||
5.02486239e-01
|
||||
4.85527465e-01
|
||||
4.68899053e-01
|
||||
4.51912126e-01
|
||||
4.35792922e-01
|
||||
4.19749246e-01
|
||||
4.03160104e-01
|
||||
3.87892670e-01
|
||||
3.72483095e-01
|
||||
3.56959142e-01
|
||||
3.41932133e-01
|
||||
3.27299742e-01
|
||||
3.12986580e-01
|
||||
2.99529266e-01
|
||||
2.85588878e-01
|
||||
2.71874803e-01
|
||||
2.58948725e-01
|
||||
2.46671464e-01
|
||||
2.33759776e-01
|
||||
2.22146006e-01
|
||||
2.10414166e-01
|
||||
1.99218362e-01
|
||||
1.87896381e-01
|
||||
1.77695360e-01
|
||||
1.67247519e-01
|
||||
1.57241201e-01
|
||||
1.48222178e-01
|
||||
1.38858514e-01
|
||||
1.29865932e-01
|
||||
1.21809158e-01
|
||||
1.13370539e-01
|
||||
1.05867050e-01
|
||||
9.85721722e-02
|
||||
9.15042118e-02
|
||||
8.52681147e-02
|
||||
7.85745748e-02
|
||||
7.27613598e-02
|
||||
6.71183191e-02
|
||||
6.16748175e-02
|
||||
5.70435429e-02
|
||||
5.25325752e-02
|
||||
4.81854122e-02
|
||||
4.40345151e-02
|
||||
4.06938756e-02
|
||||
3.68830877e-02
|
||||
3.39438131e-02
|
||||
3.11708023e-02
|
||||
2.91866909e-02
|
||||
2.67168413e-02
|
||||
2.45189807e-02
|
||||
2.31880786e-02
|
||||
2.20201720e-02
|
||||
2.04587704e-02
|
||||
1.98277530e-02
|
||||
1.88161897e-02
|
||||
1.87446709e-02
|
||||
1.83000605e-02
|
||||
1.82105513e-02
|
||||
1.90511357e-02
|
||||
1.89205349e-02
|
||||
1.98489271e-02
|
||||
2.04916886e-02
|
||||
2.15548729e-02
|
||||
2.30058943e-02
|
||||
2.42302758e-02
|
||||
2.53278213e-02
|
||||
2.69627591e-02
|
||||
2.90725876e-02
|
||||
3.10190281e-02
|
||||
3.28864847e-02
|
||||
3.53267761e-02
|
||||
3.70861975e-02
|
||||
3.95279553e-02
|
||||
4.19602708e-02
|
||||
4.44255291e-02
|
||||
4.75475342e-02
|
||||
5.00498059e-02
|
||||
5.26895688e-02
|
||||
5.54709270e-02
|
||||
5.83969810e-02
|
||||
6.14704661e-02
|
||||
6.46934794e-02
|
||||
6.74763162e-02
|
||||
7.05283760e-02
|
||||
7.38196289e-02
|
||||
7.67360699e-02
|
||||
7.99703989e-02
|
||||
8.34794106e-02
|
||||
8.60494118e-02
|
||||
8.96649305e-02
|
||||
9.23564544e-02
|
||||
9.55127070e-02
|
||||
9.90520457e-02
|
||||
1.01732595e-01
|
||||
1.04925396e-01
|
||||
1.07946190e-01
|
||||
1.11432067e-01
|
||||
1.14119740e-01
|
||||
1.17364735e-01
|
||||
1.19878969e-01
|
||||
1.23000531e-01
|
||||
1.26018025e-01
|
||||
1.28370265e-01
|
||||
1.31377494e-01
|
||||
1.34315963e-01
|
||||
1.36615256e-01
|
||||
1.38997884e-01
|
||||
1.42033367e-01
|
||||
1.44408876e-01
|
||||
1.46851354e-01
|
||||
1.48754451e-01
|
||||
1.51404548e-01
|
||||
1.53462861e-01
|
||||
1.55638608e-01
|
||||
1.57311880e-01
|
||||
1.59167790e-01
|
||||
1.61159716e-01
|
||||
1.63252170e-01
|
||||
1.64828915e-01
|
||||
1.66579996e-01
|
||||
1.68459239e-01
|
||||
1.69843319e-01
|
||||
1.71415960e-01
|
||||
1.72537446e-01
|
||||
1.73879298e-01
|
||||
1.75384182e-01
|
||||
1.76418541e-01
|
||||
1.77659721e-01
|
||||
1.78462391e-01
|
||||
1.79494892e-01
|
||||
1.80106593e-01
|
||||
1.80960460e-01
|
||||
1.81402296e-01
|
||||
1.82093008e-01
|
||||
1.82966921e-01
|
||||
1.83384733e-01
|
||||
1.84019950e-01
|
||||
1.84223871e-01
|
||||
1.84663104e-01
|
||||
1.84683894e-01
|
||||
1.84949702e-01
|
||||
1.84803532e-01
|
||||
1.84907217e-01
|
||||
1.85194085e-01
|
||||
1.85024479e-01
|
||||
1.85071825e-01
|
||||
1.84686995e-01
|
||||
1.84536283e-01
|
||||
1.84556661e-01
|
||||
1.84113008e-01
|
||||
1.83288136e-01
|
||||
1.83324964e-01
|
||||
1.82852842e-01
|
||||
1.81967220e-01
|
||||
1.81328209e-01
|
||||
1.80870478e-01
|
||||
1.80545758e-01
|
||||
1.79726765e-01
|
||||
1.79096371e-01
|
||||
1.78603889e-01
|
||||
1.77621570e-01
|
||||
1.76830452e-01
|
||||
1.75588290e-01
|
||||
1.75155899e-01
|
||||
1.74176305e-01
|
||||
1.73345391e-01
|
||||
-8.12108688e-01
|
||||
-8.13798285e-01
|
||||
-8.12120019e-01
|
||||
-8.07729682e-01
|
||||
-8.01108114e-01
|
||||
-7.93198094e-01
|
||||
-7.83549384e-01
|
||||
-7.72380278e-01
|
||||
-7.61033504e-01
|
||||
-7.48210573e-01
|
||||
-7.34649614e-01
|
||||
-7.20933009e-01
|
||||
-7.06934912e-01
|
||||
-6.91974703e-01
|
||||
-6.77282281e-01
|
||||
-6.61478390e-01
|
||||
-6.45832989e-01
|
||||
-6.30176226e-01
|
||||
-6.13792744e-01
|
||||
-5.97889262e-01
|
||||
-5.81067963e-01
|
||||
-5.64586580e-01
|
||||
-5.47674878e-01
|
||||
-5.30909270e-01
|
||||
-5.14161952e-01
|
||||
-4.97338634e-01
|
||||
-4.80370032e-01
|
||||
-4.63796309e-01
|
||||
-4.46872194e-01
|
||||
-4.30191915e-01
|
||||
-4.13640833e-01
|
||||
-3.97134978e-01
|
||||
-3.80611959e-01
|
||||
-3.64617809e-01
|
||||
-3.48410950e-01
|
||||
-3.32588953e-01
|
||||
-3.16448749e-01
|
||||
-3.01206831e-01
|
||||
-2.85472606e-01
|
||||
-2.70508658e-01
|
||||
-2.55549976e-01
|
||||
-2.41176041e-01
|
||||
-2.26670690e-01
|
||||
-2.12650508e-01
|
||||
-1.98426095e-01
|
||||
-1.85224051e-01
|
||||
-1.71661483e-01
|
||||
-1.58416010e-01
|
||||
-1.46025077e-01
|
||||
-1.33741698e-01
|
||||
-1.21568437e-01
|
||||
-1.10098235e-01
|
||||
-9.86249910e-02
|
||||
-8.77719020e-02
|
||||
-7.68552649e-02
|
||||
-6.65147038e-02
|
||||
-5.60784828e-02
|
||||
-4.67858472e-02
|
||||
-3.72636720e-02
|
||||
-2.81965059e-02
|
||||
-1.95362856e-02
|
||||
-1.12478586e-02
|
||||
-3.30558332e-03
|
||||
4.30906880e-03
|
||||
1.16095622e-02
|
||||
1.86056013e-02
|
||||
2.53039798e-02
|
||||
3.17097572e-02
|
||||
3.72354378e-02
|
||||
4.31820855e-02
|
||||
4.82211878e-02
|
||||
5.36606655e-02
|
||||
5.81771750e-02
|
||||
6.24916175e-02
|
||||
6.65821082e-02
|
||||
7.04323092e-02
|
||||
7.34393464e-02
|
||||
7.68928577e-02
|
||||
7.94559427e-02
|
||||
8.24304920e-02
|
||||
8.44885808e-02
|
||||
8.63479092e-02
|
||||
8.85748689e-02
|
||||
8.98526819e-02
|
||||
9.09072206e-02
|
||||
9.23108779e-02
|
||||
9.27512647e-02
|
||||
9.35482693e-02
|
||||
9.39778899e-02
|
||||
9.40595632e-02
|
||||
9.38073414e-02
|
||||
9.38221391e-02
|
||||
9.34032231e-02
|
||||
9.25870965e-02
|
||||
9.19910884e-02
|
||||
9.09265638e-02
|
||||
8.94388081e-02
|
||||
8.81516652e-02
|
||||
8.69719991e-02
|
||||
8.52406905e-02
|
||||
8.30246502e-02
|
||||
8.15543474e-02
|
||||
7.94495762e-02
|
||||
7.73897679e-02
|
||||
7.53225871e-02
|
||||
7.26188323e-02
|
||||
7.05489073e-02
|
||||
6.77618837e-02
|
||||
6.55495494e-02
|
||||
6.25765040e-02
|
||||
5.95552273e-02
|
||||
5.70482515e-02
|
||||
5.43268936e-02
|
||||
5.14071613e-02
|
||||
4.83007709e-02
|
||||
4.56069492e-02
|
||||
4.20330767e-02
|
||||
3.95043829e-02
|
||||
3.60089968e-02
|
||||
3.34951632e-02
|
||||
2.99678738e-02
|
||||
2.67970022e-02
|
||||
2.38860998e-02
|
||||
2.05736836e-02
|
||||
1.75158529e-02
|
||||
1.46432329e-02
|
||||
1.13141851e-02
|
||||
8.79013582e-03
|
||||
5.71367724e-03
|
||||
2.19029959e-03
|
||||
-5.21187154e-04
|
||||
-3.18937877e-03
|
||||
-6.41812245e-03
|
||||
-8.91831113e-03
|
||||
-1.20270528e-02
|
||||
-1.50331940e-02
|
||||
-1.73749774e-02
|
||||
-2.03723834e-02
|
||||
-2.27109381e-02
|
||||
-2.51183900e-02
|
||||
-2.81686647e-02
|
||||
-3.05507079e-02
|
||||
-3.24039945e-02
|
||||
-3.50122385e-02
|
||||
-3.70343796e-02
|
||||
-3.91786610e-02
|
||||
-4.14139446e-02
|
||||
-4.37174157e-02
|
||||
-4.54815632e-02
|
||||
-4.74020397e-02
|
||||
-4.94385307e-02
|
||||
-5.09706813e-02
|
||||
-5.26847205e-02
|
||||
-5.45334041e-02
|
||||
-5.58913262e-02
|
||||
-5.74410036e-02
|
||||
-5.91324666e-02
|
||||
-6.03383025e-02
|
||||
-6.17396035e-02
|
||||
-6.26945202e-02
|
||||
-6.38735728e-02
|
||||
-6.52179802e-02
|
||||
-6.60938500e-02
|
||||
-6.65867697e-02
|
||||
-6.73501175e-02
|
||||
-6.83125801e-02
|
||||
-6.94218625e-02
|
||||
-7.00488232e-02
|
||||
-7.02825569e-02
|
||||
-7.07790261e-02
|
||||
-7.14687657e-02
|
||||
-7.17100725e-02
|
||||
-7.21735687e-02
|
||||
-7.22097677e-02
|
||||
-7.24835154e-02
|
||||
-7.23411832e-02
|
||||
-7.24445106e-02
|
||||
-7.27283408e-02
|
||||
-7.25541275e-02
|
||||
-7.25947621e-02
|
||||
-7.22024202e-02
|
||||
-7.20432386e-02
|
||||
-7.20551905e-02
|
||||
-7.16020244e-02
|
||||
-7.13583847e-02
|
||||
-7.12684133e-02
|
||||
-7.07004740e-02
|
||||
-7.03325025e-02
|
||||
-6.95203961e-02
|
||||
-6.89329495e-02
|
||||
-6.85101784e-02
|
||||
-6.82080094e-02
|
||||
-6.74034472e-02
|
||||
-6.67807629e-02
|
||||
-6.62912260e-02
|
||||
-6.53084501e-02
|
||||
-6.45140565e-02
|
||||
-6.38576285e-02
|
||||
-6.27112636e-02
|
||||
-6.23465022e-02
|
||||
-6.14133743e-02
|
||||
-6.06135716e-02
|
||||
-5.93203861e-02
|
||||
-5.88062092e-02
|
||||
-5.77216493e-02
|
||||
-5.67687986e-02
|
||||
-5.59121569e-02
|
||||
-5.51255315e-02
|
||||
-5.37990608e-02
|
||||
-5.32173962e-02
|
||||
-5.20402042e-02
|
||||
-5.09762183e-02
|
||||
-4.99947363e-02
|
||||
-4.90731793e-02
|
||||
-4.81950142e-02
|
||||
-4.73481076e-02
|
||||
-4.59328142e-02
|
||||
-4.52413667e-02
|
||||
-4.45296495e-02
|
||||
-4.32117752e-02
|
||||
-4.19992001e-02
|
||||
-4.14540379e-02
|
||||
-4.02564553e-02
|
||||
-3.91302979e-02
|
||||
-3.86466594e-02
|
||||
-3.74923604e-02
|
||||
-3.63961359e-02
|
||||
-3.59326297e-02
|
||||
-3.47912889e-02
|
||||
-3.37027395e-02
|
||||
-3.26522849e-02
|
||||
-3.22198526e-02
|
||||
-3.10988696e-02
|
||||
-3.06135589e-02
|
||||
-2.94526145e-02
|
||||
-2.89368368e-02
|
||||
-2.77523514e-02
|
||||
-2.72181462e-02
|
||||
-2.60189586e-02
|
||||
-2.54728066e-02
|
||||
-2.48544658e-02
|
||||
-2.41826411e-02
|
||||
-2.34710812e-02
|
||||
-2.27298313e-02
|
||||
-2.19662576e-02
|
||||
-2.11857835e-02
|
||||
-2.03923731e-02
|
||||
-2.01797141e-02
|
||||
-1.92511847e-02
|
||||
-1.89384471e-02
|
||||
-1.85263232e-02
|
||||
-1.74501194e-02
|
||||
@@ -0,0 +1,502 @@
|
||||
1651 9 e000 1 1F5 10
|
||||
0.00000000e+00
|
||||
0.00000000e+00
|
||||
0.00000000e+00
|
||||
0.00000000e+00
|
||||
0.00000000e+00
|
||||
0.00000000e+00
|
||||
0.00000000e+00
|
||||
0.00000000e+00
|
||||
0.00000000e+00
|
||||
0.00000000e+00
|
||||
0.00000000e+00
|
||||
0.00000000e+00
|
||||
0.00000000e+00
|
||||
0.00000000e+00
|
||||
0.00000000e+00
|
||||
0.00000000e+00
|
||||
0.00000000e+00
|
||||
0.00000000e+00
|
||||
0.00000000e+00
|
||||
0.00000000e+00
|
||||
0.00000000e+00
|
||||
0.00000000e+00
|
||||
0.00000000e+00
|
||||
0.00000000e+00
|
||||
0.00000000e+00
|
||||
0.00000000e+00
|
||||
0.00000000e+00
|
||||
0.00000000e+00
|
||||
0.00000000e+00
|
||||
0.00000000e+00
|
||||
0.00000000e+00
|
||||
0.00000000e+00
|
||||
0.00000000e+00
|
||||
0.00000000e+00
|
||||
0.00000000e+00
|
||||
0.00000000e+00
|
||||
0.00000000e+00
|
||||
0.00000000e+00
|
||||
0.00000000e+00
|
||||
0.00000000e+00
|
||||
0.00000000e+00
|
||||
0.00000000e+00
|
||||
0.00000000e+00
|
||||
0.00000000e+00
|
||||
0.00000000e+00
|
||||
0.00000000e+00
|
||||
0.00000000e+00
|
||||
0.00000000e+00
|
||||
0.00000000e+00
|
||||
0.00000000e+00
|
||||
0.00000000e+00
|
||||
4.57763672e-05
|
||||
1.83105469e-04
|
||||
4.11987305e-04
|
||||
7.32421875e-04
|
||||
1.14440918e-03
|
||||
1.64794922e-03
|
||||
2.22778320e-03
|
||||
2.88391113e-03
|
||||
3.63159180e-03
|
||||
4.45556641e-03
|
||||
5.34057617e-03
|
||||
6.30187988e-03
|
||||
7.33947754e-03
|
||||
8.42285156e-03
|
||||
9.56726074e-03
|
||||
1.07727051e-02
|
||||
1.20391846e-02
|
||||
1.33361816e-02
|
||||
1.46942139e-02
|
||||
1.60980225e-02
|
||||
1.75476074e-02
|
||||
1.90277100e-02
|
||||
2.05383301e-02
|
||||
2.20794678e-02
|
||||
2.36663818e-02
|
||||
2.52685547e-02
|
||||
2.69012451e-02
|
||||
2.85491943e-02
|
||||
3.02124023e-02
|
||||
3.19061279e-02
|
||||
3.35998535e-02
|
||||
3.53088379e-02
|
||||
3.70330811e-02
|
||||
3.87573242e-02
|
||||
4.04815674e-02
|
||||
4.22210693e-02
|
||||
4.39453125e-02
|
||||
4.56695557e-02
|
||||
4.74090576e-02
|
||||
4.91180420e-02
|
||||
5.08270264e-02
|
||||
5.25360107e-02
|
||||
5.42297363e-02
|
||||
5.59082031e-02
|
||||
5.75714111e-02
|
||||
5.92041016e-02
|
||||
6.08367920e-02
|
||||
6.24542236e-02
|
||||
6.40411377e-02
|
||||
6.55975342e-02
|
||||
6.71539307e-02
|
||||
6.86645508e-02
|
||||
7.01599121e-02
|
||||
7.16247559e-02
|
||||
7.30743408e-02
|
||||
7.44781494e-02
|
||||
7.58666992e-02
|
||||
7.72247314e-02
|
||||
7.85369873e-02
|
||||
7.98339844e-02
|
||||
8.11004639e-02
|
||||
8.23211670e-02
|
||||
8.35266113e-02
|
||||
8.46862793e-02
|
||||
8.58154297e-02
|
||||
8.69140625e-02
|
||||
8.79669189e-02
|
||||
8.90045166e-02
|
||||
8.99963379e-02
|
||||
9.09576416e-02
|
||||
9.18884277e-02
|
||||
9.27734375e-02
|
||||
9.36279297e-02
|
||||
9.44519043e-02
|
||||
9.52453613e-02
|
||||
9.59930420e-02
|
||||
9.67254639e-02
|
||||
9.74121094e-02
|
||||
9.80682373e-02
|
||||
9.86785889e-02
|
||||
9.92736816e-02
|
||||
9.98382568e-02
|
||||
1.00357056e-01
|
||||
1.00845337e-01
|
||||
1.01318359e-01
|
||||
1.01745605e-01
|
||||
1.02157593e-01
|
||||
1.02523804e-01
|
||||
1.02874756e-01
|
||||
1.03195190e-01
|
||||
1.03469849e-01
|
||||
1.03744507e-01
|
||||
1.03973389e-01
|
||||
1.04187012e-01
|
||||
1.04370117e-01
|
||||
1.04522705e-01
|
||||
1.04660034e-01
|
||||
1.04782104e-01
|
||||
1.04873657e-01
|
||||
1.04934692e-01
|
||||
1.04980469e-01
|
||||
1.05010986e-01
|
||||
1.05010986e-01
|
||||
1.05010986e-01
|
||||
1.04980469e-01
|
||||
1.04934692e-01
|
||||
1.04873657e-01
|
||||
1.04782104e-01
|
||||
1.04690552e-01
|
||||
1.04583740e-01
|
||||
1.04461670e-01
|
||||
1.04324341e-01
|
||||
1.04171753e-01
|
||||
1.04003906e-01
|
||||
1.03836060e-01
|
||||
1.03652954e-01
|
||||
1.03454590e-01
|
||||
1.03256226e-01
|
||||
1.03042603e-01
|
||||
1.02813721e-01
|
||||
1.02600098e-01
|
||||
1.02355957e-01
|
||||
1.02127075e-01
|
||||
1.01882935e-01
|
||||
1.01623535e-01
|
||||
1.01379395e-01
|
||||
1.01119995e-01
|
||||
1.00860596e-01
|
||||
1.00585938e-01
|
||||
1.00326538e-01
|
||||
1.00051880e-01
|
||||
9.97924805e-02
|
||||
9.95178223e-02
|
||||
9.92431641e-02
|
||||
9.89837646e-02
|
||||
9.87091064e-02
|
||||
9.84344482e-02
|
||||
9.81750488e-02
|
||||
9.79156494e-02
|
||||
9.76409912e-02
|
||||
9.73815918e-02
|
||||
9.71221924e-02
|
||||
9.68780518e-02
|
||||
9.66186523e-02
|
||||
9.63745117e-02
|
||||
9.61303711e-02
|
||||
9.59014893e-02
|
||||
9.56726074e-02
|
||||
9.54437256e-02
|
||||
9.52148438e-02
|
||||
9.50012207e-02
|
||||
9.47875977e-02
|
||||
9.45739746e-02
|
||||
9.43756104e-02
|
||||
9.41772461e-02
|
||||
9.39941406e-02
|
||||
9.38110352e-02
|
||||
9.36279297e-02
|
||||
9.34600830e-02
|
||||
9.32922363e-02
|
||||
9.31396484e-02
|
||||
9.29870605e-02
|
||||
9.28497314e-02
|
||||
9.27124023e-02
|
||||
9.25903320e-02
|
||||
9.24682617e-02
|
||||
9.23461914e-02
|
||||
9.22393799e-02
|
||||
9.21325684e-02
|
||||
9.20410156e-02
|
||||
9.19494629e-02
|
||||
9.18731689e-02
|
||||
9.17968750e-02
|
||||
9.17358398e-02
|
||||
9.16748047e-02
|
||||
9.16137695e-02
|
||||
9.15679932e-02
|
||||
9.15222168e-02
|
||||
9.14916992e-02
|
||||
9.14611816e-02
|
||||
9.14306641e-02
|
||||
9.14154053e-02
|
||||
9.14154053e-02
|
||||
9.14001465e-02
|
||||
9.14001465e-02
|
||||
9.14154053e-02
|
||||
9.14306641e-02
|
||||
9.14459229e-02
|
||||
9.14611816e-02
|
||||
9.14916992e-02
|
||||
9.15222168e-02
|
||||
9.15527344e-02
|
||||
9.15985107e-02
|
||||
9.16442871e-02
|
||||
9.17053223e-02
|
||||
9.17510986e-02
|
||||
9.18121338e-02
|
||||
9.18731689e-02
|
||||
9.19342041e-02
|
||||
9.19647217e-02
|
||||
9.19036865e-02
|
||||
9.17510986e-02
|
||||
9.15069580e-02
|
||||
9.11865234e-02
|
||||
9.07745361e-02
|
||||
9.02709961e-02
|
||||
8.97064209e-02
|
||||
8.90502930e-02
|
||||
8.83178711e-02
|
||||
8.75244141e-02
|
||||
8.66699219e-02
|
||||
8.57391357e-02
|
||||
8.47625732e-02
|
||||
8.37097168e-02
|
||||
8.26110840e-02
|
||||
8.14666748e-02
|
||||
8.02612305e-02
|
||||
7.90252686e-02
|
||||
7.77282715e-02
|
||||
7.64007568e-02
|
||||
7.50274658e-02
|
||||
7.36236572e-02
|
||||
7.21893311e-02
|
||||
7.07244873e-02
|
||||
6.92291260e-02
|
||||
6.77185059e-02
|
||||
6.61773682e-02
|
||||
6.46209717e-02
|
||||
6.30493164e-02
|
||||
6.14624023e-02
|
||||
5.98602295e-02
|
||||
5.82580566e-02
|
||||
5.66406250e-02
|
||||
5.50231934e-02
|
||||
5.33905029e-02
|
||||
5.17730713e-02
|
||||
5.01403809e-02
|
||||
4.85229492e-02
|
||||
4.69055176e-02
|
||||
4.53033447e-02
|
||||
4.37011719e-02
|
||||
4.21142578e-02
|
||||
4.05273438e-02
|
||||
3.89709473e-02
|
||||
3.74145508e-02
|
||||
3.58734131e-02
|
||||
3.43627930e-02
|
||||
3.28674316e-02
|
||||
3.13873291e-02
|
||||
2.99377441e-02
|
||||
2.85034180e-02
|
||||
2.70996094e-02
|
||||
2.57110596e-02
|
||||
2.43530273e-02
|
||||
2.30102539e-02
|
||||
2.17132568e-02
|
||||
2.04315186e-02
|
||||
1.91802979e-02
|
||||
1.79595947e-02
|
||||
1.67694092e-02
|
||||
1.56097412e-02
|
||||
1.44805908e-02
|
||||
1.33819580e-02
|
||||
1.23138428e-02
|
||||
1.12762451e-02
|
||||
1.02691650e-02
|
||||
9.30786133e-03
|
||||
8.36181641e-03
|
||||
7.46154785e-03
|
||||
6.57653809e-03
|
||||
5.73730469e-03
|
||||
4.92858887e-03
|
||||
4.15039063e-03
|
||||
3.40270996e-03
|
||||
2.70080566e-03
|
||||
2.01416016e-03
|
||||
1.37329102e-03
|
||||
7.47680664e-04
|
||||
1.67846680e-04
|
||||
-3.81469727e-04
|
||||
-9.15527344e-04
|
||||
-1.40380859e-03
|
||||
-1.86157227e-03
|
||||
-2.30407715e-03
|
||||
-2.70080566e-03
|
||||
-3.08227539e-03
|
||||
-3.43322754e-03
|
||||
-3.75366211e-03
|
||||
-4.04357910e-03
|
||||
-4.31823730e-03
|
||||
-4.56237793e-03
|
||||
-4.77600098e-03
|
||||
-4.97436523e-03
|
||||
-5.14221191e-03
|
||||
-5.27954102e-03
|
||||
-5.40161133e-03
|
||||
-5.50842285e-03
|
||||
-5.58471680e-03
|
||||
-5.63049316e-03
|
||||
-5.67626953e-03
|
||||
-5.69152832e-03
|
||||
-5.69152832e-03
|
||||
-5.67626953e-03
|
||||
-5.63049316e-03
|
||||
-5.58471680e-03
|
||||
-5.50842285e-03
|
||||
-5.43212891e-03
|
||||
-5.32531738e-03
|
||||
-5.20324707e-03
|
||||
-5.08117676e-03
|
||||
-4.94384766e-03
|
||||
-4.79125977e-03
|
||||
-4.62341309e-03
|
||||
-4.45556641e-03
|
||||
-4.25720215e-03
|
||||
-4.07409668e-03
|
||||
-3.86047363e-03
|
||||
-3.66210938e-03
|
||||
-3.43322754e-03
|
||||
-3.20434570e-03
|
||||
-2.97546387e-03
|
||||
-2.73132324e-03
|
||||
-2.48718262e-03
|
||||
-2.24304199e-03
|
||||
-1.98364258e-03
|
||||
-1.73950195e-03
|
||||
-1.48010254e-03
|
||||
-1.20544434e-03
|
||||
-9.46044922e-04
|
||||
-6.86645508e-04
|
||||
-4.11987305e-04
|
||||
-1.52587891e-04
|
||||
1.22070313e-04
|
||||
3.96728516e-04
|
||||
6.56127930e-04
|
||||
9.30786133e-04
|
||||
1.19018555e-03
|
||||
1.44958496e-03
|
||||
1.72424316e-03
|
||||
1.98364258e-03
|
||||
2.22778320e-03
|
||||
2.48718262e-03
|
||||
2.73132324e-03
|
||||
2.97546387e-03
|
||||
3.21960449e-03
|
||||
3.46374512e-03
|
||||
3.69262695e-03
|
||||
3.92150879e-03
|
||||
4.15039063e-03
|
||||
4.36401367e-03
|
||||
4.57763672e-03
|
||||
4.79125977e-03
|
||||
4.98962402e-03
|
||||
5.18798828e-03
|
||||
5.38635254e-03
|
||||
5.56945801e-03
|
||||
5.75256348e-03
|
||||
5.92041016e-03
|
||||
6.08825684e-03
|
||||
6.25610352e-03
|
||||
6.40869141e-03
|
||||
6.54602051e-03
|
||||
6.68334961e-03
|
||||
6.82067871e-03
|
||||
6.95800781e-03
|
||||
7.08007813e-03
|
||||
7.18688965e-03
|
||||
7.29370117e-03
|
||||
7.40051270e-03
|
||||
7.49206543e-03
|
||||
7.58361816e-03
|
||||
7.65991211e-03
|
||||
7.73620605e-03
|
||||
7.79724121e-03
|
||||
7.85827637e-03
|
||||
7.91931152e-03
|
||||
7.96508789e-03
|
||||
8.01086426e-03
|
||||
8.04138184e-03
|
||||
8.07189941e-03
|
||||
8.10241699e-03
|
||||
8.11767578e-03
|
||||
8.13293457e-03
|
||||
8.14819336e-03
|
||||
8.14819336e-03
|
||||
8.14819336e-03
|
||||
8.13293457e-03
|
||||
8.11767578e-03
|
||||
8.10241699e-03
|
||||
8.08715820e-03
|
||||
8.05664063e-03
|
||||
8.02612305e-03
|
||||
7.99560547e-03
|
||||
7.94982910e-03
|
||||
7.90405273e-03
|
||||
7.85827637e-03
|
||||
7.79724121e-03
|
||||
7.75146484e-03
|
||||
7.69042969e-03
|
||||
7.62939453e-03
|
||||
7.55310059e-03
|
||||
7.49206543e-03
|
||||
7.41577148e-03
|
||||
7.33947754e-03
|
||||
7.26318359e-03
|
||||
7.18688965e-03
|
||||
7.09533691e-03
|
||||
7.01904297e-03
|
||||
6.92749023e-03
|
||||
6.83593750e-03
|
||||
6.74438477e-03
|
||||
6.65283203e-03
|
||||
6.56127930e-03
|
||||
6.46972656e-03
|
||||
6.36291504e-03
|
||||
6.27136230e-03
|
||||
6.17980957e-03
|
||||
6.07299805e-03
|
||||
5.96618652e-03
|
||||
5.87463379e-03
|
||||
5.76782227e-03
|
||||
5.66101074e-03
|
||||
5.56945801e-03
|
||||
5.46264648e-03
|
||||
5.35583496e-03
|
||||
5.26428223e-03
|
||||
5.15747070e-03
|
||||
5.05065918e-03
|
||||
4.94384766e-03
|
||||
4.85229492e-03
|
||||
4.74548340e-03
|
||||
4.65393066e-03
|
||||
4.54711914e-03
|
||||
4.45556641e-03
|
||||
4.34875488e-03
|
||||
4.25720215e-03
|
||||
4.15039063e-03
|
||||
4.05883789e-03
|
||||
3.96728516e-03
|
||||
3.87573242e-03
|
||||
3.78417969e-03
|
||||
3.69262695e-03
|
||||
3.60107422e-03
|
||||
3.50952148e-03
|
||||
3.41796875e-03
|
||||
3.34167480e-03
|
||||
3.25012207e-03
|
||||
3.17382813e-03
|
||||
3.09753418e-03
|
||||
3.00598145e-03
|
||||
@@ -0,0 +1,502 @@
|
||||
1651 9 c000 1 1F5 10
|
||||
0.00000000e+00
|
||||
0.00000000e+00
|
||||
0.00000000e+00
|
||||
0.00000000e+00
|
||||
0.00000000e+00
|
||||
0.00000000e+00
|
||||
0.00000000e+00
|
||||
0.00000000e+00
|
||||
0.00000000e+00
|
||||
0.00000000e+00
|
||||
0.00000000e+00
|
||||
0.00000000e+00
|
||||
0.00000000e+00
|
||||
0.00000000e+00
|
||||
0.00000000e+00
|
||||
0.00000000e+00
|
||||
0.00000000e+00
|
||||
0.00000000e+00
|
||||
0.00000000e+00
|
||||
0.00000000e+00
|
||||
0.00000000e+00
|
||||
0.00000000e+00
|
||||
0.00000000e+00
|
||||
0.00000000e+00
|
||||
0.00000000e+00
|
||||
0.00000000e+00
|
||||
0.00000000e+00
|
||||
0.00000000e+00
|
||||
0.00000000e+00
|
||||
0.00000000e+00
|
||||
0.00000000e+00
|
||||
0.00000000e+00
|
||||
0.00000000e+00
|
||||
0.00000000e+00
|
||||
0.00000000e+00
|
||||
0.00000000e+00
|
||||
0.00000000e+00
|
||||
0.00000000e+00
|
||||
0.00000000e+00
|
||||
0.00000000e+00
|
||||
0.00000000e+00
|
||||
0.00000000e+00
|
||||
0.00000000e+00
|
||||
0.00000000e+00
|
||||
0.00000000e+00
|
||||
0.00000000e+00
|
||||
0.00000000e+00
|
||||
0.00000000e+00
|
||||
0.00000000e+00
|
||||
0.00000000e+00
|
||||
1.00000001e-01
|
||||
1.00000001e-01
|
||||
1.00000001e-01
|
||||
1.00000001e-01
|
||||
1.00000001e-01
|
||||
1.00000001e-01
|
||||
1.00000001e-01
|
||||
1.00000001e-01
|
||||
1.00000001e-01
|
||||
1.00000001e-01
|
||||
1.00000001e-01
|
||||
1.00000001e-01
|
||||
1.00000001e-01
|
||||
1.00000001e-01
|
||||
1.00000001e-01
|
||||
1.00000001e-01
|
||||
1.00000001e-01
|
||||
1.00000001e-01
|
||||
1.00000001e-01
|
||||
1.00000001e-01
|
||||
1.00000001e-01
|
||||
1.00000001e-01
|
||||
1.00000001e-01
|
||||
1.00000001e-01
|
||||
1.00000001e-01
|
||||
1.00000001e-01
|
||||
1.00000001e-01
|
||||
1.00000001e-01
|
||||
1.00000001e-01
|
||||
1.00000001e-01
|
||||
1.00000001e-01
|
||||
1.00000001e-01
|
||||
1.00000001e-01
|
||||
1.00000001e-01
|
||||
1.00000001e-01
|
||||
1.00000001e-01
|
||||
1.00000001e-01
|
||||
1.00000001e-01
|
||||
1.00000001e-01
|
||||
1.00000001e-01
|
||||
1.00000001e-01
|
||||
1.00000001e-01
|
||||
1.00000001e-01
|
||||
1.00000001e-01
|
||||
1.00000001e-01
|
||||
1.00000001e-01
|
||||
1.00000001e-01
|
||||
1.00000001e-01
|
||||
1.00000001e-01
|
||||
1.00000001e-01
|
||||
1.00000001e-01
|
||||
1.00000001e-01
|
||||
1.00000001e-01
|
||||
1.00000001e-01
|
||||
1.00000001e-01
|
||||
1.00000001e-01
|
||||
1.00000001e-01
|
||||
1.00000001e-01
|
||||
1.00000001e-01
|
||||
1.00000001e-01
|
||||
1.00000001e-01
|
||||
1.00000001e-01
|
||||
1.00000001e-01
|
||||
1.00000001e-01
|
||||
1.00000001e-01
|
||||
1.00000001e-01
|
||||
1.00000001e-01
|
||||
1.00000001e-01
|
||||
1.00000001e-01
|
||||
1.00000001e-01
|
||||
1.00000001e-01
|
||||
1.00000001e-01
|
||||
1.00000001e-01
|
||||
1.00000001e-01
|
||||
1.00000001e-01
|
||||
1.00000001e-01
|
||||
1.00000001e-01
|
||||
1.00000001e-01
|
||||
1.00000001e-01
|
||||
1.00000001e-01
|
||||
1.00000001e-01
|
||||
1.00000001e-01
|
||||
1.00000001e-01
|
||||
1.00000001e-01
|
||||
1.00000001e-01
|
||||
1.00000001e-01
|
||||
1.00000001e-01
|
||||
1.00000001e-01
|
||||
1.00000001e-01
|
||||
1.00000001e-01
|
||||
1.00000001e-01
|
||||
1.00000001e-01
|
||||
1.00000001e-01
|
||||
1.00000001e-01
|
||||
1.00000001e-01
|
||||
1.00000001e-01
|
||||
1.00000001e-01
|
||||
1.00000001e-01
|
||||
1.00000001e-01
|
||||
1.00000001e-01
|
||||
1.00000001e-01
|
||||
1.00000001e-01
|
||||
1.00000001e-01
|
||||
1.00000001e-01
|
||||
1.00000001e-01
|
||||
1.00000001e-01
|
||||
1.00000001e-01
|
||||
1.00000001e-01
|
||||
1.00000001e-01
|
||||
1.00000001e-01
|
||||
1.00000001e-01
|
||||
1.00000001e-01
|
||||
1.00000001e-01
|
||||
1.00000001e-01
|
||||
1.00000001e-01
|
||||
1.00000001e-01
|
||||
1.00000001e-01
|
||||
1.00000001e-01
|
||||
1.00000001e-01
|
||||
1.00000001e-01
|
||||
1.00000001e-01
|
||||
1.00000001e-01
|
||||
1.00000001e-01
|
||||
1.00000001e-01
|
||||
1.00000001e-01
|
||||
1.00000001e-01
|
||||
1.00000001e-01
|
||||
1.00000001e-01
|
||||
1.00000001e-01
|
||||
1.00000001e-01
|
||||
1.00000001e-01
|
||||
1.00000001e-01
|
||||
1.00000001e-01
|
||||
1.00000001e-01
|
||||
1.00000001e-01
|
||||
1.00000001e-01
|
||||
1.00000001e-01
|
||||
1.00000001e-01
|
||||
1.00000001e-01
|
||||
1.00000001e-01
|
||||
1.00000001e-01
|
||||
1.00000001e-01
|
||||
1.00000001e-01
|
||||
1.00000001e-01
|
||||
1.00000001e-01
|
||||
1.00000001e-01
|
||||
1.00000001e-01
|
||||
1.00000001e-01
|
||||
1.00000001e-01
|
||||
1.00000001e-01
|
||||
1.00000001e-01
|
||||
1.00000001e-01
|
||||
1.00000001e-01
|
||||
1.00000001e-01
|
||||
1.00000001e-01
|
||||
1.00000001e-01
|
||||
1.00000001e-01
|
||||
1.00000001e-01
|
||||
1.00000001e-01
|
||||
1.00000001e-01
|
||||
1.00000001e-01
|
||||
1.00000001e-01
|
||||
1.00000001e-01
|
||||
1.00000001e-01
|
||||
1.00000001e-01
|
||||
1.00000001e-01
|
||||
1.00000001e-01
|
||||
1.00000001e-01
|
||||
1.00000001e-01
|
||||
1.00000001e-01
|
||||
1.00000001e-01
|
||||
1.00000001e-01
|
||||
1.00000001e-01
|
||||
1.00000001e-01
|
||||
1.00000001e-01
|
||||
1.00000001e-01
|
||||
1.00000001e-01
|
||||
1.00000001e-01
|
||||
1.00000001e-01
|
||||
1.00000001e-01
|
||||
1.00000001e-01
|
||||
1.00000001e-01
|
||||
1.00000001e-01
|
||||
1.00000001e-01
|
||||
1.00000001e-01
|
||||
1.00000001e-01
|
||||
1.00000001e-01
|
||||
1.00000001e-01
|
||||
1.00000001e-01
|
||||
1.00000001e-01
|
||||
1.00000001e-01
|
||||
1.00000001e-01
|
||||
1.00000001e-01
|
||||
1.00000001e-01
|
||||
1.00000001e-01
|
||||
1.00000001e-01
|
||||
1.00000001e-01
|
||||
1.00000001e-01
|
||||
1.00000001e-01
|
||||
0.00000000e+00
|
||||
0.00000000e+00
|
||||
0.00000000e+00
|
||||
0.00000000e+00
|
||||
0.00000000e+00
|
||||
0.00000000e+00
|
||||
0.00000000e+00
|
||||
0.00000000e+00
|
||||
0.00000000e+00
|
||||
0.00000000e+00
|
||||
0.00000000e+00
|
||||
0.00000000e+00
|
||||
0.00000000e+00
|
||||
0.00000000e+00
|
||||
0.00000000e+00
|
||||
0.00000000e+00
|
||||
0.00000000e+00
|
||||
0.00000000e+00
|
||||
0.00000000e+00
|
||||
0.00000000e+00
|
||||
0.00000000e+00
|
||||
0.00000000e+00
|
||||
0.00000000e+00
|
||||
0.00000000e+00
|
||||
0.00000000e+00
|
||||
0.00000000e+00
|
||||
0.00000000e+00
|
||||
0.00000000e+00
|
||||
0.00000000e+00
|
||||
0.00000000e+00
|
||||
0.00000000e+00
|
||||
0.00000000e+00
|
||||
0.00000000e+00
|
||||
0.00000000e+00
|
||||
0.00000000e+00
|
||||
0.00000000e+00
|
||||
0.00000000e+00
|
||||
0.00000000e+00
|
||||
0.00000000e+00
|
||||
0.00000000e+00
|
||||
0.00000000e+00
|
||||
0.00000000e+00
|
||||
0.00000000e+00
|
||||
0.00000000e+00
|
||||
0.00000000e+00
|
||||
0.00000000e+00
|
||||
0.00000000e+00
|
||||
0.00000000e+00
|
||||
0.00000000e+00
|
||||
0.00000000e+00
|
||||
0.00000000e+00
|
||||
0.00000000e+00
|
||||
0.00000000e+00
|
||||
0.00000000e+00
|
||||
0.00000000e+00
|
||||
0.00000000e+00
|
||||
0.00000000e+00
|
||||
0.00000000e+00
|
||||
0.00000000e+00
|
||||
0.00000000e+00
|
||||
0.00000000e+00
|
||||
0.00000000e+00
|
||||
0.00000000e+00
|
||||
0.00000000e+00
|
||||
0.00000000e+00
|
||||
0.00000000e+00
|
||||
0.00000000e+00
|
||||
0.00000000e+00
|
||||
0.00000000e+00
|
||||
0.00000000e+00
|
||||
0.00000000e+00
|
||||
0.00000000e+00
|
||||
0.00000000e+00
|
||||
0.00000000e+00
|
||||
0.00000000e+00
|
||||
0.00000000e+00
|
||||
0.00000000e+00
|
||||
0.00000000e+00
|
||||
0.00000000e+00
|
||||
0.00000000e+00
|
||||
0.00000000e+00
|
||||
0.00000000e+00
|
||||
0.00000000e+00
|
||||
0.00000000e+00
|
||||
0.00000000e+00
|
||||
0.00000000e+00
|
||||
0.00000000e+00
|
||||
0.00000000e+00
|
||||
0.00000000e+00
|
||||
0.00000000e+00
|
||||
0.00000000e+00
|
||||
0.00000000e+00
|
||||
0.00000000e+00
|
||||
0.00000000e+00
|
||||
0.00000000e+00
|
||||
0.00000000e+00
|
||||
0.00000000e+00
|
||||
0.00000000e+00
|
||||
0.00000000e+00
|
||||
0.00000000e+00
|
||||
0.00000000e+00
|
||||
0.00000000e+00
|
||||
0.00000000e+00
|
||||
0.00000000e+00
|
||||
0.00000000e+00
|
||||
0.00000000e+00
|
||||
0.00000000e+00
|
||||
0.00000000e+00
|
||||
0.00000000e+00
|
||||
0.00000000e+00
|
||||
0.00000000e+00
|
||||
0.00000000e+00
|
||||
0.00000000e+00
|
||||
0.00000000e+00
|
||||
0.00000000e+00
|
||||
0.00000000e+00
|
||||
0.00000000e+00
|
||||
0.00000000e+00
|
||||
0.00000000e+00
|
||||
0.00000000e+00
|
||||
0.00000000e+00
|
||||
0.00000000e+00
|
||||
0.00000000e+00
|
||||
0.00000000e+00
|
||||
0.00000000e+00
|
||||
0.00000000e+00
|
||||
0.00000000e+00
|
||||
0.00000000e+00
|
||||
0.00000000e+00
|
||||
0.00000000e+00
|
||||
0.00000000e+00
|
||||
0.00000000e+00
|
||||
0.00000000e+00
|
||||
0.00000000e+00
|
||||
0.00000000e+00
|
||||
0.00000000e+00
|
||||
0.00000000e+00
|
||||
0.00000000e+00
|
||||
0.00000000e+00
|
||||
0.00000000e+00
|
||||
0.00000000e+00
|
||||
0.00000000e+00
|
||||
0.00000000e+00
|
||||
0.00000000e+00
|
||||
0.00000000e+00
|
||||
0.00000000e+00
|
||||
0.00000000e+00
|
||||
0.00000000e+00
|
||||
0.00000000e+00
|
||||
0.00000000e+00
|
||||
0.00000000e+00
|
||||
0.00000000e+00
|
||||
0.00000000e+00
|
||||
0.00000000e+00
|
||||
0.00000000e+00
|
||||
0.00000000e+00
|
||||
0.00000000e+00
|
||||
0.00000000e+00
|
||||
0.00000000e+00
|
||||
0.00000000e+00
|
||||
0.00000000e+00
|
||||
0.00000000e+00
|
||||
0.00000000e+00
|
||||
0.00000000e+00
|
||||
0.00000000e+00
|
||||
0.00000000e+00
|
||||
0.00000000e+00
|
||||
0.00000000e+00
|
||||
0.00000000e+00
|
||||
0.00000000e+00
|
||||
0.00000000e+00
|
||||
0.00000000e+00
|
||||
0.00000000e+00
|
||||
0.00000000e+00
|
||||
0.00000000e+00
|
||||
0.00000000e+00
|
||||
0.00000000e+00
|
||||
0.00000000e+00
|
||||
0.00000000e+00
|
||||
0.00000000e+00
|
||||
0.00000000e+00
|
||||
0.00000000e+00
|
||||
0.00000000e+00
|
||||
0.00000000e+00
|
||||
0.00000000e+00
|
||||
0.00000000e+00
|
||||
0.00000000e+00
|
||||
0.00000000e+00
|
||||
0.00000000e+00
|
||||
0.00000000e+00
|
||||
0.00000000e+00
|
||||
0.00000000e+00
|
||||
0.00000000e+00
|
||||
0.00000000e+00
|
||||
0.00000000e+00
|
||||
0.00000000e+00
|
||||
0.00000000e+00
|
||||
0.00000000e+00
|
||||
0.00000000e+00
|
||||
0.00000000e+00
|
||||
0.00000000e+00
|
||||
0.00000000e+00
|
||||
0.00000000e+00
|
||||
0.00000000e+00
|
||||
0.00000000e+00
|
||||
0.00000000e+00
|
||||
0.00000000e+00
|
||||
0.00000000e+00
|
||||
0.00000000e+00
|
||||
0.00000000e+00
|
||||
0.00000000e+00
|
||||
0.00000000e+00
|
||||
0.00000000e+00
|
||||
0.00000000e+00
|
||||
0.00000000e+00
|
||||
0.00000000e+00
|
||||
0.00000000e+00
|
||||
0.00000000e+00
|
||||
0.00000000e+00
|
||||
0.00000000e+00
|
||||
0.00000000e+00
|
||||
0.00000000e+00
|
||||
0.00000000e+00
|
||||
0.00000000e+00
|
||||
0.00000000e+00
|
||||
0.00000000e+00
|
||||
0.00000000e+00
|
||||
0.00000000e+00
|
||||
0.00000000e+00
|
||||
0.00000000e+00
|
||||
0.00000000e+00
|
||||
0.00000000e+00
|
||||
0.00000000e+00
|
||||
0.00000000e+00
|
||||
0.00000000e+00
|
||||
0.00000000e+00
|
||||
0.00000000e+00
|
||||
0.00000000e+00
|
||||
0.00000000e+00
|
||||
0.00000000e+00
|
||||
0.00000000e+00
|
||||
0.00000000e+00
|
||||
0.00000000e+00
|
||||
0.00000000e+00
|
||||
0.00000000e+00
|
||||
0.00000000e+00
|
||||
0.00000000e+00
|
||||
0.00000000e+00
|
||||
0.00000000e+00
|
||||
0.00000000e+00
|
||||
0.00000000e+00
|
||||
0.00000000e+00
|
||||
@@ -0,0 +1,502 @@
|
||||
1651 9 c000 1 1f5 10
|
||||
0.0
|
||||
0.0
|
||||
0.0
|
||||
0.0
|
||||
0.0
|
||||
0.0
|
||||
0.0
|
||||
0.0
|
||||
0.0
|
||||
0.0
|
||||
0.0
|
||||
0.0
|
||||
0.0
|
||||
0.0
|
||||
0.0
|
||||
0.0
|
||||
0.0
|
||||
0.0
|
||||
0.0
|
||||
0.0
|
||||
0.0
|
||||
0.0
|
||||
0.0
|
||||
0.0
|
||||
0.0
|
||||
0.0
|
||||
0.0
|
||||
0.0
|
||||
0.0
|
||||
0.0
|
||||
0.0
|
||||
0.0
|
||||
0.0
|
||||
0.0
|
||||
0.0
|
||||
0.0
|
||||
0.0
|
||||
0.0
|
||||
0.0
|
||||
0.0
|
||||
0.0
|
||||
0.0
|
||||
0.0
|
||||
0.0
|
||||
0.0
|
||||
0.0
|
||||
0.0
|
||||
0.0
|
||||
0.0
|
||||
0.0
|
||||
0.984732032
|
||||
0.985187709
|
||||
0.982450664
|
||||
0.977129519
|
||||
0.969670475
|
||||
0.960399866
|
||||
0.949556708
|
||||
0.937906206
|
||||
0.925458729
|
||||
0.911630392
|
||||
0.897134006
|
||||
0.88253212
|
||||
0.867095113
|
||||
0.850838721
|
||||
0.834955096
|
||||
0.818626642
|
||||
0.801803768
|
||||
0.784449935
|
||||
0.767719507
|
||||
0.750176072
|
||||
0.732458055
|
||||
0.714482546
|
||||
0.69677949
|
||||
0.679186642
|
||||
0.661584914
|
||||
0.643296063
|
||||
0.625554621
|
||||
0.607573867
|
||||
0.589917958
|
||||
0.572450101
|
||||
0.554479182
|
||||
0.537230074
|
||||
0.519909739
|
||||
0.50248611
|
||||
0.485527396
|
||||
0.468898982
|
||||
0.451912045
|
||||
0.435792863
|
||||
0.419749171
|
||||
0.403160006
|
||||
0.387892604
|
||||
0.372483075
|
||||
0.356959075
|
||||
0.341931999
|
||||
0.327299654
|
||||
0.312986642
|
||||
0.299529314
|
||||
0.285588682
|
||||
0.271874666
|
||||
0.258948803
|
||||
0.246671498
|
||||
0.233759791
|
||||
0.222145841
|
||||
0.210414022
|
||||
0.199218243
|
||||
0.187896281
|
||||
0.177695274
|
||||
0.167247444
|
||||
0.157241136
|
||||
0.148222104
|
||||
0.138858452
|
||||
0.12986587
|
||||
0.121809088
|
||||
0.113370478
|
||||
0.105866991
|
||||
0.0985721201
|
||||
0.091504164
|
||||
0.0852680579
|
||||
0.0785744935
|
||||
0.0727612823
|
||||
0.0671182498
|
||||
0.0616747439
|
||||
0.0570434704
|
||||
0.0525325015
|
||||
0.048185356
|
||||
0.0440344587
|
||||
0.040693827
|
||||
0.0368830413
|
||||
0.0339437723
|
||||
0.0311707556
|
||||
0.0291866511
|
||||
0.026716806
|
||||
0.0245189443
|
||||
0.0231880397
|
||||
0.0220201313
|
||||
0.0204587355
|
||||
0.0198277235
|
||||
0.0188161656
|
||||
0.0187446401
|
||||
0.0183000267
|
||||
0.0182103366
|
||||
0.0190511569
|
||||
0.0189203545
|
||||
0.0198489726
|
||||
0.0204917192
|
||||
0.0215548798
|
||||
0.0230059028
|
||||
0.0242300928
|
||||
0.0253278688
|
||||
0.0269627869
|
||||
0.0290726051
|
||||
0.0310190395
|
||||
0.0328864902
|
||||
0.0353267714
|
||||
0.0370861851
|
||||
0.0395279415
|
||||
0.041960258
|
||||
0.0444255173
|
||||
0.0475475192
|
||||
0.050049793
|
||||
0.052689556
|
||||
0.0554709136
|
||||
0.0583969653
|
||||
0.0614704527
|
||||
0.0646934658
|
||||
0.0674761161
|
||||
0.0705284104
|
||||
0.0738192797
|
||||
0.076736182
|
||||
0.0799702927
|
||||
0.0834793299
|
||||
0.0860495269
|
||||
0.0896650106
|
||||
0.0923565105
|
||||
0.0955127403
|
||||
0.0990520641
|
||||
0.101732418
|
||||
0.104925446
|
||||
0.107946225
|
||||
0.111431904
|
||||
0.114119798
|
||||
0.117364772
|
||||
0.119878992
|
||||
0.123000547
|
||||
0.126018032
|
||||
0.12837027
|
||||
0.131377488
|
||||
0.134315953
|
||||
0.136615247
|
||||
0.138997868
|
||||
0.142033353
|
||||
0.144408852
|
||||
0.146851152
|
||||
0.148754478
|
||||
0.15140456
|
||||
0.153462857
|
||||
0.155638605
|
||||
0.157311857
|
||||
0.159167767
|
||||
0.161159694
|
||||
0.163251966
|
||||
0.164828926
|
||||
0.166580006
|
||||
0.168459237
|
||||
0.169843316
|
||||
0.171415955
|
||||
0.172537416
|
||||
0.173879266
|
||||
0.175384164
|
||||
0.176418513
|
||||
0.17765969
|
||||
0.178462356
|
||||
0.179494858
|
||||
0.18010655
|
||||
0.180960417
|
||||
0.181402266
|
||||
0.18209298
|
||||
0.182966709
|
||||
0.183384746
|
||||
0.184019953
|
||||
0.184223861
|
||||
0.184663087
|
||||
0.184683859
|
||||
0.184949666
|
||||
0.184803501
|
||||
0.184907183
|
||||
0.185194045
|
||||
0.18502444
|
||||
0.185071781
|
||||
0.184686944
|
||||
0.184536234
|
||||
0.184556618
|
||||
0.184112966
|
||||
0.183288097
|
||||
0.183324918
|
||||
0.182852805
|
||||
0.181967169
|
||||
0.181328177
|
||||
0.180870444
|
||||
0.180545717
|
||||
0.17972672
|
||||
0.179096311
|
||||
0.178603843
|
||||
0.177621514
|
||||
0.176830411
|
||||
0.17558825
|
||||
0.175155848
|
||||
0.174176261
|
||||
0.173345357
|
||||
-0.812108696
|
||||
-0.813798308
|
||||
-0.812119961
|
||||
-0.807729721
|
||||
-0.801108062
|
||||
-0.793198109
|
||||
-0.783549368
|
||||
-0.772380233
|
||||
-0.761033535
|
||||
-0.748210549
|
||||
-0.734649658
|
||||
-0.72093302
|
||||
-0.706934988
|
||||
-0.691974759
|
||||
-0.677282274
|
||||
-0.661478341
|
||||
-0.645832956
|
||||
-0.630176246
|
||||
-0.613792717
|
||||
-0.597889245
|
||||
-0.581067979
|
||||
-0.56458658
|
||||
-0.547674894
|
||||
-0.53090924
|
||||
-0.514161944
|
||||
-0.497338653
|
||||
-0.480369985
|
||||
-0.463796288
|
||||
-0.446872354
|
||||
-0.430191815
|
||||
-0.413640589
|
||||
-0.397134781
|
||||
-0.380612016
|
||||
-0.364617825
|
||||
-0.348410964
|
||||
-0.332588941
|
||||
-0.316448629
|
||||
-0.301206768
|
||||
-0.285472572
|
||||
-0.270508617
|
||||
-0.255549908
|
||||
-0.241176009
|
||||
-0.226670668
|
||||
-0.212650478
|
||||
-0.198426038
|
||||
-0.185224026
|
||||
-0.171661466
|
||||
-0.158415988
|
||||
-0.146025047
|
||||
-0.133741677
|
||||
-0.121568412
|
||||
-0.110098213
|
||||
-0.0986248776
|
||||
-0.0877719074
|
||||
-0.0768552274
|
||||
-0.0665146485
|
||||
-0.0560784526
|
||||
-0.0467858091
|
||||
-0.0372636616
|
||||
-0.0281965043
|
||||
-0.0195362847
|
||||
-0.0112478621
|
||||
-0.00330558047
|
||||
0.00430907588
|
||||
0.0116095822
|
||||
0.0186055936
|
||||
0.0253039896
|
||||
0.0317097716
|
||||
0.0372354388
|
||||
0.0431820974
|
||||
0.0482211411
|
||||
0.0536606535
|
||||
0.0581771657
|
||||
0.0624916032
|
||||
0.0665820912
|
||||
0.0704322904
|
||||
0.0734393448
|
||||
0.0768928453
|
||||
0.0794559419
|
||||
0.0824304819
|
||||
0.0844885632
|
||||
0.0863478929
|
||||
0.0885748491
|
||||
0.0898526534
|
||||
0.0909071863
|
||||
0.0923108533
|
||||
0.0927512348
|
||||
0.0935482383
|
||||
0.0939778537
|
||||
0.0940595344
|
||||
0.0938073173
|
||||
0.0938221142
|
||||
0.0934031978
|
||||
0.0925870687
|
||||
0.0919910595
|
||||
0.0909265354
|
||||
0.0894387811
|
||||
0.0881516337
|
||||
0.0869719908
|
||||
0.0852406472
|
||||
0.0830246061
|
||||
0.0815543085
|
||||
0.0794495344
|
||||
0.077389732
|
||||
0.0753225461
|
||||
0.07261879
|
||||
0.0705488622
|
||||
0.0677618682
|
||||
0.0655495003
|
||||
0.0625764579
|
||||
0.0595551804
|
||||
0.057048209
|
||||
0.0543268509
|
||||
0.0514071174
|
||||
0.0483007282
|
||||
0.0456068926
|
||||
0.0420330316
|
||||
0.0395043381
|
||||
0.036008954
|
||||
0.0334951207
|
||||
0.0299678184
|
||||
0.0267969538
|
||||
0.0238860603
|
||||
0.0205736365
|
||||
0.0175158046
|
||||
0.0146431848
|
||||
0.0113141406
|
||||
0.00879008509
|
||||
0.00571362954
|
||||
0.00219025183
|
||||
-0.000521233305
|
||||
-0.00318942592
|
||||
-0.00641816854
|
||||
-0.00891835429
|
||||
-0.012027096
|
||||
-0.0150332395
|
||||
-0.0173750222
|
||||
-0.020372428
|
||||
-0.0227109883
|
||||
-0.0251184348
|
||||
-0.0281687137
|
||||
-0.0305507556
|
||||
-0.0324040353
|
||||
-0.0350122824
|
||||
-0.0370344259
|
||||
-0.0391787142
|
||||
-0.0414139852
|
||||
-0.0437174551
|
||||
-0.0454816036
|
||||
-0.0474020839
|
||||
-0.0494385809
|
||||
-0.0509707257
|
||||
-0.0526847616
|
||||
-0.0545334518
|
||||
-0.055891376
|
||||
-0.057441052
|
||||
-0.0591325052
|
||||
-0.0603383407
|
||||
-0.0617396496
|
||||
-0.0626945645
|
||||
-0.0638736114
|
||||
-0.065218024
|
||||
-0.0660938919
|
||||
-0.0665868148
|
||||
-0.0673501641
|
||||
-0.0683126301
|
||||
-0.0694218874
|
||||
-0.0700488761
|
||||
-0.0702826083
|
||||
-0.0707790777
|
||||
-0.0714687929
|
||||
-0.0717100948
|
||||
-0.0721736327
|
||||
-0.0722098276
|
||||
-0.0724835619
|
||||
-0.0723412037
|
||||
-0.0724445581
|
||||
-0.072728388
|
||||
-0.0725541487
|
||||
-0.072594814
|
||||
-0.0722024664
|
||||
-0.0720432624
|
||||
-0.072055243
|
||||
-0.0716020763
|
||||
-0.0713584349
|
||||
-0.0712684467
|
||||
-0.0707005113
|
||||
-0.0703325421
|
||||
-0.0695204362
|
||||
-0.0689329952
|
||||
-0.0685102195
|
||||
-0.0682080463
|
||||
-0.0674034879
|
||||
-0.0667807981
|
||||
-0.0662912726
|
||||
-0.0653084666
|
||||
-0.0645141006
|
||||
-0.0638576746
|
||||
-0.0627112836
|
||||
-0.0623465478
|
||||
-0.0614133961
|
||||
-0.060613621
|
||||
-0.0593204275
|
||||
-0.0588062294
|
||||
-0.0577216744
|
||||
-0.0567688569
|
||||
-0.0559122004
|
||||
-0.055125583
|
||||
-0.0537991077
|
||||
-0.0532174408
|
||||
-0.052040223
|
||||
-0.0509762615
|
||||
-0.0499947704
|
||||
-0.0490732118
|
||||
-0.0481950492
|
||||
-0.0473481566
|
||||
-0.0459328517
|
||||
-0.0452413931
|
||||
-0.0445296802
|
||||
-0.043211814
|
||||
-0.0419992357
|
||||
-0.041454073
|
||||
-0.0402564928
|
||||
-0.0391303375
|
||||
-0.038646698
|
||||
-0.0374924019
|
||||
-0.0363961793
|
||||
-0.0359326676
|
||||
-0.0347913131
|
||||
-0.0337027833
|
||||
-0.0326523259
|
||||
-0.0322198942
|
||||
-0.0310988948
|
||||
-0.0306136012
|
||||
-0.0294526573
|
||||
-0.0289368648
|
||||
-0.027752392
|
||||
-0.0272181872
|
||||
-0.0260189995
|
||||
-0.0254728477
|
||||
-0.0248545073
|
||||
-0.0241826791
|
||||
-0.0234711226
|
||||
-0.0227298588
|
||||
-0.0219662879
|
||||
-0.0211858302
|
||||
-0.020392416
|
||||
-0.0201797523
|
||||
-0.0192512218
|
||||
-0.0189384837
|
||||
-0.0185263604
|
||||
-0.0174501576
|
||||
@@ -0,0 +1,422 @@
|
||||
/* DCL.h - C2000 Digital Control Library
|
||||
*
|
||||
*/
|
||||
//#############################################################################
|
||||
//!
|
||||
//! Copyright: Copyright (C) 2023 Texas Instruments Incorporated -
|
||||
//! All rights reserved not granted herein.
|
||||
//! Limited License.
|
||||
//!
|
||||
//! Texas Instruments Incorporated grants a world-wide, royalty-free,
|
||||
//! non-exclusive license under copyrights and patents it now or hereafter
|
||||
//! owns or controls to make, have made, use, import, offer to sell and sell
|
||||
//! ("Utilize") this software subject to the terms herein. With respect to the
|
||||
//! foregoing patent license, such license is granted solely to the extent that
|
||||
//! any such patent is necessary to Utilize the software alone. The patent
|
||||
//! license shall not apply to any combinations which include this software,
|
||||
//! other than combinations with devices manufactured by or for TI
|
||||
//! ("TI Devices").
|
||||
//! No hardware patent is licensed hereunder.
|
||||
//!
|
||||
//! Redistributions must preserve existing copyright notices and reproduce this
|
||||
//! license (including the above copyright notice and the disclaimer and
|
||||
//! (if applicable) source code license limitations below) in the documentation
|
||||
//! and/or other materials provided with the distribution.
|
||||
//!
|
||||
//! Redistribution and use in binary form, without modification, are permitted
|
||||
//! provided that the following conditions are met:
|
||||
//!
|
||||
//! * No reverse engineering, decompilation, or disassembly of this software is
|
||||
//! permitted with respect to any software provided in binary form.
|
||||
//! * Any redistribution and use are licensed by TI for use only
|
||||
//! with TI Devices.
|
||||
//! * Nothing shall obligate TI to provide you with source code for the
|
||||
//! software licensed and provided to you in object code.
|
||||
//!
|
||||
//! If software source code is provided to you, modification and redistribution
|
||||
//! of the source code are permitted provided that the following conditions
|
||||
//! are met:
|
||||
//!
|
||||
//! * any redistribution and use of the source code, including any resulting
|
||||
//! derivative works, are licensed by TI for use only with TI Devices.
|
||||
//! * any redistribution and use of any object code compiled from the source
|
||||
//! code and any resulting derivative works, are licensed by TI for use
|
||||
//! only with TI Devices.
|
||||
//!
|
||||
//! Neither the name of Texas Instruments Incorporated nor the names of its
|
||||
//! suppliers may be used to endorse or promote products derived from this
|
||||
//! software without specific prior written permission.
|
||||
//#############################################################################
|
||||
|
||||
#ifndef _C_DCL_H
|
||||
#define _C_DCL_H
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
//! \file DCL.h
|
||||
//! \brief Contains the public interface to the common
|
||||
//! Digital Controller Library functions
|
||||
|
||||
//! \brief Library version number formatted for numerical comparison
|
||||
//!
|
||||
#define DCL_VERSION 3050000
|
||||
|
||||
#ifndef C2000_IEEE754_TYPES
|
||||
#define C2000_IEEE754_TYPES
|
||||
#ifdef __TI_EABI__
|
||||
typedef float float32_t;
|
||||
typedef double float64_t;
|
||||
#else
|
||||
typedef float float32_t;
|
||||
typedef long double float64_t;
|
||||
#endif // __TI_EABI__
|
||||
#endif // C2000_IEEE754_TYPES
|
||||
|
||||
#ifndef __TMS320C28XX_CLA__
|
||||
|
||||
#include <complex.h>
|
||||
#include <math.h>
|
||||
#include <stdbool.h>
|
||||
#include <stdint.h>
|
||||
#include <stdlib.h>
|
||||
|
||||
//! \brief Local definitions of mathematical constants
|
||||
//!
|
||||
#define CONST_PI_32 3.14159265358979323846f
|
||||
#define CONST_2PI_32 2.0f * CONST_PI_32
|
||||
|
||||
#define CONST_PI_64 3.1415926535897932384626433832795028841971693993751058209749445923078164062L
|
||||
#define CONST_2PI_64 2.0L * CONST_PI_64
|
||||
|
||||
//! \brief Defines 32-bit null address for pointer initialization
|
||||
//!
|
||||
#define NULL_ADDR 0x00000000
|
||||
|
||||
//! \brief Define the acceptable FPU numerical tolerances
|
||||
//!
|
||||
#define DEFAULT_FPU32_TOL 1.0e-06f
|
||||
#define DEFAULT_FPU64_TOL 1.0e-10f
|
||||
|
||||
//! \brief Determines numerical proximity to specified value
|
||||
//!
|
||||
#define F32_IS_VALUE(x,y) (((x < (y + DEFAULT_FPU32_TOL)) && (x > (y - DEFAULT_FPU32_TOL))) ? 1 : 0)
|
||||
#define F64_IS_VALUE(x,y) (((x < (y + DEFAULT_FPU64_TOL)) && (x > (y - DEFAULT_FPU64_TOL))) ? 1 : 0)
|
||||
|
||||
//! \brief Determines numerical proximity to zero
|
||||
//!
|
||||
#define F32_IS_ZERO(x) F32_IS_VALUE(x,0.0f)
|
||||
#define F64_IS_ZERO(x) F64_IS_VALUE(x,0.0L)
|
||||
|
||||
//! \brief Returns a random floating point result between -1.0 and +1.0
|
||||
//! where 'a' is a single or double precision float.
|
||||
//! Useful for initialization of arrays and matrices during test.
|
||||
//! Ensure compiler switch "--fp_mode = relaxed" is set to ensure h/w division.
|
||||
//!
|
||||
//! \code
|
||||
//! float32_t s = DCL_randf(1.0f);
|
||||
//!
|
||||
#define DCL_randf(a) (a * ((float32_t) rand() / (float32_t) (RAND_MAX >> 1) - 1.0f))
|
||||
#define DCL_randf64(a) (a * ((float64_t) rand() / (float64_t) (RAND_MAX >> 1) - 1.0L))
|
||||
|
||||
//! \brief Defines the lower limit on derivative filter coefficient c2
|
||||
//! in order for fc to lie below the Nyquist frequency
|
||||
//!
|
||||
#define DCL_C2_LIMIT_32 ((2.0f - CONST_PI_32) / (2.0f + CONST_PI_32))
|
||||
#define DCL_C2_LIMIT_64 ((2.0L - CONST_PI_64) / (2.0L + CONST_PI_64))
|
||||
|
||||
//! \brief Define the default control period in seconds
|
||||
//!
|
||||
#define DCL_DEFAULT_T_F32 100.0e-06f
|
||||
#define DCL_DEFAULT_T_F64 100.0e-06L
|
||||
|
||||
//! \brief Build the library with controller test points enabled
|
||||
//!
|
||||
#define DCL_TESTPOINTS_ENABLED
|
||||
|
||||
//! \brief Build the library with break points enabled
|
||||
//!
|
||||
#define DCL_BREAK_POINTS_ENABLED
|
||||
|
||||
//! \brief Defines a debug break point
|
||||
//!
|
||||
#ifdef DCL_BREAK_POINTS_ENABLED
|
||||
#define DCL_BREAK_POINT asm(" ESTOP0")
|
||||
#else
|
||||
#define DCL_BREAK_POINT ;
|
||||
#endif
|
||||
|
||||
//! \brief Boundary instructions for atomic code blocks
|
||||
//! Global interrupt mask is set at start of atomic block and
|
||||
//! restored to its' original value at the end
|
||||
//!
|
||||
#ifdef __TMS320C28XX__
|
||||
#define DCL_DISABLE_INTS DCL_disableInts()
|
||||
#define DCL_RESTORE_INTS(v) DCL_restoreInts(v)
|
||||
|
||||
//! \brief Sets global interrupts mask
|
||||
//! \return Original ST1 register value
|
||||
//!
|
||||
static inline int16_t DCL_disableInts(void)
|
||||
{
|
||||
return __disable_interrupts();
|
||||
}
|
||||
|
||||
//! \brief Restores global interrupts if they were previously enabled
|
||||
//! \param[in] v Original ST1 register value
|
||||
//! \return None
|
||||
//!
|
||||
static inline void DCL_restoreInts(int16_t v)
|
||||
{
|
||||
if (0 == (v & 0x1))
|
||||
{
|
||||
__enable_interrupts();
|
||||
}
|
||||
}
|
||||
|
||||
#else
|
||||
#define DCL_DISABLE_INTS 0
|
||||
#define DCL_RESTORE_INTS(v) ;
|
||||
#warning "CPU not recognized. Parameter updates may not be atomic."
|
||||
#endif
|
||||
|
||||
//--- Controller Common Support Structure ------------------------------------
|
||||
|
||||
//! \brief Defines the controller common support structure
|
||||
//!
|
||||
//! \details The CSS is accessed via a pointer in most of the DCL
|
||||
//! controller structs. It contains data used for testing and
|
||||
//! configuring the controller, as well as for error checking.
|
||||
//!
|
||||
typedef struct dcl_css {
|
||||
float32_t tpt; //!< Test point
|
||||
float32_t T; //!< Controller period in seconds
|
||||
uint32_t sts; //!< Status word
|
||||
uint32_t err; //!< Error code
|
||||
uint32_t loc; //!< Error location
|
||||
} DCL_CSS;
|
||||
|
||||
//! \brief Default values to initialize the CSS structure
|
||||
//!
|
||||
#define DCL_CSS_DEFAULTS { 0.0f, DCL_DEFAULT_T_F32, 0UL, 0UL, 0UL }
|
||||
|
||||
//! \brief Loads the controller period in the CSS
|
||||
//! CSS pointer must be configured first
|
||||
//! \param[in] p Pointer to the controller structure
|
||||
//! \param[in] a Sample period in seconds
|
||||
//! \return None
|
||||
//!
|
||||
#define DCL_SET_CONTROLLER_PERIOD(p,a) ((p)->css->T = a)
|
||||
|
||||
//! \brief Re-definition of legacy controller period call
|
||||
//!
|
||||
#define DCL_SET_SAMPLE_RATE DCL_SET_CONTROLLER_PERIOD
|
||||
|
||||
|
||||
//--- Status word ------------------------------------------------------------
|
||||
|
||||
//! \brief Defines the library enumerated status bits
|
||||
//!
|
||||
//! \details To perform a safe parameter update, the user first loads new
|
||||
//! parameters into the controller shadow parameter set, then sets
|
||||
//! the STS_UPDATE_PENDING bit in the controller status word. The
|
||||
//! next call to the update function performs the "shadow-to-
|
||||
//! active" set copy while global interrupts are disabled.
|
||||
//!
|
||||
enum dcl_status_bits {
|
||||
STS_NONE = 0UL, //!< Status empty
|
||||
STS_UPDATE_PENDING = (1U << 0), //!< Parameter update pending
|
||||
STS_CONTROLLER_RUNNING = (1U << 1), //!< Controller operation in progress
|
||||
STS_ADJUSTMENT_RUNNING = (1U << 2) //!< Parameter adjustment in progress
|
||||
};
|
||||
|
||||
//! \brief Macros to set the update flag in the status word to initiate
|
||||
//! controller parameter update on next DCL_update() call, and to
|
||||
//! clear the flag on completion.
|
||||
//!
|
||||
#define DCL_REQUEST_UPDATE(p) ((p)->css->sts |= STS_UPDATE_PENDING)
|
||||
#define DCL_CLEAR_UPDATE_REQUEST(p) ((p)->css->sts &= ~STS_UPDATE_PENDING)
|
||||
|
||||
//! \brief Macro to determine whether a parameter update is pending
|
||||
//! based on the STS_UPDATE_PENDING bit in the status word.
|
||||
#define DCL_UPDATE_WAITING(p) (0U != ((p)->css->sts & STS_UPDATE_PENDING))
|
||||
|
||||
//! \brief Macros placed at the beginning and end of the controller
|
||||
//! so that other functions know a control operation is in
|
||||
//! progress. Typically only used with complex controllers
|
||||
//! which may not be atomic.
|
||||
//!
|
||||
#define DCL_CONTROLLER_BEGIN(p) ((p)->css->sts |= STS_CONTROLLER_RUNNING)
|
||||
#define DCL_CONTROLLER_END(p) ((p)->css->sts &= ~STS_CONTROLLER_RUNNING)
|
||||
|
||||
//! \brief Macro to determine whether a controller is being executed
|
||||
//! based on the DCL_CONTROLLER_RUNNING bit in the status word.
|
||||
#define DCL_CONTROLLER_IN_PROGRESS(p) (0U != ((p)->css->sts & STS_CONTROLLER_RUNNING))
|
||||
|
||||
//! \brief Macros to set the flag in the status word to denote
|
||||
//! that parameter adjustment is in progress, and to
|
||||
//! clear the flag when the target is reached.
|
||||
//!
|
||||
#define DCL_ADJUSTMENT_RUNNING(p) ((p)->css->sts |= STS_ADJUSTMENT_RUNNING)
|
||||
#define DCL_ADJUSTMENT_COMPLETE(p) ((p)->css->sts &= ~STS_ADJUSTMENT_RUNNING)
|
||||
|
||||
//! \brief Macro to determine whether parameter adjustment is underway
|
||||
//! based on the DCL_ADJUSTMENT_RUNNING bit in the status word.
|
||||
#define DCL_ADJUSTMENT_IN_PROGRESS(p) (0U != ((p)->css->sts & STS_ADJUSTMENT_RUNNING))
|
||||
|
||||
|
||||
//--- Error handling ---------------------------------------------------------
|
||||
|
||||
//! \brief Build the library with error handling enabled
|
||||
//!
|
||||
#define DCL_ERROR_HANDLING_ENABLED
|
||||
|
||||
//! \brief Defines the library enumerated error codes
|
||||
//! These will be applied as bit masks in the error handler
|
||||
//!
|
||||
enum dcl_error_codes {
|
||||
ERR_NONE = 0U, //!< No error
|
||||
ERR_PARAM_RANGE = (1U << 0), //!< Parameter range exceeded
|
||||
ERR_PARAM_INVALID = (1U << 1), //!< Parameter not valid
|
||||
ERR_PARAM_WARN = (1U << 2), //!< Parameter warning
|
||||
ERR_INPUT_RANGE = (1U << 3), //!< Input range exceeded
|
||||
ERR_OVERFLOW = (1U << 4), //!< Numerical overflow
|
||||
ERR_UNDERFLOW = (1U << 5), //!< Numerical underflow
|
||||
ERR_VERSION = (1U << 6), //!< Incorrect DCL version
|
||||
ERR_DEVICE = (1U << 7), //!< Device not supported
|
||||
ERR_CONTROLLER = (1U << 8), //!< Controller operation not completed
|
||||
ERR_TIMING = (1U << 9), //!< Timing error
|
||||
ERR_COMPUTATION = (1U << 10) //!< Computation error
|
||||
};
|
||||
|
||||
//! \brief Macro to clear stored error code in CSS
|
||||
//!
|
||||
#define DCL_CLEAR_ERROR_CODE(p) (p->css->err = ERR_NONE)
|
||||
|
||||
//! \brief Macro to store code location of error in CSS
|
||||
//!
|
||||
#define DCL_GET_ERROR_LOC(n) (n->loc = (ERR_NONE == n->err) ? NULL_ADDR : __LINE__)
|
||||
|
||||
//! \brief Define error handling routine
|
||||
//!
|
||||
#define DCL_RUN_ERROR_HANDLER(n) DCL_runErrorHandler(n)
|
||||
|
||||
//! \brief Prototype for external basic error handler [DCL_error.c]
|
||||
//! \param[in] p Pointer to DCL_CSS structure
|
||||
//! \return None
|
||||
//!
|
||||
extern void DCL_runErrorHandler(DCL_CSS *p);
|
||||
|
||||
|
||||
//--- Polynomial stability functions -----------------------------------------
|
||||
|
||||
//! \brief Determines stability of a first order real polynomial
|
||||
//! P(z) = z + a1
|
||||
//! \param[in] a1 Coefficient a1
|
||||
//! \return 'true' if the root has magnitude less than 1, 'false' otherwise
|
||||
//!
|
||||
static inline bool DCL_isStablePn1(float32_t a1)
|
||||
{
|
||||
return(((a1 * a1) < 1.0f) ? true : false);
|
||||
}
|
||||
|
||||
//! \brief Determines stability of a second order polynomial with real coefficients
|
||||
//! P(z) = a0 z^2 + a1 z + a2
|
||||
//! \param[in] a1 Coefficient a1
|
||||
//! \param[in] a2 Coefficient a2
|
||||
//! \return 'true' if both roots have magnitude less than 1, 'false' otherwise
|
||||
//!
|
||||
static inline bool DCL_isStablePn2(float32_t a0, float32_t a1, float32_t a2)
|
||||
{
|
||||
float32_t b0, b1, c0;
|
||||
|
||||
b0 = a0 - a2 * a2 / a0;
|
||||
b1 = a1 - a1 * a2 / a0;
|
||||
c0 = b0 - b1 * b1 / b0;
|
||||
|
||||
if ((a0 > 0.0f) && (b0 > 0.0f) && (c0 > 0.0f))
|
||||
{
|
||||
return(true);
|
||||
}
|
||||
else
|
||||
{
|
||||
return(false);
|
||||
}
|
||||
}
|
||||
|
||||
//! \brief Determines stability of a third order polynomial with real coefficients
|
||||
//! P(z) = a0 z^3 + a1 z^2 + a2 z + a3
|
||||
//! \param[in] a1 Coefficient a1
|
||||
//! \param[in] a2 Coefficient a2
|
||||
//! \param[in] a3 Coefficient a3
|
||||
//! \return 'true' if all roots have magnitude less than 1, 'false' otherwise
|
||||
//!
|
||||
static inline bool DCL_isStablePn3(float32_t a0, float32_t a1, float32_t a2, float32_t a3)
|
||||
{
|
||||
float32_t b0, b1, b2, c0, c1, d0;
|
||||
|
||||
b0 = a0 - a3 * a3 / a0;
|
||||
b1 = a1 - a2 * a3 / a0;
|
||||
b2 = a2 - a1 * a3 / a0;
|
||||
c0 = b0 - b2 * b2 / b0;
|
||||
c1 = b1 - b1 * b2 / b0;
|
||||
d0 = c0 - c1 * c1 / c0;
|
||||
|
||||
if ((a0 > 0.0f) && (b0 > 0.0f) && (c0 > 0.0f) && (d0 > 0.0f))
|
||||
{
|
||||
return(true);
|
||||
}
|
||||
else
|
||||
{
|
||||
return(false);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
//--- ZPK3 structure ---------------------------------------------------------
|
||||
|
||||
//! \brief Defines the DCL_ZPK3 controller structure.
|
||||
//!
|
||||
//! \details Allows controllers to be defined in terms of complex pole
|
||||
//! and zero frequencies. The common structure consists of
|
||||
//! three complex zeros, three complex poles, and a real gain.
|
||||
//! All frequencies must be specified in radians/sec.
|
||||
//!
|
||||
typedef struct dcl_zpk3 {
|
||||
float complex z1;
|
||||
float complex z2;
|
||||
float complex z3;
|
||||
float complex p1;
|
||||
float complex p2;
|
||||
float complex p3;
|
||||
float32_t K;
|
||||
} DCL_ZPK3;
|
||||
|
||||
//! \brief Defines default values to initialize the DCL_ZPK3 structure
|
||||
//!
|
||||
#define ZPK3_DEFAULTS { 0.0f + 0.0f*I, 0.0f + 0.0f*I, 0.0f + 0.0f*I, \
|
||||
0.0f + 0.0f*I, 0.0f + 0.0f*I, 0.0f + 0.0f*I, \
|
||||
1.0f }
|
||||
|
||||
//! \brief Determines stability of a ZPK3 representation by checking pole magnitude
|
||||
//! \param[in] q Pointer to DCL_ZPK3 structure
|
||||
//! \return 'true' if all poles have magnitude less than 1, 'false' otherwise
|
||||
//!
|
||||
static inline bool DCL_isStableZpk3(DCL_ZPK3 *q)
|
||||
{
|
||||
return(((cabsf(q->p1) < 1.0f) && (cabsf(q->p2) < 1.0f) && (cabsf(q->p3) < 1.0f)) ? true : false);
|
||||
}
|
||||
|
||||
|
||||
//----------------------------------------------------------------------------
|
||||
|
||||
#endif // __TMS320C28XX_CLA__
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif // extern "C"
|
||||
|
||||
#endif // _C_DCL_H
|
||||
|
||||
/* end of file */
|
||||
@@ -0,0 +1,255 @@
|
||||
/* DCLC28.h - C2000 Digital Control Library header file (32-bit fixed point)
|
||||
*
|
||||
*/
|
||||
//#############################################################################
|
||||
//!
|
||||
//! Copyright: Copyright (C) 2023 Texas Instruments Incorporated -
|
||||
//! All rights reserved not granted herein.
|
||||
//! Limited License.
|
||||
//!
|
||||
//! Texas Instruments Incorporated grants a world-wide, royalty-free,
|
||||
//! non-exclusive license under copyrights and patents it now or hereafter
|
||||
//! owns or controls to make, have made, use, import, offer to sell and sell
|
||||
//! ("Utilize") this software subject to the terms herein. With respect to the
|
||||
//! foregoing patent license, such license is granted solely to the extent that
|
||||
//! any such patent is necessary to Utilize the software alone. The patent
|
||||
//! license shall not apply to any combinations which include this software,
|
||||
//! other than combinations with devices manufactured by or for TI
|
||||
//! ("TI Devices").
|
||||
//! No hardware patent is licensed hereunder.
|
||||
//!
|
||||
//! Redistributions must preserve existing copyright notices and reproduce this
|
||||
//! license (including the above copyright notice and the disclaimer and
|
||||
//! (if applicable) source code license limitations below) in the documentation
|
||||
//! and/or other materials provided with the distribution.
|
||||
//!
|
||||
//! Redistribution and use in binary form, without modification, are permitted
|
||||
//! provided that the following conditions are met:
|
||||
//!
|
||||
//! * No reverse engineering, decompilation, or disassembly of this software is
|
||||
//! permitted with respect to any software provided in binary form.
|
||||
//! * Any redistribution and use are licensed by TI for use only
|
||||
//! with TI Devices.
|
||||
//! * Nothing shall obligate TI to provide you with source code for the
|
||||
//! software licensed and provided to you in object code.
|
||||
//!
|
||||
//! If software source code is provided to you, modification and redistribution
|
||||
//! of the source code are permitted provided that the following conditions
|
||||
//! are met:
|
||||
//!
|
||||
//! * any redistribution and use of the source code, including any resulting
|
||||
//! derivative works, are licensed by TI for use only with TI Devices.
|
||||
//! * any redistribution and use of any object code compiled from the source
|
||||
//! code and any resulting derivative works, are licensed by TI for use
|
||||
//! only with TI Devices.
|
||||
//!
|
||||
//! Neither the name of Texas Instruments Incorporated nor the names of its
|
||||
//! suppliers may be used to endorse or promote products derived from this
|
||||
//! software without specific prior written permission.
|
||||
//#############################################################################
|
||||
|
||||
#ifndef _C_DCLC28_H
|
||||
#define _C_DCLC28_H
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
//! \file DCLC28.h
|
||||
//! \brief Contains the public interface to the
|
||||
//! fixed-point Digital Controller Library functions
|
||||
|
||||
#include "DCL.h"
|
||||
#include <stdint.h>
|
||||
|
||||
#define Q24_PLUS_1 0x01000000
|
||||
#define Q24_MINUS_1 0xFF000000
|
||||
|
||||
|
||||
//--- Linear PID controller ---------------------------------------------------
|
||||
|
||||
//! \brief Defines the DCL_PID32 shadow parameter set
|
||||
//!
|
||||
typedef struct dcl_pid32_sps {
|
||||
int32_t Kp; //!< Proportional gain
|
||||
int32_t Ki; //!< Integral gain
|
||||
int32_t Kd; //!< Derivative gain
|
||||
int32_t c1; //!< D-term filter coefficient 1
|
||||
int32_t c2; //!< D-term filter coefficient 2
|
||||
int32_t Umax; //!< Upper saturation limit
|
||||
int32_t Umin; //!< Lower saturation limit
|
||||
} DCL_PID32_SPS;
|
||||
|
||||
//! \brief Defines default values to initialize the DCL_PID shadow structure
|
||||
//!
|
||||
#define PID32_SPS_DEFAULTS { Q24_PLUS_1, 0L, 0L, Q24_PLUS_1, 0L, \
|
||||
Q24_PLUS_1, Q24_MINUS_1 }
|
||||
|
||||
//! \brief Defines the fixed-point linear PID32 controller structure
|
||||
//!
|
||||
typedef struct dcl_pid32 {
|
||||
int32_t Kp; //!< Proportional gain
|
||||
int32_t Ki; //!< Integral gain
|
||||
int32_t Kd; //!< Derivative gain
|
||||
int32_t c1; //!< D-term filter coefficient 1
|
||||
int32_t c2; //!< D-term filter coefficient 2
|
||||
int32_t d2; //!< D-term filter intermediate storage 1
|
||||
int32_t d3; //!< D-term filter intermediate storage 2
|
||||
int32_t i10; //!< I-term intermediate storage
|
||||
int32_t i14; //!< Intermediate saturation storage
|
||||
int32_t Umax; //!< Upper saturation limit
|
||||
int32_t Umin; //!< Lower saturation limit
|
||||
DCL_PID32_SPS *sps; //!< Pointer to the shadow parameter set
|
||||
DCL_CSS *css; //!< Pointer to the common support structure
|
||||
} DCL_PID32;
|
||||
|
||||
//! \brief Defines default values to initialize the PID structure
|
||||
//!
|
||||
#define DCL_PID32_DEFAULTS { Q24_PLUS_1, 0L, 0L, Q24_PLUS_1, 0L, 0L, 0L, 0L, \
|
||||
Q24_PLUS_1, Q24_PLUS_1, Q24_MINUS_1, \
|
||||
NULL_ADDR, NULL_ADDR }
|
||||
|
||||
//! \brief Resets PID internal storage data
|
||||
//! \param[in] p Pointer to the DCL_PID32 structure
|
||||
//! \return None
|
||||
//!
|
||||
static inline void DCL_resetPID32(DCL_PID32 *p)
|
||||
{
|
||||
uint16_t v;
|
||||
|
||||
v = DCL_DISABLE_INTS;
|
||||
p->d2 = p->d3 = p->i10 = 0L;
|
||||
p->i14 = Q24_PLUS_1;
|
||||
DCL_RESTORE_INTS(v);
|
||||
}
|
||||
|
||||
//! \brief Loads PID tuning parameters
|
||||
//! \param[in] p Pointer to the DCL_PID32 active controller structure
|
||||
//! \return None
|
||||
//!
|
||||
static inline void DCL_updatePID32(DCL_PID32 *p)
|
||||
{
|
||||
uint16_t v;
|
||||
|
||||
if (p->css->sts & STS_UPDATE_PENDING)
|
||||
{
|
||||
v = DCL_DISABLE_INTS;
|
||||
p->Kp = p->sps->Kp;
|
||||
p->Ki = p->sps->Ki;
|
||||
p->Kd = p->sps->Kd;
|
||||
p->c1 = p->sps->c1;
|
||||
p->c2 = p->sps->c2;
|
||||
p->Umax = p->sps->Umax;
|
||||
p->Umin = p->sps->Umin;
|
||||
DCL_RESTORE_INTS(v);
|
||||
DCL_CLEAR_UPDATE_REQUEST(p);
|
||||
}
|
||||
}
|
||||
|
||||
//! \brief Loads PID32 tuning parameters
|
||||
//! Implemented as assembly module
|
||||
//! \param[in] p Pointer to the active DCL_PID32 controller structure
|
||||
//! \return None
|
||||
//!
|
||||
extern void DCL_fupdatePID32(DCL_PID32 *p);
|
||||
|
||||
//! \brief Executes a parallel form PID controller on the C28x
|
||||
//! \param[in] p Pointer to the DCL_PID32 structure
|
||||
//! \param[in] rk The controller set-point reference
|
||||
//! \param[in] yk The measured feedback value
|
||||
//! \param[in] lk External output clamp flag
|
||||
//! \return The control effort
|
||||
//!
|
||||
extern int32_t DCL_runPID_A1(DCL_PID32 *p, int32_t rk, int32_t yk);
|
||||
|
||||
|
||||
//--- Linear PI controller ----------------------------------------------------
|
||||
|
||||
//! \brief Defines the PI32 shadow parameter set
|
||||
//!
|
||||
typedef struct dcl_pi32_sps {
|
||||
int32_t Kp; //!< Proportional gain
|
||||
int32_t Ki; //!< Integral gain
|
||||
int32_t Umax; //!< Upper saturation limit
|
||||
int32_t Umin; //!< Lower saturation limit
|
||||
} DCL_PI32_SPS;
|
||||
|
||||
//! \brief Defines default values to initialize the PI32 shadow structure
|
||||
//!
|
||||
#define PI32_SPS_DEFAULTS { Q24_PLUS_1, 0L, Q24_PLUS_1, Q24_MINUS_1 }
|
||||
|
||||
//! \brief Defines the PI32 controller structure
|
||||
//!
|
||||
typedef struct dcl_pi32 {
|
||||
int32_t Kp; //!< Proportional gain
|
||||
int32_t Ki; //!< Integral gain
|
||||
int32_t i6; //!< Saturation storage
|
||||
int32_t i10; //!< I storage
|
||||
int32_t Umax; //!< Upper saturation limit
|
||||
int32_t Umin; //!< Lower saturation limit
|
||||
DCL_PI32_SPS *sps; //!< Pointer to the shadow parameter set
|
||||
DCL_CSS *css; //!< Pointer to the common support structure
|
||||
} DCL_PI32;
|
||||
|
||||
//! \brief Defines default values to initialize the active PI structure
|
||||
//!
|
||||
#define DCL_PI32_DEFAULTS { Q24_PLUS_1, 0L, Q24_PLUS_1, 0L, \
|
||||
Q24_PLUS_1, Q24_MINUS_1, \
|
||||
NULL_ADDR, NULL_ADDR }
|
||||
|
||||
//! \brief Resets PI32 internal storage data
|
||||
//! \param[in] p Pointer to the DCL_PI32 active controller structure
|
||||
//! \return None
|
||||
//!
|
||||
static inline void DCL_resetPI32(DCL_PI32 *p)
|
||||
{
|
||||
int16_t v;
|
||||
|
||||
v = DCL_DISABLE_INTS;
|
||||
p->i10 = 0L;
|
||||
p->i6 = Q24_PLUS_1;
|
||||
DCL_RESTORE_INTS(v);
|
||||
}
|
||||
|
||||
//! \brief Loads active PI32 controller parameters
|
||||
//! \param[in] p Pointer to the DCL_PI32 active controller structure
|
||||
//! \return None
|
||||
//!
|
||||
static inline void DCL_updatePI32(DCL_PI32 *p)
|
||||
{
|
||||
uint16_t v;
|
||||
|
||||
if (p->css->sts & STS_UPDATE_PENDING)
|
||||
{
|
||||
v = DCL_DISABLE_INTS;
|
||||
p->Kp = p->sps->Kp;
|
||||
p->Ki = p->sps->Ki;
|
||||
p->Umax = p->sps->Umax;
|
||||
p->Umin = p->sps->Umin;
|
||||
DCL_RESTORE_INTS(v);
|
||||
DCL_CLEAR_UPDATE_REQUEST(p);
|
||||
}
|
||||
}
|
||||
|
||||
//! \brief Loads PI32 tuning parameters
|
||||
//! Implemented as assembly module
|
||||
//! \param[in] p Pointer to the active DCL_PI32 controller structure
|
||||
//! \return None
|
||||
//!
|
||||
extern void DCL_fupdatePI32(DCL_PI32 *p);
|
||||
|
||||
//! \brief Executes a series form PI_FP controller on the C28x
|
||||
//! \param[in] p Pointer to the DCL_PI structure
|
||||
//! \param[in] rk The controller set-point reference
|
||||
//! \param[in] yk The measured feedback value
|
||||
//! \return The control effort
|
||||
//!
|
||||
extern int32_t DCL_runPI_A1(DCL_PI32 *p, int32_t rk, int32_t yk);
|
||||
|
||||
//----------------------------------------------------------------------------
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif // extern "C"
|
||||
|
||||
#endif // _C_DCLC28_H
|
||||
@@ -0,0 +1,479 @@
|
||||
/* DCLCLA.h - C2000 Digital Controller Library header file
|
||||
*
|
||||
*/
|
||||
//#############################################################################
|
||||
//!
|
||||
//! Copyright: Copyright (C) 2023 Texas Instruments Incorporated -
|
||||
//! All rights reserved not granted herein.
|
||||
//! Limited License.
|
||||
//!
|
||||
//! Texas Instruments Incorporated grants a world-wide, royalty-free,
|
||||
//! non-exclusive license under copyrights and patents it now or hereafter
|
||||
//! owns or controls to make, have made, use, import, offer to sell and sell
|
||||
//! ("Utilize") this software subject to the terms herein. With respect to the
|
||||
//! foregoing patent license, such license is granted solely to the extent that
|
||||
//! any such patent is necessary to Utilize the software alone. The patent
|
||||
//! license shall not apply to any combinations which include this software,
|
||||
//! other than combinations with devices manufactured by or for TI
|
||||
//! ("TI Devices").
|
||||
//! No hardware patent is licensed hereunder.
|
||||
//!
|
||||
//! Redistributions must preserve existing copyright notices and reproduce this
|
||||
//! license (including the above copyright notice and the disclaimer and
|
||||
//! (if applicable) source code license limitations below) in the documentation
|
||||
//! and/or other materials provided with the distribution.
|
||||
//!
|
||||
//! Redistribution and use in binary form, without modification, are permitted
|
||||
//! provided that the following conditions are met:
|
||||
//!
|
||||
//! * No reverse engineering, decompilation, or disassembly of this software is
|
||||
//! permitted with respect to any software provided in binary form.
|
||||
//! * Any redistribution and use are licensed by TI for use only
|
||||
//! with TI Devices.
|
||||
//! * Nothing shall obligate TI to provide you with source code for the
|
||||
//! software licensed and provided to you in object code.
|
||||
//!
|
||||
//! If software source code is provided to you, modification and redistribution
|
||||
//! of the source code are permitted provided that the following conditions
|
||||
//! are met:
|
||||
//!
|
||||
//! * any redistribution and use of the source code, including any resulting
|
||||
//! derivative works, are licensed by TI for use only with TI Devices.
|
||||
//! * any redistribution and use of any object code compiled from the source
|
||||
//! code and any resulting derivative works, are licensed by TI for use
|
||||
//! only with TI Devices.
|
||||
//!
|
||||
//! Neither the name of Texas Instruments Incorporated nor the names of its
|
||||
//! suppliers may be used to endorse or promote products derived from this
|
||||
//! software without specific prior written permission.
|
||||
//#############################################################################
|
||||
|
||||
#ifndef _C_DCLCLA_H
|
||||
#define _C_DCLCLA_H
|
||||
|
||||
//! \file DCLCLA.h
|
||||
//! \brief Contains the public interface to the
|
||||
//! Digital Controller Library CLA functions
|
||||
|
||||
#include "DCL.h"
|
||||
|
||||
|
||||
//--- Linear PID controller ---------------------------------------------------
|
||||
|
||||
//! \brief Defines the DCL_PID_CLA controller structure
|
||||
//!
|
||||
typedef struct {
|
||||
float32_t Kp; //!< Proportional gain
|
||||
float32_t Ki; //!< Integral gain
|
||||
float32_t Kd; //!< Derivative gain
|
||||
float32_t Kr; //!< Set point weight
|
||||
float32_t c1; //!< D-term filter coefficient 1
|
||||
float32_t c2; //!< D-term filter coefficient 2
|
||||
float32_t d2; //!< D-term filter intermediate storage 1
|
||||
float32_t d3; //!< D-term filter intermediate storage 2
|
||||
float32_t i10; //!< I-term intermediate storage
|
||||
float32_t i14; //!< Intermediate saturation storage
|
||||
float32_t Umax; //!< Upper saturation limit
|
||||
float32_t Umin; //!< Lower saturation limit
|
||||
} DCL_PID_CLA;
|
||||
|
||||
//! \brief Defines default values to initialize the DCL_PID structure
|
||||
//!
|
||||
#define PID_CLA_DEFAULTS { 1.0f, 0.0f, 0.0f, 1.0f, 0.0f, 0.0f, 0.0f, 0.0f, \
|
||||
0.0f, 0.0f, 1.0f, -1.0f }
|
||||
|
||||
//! \brief Executes an ideal form PID controller on the CLA
|
||||
//! \param[in] p Pointer to the DCL_PID_CLA structure
|
||||
//! \param[in] rk The controller set-point reference
|
||||
//! \param[in] yk The measured feedback value
|
||||
//! \param[in] lk External output clamp flag
|
||||
//! \return The control effort
|
||||
//!
|
||||
extern float32_t DCL_runPID_L1(DCL_PID_CLA *p, float32_t rk, float32_t yk, float32_t lk);
|
||||
|
||||
//! \brief Executes a parallel form PID controller on the CLA
|
||||
//! \param[in] p Pointer to the DCL_PID_CLA structure
|
||||
//! \param[in] rk The controller set-point reference
|
||||
//! \param[in] yk The measured feedback value
|
||||
//! \param[in] lk External output clamp flag
|
||||
//! \return The control effort
|
||||
//!
|
||||
extern float32_t DCL_runPID_L2(DCL_PID_CLA *p, float32_t rk, float32_t yk, float32_t lk);
|
||||
|
||||
|
||||
//--- Linear PI controller ----------------------------------------------------
|
||||
|
||||
//! \brief Defines the DCL_PI_CLA controller structure
|
||||
//!
|
||||
typedef struct {
|
||||
float32_t Kp; //!< Proportional gain
|
||||
float32_t Ki; //!< Integral gain
|
||||
float32_t i10; //!< I storage
|
||||
float32_t Umax; //!< Upper control saturation limit
|
||||
float32_t Umin; //!< Lower control saturation limit
|
||||
float32_t i6; //!< Saturation storage
|
||||
float32_t i11; //!< I storage
|
||||
float32_t Imax; //!< Upper integrator saturation limit
|
||||
float32_t Imin; //!< Lower integrator saturation limit
|
||||
} DCL_PI_CLA;
|
||||
|
||||
//! \brief Defines default values to initialize the PI_CLA structure
|
||||
//!
|
||||
#define PI_CLA_DEFAULTS { 1.0f, 0.0f, 0.0f, 1.0f, -1.0f, 1.0f, 1.0f, -1.0f }
|
||||
|
||||
//! \brief Executes a series form PI controller on the CLA
|
||||
//! \param[in] p Pointer to the DCL_PI_CLA structure
|
||||
//! \param[in] rk The controller set-point reference
|
||||
//! \param[in] yk The measured feedback value
|
||||
//! \return The control effort
|
||||
//!
|
||||
extern float32_t DCL_runPI_L1(DCL_PI_CLA *p, float32_t rk, float32_t yk);
|
||||
|
||||
//! \brief Executes a parallel form PI controller on the CLA
|
||||
//! \param[in] p Pointer to the DCL_PI_CLA structure
|
||||
//! \param[in] rk The controller set-point reference
|
||||
//! \param[in] yk The measured feedback value
|
||||
//! \return The control effort
|
||||
//!
|
||||
extern float32_t DCL_runPI_L2(DCL_PI_CLA *p, float32_t rk, float32_t yk);
|
||||
|
||||
//! \brief Executes an inline series form PI controller on the CLA
|
||||
//! Implemented as inline C function
|
||||
//! \param[in] p Pointer to the DCL_PI structure
|
||||
//! \param[in] rk The controller set-point reference
|
||||
//! \param[in] yk The measured feedback value
|
||||
//! \return The control effort
|
||||
//!
|
||||
static inline float32_t DCL_runPI_L3(DCL_PI_CLA *p, float32_t rk, float32_t yk)
|
||||
{
|
||||
float32_t v2, v4, v5, v9;
|
||||
|
||||
asm(" MSETFLG RNDF32=1");
|
||||
v2 = p->Kp * (rk - yk);
|
||||
v4 = p->i10 + (p->Ki * p->i6 * v2);
|
||||
v5 = v2 + v4;
|
||||
v9 = (v5 > p->Umax) ? p->Umax : v5;
|
||||
v9 = (v9 < p->Umin) ? p->Umin : v9;
|
||||
p->i10 = v4;
|
||||
p->i6 = (v5 == v9) ? 1.0f : 0.0f;
|
||||
|
||||
return(v9);
|
||||
}
|
||||
|
||||
//! \brief Executes an parallel form PI controller on the CLA
|
||||
//! Implemented as inline C function
|
||||
//! \param[in] p Pointer to the DCL_PI structure
|
||||
//! \param[in] rk The controller set-point reference
|
||||
//! \param[in] yk The measured feedback value
|
||||
//! \return The control effort
|
||||
//!
|
||||
static inline float32_t DCL_runPI_L4(DCL_PI_CLA *p, float32_t rk, float32_t yk)
|
||||
{
|
||||
float32_t v1, v2, v4, v5, v9;
|
||||
|
||||
asm(" MSETFLG RNDF32=1");
|
||||
v1 = rk - yk;
|
||||
v2 = p->Kp * v1;
|
||||
v4 = (v1 * p->Ki * p->i6) + p->i10;
|
||||
p->i10 = v4;
|
||||
v5 = v2 + v4;
|
||||
v9 = (v5 > p->Umax) ? p->Umax : v5;
|
||||
v9 = (v9 < p->Umin) ? p->Umin : v9;
|
||||
p->i6 = (v5 == v9) ? 1.0f : 0.0f;
|
||||
|
||||
return(v9);
|
||||
}
|
||||
|
||||
//! \brief Executes a series form PI controller with Tustin integrator
|
||||
//! on the CLA.
|
||||
//! \param[in] p Pointer to the DCL_PI_CLA structure
|
||||
//! \param[in] rk The controller set-point reference
|
||||
//! \param[in] yk The measured feedback value
|
||||
//! \return The control effort
|
||||
//!
|
||||
static inline float32_t DCL_runPI_L5(DCL_PI_CLA *p, float32_t rk, float32_t yk)
|
||||
{
|
||||
float32_t v2, v4, v5, v8, v9;
|
||||
|
||||
asm(" MSETFLG RNDF32=1");
|
||||
v2 = (rk - yk) * p->Kp;
|
||||
v8 = v2 * p->Ki * p->i6;
|
||||
v4 = v8 + p->i11 + p->i10;
|
||||
v5 = v2 + v4;
|
||||
p->i10 = v4;
|
||||
p->i11 = v8;
|
||||
v9 = (v5 > p->Umax) ? p->Umax : v5;
|
||||
v9 = (v9 < p->Umin) ? p->Umin : v9;
|
||||
p->i6 = (v5 == v9) ? 1.0f : 0.0f;
|
||||
|
||||
return(v9);
|
||||
}
|
||||
|
||||
|
||||
//--- Direct Form 1 - 1st order -----------------------------------------------
|
||||
|
||||
//! \brief Defines the DCL_DF11 controller structure
|
||||
//!
|
||||
typedef struct {
|
||||
float32_t b0; //!< b0
|
||||
float32_t b1; //!< b1
|
||||
float32_t a1; //!< a1
|
||||
float32_t d1; //!< e(k-1)
|
||||
float32_t d2; //!< u(k-1)
|
||||
} DCL_DF11_CLA;
|
||||
|
||||
//! \brief Defines default values to initialize the DCL_DF11_CLA structure
|
||||
//!
|
||||
#define DF11_CLA_DEFAULTS { 0.5f, 0.5f, 1.0f, 0.0f, 0.0f }
|
||||
|
||||
//! \brief Executes a 1st order Direct Form 1 controller on the CLA
|
||||
//! \param[in] p Pointer to the DCL_DF11_CLA controller structure
|
||||
//! \param[in] ek The servo error
|
||||
//! \return The control effort
|
||||
//!
|
||||
extern float32_t DCL_runDF11_L1(DCL_DF11_CLA *p, float32_t ek);
|
||||
|
||||
|
||||
//--- Direct Form 1 - 3rd order -----------------------------------------------
|
||||
|
||||
//! \brief Defines the DCL_DF13_CLA controller structure
|
||||
//!
|
||||
typedef struct {
|
||||
// coefficients
|
||||
float32_t b0; //!< b0
|
||||
float32_t b1; //!< b1
|
||||
float32_t b2; //!< b2
|
||||
float32_t b3; //!< b3
|
||||
float32_t a0; //!< a0
|
||||
float32_t a1; //!< a1
|
||||
float32_t a2; //!< a2
|
||||
float32_t a3; //!< a3
|
||||
|
||||
//data
|
||||
float32_t d0; //!< e(k)
|
||||
float32_t d1; //!< e(k-1)
|
||||
float32_t d2; //!< e(k-2)
|
||||
float32_t d3; //!< e(k-3)
|
||||
float32_t d4; //!< u(k)
|
||||
float32_t d5; //!< u(k-1)
|
||||
float32_t d6; //!< u(k-2)
|
||||
float32_t d7; //!< u(k-3)
|
||||
} DCL_DF13_CLA;
|
||||
|
||||
//! \brief Defines default values to initialize the DCL_DF13_CLA structure
|
||||
//!
|
||||
#define DF13_CLA_DEFAULTS { 0.25f, 0.25f, 0.25f, 0.25f, 0.0f, 0.0f, 0.0f, 0.0f, \
|
||||
0.0f, 0.0f, 0.0f, 0.0f, 0.0f, 0.0f, 0.0f, 0.0f }
|
||||
|
||||
//! \brief Executes a full 3rd order Direct Form 1 controller on the CLA
|
||||
//! \param[in] p Pointer to the DCL_DF13_CLA controller structure
|
||||
//! \param[in] ek The servo error
|
||||
//! \return The control effort
|
||||
//!
|
||||
extern float32_t DCL_runDF13_L1(DCL_DF13_CLA *p, float32_t ek);
|
||||
|
||||
//! \brief Executes an immediate 3rd order Direct Form 1 controller on the CLA
|
||||
//! \param[in] p Pointer to the DCL_DF13_CLA controller structure
|
||||
//! \param[in] ek The servo error
|
||||
//! \param[in] vk The partial pre-computed control effort
|
||||
//! \return The control effort
|
||||
//!
|
||||
extern float32_t DCL_runDF13_L2(DCL_DF13_CLA *p, float32_t ek, float32_t vk);
|
||||
|
||||
//! \brief Executes a partial pre-computed 3rd order Direct Form 1 controller on the CLA
|
||||
//! \param[in] p Pointer to the DCL_DF13_CLA controller structure
|
||||
//! \param[in] ek The servo error
|
||||
//! \param[in] uk The controller output in the previous sample interval
|
||||
//! \return The control effort
|
||||
//!
|
||||
extern float32_t DCL_runDF13_L3(DCL_DF13_CLA *p, float32_t ek, float32_t uk);
|
||||
|
||||
//! \brief Executes a full 3rd order Direct Form 1 controller on the CLA
|
||||
//! Implemented as inline C function
|
||||
//! Note: d0 not used
|
||||
//! \param[in] p Pointer to the DCL_DF13_CLA controller structure
|
||||
//! \param[in] ek The servo error
|
||||
//! \return The control effort
|
||||
//!
|
||||
static inline float32_t DCL_runDF13_L4(DCL_DF13_CLA *p, float32_t ek)
|
||||
{
|
||||
asm(" MSETFLG RNDF32=1");
|
||||
p->d4 = (ek * p->b0) + (p->d1 * p->b1) + (p->d2 * p->b2) + (p->d3 * p->b3) - (p->d5 * p->a1) - (p->d6 * p->a2) - (p->d7 * p->a3);
|
||||
p->d3 = p->d2;
|
||||
p->d2 = p->d1;
|
||||
p->d1 = ek;
|
||||
p->d7 = p->d6;
|
||||
p->d6 = p->d5;
|
||||
p->d5 = p->d4;
|
||||
|
||||
return(p->d4);
|
||||
}
|
||||
|
||||
//! \brief Executes an immediate 3rd order Direct Form 1 controller on the CLA
|
||||
//! Implemented as inline C function
|
||||
//! \param[in] p Pointer to the DCL_DF13_CLA controller structure
|
||||
//! \param[in] ek The servo error
|
||||
//! \param[in] vk The partial pre-computed control effort
|
||||
//! \return The control effort
|
||||
//!
|
||||
static inline float32_t DCL_runDF13_L5(DCL_DF13_CLA *p, float32_t ek, float32_t vk)
|
||||
{
|
||||
asm(" MSETFLG RNDF32=1");
|
||||
p->d4 = (ek * p->b0) + vk;
|
||||
|
||||
return(p->d4);
|
||||
}
|
||||
|
||||
//! \brief Executes a partial pre-computed 3rd order Direct Form 1 controller on the CLA
|
||||
//! Implemented as inline C function
|
||||
//! Note: d0 not used
|
||||
//! \param[in] p Pointer to the DCL_DF13_CLA controller structure
|
||||
//! \param[in] ek The servo error
|
||||
//! \param[in] uk The controller output in the previous sample interval
|
||||
//! \return The control effort
|
||||
//!
|
||||
static inline float32_t DCL_runDF13_L6(DCL_DF13_CLA *p, float32_t ek, float32_t uk)
|
||||
{
|
||||
float32_t v9;
|
||||
|
||||
asm(" MSETFLG RNDF32=1");
|
||||
v9 = (ek * p->b1) + (p->d1 * p->b2) + (p->d2 * p->b3) - (uk * p->a1) - (p->d5 * p->a2) - (p->d6 * p->a3);
|
||||
p->d2 = p->d1;
|
||||
p->d1 = ek;
|
||||
p->d6 = p->d5;
|
||||
p->d5 = uk;
|
||||
|
||||
return(v9);
|
||||
}
|
||||
|
||||
|
||||
//--- Direct Form 2 - 2nd order -----------------------------------------------
|
||||
|
||||
//! \brief Defines the DCL_DF22_CLA controller structure
|
||||
//!
|
||||
typedef struct {
|
||||
float32_t b0; //!< b0
|
||||
float32_t b1; //!< b1
|
||||
float32_t b2; //!< b2
|
||||
float32_t a1; //!< a1
|
||||
float32_t a2; //!< a2
|
||||
float32_t x1; //!< x1
|
||||
float32_t x2; //!< x2
|
||||
} DCL_DF22_CLA;
|
||||
|
||||
//! \brief Defines default values to initialize the DCL_DF22_CLA structure
|
||||
//!
|
||||
#define DF22_CLA_DEFAULTS { 1.0f, 0.0f, 0.0f, 0.0f, 0.0f, 0.0f, 0.0f }
|
||||
|
||||
//! \brief Executes a full 2nd order Direct Form 2 controller on the CLA
|
||||
//! \param[in] p Pointer to the DCL_DF22_CLA controller structure
|
||||
//! \param[in] ek The servo error
|
||||
//! \return The control effort
|
||||
//!
|
||||
extern float32_t DCL_runDF22_L1(DCL_DF22_CLA *p, float32_t ek);
|
||||
|
||||
//! \brief Executes an immediate 2nd order Direct Form 2 controller on the CLA
|
||||
//! \param[in] p Pointer to the DCL_DF22_CLA controller structure
|
||||
//! \param[in] ek The servo error
|
||||
//! \return The control effort
|
||||
//!
|
||||
extern float32_t DCL_runDF22_L2(DCL_DF22_CLA *p, float32_t ek);
|
||||
|
||||
//! \brief Executes a partial pre-computed 2nd order Direct Form 2 controller on the CLA
|
||||
//! \param[in] p Pointer to the DCL_DF22_CLA controller structure
|
||||
//! \param[in] ek The servo error
|
||||
//! \param[in] uk The controller output in the previous sample interval
|
||||
//!
|
||||
extern void DCL_runDF22_L3(DCL_DF22_CLA *p, float32_t ek, float32_t uk);
|
||||
|
||||
//! \brief Executes a full 2nd order Direct Form 2 controller on the CLA
|
||||
//! Implemented as inline C function
|
||||
//! \param[in] p Pointer to the DCL_DF22 controller structure
|
||||
//! \param[in] ek The servo error
|
||||
//! \return The control effort
|
||||
//!
|
||||
static inline float32_t DCL_runDF22_L4(DCL_DF22_CLA *p, float32_t ek)
|
||||
{
|
||||
float32_t v7;
|
||||
|
||||
asm(" MSETFLG RNDF32=1");
|
||||
v7 = (ek * p->b0) + p->x1;
|
||||
p->x1 = (ek * p->b1) + p->x2 - (v7 * p->a1);
|
||||
p->x2 = (ek * p->b2) - (v7 * p->a2);
|
||||
|
||||
return(v7);
|
||||
}
|
||||
|
||||
|
||||
//--- Direct Form 2 - 3rd order -----------------------------------------------
|
||||
|
||||
//! \brief Defines the DCL_DF23_CLA controller structure
|
||||
//!
|
||||
typedef struct {
|
||||
float32_t b0; //!< b0
|
||||
float32_t b1; //!< b1
|
||||
float32_t b2; //!< b2
|
||||
float32_t b3; //!< b3
|
||||
float32_t a1; //!< a1
|
||||
float32_t a2; //!< a2
|
||||
float32_t a3; //!< a3
|
||||
float32_t x1; //!< x1
|
||||
float32_t x2; //!< x2
|
||||
float32_t x3; //!< x3
|
||||
} DCL_DF23_CLA;
|
||||
|
||||
//! \brief Defines default values to initialize the DCL_DF23_CLA structure
|
||||
//!
|
||||
#define DF23_CLA_DEFAULTS { 1.0f, 0.0f, 0.0f, 0.0f, 0.0f, 0.0f, 0.0f, 0.0f, 0.0f, 0.0f }
|
||||
|
||||
//! \brief Executes a full 3rd order Direct Form 2 controller on the CLA
|
||||
//! \param[in] p Pointer to the DCL_DF23_CLA controller structure
|
||||
//! \param[in] ek The servo error
|
||||
//! \return The control effort
|
||||
//!
|
||||
extern float32_t DCL_runDF23_L1(DCL_DF23_CLA *p, float32_t ek);
|
||||
|
||||
//! \brief Executes an immediate 3rd order Direct Form 2 controller on the CLA
|
||||
//! \param[in] p Pointer to the DCL_DF23_CLA controller structure
|
||||
//! \param[in] ek The servo error
|
||||
//! \return The control effort
|
||||
//!
|
||||
extern float32_t DCL_runDF23_L2(DCL_DF23_CLA *p, float32_t ek);
|
||||
|
||||
//! \brief Executes a partial pre-computed 2nd order Direct Form 2 controller on the CLA
|
||||
//! \param[in] p Pointer to the DCL_DF23_CLA controller structure
|
||||
//! \param[in] ek The servo error
|
||||
//! \param[in] uk The controller output in the previous sample interval
|
||||
//!
|
||||
extern void DCL_runDF23_L3(DCL_DF23_CLA *p, float32_t ek, float32_t uk);
|
||||
|
||||
|
||||
//--- Direct Form 2 - clamp ---------------------------------------------------
|
||||
|
||||
//! \brief Saturates a control variable and returns 1.0f if either limit is exceeded
|
||||
//!
|
||||
//! \details Can be used to saturate a pre-computed Direct Form 2 controller.
|
||||
//! If the immediate result is in range it can be used, otherwise
|
||||
//! it can be clamped and the next partial pre-computation skipped.
|
||||
//! An example of use with a pre-computed DF22 controller follows:
|
||||
//!
|
||||
//! \code
|
||||
//! uk = DCL_runDF22_L2(&arma2, rk); // immediate result from pre-computed controller
|
||||
//! f = DCL_runClamp_L1(&uk, 1.0f, -1.0f); // clamp immediate result to +/-1.0
|
||||
//! // ...use uk here...
|
||||
//! if (0.5f > f) // if immediate result is in range...
|
||||
//! {
|
||||
//! DCL_runDF22_L3(&arma2, rk, uk); // ...pre-compute the next partial result
|
||||
//! }
|
||||
//! \endcode
|
||||
//!
|
||||
//! \param[in] data The address of the data variable
|
||||
//! \param[in] Umax The upper limit
|
||||
//! \param[in] Umin The lower limit
|
||||
//! \return Returns 0.0f if (Umin < data < Umax), else 1.0f
|
||||
//!
|
||||
extern float32_t DCL_runClamp_L1(float32_t *data, float32_t Umax, float32_t Umin);
|
||||
|
||||
#endif // _C_DCLCLA_H
|
||||
|
||||
/* end of file */
|
||||
File diff suppressed because it is too large.
Load diff
@@ -0,0 +1,403 @@
|
||||
/* DCLF64.h - Digital Control Library (64-bit floating point)
|
||||
*
|
||||
*/
|
||||
//#############################################################################
|
||||
//!
|
||||
//! Copyright: Copyright (C) 2023 Texas Instruments Incorporated -
|
||||
//! All rights reserved not granted herein.
|
||||
//! Limited License.
|
||||
//!
|
||||
//! Texas Instruments Incorporated grants a world-wide, royalty-free,
|
||||
//! non-exclusive license under copyrights and patents it now or hereafter
|
||||
//! owns or controls to make, have made, use, import, offer to sell and sell
|
||||
//! ("Utilize") this software subject to the terms herein. With respect to the
|
||||
//! foregoing patent license, such license is granted solely to the extent that
|
||||
//! any such patent is necessary to Utilize the software alone. The patent
|
||||
//! license shall not apply to any combinations which include this software,
|
||||
//! other than combinations with devices manufactured by or for TI
|
||||
//! ("TI Devices").
|
||||
//! No hardware patent is licensed hereunder.
|
||||
//!
|
||||
//! Redistributions must preserve existing copyright notices and reproduce this
|
||||
//! license (including the above copyright notice and the disclaimer and
|
||||
//! (if applicable) source code license limitations below) in the documentation
|
||||
//! and/or other materials provided with the distribution.
|
||||
//!
|
||||
//! Redistribution and use in binary form, without modification, are permitted
|
||||
//! provided that the following conditions are met:
|
||||
//!
|
||||
//! * No reverse engineering, decompilation, or disassembly of this software is
|
||||
//! permitted with respect to any software provided in binary form.
|
||||
//! * Any redistribution and use are licensed by TI for use only
|
||||
//! with TI Devices.
|
||||
//! * Nothing shall obligate TI to provide you with source code for the
|
||||
//! software licensed and provided to you in object code.
|
||||
//!
|
||||
//! If software source code is provided to you, modification and redistribution
|
||||
//! of the source code are permitted provided that the following conditions
|
||||
//! are met:
|
||||
//!
|
||||
//! * any redistribution and use of the source code, including any resulting
|
||||
//! derivative works, are licensed by TI for use only with TI Devices.
|
||||
//! * any redistribution and use of any object code compiled from the source
|
||||
//! code and any resulting derivative works, are licensed by TI for use
|
||||
//! only with TI Devices.
|
||||
//!
|
||||
//! Neither the name of Texas Instruments Incorporated nor the names of its
|
||||
//! suppliers may be used to endorse or promote products derived from this
|
||||
//! software without specific prior written permission.
|
||||
//#############################################################################
|
||||
|
||||
#ifndef _C_DCLF64_H
|
||||
#define _C_DCLF64_H
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
//! \file DCLF64.h
|
||||
//! \brief Contains the public interface to the
|
||||
//! 64-bit PID controller functions
|
||||
|
||||
#include "DCL.h"
|
||||
|
||||
//--- PIDF64 controller -----------------------------------------------
|
||||
|
||||
#pragma CODE_SECTION(DCL_updatePIDF64,"dclfuncs")
|
||||
#pragma CODE_SECTION(DCL_runPIDF64_S1,"dclfuncs")
|
||||
|
||||
//! \brief Defines the shadow PIDF64 controller structure
|
||||
//!
|
||||
typedef struct dcl_pidf64_sps {
|
||||
float64_t Kp; //!< Proportional gain
|
||||
float64_t Ki; //!< Integral gain
|
||||
float64_t Kd; //!< Derivative gain
|
||||
float64_t Kr; //!< Set point weight
|
||||
float64_t c1; //!< D-term filter coefficient 1
|
||||
float64_t c2; //!< D-term filter coefficient 2
|
||||
float64_t Umax; //!< Upper saturation limit
|
||||
float64_t Umin; //!< Lower saturation limit
|
||||
} DCL_PIDF64_SPS;
|
||||
|
||||
//! \brief Defines default values to initialize the DCL_PIDF64 shadow structure
|
||||
//!
|
||||
#define PIDF64_SPS_DEFAULTS { 1.0L, 0.0L, 0.0L, 1.0L, 1.0L, 0.0L, 1.0L, -1.0L }
|
||||
|
||||
//! \brief Defines the active PIDF64 controller structure
|
||||
//!
|
||||
typedef struct dcl_pidf64 {
|
||||
// active parameters
|
||||
float64_t Kp; //!< Proportional gain
|
||||
float64_t Ki; //!< Integral gain
|
||||
float64_t Kd; //!< Derivative gain
|
||||
float64_t Kr; //!< Set point weight
|
||||
float64_t c1; //!< D-term filter coefficient 1
|
||||
float64_t c2; //!< D-term filter coefficient 2
|
||||
float64_t d2; //!< D-term filter intermediate storage 1
|
||||
float64_t d3; //!< D-term filter intermediate storage 2
|
||||
float64_t i10; //!< I-term intermediate storage
|
||||
float64_t i14; //!< Intermediate saturation storage
|
||||
float64_t i16; //!< Spare
|
||||
float64_t Umax; //!< Upper saturation limit
|
||||
float64_t Umin; //!< Lower saturation limit
|
||||
DCL_PIDF64_SPS *sps; //!< Pointer to shadow parameter set
|
||||
DCL_CSS *css; //!< Pointer to common support structure
|
||||
} DCL_PIDF64;
|
||||
|
||||
//! \brief Defines default values to initialize the DCL_PIDF64 active structure
|
||||
//!
|
||||
#define PIDF64_DEFAULTS { 1.0L, 0.0L, 0.0L, 1.0L, 1.0L, 0.0L, 0.0L, 0.0L, \
|
||||
0.0L, 1.0L, 0.0L, 1.0L, -1.0L, NULL_ADDR, NULL_ADDR }
|
||||
|
||||
//! \brief Resets the PIDF64 internal storage data
|
||||
//! \param[in] p Pointer to the DCL_PIDF64 structure
|
||||
//! \return None
|
||||
//!
|
||||
static inline void DCL_resetPIDF64(DCL_PIDF64 *p)
|
||||
{
|
||||
uint16_t v;
|
||||
|
||||
v = DCL_DISABLE_INTS;
|
||||
p->d2 = p->d3 = p->i10 = 0.0L;
|
||||
p->i14 = 1.0L;
|
||||
DCL_RESTORE_INTS(v);
|
||||
}
|
||||
|
||||
//! \brief Copies shadow controller parameters to the active
|
||||
//! DCL_PIDF64 structure while global interrupts disabled
|
||||
//! \param[in] p Pointer to the DCL_PIDF64 controller structure
|
||||
//! \return None
|
||||
//!
|
||||
static inline void DCL_updatePIDF64(DCL_PIDF64 *p)
|
||||
{
|
||||
uint16_t v;
|
||||
|
||||
if (p->css->sts == STS_UPDATE_PENDING)
|
||||
{
|
||||
v = DCL_DISABLE_INTS;
|
||||
p->Kp = p->sps->Kp;
|
||||
p->Ki = p->sps->Ki;
|
||||
p->Kd = p->sps->Kd;
|
||||
p->Kr = p->sps->Kr;
|
||||
p->c1 = p->sps->c1;
|
||||
p->c2 = p->sps->c2;
|
||||
p->Umax = p->sps->Umax;
|
||||
p->Umin = p->sps->Umin;
|
||||
DCL_RESTORE_INTS(v);
|
||||
DCL_CLEAR_UPDATE_REQUEST(p);
|
||||
}
|
||||
}
|
||||
|
||||
//! \brief Loads the derivative path filter shadow coefficients
|
||||
//! Note: changes will not become effective until update called
|
||||
//! \param[in] p Pointer to the DCL_PIDF64 structure
|
||||
//! \param[in] fc The desired filter bandwidth in Hz
|
||||
//! \param[in] T The sample period in seconds
|
||||
//! \return None
|
||||
//!
|
||||
static inline void DCL_setPIDF64filterBW(DCL_PIDF64 *p, float64_t fc)
|
||||
{
|
||||
float64_t tau;
|
||||
|
||||
#ifdef DCL_ERROR_HANDLING_ENABLED
|
||||
p->css->err |= ((fc >= 1.0L / (2.0L * p->css->T)) || (fc <= 0.0L)) ? ERR_PARAM_RANGE : ERR_NONE;
|
||||
if (p->css->err)
|
||||
{
|
||||
DCL_GET_ERROR_LOC(p->css);
|
||||
DCL_RUN_ERROR_HANDLER(p->css);
|
||||
}
|
||||
#endif
|
||||
|
||||
tau = 1.0L / (2.0L * CONST_PI_64 * fc);
|
||||
p->sps->c1 = 2.0L / (p->css->T + 2.0L * tau);
|
||||
p->sps->c2 = (p->css->T - 2.0L * tau) / (p->css->T + 2.0L * tau);
|
||||
}
|
||||
|
||||
//! \brief Loads the PIDF64 derivative path filter active coefficients
|
||||
//! Note: new coefficients take effect immediately. SPS &
|
||||
//! CSS contents are unaffected.
|
||||
//! \param[in] p Pointer to the DCL_PIDF64 structure
|
||||
//! \param[in] fc The desired filter bandwidth in Hz
|
||||
//! \param[in] T The controller update rate in seconds
|
||||
//! \return None
|
||||
//!
|
||||
static inline void DCL_setActivePIDF64filterBW(DCL_PIDF64 *p, float64_t fc, float64_t T)
|
||||
{
|
||||
float64_t tau;
|
||||
|
||||
#ifdef DCL_ERROR_HANDLING_ENABLED
|
||||
p->css->err |= ((fc >= 1.0L / (2.0L * T)) || (fc <= 0.0L)) ? ERR_PARAM_RANGE : ERR_NONE;
|
||||
if (p->css->err)
|
||||
{
|
||||
DCL_GET_ERROR_LOC(p->css);
|
||||
DCL_RUN_ERROR_HANDLER(p->css);
|
||||
}
|
||||
#endif
|
||||
|
||||
tau = 1.0L / (2.0L * CONST_PI_64 * fc);
|
||||
p->c1 = 2.0L / (T + 2.0L * tau);
|
||||
p->c2 = (T - 2.0L * tau) / (T + 2.0L * tau);
|
||||
}
|
||||
|
||||
//! \brief Returns the active derivative path filter bandwidth in Hz
|
||||
//! \param[in] p Pointer to the DCL_PIDF64 structure
|
||||
//! \return The filter bandwidth in Hz
|
||||
//!
|
||||
static inline float64_t DCL_getPIDF64filterBW(DCL_PIDF64 *p)
|
||||
{
|
||||
float64_t tau;
|
||||
|
||||
tau = ((2.0L - p->c1 * p->css->T) / (2.0L * p->c1));
|
||||
return(1.0L / (2.0L * CONST_PI_64 * tau));
|
||||
}
|
||||
|
||||
//! \brief Executes an inline series form PIDF64 controller
|
||||
//! \param[in] p Pointer to the DCL_PIDF64 structure
|
||||
//! \param[in] rk The controller set-point reference
|
||||
//! \param[in] yk The measured feedback value
|
||||
//! \param[in] lk External output clamp flag
|
||||
//! \return The control effort
|
||||
//!
|
||||
static inline float64_t DCL_runPIDF64_S1(DCL_PIDF64 *p, float64_t rk, float64_t yk, float64_t lk)
|
||||
{
|
||||
float64_t v1, v4, v5, v8, v9, v10, v12;
|
||||
|
||||
#ifdef DCL_ERROR_HANDLING_ENABLED
|
||||
p->css->err |= (p->css->sts & STS_CONTROLLER_RUNNING) ? ERR_CONTROLLER : ERR_NONE;
|
||||
if (p->css->err)
|
||||
{
|
||||
DCL_GET_ERROR_LOC(p->css);
|
||||
DCL_RUN_ERROR_HANDLER(p->css);
|
||||
}
|
||||
DCL_CONTROLLER_BEGIN(p);
|
||||
#endif
|
||||
|
||||
v5 = (p->Kr * rk) - yk;
|
||||
v8 = ((rk - yk) * p->Ki * p->Kp * p->i14) + p->i10;
|
||||
p->i10 = v8;
|
||||
v1 = yk * p->Kd * p->c1;
|
||||
v4 = v1 - p->d2 - p->d3;
|
||||
p->d2 = v1;
|
||||
p->d3 = v4 * p->c2;
|
||||
v9 = ((v5 - v4) * p->Kp) + v8;
|
||||
v10 = (v9 > p->Umax) ? p->Umax : v9;
|
||||
v10 = (v10 < p->Umin) ? p->Umin : v10;
|
||||
v12 = (v10 == v9) ? 1.0 : 0.0;
|
||||
p->i14 = v12 * lk;
|
||||
|
||||
#ifdef DCL_TESTPOINTS_ENABLED
|
||||
p->css->tpt = (float32_t) v5;
|
||||
#endif
|
||||
|
||||
#ifdef DCL_ERROR_HANDLING_ENABLED
|
||||
DCL_CONTROLLER_END(p);
|
||||
#endif
|
||||
|
||||
return(v10);
|
||||
}
|
||||
|
||||
//--- DF22F64 controller -----------------------------------------------------
|
||||
|
||||
#pragma CODE_SECTION(DCL_updateDF22F64,"dclfuncs")
|
||||
#pragma CODE_SECTION(DCL_runDF22F64_S1,"dclfuncs")
|
||||
#pragma CODE_SECTION(DCL_runDF22F64_S2,"dclfuncs")
|
||||
#pragma CODE_SECTION(DCL_runDF22F64_S3,"dclfuncs")
|
||||
|
||||
//! \brief Defines the DCL_DF22F64 shadow parameter set
|
||||
//!
|
||||
typedef struct dcl_df22f64_sps {
|
||||
float64_t b0; //!< b0
|
||||
float64_t b1; //!< b1
|
||||
float64_t b2; //!< b2
|
||||
float64_t a1; //!< a1
|
||||
float64_t a2; //!< a2
|
||||
} DCL_DF22F64_SPS;
|
||||
|
||||
#define DF22F64_SPS_DEFAULTS { 1.0, 0.0, 0.0, 0.0, 0.0 }
|
||||
|
||||
//! \brief Defines the DCL_DF22F64 controller structure
|
||||
//!
|
||||
typedef struct dcl_df22f64 {
|
||||
float64_t b0; //!< b0
|
||||
float64_t b1; //!< b1
|
||||
float64_t b2; //!< b2
|
||||
float64_t a1; //!< a1
|
||||
float64_t a2; //!< a2
|
||||
float64_t x1; //!< x1
|
||||
float64_t x2; //!< x2
|
||||
DCL_DF22F64_SPS *sps; //!< Pointer to the shadow parameter set
|
||||
DCL_CSS *css; //!< Pointer to the common support structure
|
||||
} DCL_DF22F64;
|
||||
|
||||
//! \brief Defines default values to initialize the DCL_DF22F64
|
||||
//! structure
|
||||
//!
|
||||
#define DF22F64_DEFAULTS { 1.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, \
|
||||
NULL_ADDR, NULL_ADDR }
|
||||
|
||||
//! \brief Resets internal DF22F64 controller data to zero
|
||||
//! \param[in] p Pointer to the DCL_DF22F64 controller structure
|
||||
//! \return None
|
||||
//!
|
||||
static inline void DCL_resetDF22F64(DCL_DF22F64 *p)
|
||||
{
|
||||
uint16_t v;
|
||||
|
||||
v = DCL_DISABLE_INTS;
|
||||
p->x1 = p->x2 = 0.0;
|
||||
DCL_RESTORE_INTS(v);
|
||||
}
|
||||
|
||||
//! \brief Updates active coefficients from shadow set
|
||||
//! \param[in] p Pointer to the DCL_DF22F64 controller structure
|
||||
//! \return None
|
||||
//!
|
||||
static inline void DCL_updateDF22F64(DCL_DF22F64 *p)
|
||||
{
|
||||
uint16_t v;
|
||||
|
||||
if (p->css->sts & STS_UPDATE_PENDING)
|
||||
{
|
||||
v = DCL_DISABLE_INTS;
|
||||
p->b0 = p->sps->b0;
|
||||
p->b1 = p->sps->b1;
|
||||
p->b2 = p->sps->b2;
|
||||
p->a1 = p->sps->a1;
|
||||
p->a2 = p->sps->a2;
|
||||
DCL_RESTORE_INTS(v);
|
||||
DCL_CLEAR_UPDATE_REQUEST(p);
|
||||
}
|
||||
}
|
||||
|
||||
//! \brief Executes a full 2nd order Direct Form 2 controller on the
|
||||
//! FPU64. Implemented as inline C function.
|
||||
//! \param[in] p Pointer to the DCL_DF22F64 controller structure
|
||||
//! \param[in] ek The servo error
|
||||
//! \return The control effort
|
||||
//!
|
||||
static inline float64_t DCL_runDF22F64_S1(DCL_DF22F64 *p, float64_t ek)
|
||||
{
|
||||
float64_t v7;
|
||||
|
||||
v7 = (ek * p->b0) + p->x1;
|
||||
p->x1 = (ek * p->b1) + p->x2 - (v7 * p->a1);
|
||||
p->x2 = (ek * p->b2) - (v7 * p->a2);
|
||||
|
||||
#ifdef DCL_TESTPOINTS_ENABLED
|
||||
p->css->tpt = (float32_t) p->x2;
|
||||
#endif
|
||||
|
||||
return(v7);
|
||||
}
|
||||
|
||||
//! \brief Executes an immediate 2nd order Direct Form 2 controller
|
||||
//! on the FPU64. Implemented as inline C function.
|
||||
//! \param[in] p Pointer to the DCL_DF22F64 controller structure
|
||||
//! \param[in] ek The servo error
|
||||
//! \return The control effort
|
||||
//!
|
||||
static inline float64_t DCL_runDF22F64_S2(DCL_DF22F64 *p, float64_t ek)
|
||||
{
|
||||
return((ek * p->b0) + p->x1);
|
||||
}
|
||||
|
||||
//! \brief Executes a partial pre-computed 2nd order Direct Form 2
|
||||
//! controller on the FPU64. Implemented as inline C function.
|
||||
//! \param[in] p Pointer to the DCL_DF22F64 controller structure
|
||||
//! \param[in] ek The servo error
|
||||
//! \param[in] uk The controller output in the previous sample interval
|
||||
//!
|
||||
static inline void DCL_runDF22F64_S3(DCL_DF22F64 *p, float64_t ek, float64_t uk)
|
||||
{
|
||||
p->x1 = (ek * p->b1) + p->x2 - (uk * p->a1);
|
||||
p->x2 = (ek * p->b2) - (uk * p->a2);
|
||||
}
|
||||
|
||||
//----------------------------------------------------------------------------
|
||||
|
||||
//! \brief Saturates a control variable and returns 1 if either limit
|
||||
//! is exceeded
|
||||
//! \param[in] data The address of the data variable
|
||||
//! \param[in] Umax The upper limit
|
||||
//! \param[in] Umin The lower limit
|
||||
//! \return Returns 0 if (Umin < data < Umax), else 1
|
||||
//!
|
||||
static inline int16_t DCL_runClamp_S1(float64_t *data, float64_t Umax, float64_t Umin)
|
||||
{
|
||||
float64_t iv = *(data);
|
||||
|
||||
*(data) = (*(data) > Umax) ? Umax : *(data);
|
||||
*(data) = (*(data) < Umin) ? Umin : *(data);
|
||||
|
||||
return(((iv < Umax) && (iv > Umin)) ? 0 : 1);
|
||||
}
|
||||
|
||||
//----------------------------------------------------------------------------
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif // extern "C"
|
||||
|
||||
#endif // _C_DCLF64_H
|
||||
|
||||
/* end of file */
|
||||
@@ -0,0 +1,228 @@
|
||||
/* DCL_MLOG.h - Multi-channel data logger
|
||||
*
|
||||
*/
|
||||
//#############################################################################
|
||||
//!
|
||||
//! Copyright: Copyright (C) 2023 Texas Instruments Incorporated -
|
||||
//! All rights reserved not granted herein.
|
||||
//! Limited License.
|
||||
//!
|
||||
//! Texas Instruments Incorporated grants a world-wide, royalty-free,
|
||||
//! non-exclusive license under copyrights and patents it now or hereafter
|
||||
//! owns or controls to make, have made, use, import, offer to sell and sell
|
||||
//! ("Utilize") this software subject to the terms herein. With respect to the
|
||||
//! foregoing patent license, such license is granted solely to the extent that
|
||||
//! any such patent is necessary to Utilize the software alone. The patent
|
||||
//! license shall not apply to any combinations which include this software,
|
||||
//! other than combinations with devices manufactured by or for TI
|
||||
//! ("TI Devices").
|
||||
//! No hardware patent is licensed hereunder.
|
||||
//!
|
||||
//! Redistributions must preserve existing copyright notices and reproduce this
|
||||
//! license (including the above copyright notice and the disclaimer and
|
||||
//! (if applicable) source code license limitations below) in the documentation
|
||||
//! and/or other materials provided with the distribution.
|
||||
//!
|
||||
//! Redistribution and use in binary form, without modification, are permitted
|
||||
//! provided that the following conditions are met:
|
||||
//!
|
||||
//! * No reverse engineering, decompilation, or disassembly of this software is
|
||||
//! permitted with respect to any software provided in binary form.
|
||||
//! * Any redistribution and use are licensed by TI for use only
|
||||
//! with TI Devices.
|
||||
//! * Nothing shall obligate TI to provide you with source code for the
|
||||
//! software licensed and provided to you in object code.
|
||||
//!
|
||||
//! If software source code is provided to you, modification and redistribution
|
||||
//! of the source code are permitted provided that the following conditions
|
||||
//! are met:
|
||||
//!
|
||||
//! * any redistribution and use of the source code, including any resulting
|
||||
//! derivative works, are licensed by TI for use only with TI Devices.
|
||||
//! * any redistribution and use of any object code compiled from the source
|
||||
//! code and any resulting derivative works, are licensed by TI for use
|
||||
//! only with TI Devices.
|
||||
//!
|
||||
//! Neither the name of Texas Instruments Incorporated nor the names of its
|
||||
//! suppliers may be used to endorse or promote products derived from this
|
||||
//! software without specific prior written permission.
|
||||
//#############################################################################
|
||||
|
||||
#ifndef _C_DCL_MLOG_H
|
||||
#define _C_DCL_MLOG_H
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
//! \file DCL_MLOG.h
|
||||
//! \brief Contains the public interface to the multi-channel data log module (MLOG)
|
||||
//!
|
||||
|
||||
#include <stdint.h>
|
||||
#include "DCL_fdlog.h"
|
||||
|
||||
//! \brief Defines the number of MLOG channels
|
||||
//!
|
||||
#define MLOG_CHANS 4
|
||||
|
||||
//! \brief Defines the MLOG structure
|
||||
//!
|
||||
typedef volatile struct dcl_mlog {
|
||||
FDLOG captFrame[MLOG_CHANS]; //!< Capture data frames
|
||||
float32_t *data[MLOG_CHANS]; //!< Data channel pointers
|
||||
float32_t trigMax; //!< Upper trigger threshold
|
||||
float32_t trigMin; //!< Lower trigger threshold
|
||||
uint16_t tScale; //!< Number of samples per log write
|
||||
uint16_t sCount; //!< Sample counter
|
||||
uint16_t mode; //!< Operating mode
|
||||
} MLOG;
|
||||
|
||||
//! \brief Defines default values to initialise the MLOG structure
|
||||
//! Note: modify to match number of channels
|
||||
//!
|
||||
#define MLOG_DEFAULTS { { FDLOG_DEFAULTS, FDLOG_DEFAULTS, FDLOG_DEFAULTS, FDLOG_DEFAULTS }, \
|
||||
{ 0x00000000, 0x00000000, 0x00000000, 0x00000000 }, \
|
||||
0.1, -0.1, 1, 1, 0 }
|
||||
|
||||
//! \brief Enumerated MLOG operating modes
|
||||
//!
|
||||
typedef enum
|
||||
{
|
||||
MLOG_invalid = 0, //!< Buffer pointers not initialised
|
||||
MLOG_idle, //!< Memory initialised but module not armed
|
||||
MLOG_armed, //!< Armed: capturing monitor frame data and waiting for trigger
|
||||
MLOG_capture, //!< Triggered: logging data into capture frame
|
||||
MLOG_complete, //!< Full data frame captured and available for read-out
|
||||
MLOG_numStates //!< Number of MLOG states
|
||||
} MLOG_states;
|
||||
|
||||
|
||||
//! \brief Initializes the MLOG module
|
||||
//! \param[in] q The MLOG structure
|
||||
//! \param[in] addr The start address of the memory block
|
||||
//! \param[in] size The size of the memory block in 32-bit words
|
||||
//! \param[in] tmin The upper trigger threshold
|
||||
//! \param[in] tmax The lower trigger threshold
|
||||
//!
|
||||
static inline void DCL_initMLOG(MLOG *q, float32_t *addr, uint16_t size, float32_t tmax, float32_t tmin, uint16_t div)
|
||||
{
|
||||
int i;
|
||||
|
||||
for (i=0; i<MLOG_CHANS; i++)
|
||||
{
|
||||
// assign and clear capture frame, and initialize index to end of lead frame
|
||||
DCL_initLog(&(q->captFrame[i]), (addr + i*size), size);
|
||||
DCL_clearLog(&(q->captFrame[i]));
|
||||
}
|
||||
|
||||
q->trigMax = tmax;
|
||||
q->trigMin = tmin;
|
||||
q->tScale = div;
|
||||
q->sCount = div;
|
||||
q->mode = MLOG_idle;
|
||||
}
|
||||
|
||||
|
||||
//! \brief Resets the MLOG module: clears all frame buffers and sets idle mode
|
||||
//! \param[in] q The MLOG structure
|
||||
//! \return The operating mode
|
||||
//!
|
||||
static inline void DCL_resetMLOG(MLOG *q)
|
||||
{
|
||||
int i;
|
||||
|
||||
for (i=0; i<MLOG_CHANS; i++)
|
||||
{
|
||||
DCL_clearLog(&(q->captFrame[i]));
|
||||
}
|
||||
|
||||
q->mode = MLOG_idle;
|
||||
}
|
||||
|
||||
|
||||
//! \brief Changes the MLOG mode to "MLOG_armed". Only valid if current operating mode is "MLOG_idle"
|
||||
//! \param[in] q The MLOG structure
|
||||
//! \return The operating mode
|
||||
//!
|
||||
static inline uint16_t DCL_armMLOG(MLOG *q)
|
||||
{
|
||||
q->mode = (q->mode == MLOG_idle) ? MLOG_armed : MLOG_idle;
|
||||
return(q->mode);
|
||||
}
|
||||
|
||||
|
||||
//! \brief Runs the MLOG module
|
||||
//! \param[in] q The MLOG structure
|
||||
//! \return The operating mode
|
||||
//!
|
||||
static inline uint16_t DCL_runMLOG(MLOG *q)
|
||||
{
|
||||
int i;
|
||||
|
||||
// skip sample unless counter reaches zero
|
||||
if (--(q->sCount) == 0)
|
||||
{
|
||||
switch(q->mode)
|
||||
{
|
||||
// MLOG not initialised
|
||||
case MLOG_invalid:
|
||||
break;
|
||||
|
||||
// idle: do nothing
|
||||
case MLOG_idle:
|
||||
break;
|
||||
|
||||
// armed: ready to begin capturing when either trigger threshold is crossed
|
||||
case MLOG_armed:
|
||||
// check for trigger condition
|
||||
if ((*(q->data[0]) > q->trigMax) || (*(q->data[0]) < q->trigMin))
|
||||
{
|
||||
for (i=0; i<MLOG_CHANS; i++)
|
||||
{
|
||||
DCL_fwriteLog(&(q->captFrame[i]), *(q->data[i]));
|
||||
}
|
||||
q->mode = MLOG_capture;
|
||||
}
|
||||
break;
|
||||
|
||||
// capture mode: acquiring data
|
||||
case MLOG_capture:
|
||||
// check for full capture frame
|
||||
if (q->captFrame[0].dptr == q->captFrame[0].fptr)
|
||||
{
|
||||
q->mode = MLOG_complete;
|
||||
}
|
||||
else
|
||||
{
|
||||
// log data channels
|
||||
for (i=0; i<MLOG_CHANS; i++)
|
||||
{
|
||||
DCL_fwriteLog(&(q->captFrame[i]), *(q->data[i]));
|
||||
}
|
||||
}
|
||||
break;
|
||||
|
||||
// complete: do nothing - results available in capture buffer
|
||||
case MLOG_complete:
|
||||
break;
|
||||
|
||||
default:
|
||||
;
|
||||
}
|
||||
|
||||
q->sCount = q->tScale;
|
||||
}
|
||||
|
||||
return(q->mode);
|
||||
}
|
||||
|
||||
//----------------------------------------------------------------------------
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif // extern "C"
|
||||
|
||||
#endif // _C_DCL_MLOG_H
|
||||
|
||||
/* end of file */
|
||||
@@ -0,0 +1,228 @@
|
||||
/* DCL_MLOG32.h - Multi-channel data logger (32-bit fixed point version)
|
||||
*
|
||||
*/
|
||||
//#############################################################################
|
||||
//!
|
||||
//! Copyright: Copyright (C) 2023 Texas Instruments Incorporated -
|
||||
//! All rights reserved not granted herein.
|
||||
//! Limited License.
|
||||
//!
|
||||
//! Texas Instruments Incorporated grants a world-wide, royalty-free,
|
||||
//! non-exclusive license under copyrights and patents it now or hereafter
|
||||
//! owns or controls to make, have made, use, import, offer to sell and sell
|
||||
//! ("Utilize") this software subject to the terms herein. With respect to the
|
||||
//! foregoing patent license, such license is granted solely to the extent that
|
||||
//! any such patent is necessary to Utilize the software alone. The patent
|
||||
//! license shall not apply to any combinations which include this software,
|
||||
//! other than combinations with devices manufactured by or for TI
|
||||
//! ("TI Devices").
|
||||
//! No hardware patent is licensed hereunder.
|
||||
//!
|
||||
//! Redistributions must preserve existing copyright notices and reproduce this
|
||||
//! license (including the above copyright notice and the disclaimer and
|
||||
//! (if applicable) source code license limitations below) in the documentation
|
||||
//! and/or other materials provided with the distribution.
|
||||
//!
|
||||
//! Redistribution and use in binary form, without modification, are permitted
|
||||
//! provided that the following conditions are met:
|
||||
//!
|
||||
//! * No reverse engineering, decompilation, or disassembly of this software is
|
||||
//! permitted with respect to any software provided in binary form.
|
||||
//! * Any redistribution and use are licensed by TI for use only
|
||||
//! with TI Devices.
|
||||
//! * Nothing shall obligate TI to provide you with source code for the
|
||||
//! software licensed and provided to you in object code.
|
||||
//!
|
||||
//! If software source code is provided to you, modification and redistribution
|
||||
//! of the source code are permitted provided that the following conditions
|
||||
//! are met:
|
||||
//!
|
||||
//! * any redistribution and use of the source code, including any resulting
|
||||
//! derivative works, are licensed by TI for use only with TI Devices.
|
||||
//! * any redistribution and use of any object code compiled from the source
|
||||
//! code and any resulting derivative works, are licensed by TI for use
|
||||
//! only with TI Devices.
|
||||
//!
|
||||
//! Neither the name of Texas Instruments Incorporated nor the names of its
|
||||
//! suppliers may be used to endorse or promote products derived from this
|
||||
//! software without specific prior written permission.
|
||||
//#############################################################################
|
||||
|
||||
#ifndef _C_DCL_MLOG32_H
|
||||
#define _C_DCL_MLOG32_H
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
//! \file DCL_MLOG32.h
|
||||
//! \brief Contains the public interface to the multi-channel data log module (MLOG32)
|
||||
//!
|
||||
|
||||
#include <stdint.h>
|
||||
#include "DCL_log32.h"
|
||||
|
||||
//! \brief Defines the number of MLOG32 channels
|
||||
//!
|
||||
#define MLOG32_CHANS 4
|
||||
|
||||
//! \brief Defines the MLOG32 structure
|
||||
//!
|
||||
typedef volatile struct dcl_mlog32 {
|
||||
LOG32 captFrame[MLOG32_CHANS]; //!< Capture data frames
|
||||
int32_t *data[MLOG32_CHANS]; //!< Data channel pointers
|
||||
int32_t trigMax; //!< Upper trigger threshold
|
||||
int32_t trigMin; //!< Lower trigger threshold
|
||||
uint16_t tScale; //!< Number of samples per log write
|
||||
uint16_t sCount; //!< Sample counter
|
||||
uint16_t mode; //!< Operating mode
|
||||
} MLOG32;
|
||||
|
||||
//! \brief Defines default values to initialise the MLOG32 structure
|
||||
//! Note: modify to match number of channels defined above
|
||||
//!
|
||||
#define MLOG32_DEFAULTS { { LOG32_DEFAULTS, LOG32_DEFAULTS, LOG32_DEFAULTS, LOG32_DEFAULTS }, \
|
||||
{ 0x00000000, 0x00000000, 0x00000000, 0x00000000 }, \
|
||||
0.1, -0.1, 1, 1, 0 }
|
||||
|
||||
//! \brief Enumerated MLOG32 operating modes
|
||||
//!
|
||||
typedef enum
|
||||
{
|
||||
MLOG32_invalid = 0, //!< Buffer pointers not initialised
|
||||
MLOG32_idle, //!< Memory initialised but module not armed
|
||||
MLOG32_armed, //!< Armed: capturing monitor frame data and waiting for trigger
|
||||
MLOG32_capture, //!< Triggered: logging data into capture frame
|
||||
MLOG32_complete, //!< Full data frame captured and available for read-out
|
||||
MLOG32_numStates //!< Number of MLOG states
|
||||
} MLOG32_states;
|
||||
|
||||
|
||||
//! \brief Initializes the MLOG32 module
|
||||
//! \param[in] q The MLOG32 structure
|
||||
//! \param[in] addr The start address of the memory block
|
||||
//! \param[in] size The size of the memory block in 32-bit words
|
||||
//! \param[in] tmin The upper trigger threshold
|
||||
//! \param[in] tmax The lower trigger threshold
|
||||
//!
|
||||
static inline void DCL_initMLOG32(MLOG32 *q, int32_t *addr, uint16_t size, int32_t tmax, int32_t tmin, uint16_t div)
|
||||
{
|
||||
int i;
|
||||
|
||||
for (i=0; i<MLOG32_CHANS; i++)
|
||||
{
|
||||
// assign and clear capture frame, and initialize index to end of lead frame
|
||||
DCL_initLog32(&(q->captFrame[i]), (addr + i*size), size);
|
||||
DCL_clearLog32(&(q->captFrame[i]));
|
||||
}
|
||||
|
||||
q->trigMax = tmax;
|
||||
q->trigMin = tmin;
|
||||
q->tScale = div;
|
||||
q->sCount = div;
|
||||
q->mode = MLOG32_idle;
|
||||
}
|
||||
|
||||
|
||||
//! \brief Resets the MLOG32 module: clears all frame buffers and sets idle mode
|
||||
//! \param[in] q The MLOG32 structure
|
||||
//! \return The operating mode
|
||||
//!
|
||||
static inline void DCL_resetMLOG32(MLOG32 *q)
|
||||
{
|
||||
int i;
|
||||
|
||||
for (i=0; i<MLOG32_CHANS; i++)
|
||||
{
|
||||
DCL_clearLog32(&(q->captFrame[i]));
|
||||
}
|
||||
|
||||
q->mode = MLOG32_idle;
|
||||
}
|
||||
|
||||
|
||||
//! \brief Changes the MLOG32 mode to "MLOG32_armed". Only valid if current operating mode is "MLOG32_idle"
|
||||
//! \param[in] q The MLOG32 structure
|
||||
//! \return The operating mode
|
||||
//!
|
||||
static inline uint16_t DCL_armMLOG32(MLOG32 *q)
|
||||
{
|
||||
q->mode = (q->mode == MLOG32_idle) ? MLOG32_armed : MLOG32_idle;
|
||||
return(q->mode);
|
||||
}
|
||||
|
||||
|
||||
//! \brief Runs the MLOG32 module
|
||||
//! \param[in] q The MLOG32 structure
|
||||
//! \return The operating mode
|
||||
//!
|
||||
static inline uint16_t DCL_runMLOG32(MLOG32 *q)
|
||||
{
|
||||
int i;
|
||||
|
||||
// skip sample unless counter reaches zero
|
||||
if (--(q->sCount) == 0)
|
||||
{
|
||||
switch(q->mode)
|
||||
{
|
||||
// MLOG32 not initialised
|
||||
case MLOG32_invalid:
|
||||
break;
|
||||
|
||||
// idle: do nothing
|
||||
case MLOG32_idle:
|
||||
break;
|
||||
|
||||
// armed: ready to begin capturing when either trigger threshold is crossed
|
||||
case MLOG32_armed:
|
||||
// check for trigger condition
|
||||
if ((*(q->data[0]) > q->trigMax) || (*(q->data[0]) < q->trigMin))
|
||||
{
|
||||
for (i=0; i<MLOG32_CHANS; i++)
|
||||
{
|
||||
DCL_writeLog32(&(q->captFrame[i]), *(q->data[i]));
|
||||
}
|
||||
q->mode = MLOG32_capture;
|
||||
}
|
||||
break;
|
||||
|
||||
// capture mode: acquiring data
|
||||
case MLOG32_capture:
|
||||
// check for full capture frame
|
||||
if (q->captFrame[0].dptr == q->captFrame[0].fptr)
|
||||
{
|
||||
q->mode = MLOG32_complete;
|
||||
}
|
||||
else
|
||||
{
|
||||
// log data channels
|
||||
for (i=0; i<MLOG32_CHANS; i++)
|
||||
{
|
||||
DCL_writeLog32(&(q->captFrame[i]), *(q->data[i]));
|
||||
}
|
||||
}
|
||||
break;
|
||||
|
||||
// complete: do nothing - results available in capture buffer
|
||||
case MLOG32_complete:
|
||||
break;
|
||||
|
||||
default:
|
||||
;
|
||||
}
|
||||
|
||||
q->sCount = q->tScale;
|
||||
}
|
||||
|
||||
return(q->mode);
|
||||
}
|
||||
|
||||
//----------------------------------------------------------------------------
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif // extern "C"
|
||||
|
||||
#endif // _C_DCL_MLOG32_H
|
||||
|
||||
/* end of file */
|
||||
@@ -0,0 +1,565 @@
|
||||
/* DCL_NLPID.h - non-linear PID controller
|
||||
*
|
||||
*/
|
||||
//#############################################################################
|
||||
//!
|
||||
//! Copyright: Copyright (C) 2023 Texas Instruments Incorporated -
|
||||
//! All rights reserved not granted herein.
|
||||
//! Limited License.
|
||||
//!
|
||||
//! Texas Instruments Incorporated grants a world-wide, royalty-free,
|
||||
//! non-exclusive license under copyrights and patents it now or hereafter
|
||||
//! owns or controls to make, have made, use, import, offer to sell and sell
|
||||
//! ("Utilize") this software subject to the terms herein. With respect to the
|
||||
//! foregoing patent license, such license is granted solely to the extent that
|
||||
//! any such patent is necessary to Utilize the software alone. The patent
|
||||
//! license shall not apply to any combinations which include this software,
|
||||
//! other than combinations with devices manufactured by or for TI
|
||||
//! ("TI Devices").
|
||||
//! No hardware patent is licensed hereunder.
|
||||
//!
|
||||
//! Redistributions must preserve existing copyright notices and reproduce this
|
||||
//! license (including the above copyright notice and the disclaimer and
|
||||
//! (if applicable) source code license limitations below) in the documentation
|
||||
//! and/or other materials provided with the distribution.
|
||||
//!
|
||||
//! Redistribution and use in binary form, without modification, are permitted
|
||||
//! provided that the following conditions are met:
|
||||
//!
|
||||
//! * No reverse engineering, decompilation, or disassembly of this software is
|
||||
//! permitted with respect to any software provided in binary form.
|
||||
//! * Any redistribution and use are licensed by TI for use only
|
||||
//! with TI Devices.
|
||||
//! * Nothing shall obligate TI to provide you with source code for the
|
||||
//! software licensed and provided to you in object code.
|
||||
//!
|
||||
//! If software source code is provided to you, modification and redistribution
|
||||
//! of the source code are permitted provided that the following conditions
|
||||
//! are met:
|
||||
//!
|
||||
//! * any redistribution and use of the source code, including any resulting
|
||||
//! derivative works, are licensed by TI for use only with TI Devices.
|
||||
//! * any redistribution and use of any object code compiled from the source
|
||||
//! code and any resulting derivative works, are licensed by TI for use
|
||||
//! only with TI Devices.
|
||||
//!
|
||||
//! Neither the name of Texas Instruments Incorporated nor the names of its
|
||||
//! suppliers may be used to endorse or promote products derived from this
|
||||
//! software without specific prior written permission.
|
||||
//#############################################################################
|
||||
|
||||
#ifndef _C_DCL_NLPID_H
|
||||
#define _C_DCL_NLPID_H
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
//! \file DCL_NLPID.h
|
||||
//! \brief Contains the public interface to the
|
||||
//! non-linear PID, PI, & NLF controller functions
|
||||
|
||||
#include "DCL.h"
|
||||
|
||||
//! \brief Sets the lower bound on the linear region semi-width
|
||||
//!
|
||||
#define DCL_DELTA_MIN 1.0e-04f
|
||||
|
||||
//! \brief Sets an upper bound on allowable controller gain, and
|
||||
//! therefore fixes the minimum linear region semi-width
|
||||
//!
|
||||
#define DCL_GAMMA_MAX 100
|
||||
|
||||
|
||||
//--- Non-linear PID controllers ---------------------------------------------
|
||||
|
||||
#pragma CODE_SECTION(DCL_updateNLPID,"dclfuncs")
|
||||
#pragma CODE_SECTION(DCL_runNLPID_C1,"dclfuncs")
|
||||
#pragma CODE_SECTION(DCL_runNLPID_C2,"dclfuncs")
|
||||
#pragma CODE_SECTION(DCL_runNLF_C1,"dclfuncs")
|
||||
|
||||
//! \brief Defines the shadow DCL_NLPID controller structure
|
||||
//!
|
||||
typedef struct dcl_nlpid_sps {
|
||||
float32_t Kp; //!< Linear proportional gain
|
||||
float32_t Ki; //!< Linear integral gain
|
||||
float32_t Kd; //!< Linear derivative gain
|
||||
float32_t alpha_p; //!< P path non-linear exponent
|
||||
float32_t alpha_i; //!< I path non-linear exponent
|
||||
float32_t alpha_d; //!< D path non-linear exponent
|
||||
float32_t delta_p; //!< P path linearized range
|
||||
float32_t delta_i; //!< I path linearized range
|
||||
float32_t delta_d; //!< D path linearized range
|
||||
float32_t gamma_p; //!< P path gain limit
|
||||
float32_t gamma_i; //!< I path gain limit
|
||||
float32_t gamma_d; //!< D path gain limit
|
||||
float32_t c1; //!< D path filter coefficient 1
|
||||
float32_t c2; //!< D path filter coefficient 2
|
||||
float32_t Umax; //!< Upper saturation limit
|
||||
float32_t Umin; //!< Lower saturation limit
|
||||
} DCL_NLPID_SPS;
|
||||
|
||||
//! \brief Defines default values to initialize the DCL_NLPID structure
|
||||
//!
|
||||
#define NLPID_SPS_DEFAULTS { 1.0f, 0.0f, 0.0f, \
|
||||
1.0f, 1.0f, 1.0f, \
|
||||
0.1f, 0.1f, 0.1f, \
|
||||
1.0f, 1.0f, 1.0f, \
|
||||
1.0f, 0.0f, \
|
||||
1.0f, -1.0f }
|
||||
|
||||
//! \brief Defines the active DCL_NLPID controller structure
|
||||
//!
|
||||
typedef struct dcl_nlpid {
|
||||
float32_t Kp; //!< Linear proportional gain
|
||||
float32_t Ki; //!< Linear integral gain
|
||||
float32_t Kd; //!< Linear derivative gain
|
||||
float32_t alpha_p; //!< P path non-linear exponent
|
||||
float32_t alpha_i; //!< I path non-linear exponent
|
||||
float32_t alpha_d; //!< D path non-linear exponent
|
||||
float32_t delta_p; //!< P path linearized range
|
||||
float32_t delta_i; //!< I path linearized range
|
||||
float32_t delta_d; //!< D path linearized range
|
||||
float32_t gamma_p; //!< P path gain limit
|
||||
float32_t gamma_i; //!< I path gain limit
|
||||
float32_t gamma_d; //!< D path gain limit
|
||||
float32_t c1; //!< D path filter coefficient 1
|
||||
float32_t c2; //!< D path filter coefficient 2
|
||||
float32_t d2; //!< D path filter intermediate storage 1
|
||||
float32_t d3; //!< D path filter intermediate storage 2
|
||||
float32_t i7; //!< I path intermediate storage
|
||||
float32_t i16; //!< Intermediate saturation storage
|
||||
float32_t i18; //!< Spare
|
||||
float32_t Umax; //!< Upper saturation limit
|
||||
float32_t Umin; //!< Lower saturation limit
|
||||
DCL_NLPID_SPS *sps; //!< Pointer to shadow parameter structure
|
||||
DCL_CSS *css; //!< Pointer to controller support structure
|
||||
} DCL_NLPID;
|
||||
|
||||
//! \brief Defines default values to initialize the DCL_NLPID structure
|
||||
//!
|
||||
#define NLPID_DEFAULTS { 1.0f, 0.0f, 0.0f, \
|
||||
1.0f, 1.0f, 1.0f, \
|
||||
0.1f, 0.1f, 0.1f, \
|
||||
1.0f, 1.0f, 1.0f, \
|
||||
1.0f, 0.0f, \
|
||||
0.0f, 0.0f, \
|
||||
0.0f, 1.0f, 0.0f, \
|
||||
1.0f, -1.0f, \
|
||||
NULL_ADDR, NULL_ADDR }
|
||||
|
||||
//! \brief Resets DCL_NLPID internal storage data
|
||||
//! \param[in] p Pointer to the DCL_NLPID structure
|
||||
//! \return None
|
||||
//!
|
||||
static inline void DCL_resetNLPID(DCL_NLPID *p)
|
||||
{
|
||||
uint16_t v;
|
||||
|
||||
v = DCL_DISABLE_INTS;
|
||||
p->d2 = p->d3 = p->i7 = 0.0f;
|
||||
p->i16 = 1.0f;
|
||||
DCL_RESTORE_INTS(v);
|
||||
}
|
||||
|
||||
//! \brief Copies control parameters from one DCL_NLPID structure to another
|
||||
//! \param[in] p Pointer to the DCL_NLPID structure
|
||||
//! \return None
|
||||
//!
|
||||
static inline void DCL_updateNLPID(DCL_NLPID *p)
|
||||
{
|
||||
uint16_t v;
|
||||
|
||||
#ifdef DCL_ERROR_HANDLING_ENABLED
|
||||
float32_t tau = (2.0f - p->sps->c1 * p->css->T) / (2.0f * p->sps->c1);
|
||||
float32_t ec2 = p->sps->c1 * (p->css->T - 2.0f * tau) / 2.0f;
|
||||
p->css->err |= ((p->sps->c2 < (ec2 - DEFAULT_FPU32_TOL)) || (p->sps->c2 > (ec2 + DEFAULT_FPU32_TOL))) ? ERR_PARAM_INVALID : ERR_NONE;
|
||||
p->css->err |= (p->sps->delta_p < DCL_DELTA_MIN) ? ERR_PARAM_RANGE : ERR_NONE;
|
||||
p->css->err |= (p->sps->delta_i < DCL_DELTA_MIN) ? ERR_PARAM_RANGE : ERR_NONE;
|
||||
p->css->err |= (p->sps->delta_d < DCL_DELTA_MIN) ? ERR_PARAM_RANGE : ERR_NONE;
|
||||
p->css->err |= (p->sps->Umax <= p->sps->Umin) ? ERR_PARAM_INVALID : ERR_NONE;
|
||||
p->css->err |= (p->css->T <= 0.0f) ? ERR_PARAM_RANGE : ERR_NONE;
|
||||
p->css->err |= ((p->sps->Kp < 0.0f) || (p->sps->Ki < 0.0f) || (p->sps->Kd < 0.0f)) ? ERR_PARAM_RANGE : ERR_NONE;
|
||||
if (p->css->err)
|
||||
{
|
||||
DCL_GET_ERROR_LOC(p->css);
|
||||
DCL_RUN_ERROR_HANDLER(p->css);
|
||||
}
|
||||
#endif
|
||||
|
||||
if (p->css->sts == STS_UPDATE_PENDING)
|
||||
{
|
||||
v = DCL_DISABLE_INTS;
|
||||
p->Kp = p->sps->Kp;
|
||||
p->Ki = p->sps->Ki;
|
||||
p->Kd = p->sps->Kd;
|
||||
p->alpha_p = p->sps->alpha_p;
|
||||
p->alpha_i = p->sps->alpha_i;
|
||||
p->alpha_d = p->sps->alpha_d;
|
||||
p->delta_p = p->sps->delta_p;
|
||||
p->delta_i = p->sps->delta_i;
|
||||
p->delta_d = p->sps->delta_d;
|
||||
p->gamma_p = p->sps->gamma_p;
|
||||
p->gamma_i = p->sps->gamma_i;
|
||||
p->gamma_d = p->sps->gamma_d;
|
||||
p->c1 = p->sps->c1;
|
||||
p->c2 = p->sps->c2;
|
||||
p->Umax = p->sps->Umax;
|
||||
p->Umin = p->sps->Umin;
|
||||
DCL_RESTORE_INTS(v);
|
||||
DCL_CLEAR_UPDATE_REQUEST(p);
|
||||
}
|
||||
}
|
||||
|
||||
//! \brief Copies control parameters from one DCL_NLPID structure to another
|
||||
//! Implemented as an external assembly module
|
||||
//! \param[in] p Pointer to the DCL_NLPID structure
|
||||
//! \return None
|
||||
//!
|
||||
extern void DCL_fupdateNLPID(DCL_NLPID *p);
|
||||
|
||||
//! \brief Loads the shadow derivative LP filter coefficients
|
||||
//! Note: active coefficients unchanged DCL_updateNLPID() called
|
||||
//! \param[in] p Pointer to the DCL_NLPID structure
|
||||
//! \param[in] fc The desired filter bandwidth in Hz
|
||||
//! \return None
|
||||
//!
|
||||
static inline void DCL_setNLPIDfilterBW(DCL_NLPID *p, float32_t fc)
|
||||
{
|
||||
float32_t tau = 1.0f / (2.0f * CONST_PI_32 * fc);
|
||||
|
||||
#ifdef DCL_ERROR_HANDLING_ENABLED
|
||||
p->css->err |= ((fc >= 1.0f / (2.0f * p->css->T)) || (fc <= 0.0f)) ? ERR_PARAM_RANGE : ERR_NONE;
|
||||
if (p->css->err)
|
||||
{
|
||||
DCL_GET_ERROR_LOC(p->css);
|
||||
DCL_RUN_ERROR_HANDLER(p->css);
|
||||
}
|
||||
#endif
|
||||
|
||||
p->sps->c1 = 2.0f / (p->css->T + 2.0f * tau);
|
||||
p->sps->c2 = (p->css->T - 2.0f * tau) / (p->css->T + 2.0f * tau);
|
||||
}
|
||||
|
||||
//! \brief Loads the NLPID derivative path filter active coefficients
|
||||
//! Note: new coefficients take effect immediately. SPS &
|
||||
//! CSS contents are unaffected.
|
||||
//! \param[in] p Pointer to the DCL_NLPID structure
|
||||
//! \param[in] fc The desired filter bandwidth in Hz
|
||||
//! \param[in] T The controller update rate in seconds
|
||||
//! \return None
|
||||
//!
|
||||
static inline void DCL_setActiveNLPIDfilterBW(DCL_NLPID *p, float32_t fc, float32_t T)
|
||||
{
|
||||
float32_t tau;
|
||||
|
||||
#ifdef DCL_ERROR_HANDLING_ENABLED
|
||||
p->css->err |= ((fc >= 1.0f / (2.0f * T)) || (fc <= 0.0f)) ? ERR_PARAM_RANGE : ERR_NONE;
|
||||
if (p->css->err)
|
||||
{
|
||||
DCL_GET_ERROR_LOC(p->css);
|
||||
DCL_RUN_ERROR_HANDLER(p->css);
|
||||
}
|
||||
#endif
|
||||
|
||||
tau = 1.0f / (2.0f * CONST_PI_32 * fc);
|
||||
p->c1 = 2.0f / (T + 2.0f * tau);
|
||||
p->c2 = (T - 2.0f * tau) / (T + 2.0f * tau);
|
||||
}
|
||||
|
||||
//! \brief Returns the derivative LP filter bandwidth in Hz
|
||||
//! \param[in] p Pointer to the DCL_NLPID structure
|
||||
//! \return The filter bandwidth in Hz
|
||||
//!
|
||||
static inline float32_t DCL_getNLPIDfilterBW(DCL_NLPID *p)
|
||||
{
|
||||
float32_t tau = ((2.0f - p->c1 * p->css->T) / (2.0f * p->c1));
|
||||
return(1.0f / (2.0f * CONST_PI_32 * tau));
|
||||
}
|
||||
|
||||
//! \brief Returns the linearized region gain for specified (alpha,delta)
|
||||
//! \param[in] alpha The non-linear gain
|
||||
//! \param[in] delta The linear region semi-width
|
||||
//! \return The linear region gain
|
||||
//!
|
||||
static inline float32_t DCL_getNLPIDgamma(float32_t alpha, float32_t delta)
|
||||
{
|
||||
return((float32_t) powf(delta, (alpha - 1.0f)));
|
||||
}
|
||||
|
||||
//! \brief Returns the semi-width of the linear gain region for specified (alpha,gamma)
|
||||
//! \param[in] alpha The non-linear gain
|
||||
//! \param[in] gamma The linear region gain
|
||||
//! \return The linear region semi-width
|
||||
//!
|
||||
static inline float32_t DCL_getNLPIDdelta(float32_t alpha, float32_t gamma)
|
||||
{
|
||||
return((float32_t) powf(gamma, (1.0f / (alpha - 1.0f))));
|
||||
}
|
||||
|
||||
//! \brief Computes the linear gain region for specified (alpha, delta)
|
||||
//! Implemented as external assembly module
|
||||
//! \param[in] alpha The nonlinear tuning parameter (0.0f <= alpha <= 2.0f)
|
||||
//! \param[in] delta The linear region semi-width (0.0f < delta <= 1.0f)
|
||||
//! \return The linear region gain (gamma)
|
||||
//!
|
||||
extern float32_t DCL_calcGamma(float32_t alpha, float32_t delta);
|
||||
|
||||
//! \brief Computes the linearized gains for each path
|
||||
//! Note: active coefficients not update DCL_updateNLPID() called
|
||||
//! \param[in] p Pointer to the DCL_NLPID structure
|
||||
//! \return None
|
||||
//!
|
||||
static inline void DCL_setNLPIDgamma(DCL_NLPID *p)
|
||||
{
|
||||
float32_t xP = (float32_t) powf(p->sps->delta_p, (p->sps->alpha_p - 1.0f));
|
||||
float32_t xI = (float32_t) powf(p->sps->delta_i, (p->sps->alpha_i - 1.0f));
|
||||
float32_t xD = (float32_t) powf(p->sps->delta_d, (p->sps->alpha_d - 1.0f));
|
||||
|
||||
|
||||
#ifdef DCL_ERROR_HANDLING_ENABLED
|
||||
p->css->err |= ((p->sps->delta_p > 1.0f) || (p->sps->delta_p > 1.0f) || (p->sps->delta_p > 1.0f)) ? ERR_PARAM_RANGE : ERR_NONE;
|
||||
p->css->err |= (p->sps->delta_p < DCL_DELTA_MIN) ? ERR_PARAM_RANGE : ERR_NONE;
|
||||
p->css->err |= (p->sps->delta_i < DCL_DELTA_MIN) ? ERR_PARAM_RANGE : ERR_NONE;
|
||||
p->css->err |= (p->sps->delta_d < DCL_DELTA_MIN) ? ERR_PARAM_RANGE : ERR_NONE;
|
||||
p->css->err |= ((xP > DCL_GAMMA_MAX) || (xI > DCL_GAMMA_MAX) || (xD > DCL_GAMMA_MAX)) ? ERR_PARAM_RANGE : ERR_NONE;
|
||||
if (p->css->err)
|
||||
{
|
||||
DCL_GET_ERROR_LOC(p->css);
|
||||
DCL_RUN_ERROR_HANDLER(p->css);
|
||||
}
|
||||
#endif
|
||||
|
||||
p->sps->gamma_p = xP;
|
||||
p->sps->gamma_i = xI;
|
||||
p->sps->gamma_d = xD;
|
||||
}
|
||||
|
||||
//! \brief Computes the linearized gains for each path and loads the
|
||||
//! parameters in the active NLPID structure
|
||||
//! \param[in] p Pointer to the DCL_NLPID structure
|
||||
//! \return None
|
||||
//!
|
||||
static inline void DCL_setActiveNLPIDgamma(DCL_NLPID *p)
|
||||
{
|
||||
float32_t xP = (float32_t) powf(p->delta_p, (p->alpha_p - 1.0f));
|
||||
float32_t xI = (float32_t) powf(p->delta_i, (p->alpha_i - 1.0f));
|
||||
float32_t xD = (float32_t) powf(p->delta_d, (p->alpha_d - 1.0f));
|
||||
|
||||
#ifdef DCL_ERROR_HANDLING_ENABLED
|
||||
p->css->err |= ((p->delta_p > 1.0f) || (p->delta_p > 1.0f) || (p->delta_p > 1.0f)) ? ERR_PARAM_RANGE : ERR_NONE;
|
||||
p->css->err |= (p->delta_p < DCL_DELTA_MIN) ? ERR_PARAM_RANGE : ERR_NONE;
|
||||
p->css->err |= (p->delta_i < DCL_DELTA_MIN) ? ERR_PARAM_RANGE : ERR_NONE;
|
||||
p->css->err |= (p->delta_d < DCL_DELTA_MIN) ? ERR_PARAM_RANGE : ERR_NONE;
|
||||
p->css->err |= ((xP > DCL_GAMMA_MAX) || (xI > DCL_GAMMA_MAX) || (xD > DCL_GAMMA_MAX)) ? ERR_PARAM_RANGE : ERR_NONE;
|
||||
if (p->css->err)
|
||||
{
|
||||
DCL_GET_ERROR_LOC(p->css);
|
||||
DCL_RUN_ERROR_HANDLER(p->css);
|
||||
}
|
||||
#endif
|
||||
|
||||
p->gamma_p = xP;
|
||||
p->gamma_i = xI;
|
||||
p->gamma_d = xD;
|
||||
}
|
||||
|
||||
//! \brief Executes a parallel form non-linear PID controller on the FPU32
|
||||
//! \param[in] p Pointer to the DCL_NLPID structure
|
||||
//! \param[in] rk The controller set-point reference
|
||||
//! \param[in] yk The measured feedback value
|
||||
//! \param[in] lk External output clamp flag
|
||||
//! \return The control effort
|
||||
//!
|
||||
static inline float32_t DCL_runNLPID_C1(DCL_NLPID *p, float32_t rk, float32_t yk, float32_t lk)
|
||||
{
|
||||
float32_t v1, v2, v3, v4, v5, v8, v9, v10, v12, v13, v14, v15;
|
||||
|
||||
#ifdef DCL_ERROR_HANDLING_ENABLED
|
||||
p->css->err |= (p->css->sts & STS_CONTROLLER_RUNNING) ? ERR_CONTROLLER : ERR_NONE;
|
||||
if (p->css->err)
|
||||
{
|
||||
DCL_GET_ERROR_LOC(p->css);
|
||||
DCL_RUN_ERROR_HANDLER(p->css);
|
||||
}
|
||||
DCL_CONTROLLER_BEGIN(p);
|
||||
#endif
|
||||
|
||||
// pre-conditioning block
|
||||
v1 = (rk - yk) * 0.5f;
|
||||
v2 = (v1 < 0.0f) ? -1.0f : 1.0f;
|
||||
v3 = fabsf(v1);
|
||||
|
||||
#ifdef DCL_ERROR_HANDLING_ENABLED
|
||||
p->css->err |= ((p->alpha_p >= 2.0f) || (p->alpha_p <= 0.0f)) ? ERR_PARAM_RANGE : ERR_NONE;
|
||||
p->css->err |= ((p->alpha_i >= 2.0f) || (p->alpha_i <= 0.0f)) ? ERR_PARAM_RANGE : ERR_NONE;
|
||||
p->css->err |= ((p->alpha_d >= 2.0f) || (p->alpha_d <= 0.0f)) ? ERR_PARAM_RANGE : ERR_NONE;
|
||||
p->css->err |= (v3 > 1.0f) ? ERR_INPUT_RANGE : ERR_NONE;
|
||||
if (p->css->err)
|
||||
{
|
||||
DCL_GET_ERROR_LOC(p->css);
|
||||
DCL_RUN_ERROR_HANDLER(p->css);
|
||||
}
|
||||
#endif
|
||||
|
||||
// non-linear modules
|
||||
v4 = ((v3 > p->delta_p) ? (v2 * (float32_t) powf(v3, p->alpha_p)) : (v1 * p->gamma_p));
|
||||
v5 = ((v3 > p->delta_i) ? (v2 * (float32_t) powf(v3, p->alpha_i)) : (v1 * p->gamma_i));
|
||||
v9 = ((v3 > p->delta_d) ? (v2 * (float32_t) powf(v3, p->alpha_d)) : (v1 * p->gamma_d));
|
||||
|
||||
// integral path
|
||||
v8 = (v5 * p->Kp * p->Ki * p->i16) + p->i7;
|
||||
p->i7 = v8;
|
||||
|
||||
// derivative path
|
||||
v10 = v9 * p->Kd * p->c1;
|
||||
v12 = v10 - p->d2 - p->d3;
|
||||
p->d2 = v10;
|
||||
p->d3 = v12 * p->c2;
|
||||
|
||||
// output sum & clamp
|
||||
v13 = (p->Kp * (v4 + v12)) + v8;
|
||||
#ifndef __TMS320C28XX_CLA__
|
||||
v14 = __fsat(v13, p->Umax, p->Umin);
|
||||
#else
|
||||
v14 = (v13 > p->Umax) ? p->Umax : v13;
|
||||
v14 = (v14 < p->Umin) ? p->Umin : v14;
|
||||
#endif
|
||||
v15 = (v14 == v13) ? 1.0f : 0.0f;
|
||||
p->i16 = v15 * lk;
|
||||
|
||||
#ifdef DCL_TESTPOINTS_ENABLED
|
||||
p->css->tpt = v4;
|
||||
#endif
|
||||
|
||||
#ifdef DCL_ERROR_HANDLING_ENABLED
|
||||
DCL_CONTROLLER_END(p);
|
||||
#endif
|
||||
|
||||
return(v14);
|
||||
}
|
||||
|
||||
//! \brief Executes a series form non-linear PID controller on the FPU32
|
||||
//! \param[in] p Pointer to the DCL_NLPID structure
|
||||
//! \param[in] rk The controller set-point reference
|
||||
//! \param[in] yk The measured feedback value
|
||||
//! \param[in] lk External output clamp flag
|
||||
//! \return The control effort
|
||||
//!
|
||||
static inline float32_t DCL_runNLPID_C2(DCL_NLPID *p, float32_t rk, float32_t yk, float32_t lk)
|
||||
{
|
||||
float32_t v1, v2, vd2, v3, vd3, v4, v5, v6, v8, v9, v12, v15, v16, v17;
|
||||
|
||||
#ifdef DCL_ERROR_HANDLING_ENABLED
|
||||
p->css->err |= (p->css->sts & STS_CONTROLLER_RUNNING) ? ERR_CONTROLLER : ERR_NONE;
|
||||
if (p->css->err)
|
||||
{
|
||||
DCL_GET_ERROR_LOC(p->css);
|
||||
DCL_RUN_ERROR_HANDLER(p->css);
|
||||
}
|
||||
DCL_CONTROLLER_BEGIN(p);
|
||||
#endif
|
||||
|
||||
// pre-conditioning block for P & I
|
||||
v1 = (rk - yk) * 0.5f;
|
||||
v2 = (v1 < 0.0f) ? -1.0f : 1.0f;
|
||||
v3 = fabsf(v1);
|
||||
|
||||
#ifdef DCL_ERROR_HANDLING_ENABLED
|
||||
p->css->err |= ((p->alpha_p >= 2.0f) || (p->alpha_p <= 0.0f)) ? ERR_PARAM_RANGE : ERR_NONE;
|
||||
p->css->err |= ((p->alpha_i >= 2.0f) || (p->alpha_i <= 0.0f)) ? ERR_PARAM_RANGE : ERR_NONE;
|
||||
p->css->err |= (v3 > 1.0f) ? ERR_INPUT_RANGE : ERR_NONE;
|
||||
if (p->css->err)
|
||||
{
|
||||
DCL_GET_ERROR_LOC(p->css);
|
||||
DCL_RUN_ERROR_HANDLER(p->css);
|
||||
}
|
||||
#endif
|
||||
|
||||
// P & I non-linear modules
|
||||
v4 = ((v3 > p->delta_p) ? (v2 * (float32_t) powf(v3, p->alpha_p)) : (v1 * p->gamma_p));
|
||||
v5 = ((v3 > p->delta_i) ? (v2 * (float32_t) powf(v3, p->alpha_i)) : (v1 * p->gamma_i));
|
||||
|
||||
// D path non-linear block
|
||||
vd2 = (yk < 0.0f) ? -1.0f : 1.0f;
|
||||
vd3 = fabsf(yk);
|
||||
|
||||
#ifdef DCL_ERROR_HANDLING_ENABLED
|
||||
p->css->err |= ((p->alpha_d >= 2.0f) || (p->alpha_d <= 0.0f)) ? ERR_PARAM_RANGE : ERR_NONE;
|
||||
p->css->err |= (vd3 > 1.0f) ? ERR_INPUT_RANGE : ERR_NONE;
|
||||
if (p->css->err)
|
||||
{
|
||||
DCL_GET_ERROR_LOC(p->css);
|
||||
DCL_RUN_ERROR_HANDLER(p->css);
|
||||
}
|
||||
#endif
|
||||
|
||||
v6 = ((vd3 > p->delta_d) ? (vd2 * (float32_t) powf(vd3, p->alpha_d)) : (yk * p->gamma_d));
|
||||
|
||||
// integral path
|
||||
v8 = (v5 * p->Kp * p->Ki * p->i16) + p->i7;
|
||||
p->i7 = v8;
|
||||
|
||||
// derivative path
|
||||
v15 = v6 * p->Kd * p->c1;
|
||||
v16 = v15 - p->d2 - p->d3;
|
||||
p->d2 = v15;
|
||||
p->d3 = v16 * p->c2;
|
||||
|
||||
// output sum & clamp
|
||||
v9 = (p->Kp * (v4 - v16)) + v8;
|
||||
#ifndef __TMS320C28XX_CLA__
|
||||
v17 = __fsat(v9, p->Umax, p->Umin);
|
||||
#else
|
||||
v17 = (v9 > p->Umax) ? p->Umax : v9;
|
||||
v17 = (v17 < p->Umin) ? p->Umin : v17;
|
||||
#endif
|
||||
v12 = (v17 == v9) ? 1.0f : 0.0f;
|
||||
p->i16 = v12 * lk;
|
||||
|
||||
#ifdef DCL_TESTPOINTS_ENABLED
|
||||
p->css->tpt = v1;
|
||||
#endif
|
||||
|
||||
#ifdef DCL_ERROR_HANDLING_ENABLED
|
||||
DCL_CONTROLLER_END(p);
|
||||
#endif
|
||||
|
||||
return(v17);
|
||||
}
|
||||
|
||||
//! \brief Executes a series form non-linear PID controller on the FPU32
|
||||
//! Note: this prototype covers a future assembly implementation
|
||||
//! \param[in] p Pointer to the DCL_NLPID structure
|
||||
//! \param[in] rk The controller set-point reference
|
||||
//! \param[in] yk The measured feedback value
|
||||
//! \param[in] lk External output clamp flag
|
||||
//! \return The control effort
|
||||
//!
|
||||
extern float32_t DCL_runNLPID_C3(DCL_NLPID *p, float32_t rk, float32_t yk, float32_t lk);
|
||||
|
||||
//--- Basic non-linear function ----------------------------------------------
|
||||
|
||||
//! \brief Executes the non-linear control function on the FPU32
|
||||
//! \param[in] x The input variable
|
||||
//! \param[in] alpha The non-linear exponent
|
||||
//! \param[in] delta The linear region semi-width
|
||||
//! \return The non-linear output
|
||||
//!
|
||||
static inline float32_t DCL_runNLF_C1(float32_t x, float32_t alpha, float32_t delta)
|
||||
{
|
||||
float32_t v2 = (x < 0.0f) ? -1.0f : 1.0f;
|
||||
float32_t v3 = fabsf(x);
|
||||
|
||||
return((v3 > delta) ? (v2 * (float32_t) powf(v3, alpha)) : (x * powf(delta, (alpha - 1.0f))));
|
||||
}
|
||||
|
||||
//----------------------------------------------------------------------------
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif // extern "C"
|
||||
|
||||
#endif // _C_DCL_NLPID_H
|
||||
|
||||
/* end of file */
|
||||
@@ -0,0 +1,323 @@
|
||||
/* DCL_TCM.h - Transient Capture Module header file
|
||||
*
|
||||
*/
|
||||
//#############################################################################
|
||||
//!
|
||||
//! Copyright: Copyright (C) 2023 Texas Instruments Incorporated -
|
||||
//! All rights reserved not granted herein.
|
||||
//! Limited License.
|
||||
//!
|
||||
//! Texas Instruments Incorporated grants a world-wide, royalty-free,
|
||||
//! non-exclusive license under copyrights and patents it now or hereafter
|
||||
//! owns or controls to make, have made, use, import, offer to sell and sell
|
||||
//! ("Utilize") this software subject to the terms herein. With respect to the
|
||||
//! foregoing patent license, such license is granted solely to the extent that
|
||||
//! any such patent is necessary to Utilize the software alone. The patent
|
||||
//! license shall not apply to any combinations which include this software,
|
||||
//! other than combinations with devices manufactured by or for TI
|
||||
//! ("TI Devices").
|
||||
//! No hardware patent is licensed hereunder.
|
||||
//!
|
||||
//! Redistributions must preserve existing copyright notices and reproduce this
|
||||
//! license (including the above copyright notice and the disclaimer and
|
||||
//! (if applicable) source code license limitations below) in the documentation
|
||||
//! and/or other materials provided with the distribution.
|
||||
//!
|
||||
//! Redistribution and use in binary form, without modification, are permitted
|
||||
//! provided that the following conditions are met:
|
||||
//!
|
||||
//! * No reverse engineering, decompilation, or disassembly of this software is
|
||||
//! permitted with respect to any software provided in binary form.
|
||||
//! * Any redistribution and use are licensed by TI for use only
|
||||
//! with TI Devices.
|
||||
//! * Nothing shall obligate TI to provide you with source code for the
|
||||
//! software licensed and provided to you in object code.
|
||||
//!
|
||||
//! If software source code is provided to you, modification and redistribution
|
||||
//! of the source code are permitted provided that the following conditions
|
||||
//! are met:
|
||||
//!
|
||||
//! * any redistribution and use of the source code, including any resulting
|
||||
//! derivative works, are licensed by TI for use only with TI Devices.
|
||||
//! * any redistribution and use of any object code compiled from the source
|
||||
//! code and any resulting derivative works, are licensed by TI for use
|
||||
//! only with TI Devices.
|
||||
//!
|
||||
//! Neither the name of Texas Instruments Incorporated nor the names of its
|
||||
//! suppliers may be used to endorse or promote products derived from this
|
||||
//! software without specific prior written permission.
|
||||
//#############################################################################
|
||||
|
||||
#ifndef _C_DCL_TCM_H
|
||||
#define _C_DCL_TCM_H
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
//! \file DCL_TCM.h
|
||||
//! \brief Contains the public interface to the Transient Capture Module (TCM)
|
||||
//!
|
||||
|
||||
#include <stdint.h>
|
||||
#include "DCL_fdlog.h"
|
||||
|
||||
|
||||
//! \brief Defines the TCM structure
|
||||
//!
|
||||
typedef volatile struct dcl_tcm {
|
||||
FDLOG moniFrame; //!< Monitor data frame
|
||||
FDLOG leadFrame; //!< Lead data frame
|
||||
FDLOG captFrame; //!< Capture data frame
|
||||
float32_t trigMax; //!< Upper trigger threshold
|
||||
float32_t trigMin; //!< Lower trigger threshold
|
||||
uint16_t mode; //!< Operating mode
|
||||
uint16_t lead; //!< Lead frame size in 32-bit words = trigger crossing index
|
||||
} TCM;
|
||||
|
||||
|
||||
//! \brief Defines default values to initialize the TCM structure
|
||||
//!
|
||||
#define TCM_DEFAULTS { FDLOG_DEFAULTS, FDLOG_DEFAULTS, FDLOG_DEFAULTS, 0.1, -0.1, 0, 10 }
|
||||
|
||||
|
||||
//! \brief Enumerated TCM operating modes
|
||||
//!
|
||||
typedef enum dcl_tcm_states {
|
||||
TCM_invalid = 0, //!< Buffer pointers not initialized
|
||||
TCM_idle, //!< Memory initialized but module not armed
|
||||
TCM_armed, //!< Armed: capturing monitor frame data and waiting for trigger
|
||||
TCM_capture, //!< Triggered: logging data into capture frame and un-winding monitor frame
|
||||
TCM_complete, //!< Full data frame captured and available for read-out
|
||||
TCM_numStates //!< Number of TCM states
|
||||
} TCM_states;
|
||||
|
||||
|
||||
//! \brief Resets the TCM module: clears buffers and sets idle mode
|
||||
//! \param[in] q The TCM structure
|
||||
//! \param[in] addr The start address of the memory block
|
||||
//! \param[in] size The size of the memory block in 32-bit words
|
||||
//! \param[in] lead The length of the lead frame in samples
|
||||
//! \param[in] tmin The upper trigger threshold
|
||||
//! \param[in] tmax The lower trigger threshold
|
||||
//!
|
||||
static inline void DCL_initTCM(TCM *q, float32_t *addr, uint16_t size, uint16_t lead, float32_t tmin, float32_t tmax)
|
||||
{
|
||||
// assign and clear capture frame, and initialize index to end of lead frame
|
||||
DCL_initLog(&(q->captFrame), addr, size);
|
||||
DCL_clearLog(&(q->captFrame));
|
||||
q->captFrame.dptr = q->captFrame.fptr + lead;
|
||||
|
||||
// assign lead & monitor frame pointers
|
||||
DCL_initLog(&(q->leadFrame), addr, lead);
|
||||
DCL_initLog(&(q->moniFrame), q->captFrame.lptr - lead + 1, lead);
|
||||
|
||||
// load remaining TCM vars
|
||||
q->lead = lead;
|
||||
q->trigMax = tmax;
|
||||
q->trigMin = tmin;
|
||||
q->mode = TCM_idle;
|
||||
}
|
||||
|
||||
|
||||
//! \brief Resets the TCM module: clears all frame buffers and sets idle mode
|
||||
//! \param[in] q The TCM structure
|
||||
//! \return The operating mode
|
||||
//!
|
||||
static inline void DCL_resetTCM(TCM *q)
|
||||
{
|
||||
DCL_clearLog(&(q->captFrame));
|
||||
q->captFrame.dptr = q->captFrame.fptr + q->lead - 1;
|
||||
DCL_resetLog(&(q->leadFrame));
|
||||
DCL_resetLog(&(q->moniFrame));
|
||||
q->mode = TCM_idle;
|
||||
}
|
||||
|
||||
|
||||
//! \brief Changes the TCM mode to "TCM_armed". Only valid if current operating mode is "TCM_idle"
|
||||
//! \param[in] q The TCM structure
|
||||
//! \return The operating mode
|
||||
//!
|
||||
static inline uint16_t DCL_armTCM(TCM *q)
|
||||
{
|
||||
q->mode = (q->mode == TCM_idle) ? TCM_armed : TCM_idle;
|
||||
return(q->mode);
|
||||
}
|
||||
|
||||
|
||||
//! \brief Runs the TCM module
|
||||
//! \param[in] q The TCM structure
|
||||
//! \param[in] data The input data
|
||||
//! \return The operating mode
|
||||
//!
|
||||
static inline uint16_t DCL_runTCM(TCM *q, float32_t data)
|
||||
{
|
||||
switch(q->mode)
|
||||
{
|
||||
// TCM not initialized
|
||||
case TCM_invalid:
|
||||
break;
|
||||
|
||||
// idle: do nothing
|
||||
case TCM_idle:
|
||||
break;
|
||||
|
||||
// armed: ready to begin capturing when either trigger threshold is crossed
|
||||
case TCM_armed:
|
||||
// check for trigger condition
|
||||
if ((data > q->trigMax) || (data < q->trigMin))
|
||||
{
|
||||
// capture first data point & switch to capture mode
|
||||
DCL_writeLog(&(q->captFrame), data);
|
||||
DCL_writeLog(&(q->leadFrame), DCL_readLog(&(q->moniFrame)));
|
||||
q->mode = TCM_capture;
|
||||
}
|
||||
else
|
||||
{
|
||||
// log data into monitor frame
|
||||
DCL_writeLog(&(q->moniFrame), data);
|
||||
}
|
||||
break;
|
||||
|
||||
// capture mode: acquiring data
|
||||
case TCM_capture:
|
||||
// check for full capture frame
|
||||
if (q->captFrame.dptr > q->captFrame.fptr)
|
||||
{
|
||||
// write data into main frame
|
||||
DCL_writeLog(&(q->captFrame), data);
|
||||
|
||||
// check for full lead frame
|
||||
if (q->leadFrame.dptr > q->leadFrame.fptr)
|
||||
{
|
||||
// un-wind monitor data into lead frame
|
||||
DCL_writeLog(&(q->leadFrame), DCL_readLog(&(q->moniFrame)));
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
// TCM complete, capture frame spans full buffer
|
||||
q->captFrame.fptr = q->leadFrame.fptr;
|
||||
q->captFrame.dptr = q->captFrame.fptr;
|
||||
q->mode = TCM_complete;
|
||||
}
|
||||
break;
|
||||
|
||||
// complete: do nothing - results available in capture buffer
|
||||
case TCM_complete:
|
||||
break;
|
||||
|
||||
default:
|
||||
;
|
||||
}
|
||||
|
||||
return(q->mode);
|
||||
}
|
||||
|
||||
|
||||
//! \brief Computes ITAE performance index from a log of servo error.
|
||||
//! Assembly function.
|
||||
//! \param[in] elog The servo error log
|
||||
//! \param[in] prd The sampling period in seconds
|
||||
//! \return The ITAE index
|
||||
//!
|
||||
extern float32_t DCL_runITAE_C1(FDLOG *elog, float32_t prd);
|
||||
|
||||
|
||||
//! \brief Computes ITAE performance index from a log of servo error.
|
||||
//! \param[in] elog The servo error log
|
||||
//! \param[in] prd The sampling period in seconds
|
||||
//! \return The ITAE index
|
||||
//!
|
||||
static inline float32_t DCL_runITAE_C2(FDLOG *elog, float32_t prd)
|
||||
{
|
||||
float32_t tim = 0.0f;
|
||||
float32_t rlt = 0.0f;
|
||||
|
||||
// set index pointer to buffer start
|
||||
DCL_resetLog(elog);
|
||||
|
||||
// accumulate ITAE data
|
||||
while (elog->dptr <= elog->lptr)
|
||||
{
|
||||
rlt += fabs(*(elog->dptr++)) * tim;
|
||||
tim += prd;
|
||||
}
|
||||
DCL_resetLog(elog);
|
||||
|
||||
return(rlt);
|
||||
}
|
||||
|
||||
|
||||
//! \brief Computes IAE performance index from a log of servo error.
|
||||
//! Assembly function.
|
||||
//! \param[in] elog The servo error log
|
||||
//! \return The IAE index
|
||||
//!
|
||||
extern float32_t DCL_runIAE_C1(FDLOG *elog);
|
||||
|
||||
|
||||
//! \brief Computes IAE performance index from a log of servo error.
|
||||
//! \param[in] elog The servo error log
|
||||
//! \return The IAE index
|
||||
//!
|
||||
static inline float32_t DCL_runIAE_C2(FDLOG *elog)
|
||||
{
|
||||
float32_t rlt = 0.0f;
|
||||
|
||||
// set index pointer to buffer start
|
||||
DCL_resetLog(elog);
|
||||
|
||||
// accumulate IAE data
|
||||
while (elog->dptr <= elog->lptr)
|
||||
{
|
||||
rlt += fabs(*(elog->dptr++));
|
||||
}
|
||||
DCL_resetLog(elog);
|
||||
|
||||
return(rlt);
|
||||
}
|
||||
|
||||
|
||||
//! \brief Computes IES performance index from a log of servo error.
|
||||
//! Assembly function.
|
||||
//! \param[in] elog The servo error log
|
||||
//! \return The IES index
|
||||
//!
|
||||
extern float32_t DCL_runIES_C1(FDLOG *elog);
|
||||
|
||||
|
||||
//! \brief Computes IES performance index from a log of servo error.
|
||||
//! \param[in] elog The servo error log
|
||||
//! \return The IES index
|
||||
//!
|
||||
static inline float32_t DCL_runIES_C2(FDLOG *elog)
|
||||
{
|
||||
float32_t err;
|
||||
float32_t rlt = 0.0f;
|
||||
|
||||
// set index pointers to buffer start
|
||||
DCL_resetLog(elog);
|
||||
|
||||
// accumulate IES data
|
||||
while (elog->dptr <= elog->lptr)
|
||||
{
|
||||
err = *(elog->dptr++);
|
||||
rlt += (err * err);
|
||||
}
|
||||
|
||||
// restore index pointer
|
||||
DCL_resetLog(elog);
|
||||
|
||||
return(rlt);
|
||||
}
|
||||
|
||||
//----------------------------------------------------------------------------
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif // extern "C"
|
||||
|
||||
#endif // _C_DCL_TCM_H
|
||||
|
||||
/* end of file */
|
||||
@@ -0,0 +1,274 @@
|
||||
/* DCL_fdlog.h - 32-bit floating-point data logger
|
||||
*
|
||||
*/
|
||||
//#############################################################################
|
||||
//!
|
||||
//! Copyright: Copyright (C) 2023 Texas Instruments Incorporated -
|
||||
//! All rights reserved not granted herein.
|
||||
//! Limited License.
|
||||
//!
|
||||
//! Texas Instruments Incorporated grants a world-wide, royalty-free,
|
||||
//! non-exclusive license under copyrights and patents it now or hereafter
|
||||
//! owns or controls to make, have made, use, import, offer to sell and sell
|
||||
//! ("Utilize") this software subject to the terms herein. With respect to the
|
||||
//! foregoing patent license, such license is granted solely to the extent that
|
||||
//! any such patent is necessary to Utilize the software alone. The patent
|
||||
//! license shall not apply to any combinations which include this software,
|
||||
//! other than combinations with devices manufactured by or for TI
|
||||
//! ("TI Devices").
|
||||
//! No hardware patent is licensed hereunder.
|
||||
//!
|
||||
//! Redistributions must preserve existing copyright notices and reproduce this
|
||||
//! license (including the above copyright notice and the disclaimer and
|
||||
//! (if applicable) source code license limitations below) in the documentation
|
||||
//! and/or other materials provided with the distribution.
|
||||
//!
|
||||
//! Redistribution and use in binary form, without modification, are permitted
|
||||
//! provided that the following conditions are met:
|
||||
//!
|
||||
//! * No reverse engineering, decompilation, or disassembly of this software is
|
||||
//! permitted with respect to any software provided in binary form.
|
||||
//! * Any redistribution and use are licensed by TI for use only
|
||||
//! with TI Devices.
|
||||
//! * Nothing shall obligate TI to provide you with source code for the
|
||||
//! software licensed and provided to you in object code.
|
||||
//!
|
||||
//! If software source code is provided to you, modification and redistribution
|
||||
//! of the source code are permitted provided that the following conditions
|
||||
//! are met:
|
||||
//!
|
||||
//! * any redistribution and use of the source code, including any resulting
|
||||
//! derivative works, are licensed by TI for use only with TI Devices.
|
||||
//! * any redistribution and use of any object code compiled from the source
|
||||
//! code and any resulting derivative works, are licensed by TI for use
|
||||
//! only with TI Devices.
|
||||
//!
|
||||
//! Neither the name of Texas Instruments Incorporated nor the names of its
|
||||
//! suppliers may be used to endorse or promote products derived from this
|
||||
//! software without specific prior written permission.
|
||||
//#############################################################################
|
||||
|
||||
#ifndef _C_DCL_FDLOG_H
|
||||
#define _C_DCL_FDLOG_H
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
#include "DCL.h"
|
||||
#include <stdint.h>
|
||||
|
||||
//! \file DCL_fdlog.h
|
||||
//!
|
||||
//! \brief Defines the single precision data buffer structure used in
|
||||
//! the DCL.
|
||||
//!
|
||||
//! \details The FDLOG structure contains three pointers which define
|
||||
//! the start and end of a memory block, and index into it.
|
||||
//! Manipulation of the indexing pointer permits linear and
|
||||
//! circular buffers, stacks, data logs, etc. to be implemented
|
||||
//! with a common data structure. An example of initialization
|
||||
//! and use is shown below:
|
||||
//!
|
||||
//! \code
|
||||
//! #pragma DATA_SECTION(r_Array, "DataLogSection")
|
||||
//! float32_t r_Array[FDLOG_DEFAULT_SIZE];
|
||||
//! FDLOG rBuf = FDLOG_DEFAULTS;
|
||||
//! float32_t x, y = 1.234f;
|
||||
//!
|
||||
//! DCL_createFDLOG(&rBuf, r_Array, FDLOG_DEFAULT_SIZE);
|
||||
//! DCL_clearFDLOG(&rBuf);
|
||||
//!
|
||||
//! DCL_writeFDLOG(&rBuf, y);
|
||||
//! x = readFDLOG(&rBuf);
|
||||
//! \endcode
|
||||
//!
|
||||
typedef volatile struct dcl_fdlog {
|
||||
float32_t *fptr; //!< Pointer to first buffer element
|
||||
float32_t *lptr; //!< Pointer to last buffer element
|
||||
float32_t *dptr; //!< Data index pointer
|
||||
} FDLOG;
|
||||
|
||||
|
||||
//! \brief Function name compatibility with DCL version 1
|
||||
//!
|
||||
#define DCL_createLog DCL_initLog
|
||||
|
||||
//! \brief Defines a default size for the FDLOG buffer
|
||||
//!
|
||||
#define FDLOG_DEFAULT_SIZE 0x0400
|
||||
|
||||
//! \brief Defines default values to initialise the FDLOG structure
|
||||
//!
|
||||
#define FDLOG_DEFAULTS { 0x00000000, \
|
||||
0x00000000, \
|
||||
0x00000000 \
|
||||
}
|
||||
|
||||
|
||||
/******************** macro definitions ********************/
|
||||
|
||||
//! \brief Distance from indexed element to end of buffer
|
||||
//!
|
||||
#define FDLOG_SPACE(buf) ((buf)->lptr - (buf)->dptr + 1)
|
||||
|
||||
//! \brief Total buffer size in 32-bit words
|
||||
//!
|
||||
#define FDLOG_SIZE(buf) ((buf)->lptr - (buf)->fptr + 1)
|
||||
|
||||
//! \brief Current indexed element
|
||||
//!
|
||||
#define FDLOG_ELEMENT(buf) ((buf)->dptr - (buf)->fptr + 1)
|
||||
|
||||
//! \brief Index pointer is at start of buffer
|
||||
//!
|
||||
#define FDLOG_START(buf) ((buf)->dptr == (buf)->fptr)
|
||||
|
||||
//! \brief Index pointer is at end of buffer
|
||||
//!
|
||||
#define FDLOG_END(buf) ((buf)->dptr == (buf)->lptr)
|
||||
|
||||
//! \brief Indexed pointer not in buffer range
|
||||
//!
|
||||
#define FDLOG_OUT_OF_RANGE(buf) (((buf)->dptr < (buf)->fptr) || ((buf)->dptr > (buf)->lptr))
|
||||
|
||||
//! \brief Check if the buffer has a non-zero size
|
||||
//!
|
||||
#define FDLOG_EXISTS(buf) ((buf)->lptr != (buf)->fptr)
|
||||
|
||||
|
||||
/******************** inline functions ********************/
|
||||
|
||||
//! \brief Resets all structure pointers to null value
|
||||
//! \param[in] p The FDLOG structure
|
||||
//!
|
||||
static inline void DCL_deleteLog(FDLOG *p) { p->dptr = p->lptr = p->fptr = 0; }
|
||||
|
||||
//! \brief Resets the data index pointer to start of buffer
|
||||
//! \param[in] p The FDLOG structure
|
||||
//!
|
||||
static inline void DCL_resetLog(FDLOG *p) { p->dptr = p->fptr; }
|
||||
|
||||
//! \brief Assigns the buffer pointers to a memory block or array and
|
||||
//! sets the data index pointer to the first address
|
||||
//! \param[in] p The FDLOG structure
|
||||
//! \param[in] addr The start address of the memory block
|
||||
//! \param[in] size The length of the memory block in 32-bit words
|
||||
//!
|
||||
static inline void DCL_initLog(FDLOG *p, float32_t *addr, uint16_t size)
|
||||
{
|
||||
p->fptr = addr;
|
||||
p->lptr = addr + size - 1;
|
||||
p->dptr = p->fptr;
|
||||
}
|
||||
|
||||
//! \brief Writes a data point into the buffer and advances the
|
||||
//! indexing pointer, wrapping if necessary.
|
||||
//! Returns the over-written data value for delay line or FIFO
|
||||
//! implementation.
|
||||
//! \param[in] p The FDLOG structure
|
||||
//! \param[in] data The input data value
|
||||
//! \return The over-written data value
|
||||
//!
|
||||
static inline float32_t DCL_writeLog(FDLOG *p, float32_t data)
|
||||
{
|
||||
float32_t rv = *(p->dptr); // save existing data
|
||||
|
||||
// write new data to log
|
||||
*(p->dptr++) = data;
|
||||
|
||||
// check for end of buffer & wrap if necessary
|
||||
if (p->dptr > p->lptr)
|
||||
{
|
||||
p->dptr = p->fptr;
|
||||
}
|
||||
|
||||
return(rv);
|
||||
}
|
||||
|
||||
//! \brief Fills the buffer with a given data value and resets the
|
||||
//! data index pointer to the start of the buffer
|
||||
//! \param[in] p The FDLOG structure
|
||||
//! \param[in] data The fill data value
|
||||
//!
|
||||
static inline void DCL_fillLog(FDLOG *p, float32_t data)
|
||||
{
|
||||
p->dptr = p->lptr;
|
||||
*(p->dptr) = data;
|
||||
while (p->dptr > p->fptr)
|
||||
{
|
||||
*(--p->dptr) = data;
|
||||
}
|
||||
}
|
||||
|
||||
//! \brief Clears the buffer contents by writing 0 to all elements and
|
||||
//! resets the data index pointer to the start of the buffer.
|
||||
//! Deprecated in DCL version 2: alias for DCL_fillLog.
|
||||
//!
|
||||
#define DCL_clearLog(bufAddr) DCL_fillLog(bufAddr,0)
|
||||
|
||||
|
||||
//! \brief Reads a data point from the buffer and then advances the
|
||||
//! indexing pointer, wrapping if necessary
|
||||
//! \param[in] p The FDLOG structure
|
||||
//! \return The indexed data value
|
||||
//!
|
||||
static inline float32_t DCL_readLog(FDLOG *p)
|
||||
{
|
||||
float32_t rv = *(p->dptr++);
|
||||
|
||||
if (p->dptr > p->lptr)
|
||||
{
|
||||
p->dptr = p->fptr;
|
||||
}
|
||||
|
||||
return(rv);
|
||||
}
|
||||
|
||||
//! \brief Copies the contents of one log (q) into another (p) and
|
||||
//! resets both buffer index pointers. Both logs must have the
|
||||
//! same length.
|
||||
//! \param[in] p The destination FDLOG structure
|
||||
//! \param[in] q The source FDLOG structure
|
||||
//!
|
||||
static inline void DCL_copyLog(FDLOG *p, FDLOG *q)
|
||||
{
|
||||
p->dptr = p->lptr;
|
||||
q->dptr = q->lptr;
|
||||
*(p->dptr) = *(q->dptr);
|
||||
while (p->dptr > p->fptr)
|
||||
{
|
||||
*(--p->dptr) = *(--q->dptr);
|
||||
}
|
||||
}
|
||||
|
||||
//! \brief Reads a data point into the buffer and then advances the
|
||||
//! indexing pointer, wrapping if necessary
|
||||
//! Fast assembly form of DCL_readLog()
|
||||
//! Implemented as external assembly module
|
||||
//! \param[in] p The FDLOG structure
|
||||
//! \return The indexed data value
|
||||
//!
|
||||
extern float32_t DCL_freadLog(FDLOG *p);
|
||||
|
||||
//! \brief Writes a data point into the buffer and advances the indexing
|
||||
//! pointer, wrapping if necessary.
|
||||
//! Returns the over-written data value for delay line or FIFO
|
||||
//! implementation.
|
||||
//! Fast assembly form of DCL_writeLog()
|
||||
//! Implemented as external assembly module
|
||||
//! \param[in] p The FDLOG structure
|
||||
//! \param[in] data The input data value
|
||||
//! \return The over-written data value
|
||||
//!
|
||||
extern float32_t DCL_fwriteLog(FDLOG *p, float32_t data);
|
||||
|
||||
//----------------------------------------------------------------------------
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif // extern "C"
|
||||
|
||||
#endif // _C_DCL_FDLOG_H
|
||||
|
||||
/* end of file */
|
||||
@@ -0,0 +1,247 @@
|
||||
/* DCL_fdlog64.h - 64-bit floating-point data buffer utility
|
||||
*
|
||||
*/
|
||||
//#############################################################################
|
||||
//!
|
||||
//! Copyright: Copyright (C) 2023 Texas Instruments Incorporated -
|
||||
//! All rights reserved not granted herein.
|
||||
//! Limited License.
|
||||
//!
|
||||
//! Texas Instruments Incorporated grants a world-wide, royalty-free,
|
||||
//! non-exclusive license under copyrights and patents it now or hereafter
|
||||
//! owns or controls to make, have made, use, import, offer to sell and sell
|
||||
//! ("Utilize") this software subject to the terms herein. With respect to the
|
||||
//! foregoing patent license, such license is granted solely to the extent that
|
||||
//! any such patent is necessary to Utilize the software alone. The patent
|
||||
//! license shall not apply to any combinations which include this software,
|
||||
//! other than combinations with devices manufactured by or for TI
|
||||
//! ("TI Devices").
|
||||
//! No hardware patent is licensed hereunder.
|
||||
//!
|
||||
//! Redistributions must preserve existing copyright notices and reproduce this
|
||||
//! license (including the above copyright notice and the disclaimer and
|
||||
//! (if applicable) source code license limitations below) in the documentation
|
||||
//! and/or other materials provided with the distribution.
|
||||
//!
|
||||
//! Redistribution and use in binary form, without modification, are permitted
|
||||
//! provided that the following conditions are met:
|
||||
//!
|
||||
//! * No reverse engineering, decompilation, or disassembly of this software is
|
||||
//! permitted with respect to any software provided in binary form.
|
||||
//! * Any redistribution and use are licensed by TI for use only
|
||||
//! with TI Devices.
|
||||
//! * Nothing shall obligate TI to provide you with source code for the
|
||||
//! software licensed and provided to you in object code.
|
||||
//!
|
||||
//! If software source code is provided to you, modification and redistribution
|
||||
//! of the source code are permitted provided that the following conditions
|
||||
//! are met:
|
||||
//!
|
||||
//! * any redistribution and use of the source code, including any resulting
|
||||
//! derivative works, are licensed by TI for use only with TI Devices.
|
||||
//! * any redistribution and use of any object code compiled from the source
|
||||
//! code and any resulting derivative works, are licensed by TI for use
|
||||
//! only with TI Devices.
|
||||
//!
|
||||
//! Neither the name of Texas Instruments Incorporated nor the names of its
|
||||
//! suppliers may be used to endorse or promote products derived from this
|
||||
//! software without specific prior written permission.
|
||||
//#############################################################################
|
||||
|
||||
#ifndef _C_DCL_FDLOG64_H
|
||||
#define _C_DCL_FDLOG64_H
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
#include "DCL.h"
|
||||
#include <stdint.h>
|
||||
|
||||
//! \file DCL_fdlog64.h
|
||||
//!
|
||||
//! \brief Defines the double precision data buffer structure used in the DCL
|
||||
//!
|
||||
//! \details The FDLOG64 structure contains three pointers which define the
|
||||
//! start and end of a memory block, and index into it.
|
||||
//! Manipulation of the indexing pointer permits linear and
|
||||
//! circular buffers, stacks, data logs, etc. to be implemented
|
||||
//! with a common data structure. An example of initialization
|
||||
//! and use is shown below:
|
||||
//!
|
||||
//! \code
|
||||
//! #pragma DATA_SECTION(r_Array, "DataLogSection")
|
||||
//! float64_t r_Array[FDLOG_DEFAULT_SIZE];
|
||||
//! FDLOG64 rBuf = FDLOG64_DEFAULTS;
|
||||
//! float64_t x, y = 1.234L;
|
||||
//!
|
||||
//! DCL_createFDLOG64(&rBuf, r_Array, FDLOG64_DEFAULT_SIZE);
|
||||
//! DCL_clearFDLOG64(&rBuf);
|
||||
//!
|
||||
//! DCL_writeFDLOG64(&rBuf, y);
|
||||
//! x = readFDLOG64(&rBuf);
|
||||
//! \endcode
|
||||
//!
|
||||
typedef volatile struct dcl_fdlog64 {
|
||||
float64_t *fptr; //!< Pointer to first buffer element
|
||||
float64_t *lptr; //!< Pointer to last buffer element
|
||||
float64_t *dptr; //!< Data index pointer
|
||||
} FDLOG64;
|
||||
|
||||
//! \brief Defines a default size for the FDLOG64 buffer
|
||||
//!
|
||||
#define FDLOG64_DEFAULT_SIZE 0x0400
|
||||
|
||||
//! \brief Defines default values to initialize the FDLOG64 structure
|
||||
//!
|
||||
#define FDLOG64_DEFAULTS { 0x00000000, \
|
||||
0x00000000, \
|
||||
0x00000000 \
|
||||
}
|
||||
|
||||
|
||||
/******************** macro definitions ********************/
|
||||
|
||||
//! \brief Distance from indexed element to end of buffer
|
||||
//!
|
||||
#define FDLOG64_SPACE(buf) ( (buf)->lptr - (buf)->dptr + 1 )
|
||||
|
||||
//! \brief Total buffer size in 64-bit words
|
||||
//!
|
||||
#define FDLOG64_SIZE(buf) ( (buf)->lptr - (buf)->fptr + 1 )
|
||||
|
||||
//! \brief Current indexed element
|
||||
//!
|
||||
#define FDLOG64_ELEMENT(buf) ( (buf)->dptr - (buf)->fptr + 1 )
|
||||
|
||||
//! \brief Index pointer is at start of buffer
|
||||
//!
|
||||
#define FDLOG64_START(buf) ( (buf)->dptr == (buf)->fptr )
|
||||
|
||||
//! \brief Index pointer is at end of buffer
|
||||
//!
|
||||
#define FDLOG64_END(buf) ( (buf)->dptr == (buf)->lptr )
|
||||
|
||||
//! \brief Indexed pointer not in buffer range
|
||||
//!
|
||||
#define FDLOG64_OUT_OF_RANGE(buf) ( ((buf)->dptr < (buf)->fptr) || ((buf)->dptr > (buf)->lptr) )
|
||||
|
||||
//! \brief Check if the buffer has a non-zero size
|
||||
//!
|
||||
#define FDLOG64_EXISTS(buf) ( (buf)->lptr != (buf)->fptr )
|
||||
|
||||
|
||||
/******************** inline functions ********************/
|
||||
|
||||
//! \brief Resets all structure pointers to null value
|
||||
//! \param[in] p The FDLOG64 structure
|
||||
//!
|
||||
static inline void DCL_deleteLog64(FDLOG64 *p) { p->dptr = p->lptr = p->fptr = 0; }
|
||||
|
||||
//! \brief Resets the data index pointer to start of buffer
|
||||
//! \param[in] p The FDLOG64 structure
|
||||
//!
|
||||
static inline void DCL_resetLog64(FDLOG64 *p) { p->dptr = p->fptr; }
|
||||
|
||||
//! \brief Assigns the buffer pointers to a memory block or array and sets
|
||||
//! the data index pointer to the first address
|
||||
//! \param[in] p The FDLOG64 structure
|
||||
//! \param[in] addr The start address of the memory block
|
||||
//! \param[in] size The length of the memory block in 64-bit words
|
||||
//!
|
||||
static inline void DCL_initLog64(FDLOG64 *p, float64_t *addr, uint16_t size)
|
||||
{
|
||||
p->fptr = addr;
|
||||
p->lptr = addr + size - 1;
|
||||
p->dptr = p->fptr;
|
||||
}
|
||||
|
||||
//! \brief Writes a data point into the buffer and advances the indexing
|
||||
//! pointer, wrapping if necessary.
|
||||
//! Returns the over-written data value for delay line or FIFO
|
||||
//! implementation.
|
||||
//! \param[in] p The FDLOG64 structure
|
||||
//! \param[in] data The input data value
|
||||
//! \return The over-written data value
|
||||
//!
|
||||
static inline float64_t DCL_writeLog64(FDLOG64 *p, float64_t data)
|
||||
{
|
||||
float64_t rv = *(p->dptr); // save existing data
|
||||
|
||||
// write new data to log
|
||||
*(p->dptr++) = data;
|
||||
|
||||
// check for end of buffer & wrap if necessary
|
||||
if (p->dptr > p->lptr)
|
||||
{
|
||||
p->dptr = p->fptr;
|
||||
}
|
||||
|
||||
return rv;
|
||||
}
|
||||
|
||||
//! \brief Fills the buffer with a given data value and resets the data
|
||||
//! index pointer to the start of the buffer
|
||||
//! \param[in] p The FDLOG64 structure
|
||||
//! \param[in] data The fill data value
|
||||
//!
|
||||
static inline void DCL_fillLog64(FDLOG64 *p, float64_t data)
|
||||
{
|
||||
p->dptr = p->lptr;
|
||||
*(p->dptr) = data;
|
||||
while (p->dptr > p->fptr)
|
||||
{
|
||||
*(--p->dptr) = data;
|
||||
}
|
||||
}
|
||||
|
||||
//! \brief Clears the buffer contents by writing 0 to all elements and
|
||||
//! resets the data index pointer to the start of the buffer.
|
||||
//! Alias for DCL_fillLog64.
|
||||
//!
|
||||
#define DCL_clearLog64(bufAddr) DCL_fillLog64(bufAddr,0)
|
||||
|
||||
|
||||
//! \brief Reads a data point from the buffer and then advances the
|
||||
//! indexing pointer, wrapping if necessary
|
||||
//! \param[in] p The FDLOG64 structure
|
||||
//! \return The indexed data value
|
||||
//!
|
||||
static inline float64_t DCL_readLog64(FDLOG64 *p)
|
||||
{
|
||||
float64_t rv = *(p->dptr++);
|
||||
|
||||
if (p->dptr > p->lptr)
|
||||
{
|
||||
p->dptr = p->fptr;
|
||||
}
|
||||
|
||||
return rv;
|
||||
}
|
||||
|
||||
//! \brief Copies the contents of one log (q) into another (p) and resets
|
||||
//! both buffer index pointers. The function assumes both logs
|
||||
//! have the same length.
|
||||
//! \param[in] p The destination FDLOG64 structure
|
||||
//! \param[in] q The source FDLOG64 structure
|
||||
//!
|
||||
static inline void DCL_copyLog64(FDLOG64 *p, FDLOG64 *q)
|
||||
{
|
||||
p->dptr = p->lptr;
|
||||
q->dptr = q->lptr;
|
||||
*(p->dptr) = *(q->dptr);
|
||||
while (p->dptr > p->fptr)
|
||||
{
|
||||
*(--p->dptr) = *(--q->dptr);
|
||||
}
|
||||
}
|
||||
|
||||
//----------------------------------------------------------------------------
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif // extern "C"
|
||||
|
||||
#endif // _C_DCL_FDLOG64_H
|
||||
|
||||
/* end of file */
|
||||
@@ -0,0 +1,250 @@
|
||||
/* DCL_log32.h - 32-bit fixed-point data buffer utility
|
||||
*
|
||||
*/
|
||||
//#############################################################################
|
||||
//!
|
||||
//! Copyright: Copyright (C) 2023 Texas Instruments Incorporated -
|
||||
//! All rights reserved not granted herein.
|
||||
//! Limited License.
|
||||
//!
|
||||
//! Texas Instruments Incorporated grants a world-wide, royalty-free,
|
||||
//! non-exclusive license under copyrights and patents it now or hereafter
|
||||
//! owns or controls to make, have made, use, import, offer to sell and sell
|
||||
//! ("Utilize") this software subject to the terms herein. With respect to the
|
||||
//! foregoing patent license, such license is granted solely to the extent that
|
||||
//! any such patent is necessary to Utilize the software alone. The patent
|
||||
//! license shall not apply to any combinations which include this software,
|
||||
//! other than combinations with devices manufactured by or for TI
|
||||
//! ("TI Devices").
|
||||
//! No hardware patent is licensed hereunder.
|
||||
//!
|
||||
//! Redistributions must preserve existing copyright notices and reproduce this
|
||||
//! license (including the above copyright notice and the disclaimer and
|
||||
//! (if applicable) source code license limitations below) in the documentation
|
||||
//! and/or other materials provided with the distribution.
|
||||
//!
|
||||
//! Redistribution and use in binary form, without modification, are permitted
|
||||
//! provided that the following conditions are met:
|
||||
//!
|
||||
//! * No reverse engineering, decompilation, or disassembly of this software is
|
||||
//! permitted with respect to any software provided in binary form.
|
||||
//! * Any redistribution and use are licensed by TI for use only
|
||||
//! with TI Devices.
|
||||
//! * Nothing shall obligate TI to provide you with source code for the
|
||||
//! software licensed and provided to you in object code.
|
||||
//!
|
||||
//! If software source code is provided to you, modification and redistribution
|
||||
//! of the source code are permitted provided that the following conditions
|
||||
//! are met:
|
||||
//!
|
||||
//! * any redistribution and use of the source code, including any resulting
|
||||
//! derivative works, are licensed by TI for use only with TI Devices.
|
||||
//! * any redistribution and use of any object code compiled from the source
|
||||
//! code and any resulting derivative works, are licensed by TI for use
|
||||
//! only with TI Devices.
|
||||
//!
|
||||
//! Neither the name of Texas Instruments Incorporated nor the names of its
|
||||
//! suppliers may be used to endorse or promote products derived from this
|
||||
//! software without specific prior written permission.
|
||||
//#############################################################################
|
||||
|
||||
#ifndef _C_DCL_LOG32_H
|
||||
#define _C_DCL_LOG32_H
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
#include <stdint.h>
|
||||
|
||||
//! \file DCL_log32.h
|
||||
//!
|
||||
//! \brief Defines the 32-bit fixed-point data buffer structure
|
||||
//!
|
||||
//! \details The LOG32 structure contains three pointers which define the
|
||||
//! start and end of a memory block, and index into it.
|
||||
//! Manipulation of the indexing pointer permits linear and
|
||||
//! circular buffers, stacks, data logs, etc. to be implemented
|
||||
//! with a common data structure. An example of initialisation
|
||||
//! and use is shown below:
|
||||
//!
|
||||
//! \code
|
||||
//! #pragma DATA_SECTION(r_Array, "DataLogSection")
|
||||
//! int32_t r_Array[FDLOG_DEFAULT_SIZE];
|
||||
//! LOG32 rBuf = LOG32_DEFAULTS;
|
||||
//! int32_t x, y = 0x12345678;
|
||||
//!
|
||||
//! DCL_createLOG32(&rBuf, r_Array, LOG32_DEFAULT_SIZE);
|
||||
//! DCL_clearLOG32(&rBuf);
|
||||
//!
|
||||
//! DCL_writeLOG32(&rBuf, y);
|
||||
//! x = readLOG32(&rBuf);
|
||||
//! \endcode
|
||||
//!
|
||||
typedef volatile struct dcl_log32 {
|
||||
int32_t *fptr; //!< Pointer to first buffer element
|
||||
int32_t *lptr; //!< Pointer to last buffer element
|
||||
int32_t *dptr; //!< Data index pointer
|
||||
} LOG32;
|
||||
|
||||
|
||||
//! \brief Function name compatibility with DCL version 1
|
||||
//!
|
||||
#define DCL_createLog32 DCL_initLog32
|
||||
|
||||
//! \brief Defines a default size for the FDLOG buffer
|
||||
//!
|
||||
#define LOG32_DEFAULT_SIZE 0x0400
|
||||
|
||||
//! \brief Defines default values to initialise the FDLOG structure
|
||||
//!
|
||||
#define LOG32_DEFAULTS { 0x00000000, \
|
||||
0x00000000, \
|
||||
0x00000000 \
|
||||
}
|
||||
|
||||
|
||||
/******************** macro definitions ********************/
|
||||
|
||||
//! \brief Distance from indexed element to end of buffer
|
||||
//!
|
||||
#define LOG32_SPACE(buf) ((buf)->lptr - (buf)->dptr + 1)
|
||||
|
||||
//! \brief Total buffer size in 32-bit words
|
||||
//!
|
||||
#define LOG32_SIZE(buf) ((buf)->lptr - (buf)->fptr + 1)
|
||||
|
||||
//! \brief Current indexed element
|
||||
//!
|
||||
#define LOG32_ELEMENT(buf) ((buf)->dptr - (buf)->fptr + 1)
|
||||
|
||||
//! \brief Index pointer is at start of buffer
|
||||
//!
|
||||
#define LOG32_START(buf) ((buf)->dptr == (buf)->fptr)
|
||||
|
||||
//! \brief Index pointer is at end of buffer
|
||||
//!
|
||||
#define LOG32_END(buf) ((buf)->dptr == (buf)->lptr)
|
||||
|
||||
//! \brief Indexed pointer not in buffer range
|
||||
//!
|
||||
#define LOG32_OUT_OF_RANGE(buf) (((buf)->dptr < (buf)->fptr) || ((buf)->dptr > (buf)->lptr))
|
||||
|
||||
//! \brief Check if the buffer has a non-zero size
|
||||
//!
|
||||
#define LOG32_EXISTS(buf) ((buf)->lptr != (buf)->fptr)
|
||||
|
||||
|
||||
/******************** inline functions ********************/
|
||||
|
||||
//! \brief Resets all structure pointers to null value
|
||||
//! \param[in] p The LOG32 structure
|
||||
//!
|
||||
static inline void DCL_deleteLog32(LOG32 *p) { p->dptr = p->lptr = p->fptr = 0; }
|
||||
|
||||
//! \brief Resets the data index pointer to start of buffer
|
||||
//! \param[in] p The LOG32 structure
|
||||
//!
|
||||
static inline void DCL_resetLog32(LOG32 *p) { p->dptr = p->fptr; }
|
||||
|
||||
//! \brief Assigns the buffer pointers to a memory block or array and sets
|
||||
//! the data index pointer to the first address
|
||||
//! \param[in] p The LOG32 structure
|
||||
//! \param[in] addr The start address of the memory block
|
||||
//! \param[in] size The length of the memory block in 32-bit words
|
||||
//!
|
||||
static inline void DCL_initLog32(LOG32 *p, int32_t *addr, uint16_t size)
|
||||
{
|
||||
p->fptr = addr;
|
||||
p->lptr = addr + size - 1;
|
||||
p->dptr = p->fptr;
|
||||
}
|
||||
|
||||
//! \brief Writes a data point into the buffer and advances the indexing
|
||||
//! pointer, wrapping if necessary.
|
||||
//! Returns the over-written data value for delay line or FIFO
|
||||
//! implementation.
|
||||
//! \param[in] p The LOG32 structure
|
||||
//! \param[in] data The input data value
|
||||
//! \return The over-written data value
|
||||
//!
|
||||
static inline int32_t DCL_writeLog32(LOG32 *p, int32_t data)
|
||||
{
|
||||
int32_t rv = *(p->dptr); // save existing data
|
||||
|
||||
// write new data to log
|
||||
*(p->dptr++) = data;
|
||||
|
||||
// check for end of buffer & wrap if necessary
|
||||
if (p->dptr > p->lptr)
|
||||
{
|
||||
p->dptr = p->fptr;
|
||||
}
|
||||
|
||||
return(rv);
|
||||
}
|
||||
|
||||
//! \brief Fills the buffer with a given data value and resets the data
|
||||
//! index pointer to the start of the buffer
|
||||
//! \param[in] p The LOG32 structure
|
||||
//! \param[in] data The fill data value
|
||||
//!
|
||||
static inline void DCL_fillLog32(LOG32 *p, int32_t data)
|
||||
{
|
||||
p->dptr = p->lptr;
|
||||
*(p->dptr) = data;
|
||||
while (p->dptr > p->fptr)
|
||||
{
|
||||
*(--p->dptr) = data;
|
||||
}
|
||||
}
|
||||
|
||||
//! \brief Clears the buffer contents by writing 0 to all elements and
|
||||
//! resets the data index pointer to the start of the buffer.
|
||||
//!
|
||||
#define DCL_clearLog32(bufAddr) DCL_fillLog32(bufAddr, 0L)
|
||||
|
||||
|
||||
//! \brief Reads a data point from the buffer and then advances the
|
||||
//! indexing pointer, wrapping if necessary
|
||||
//! \param[in] p The LOG32 structure
|
||||
//! \return The indexed data value
|
||||
//!
|
||||
static inline int32_t DCL_readLog32(LOG32 *p)
|
||||
{
|
||||
int32_t rv = *(p->dptr++);
|
||||
|
||||
if (p->dptr > p->lptr)
|
||||
{
|
||||
p->dptr = p->fptr;
|
||||
}
|
||||
|
||||
return(rv);
|
||||
}
|
||||
|
||||
//! \brief Copies the contents of one log (q) into another (p) and resets
|
||||
//! both buffer index pointers. The function assumes both logs
|
||||
//! have the same length.
|
||||
//! \param[in] p The destination LOG32 structure
|
||||
//! \param[in] q The source LOG32 structure
|
||||
//!
|
||||
static inline void DCL_copyLog32(LOG32 *p, LOG32 *q)
|
||||
{
|
||||
p->dptr = p->lptr;
|
||||
q->dptr = q->lptr;
|
||||
*(p->dptr) = *(q->dptr);
|
||||
while (p->dptr > p->fptr)
|
||||
{
|
||||
*(--p->dptr) = *(--q->dptr);
|
||||
}
|
||||
}
|
||||
|
||||
//----------------------------------------------------------------------------
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif // extern "C"
|
||||
|
||||
#endif // _C_DCL_LOG32_H
|
||||
|
||||
/* end of file */
|
||||
@@ -0,0 +1,564 @@
|
||||
/* DCL_refgen.h - Reference generator module header file
|
||||
*
|
||||
*/
|
||||
//#############################################################################
|
||||
//!
|
||||
//! Copyright: Copyright (C) 2023 Texas Instruments Incorporated -
|
||||
//! All rights reserved not granted herein.
|
||||
//! Limited License.
|
||||
//!
|
||||
//! Texas Instruments Incorporated grants a world-wide, royalty-free,
|
||||
//! non-exclusive license under copyrights and patents it now or hereafter
|
||||
//! owns or controls to make, have made, use, import, offer to sell and sell
|
||||
//! ("Utilize") this software subject to the terms herein. With respect to the
|
||||
//! foregoing patent license, such license is granted solely to the extent that
|
||||
//! any such patent is necessary to Utilize the software alone. The patent
|
||||
//! license shall not apply to any combinations which include this software,
|
||||
//! other than combinations with devices manufactured by or for TI
|
||||
//! ("TI Devices").
|
||||
//! No hardware patent is licensed hereunder.
|
||||
//!
|
||||
//! Redistributions must preserve existing copyright notices and reproduce this
|
||||
//! license (including the above copyright notice and the disclaimer and
|
||||
//! (if applicable) source code license limitations below) in the documentation
|
||||
//! and/or other materials provided with the distribution.
|
||||
//!
|
||||
//! Redistribution and use in binary form, without modification, are permitted
|
||||
//! provided that the following conditions are met:
|
||||
//!
|
||||
//! * No reverse engineering, decompilation, or disassembly of this software is
|
||||
//! permitted with respect to any software provided in binary form.
|
||||
//! * Any redistribution and use are licensed by TI for use only
|
||||
//! with TI Devices.
|
||||
//! * Nothing shall obligate TI to provide you with source code for the
|
||||
//! software licensed and provided to you in object code.
|
||||
//!
|
||||
//! If software source code is provided to you, modification and redistribution
|
||||
//! of the source code are permitted provided that the following conditions
|
||||
//! are met:
|
||||
//!
|
||||
//! * any redistribution and use of the source code, including any resulting
|
||||
//! derivative works, are licensed by TI for use only with TI Devices.
|
||||
//! * any redistribution and use of any object code compiled from the source
|
||||
//! code and any resulting derivative works, are licensed by TI for use
|
||||
//! only with TI Devices.
|
||||
//!
|
||||
//! Neither the name of Texas Instruments Incorporated nor the names of its
|
||||
//! suppliers may be used to endorse or promote products derived from this
|
||||
//! software without specific prior written permission.
|
||||
//#############################################################################
|
||||
|
||||
#ifndef _C_DCL_REFGEN_H
|
||||
#define _C_DCL_REFGEN_H
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
#include "DCL.h"
|
||||
|
||||
//! \brief Region related symbols for function placement
|
||||
//
|
||||
#pragma CODE_SECTION(DCL_runRefgen,"dclfuncs")
|
||||
#pragma CODE_SECTION(DCL_getRefgenPhaseA,"dclfuncs")
|
||||
#pragma CODE_SECTION(DCL_getRefgenPhaseB,"dclfuncs")
|
||||
#pragma CODE_SECTION(DCL_getRefgenPhaseC,"dclfuncs")
|
||||
|
||||
//! \brief Defines the minimum normalized increment
|
||||
//!
|
||||
#define DCL_REFGEN_MIN_INC 1.0e-06f
|
||||
|
||||
//! \brief Defines the REFGEN operating modes
|
||||
//!
|
||||
enum dcl_rgen_modes {
|
||||
REFGEN_OFF = 0,
|
||||
REFGEN_STATIC,
|
||||
REFGEN_SINE,
|
||||
REFGEN_SQUARE,
|
||||
REFGEN_SAW,
|
||||
REFGEN_TRIANGLE,
|
||||
REFGEN_PULSE,
|
||||
REFGEN_SINE2,
|
||||
REFGEN_SINE3
|
||||
};
|
||||
|
||||
//! \brief Defines the DCL_REFGEN structure
|
||||
//!
|
||||
typedef volatile struct dcl_refgen {
|
||||
float32_t rtgt; //!< Target ramp value
|
||||
float32_t rinc; //!< Ramp increment
|
||||
float32_t amtgt; //!< Target amplitude value
|
||||
float32_t aminc; //!< Amplitude increment
|
||||
float32_t fmtgt; //!< Frequency ramp value
|
||||
float32_t fminc; //!< Frequency increment
|
||||
float32_t thinc; //!< Angular increment
|
||||
float32_t duty; //!< Pulse duty cycle
|
||||
float32_t umax; //!< Maximum allowable output
|
||||
float32_t umin; //!< Minimum allowable output
|
||||
float32_t yr; //!< Ramp generator output
|
||||
float32_t ampl; //!< Dynamic amplitude
|
||||
float32_t freq; //!< Dynamic frequency
|
||||
float32_t theta; //!< Normalized angle - phase A
|
||||
float32_t thetb; //!< Normalized angle - phase B
|
||||
float32_t thetc; //!< Normalized angle - phase C
|
||||
float32_t ya; //!< Phase A output
|
||||
float32_t yb; //!< Phase B output
|
||||
float32_t yc; //!< Phase C output
|
||||
int16_t mode; //!< Operating mode
|
||||
int16_t spare; //!< Spare for alignment
|
||||
DCL_CSS *css; //!< Pointer to the common support structure
|
||||
} DCL_REFGEN;
|
||||
|
||||
//! \brief Defines default values to initialize the DCL_REFGEN structure
|
||||
//!
|
||||
#define DCL_REFGEN_DEFAULTS { 0.0f, 0.0f, \
|
||||
0.0f, 0.0f, \
|
||||
0.0f, 0.0f, 0.0f, \
|
||||
0.0f, 1.0f, 1.0f, 1.0f, -1.0f, \
|
||||
0.0f, 0.0f, 0.0f, 0.0f, \
|
||||
0.0f, 0.0f, 0.0f, \
|
||||
REFGEN_OFF, 0, NULL_ADDR }
|
||||
|
||||
//----------------------------------------------------------------------------
|
||||
|
||||
//! \brief Resets DCL_REFGEN dynamic data
|
||||
//! \param[in] p Pointer to the DCL_REFGEN structure
|
||||
//! \return None
|
||||
//!
|
||||
static inline void DCL_resetRefgen(DCL_REFGEN *p)
|
||||
{
|
||||
p->ampl = 0.0f;
|
||||
p->freq = 0.0f;
|
||||
p->rinc = 0.0f;
|
||||
p->theta = 0.0f;
|
||||
p->thetb = 0.0f;
|
||||
p->thetc = 0.0f;
|
||||
p->thinc = 0.0f;
|
||||
p->yr = 0.0f;
|
||||
p->ya = 0.0f;
|
||||
p->yb = 0.0f;
|
||||
p->yc = 0.0f;
|
||||
}
|
||||
|
||||
|
||||
//! \brief Loads the REFGEN ramp parameters
|
||||
//!
|
||||
//! \param[in] p Pointer to the DCL_REFGEN structure
|
||||
//! \param[in] tgt The new static reference target
|
||||
//! \param[in] tr The time interval to reach the new target
|
||||
//! \return Void
|
||||
//!
|
||||
static inline void DCL_setRefgenRamp(DCL_REFGEN *p, float32_t tgt, float32_t tr)
|
||||
{
|
||||
#ifdef DCL_ERROR_HANDLING_ENABLED
|
||||
p->css->err |= (tr < 0.0f) ? ERR_PARAM_RANGE : ERR_NONE;
|
||||
if (p->css->err)
|
||||
{
|
||||
DCL_GET_ERROR_LOC(p->css);
|
||||
DCL_RUN_ERROR_HANDLER(p->css);
|
||||
}
|
||||
#endif
|
||||
|
||||
// compute ramp increment
|
||||
tr = (tr < p->css->T) ? p->css->T : tr;
|
||||
p->rtgt = tgt;
|
||||
p->rinc = p->css->T * (tgt - p->yr) / tr;
|
||||
|
||||
// clamp minimum ramp increment
|
||||
if (!(0.0f == p->rinc) && (fabsf(p->rinc) < DCL_REFGEN_MIN_INC))
|
||||
{
|
||||
#ifdef DCL_ERROR_HANDLING_ENABLED
|
||||
p->css->err = ERR_COMPUTATION;
|
||||
DCL_GET_ERROR_LOC(p->css);
|
||||
DCL_RUN_ERROR_HANDLER(p->css);
|
||||
#endif
|
||||
if (signbit(p->rinc))
|
||||
{
|
||||
p->rinc = -DCL_REFGEN_MIN_INC;
|
||||
}
|
||||
else
|
||||
{
|
||||
p->rinc = DCL_REFGEN_MIN_INC;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
//! \brief Loads the REFGEN dynamic amplitude
|
||||
//!
|
||||
//! \param[in] p Pointer to the DCL_REFGEN structure
|
||||
//! \param[in] ampl The new target amplitude
|
||||
//! \param[in] tr The time interval to reach the new target
|
||||
//! \return Void
|
||||
//!
|
||||
static inline void DCL_setRefgenAmpl(DCL_REFGEN *p, float32_t ampl, float32_t tr)
|
||||
{
|
||||
#ifdef DCL_ERROR_HANDLING_ENABLED
|
||||
p->css->err |= (tr < 0.0f) ? ERR_PARAM_RANGE : ERR_NONE;
|
||||
if (p->css->err)
|
||||
{
|
||||
DCL_GET_ERROR_LOC(p->css);
|
||||
DCL_RUN_ERROR_HANDLER(p->css);
|
||||
}
|
||||
#endif
|
||||
|
||||
// compute amplitude increment
|
||||
tr = (tr < p->css->T) ? p->css->T : tr;
|
||||
p->amtgt = ampl;
|
||||
p->aminc = p->css->T * (ampl - p->ampl) / tr;
|
||||
|
||||
// clamp minimum amplitude increment
|
||||
if ((p->aminc > 0.0f) && (fabsf(p->aminc) < DCL_REFGEN_MIN_INC))
|
||||
{
|
||||
#ifdef DCL_ERROR_HANDLING_ENABLED
|
||||
p->css->err = ERR_COMPUTATION;
|
||||
DCL_GET_ERROR_LOC(p->css);
|
||||
DCL_RUN_ERROR_HANDLER(p->css);
|
||||
#endif
|
||||
if (signbit(p->aminc))
|
||||
{
|
||||
p->aminc = -DCL_REFGEN_MIN_INC;
|
||||
}
|
||||
else
|
||||
{
|
||||
p->aminc = DCL_REFGEN_MIN_INC;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
//! \brief Loads the REFGEN frequency
|
||||
//!
|
||||
//! \param[in] p Pointer to the DCL_REFGEN structure
|
||||
//! \param[in] freq The new frequency in Hz
|
||||
//! \param[in] tr The time interval to reach the new target
|
||||
//! \return Void
|
||||
//!
|
||||
static inline void DCL_setRefgenFreq(DCL_REFGEN *p, float32_t freq, float32_t tr)
|
||||
{
|
||||
#ifdef DCL_ERROR_HANDLING_ENABLED
|
||||
p->css->err |= (tr < 0.0f) ? ERR_PARAM_RANGE : ERR_NONE;
|
||||
if (p->css->err)
|
||||
{
|
||||
DCL_GET_ERROR_LOC(p->css);
|
||||
DCL_RUN_ERROR_HANDLER(p->css);
|
||||
}
|
||||
#endif
|
||||
|
||||
// compute frequency increment
|
||||
tr = (tr < p->css->T) ? p->css->T : tr;
|
||||
p->fmtgt = freq;
|
||||
p->fminc = p->css->T * (freq - p->freq) / tr;
|
||||
|
||||
// clamp minimum frequency increment
|
||||
if ((p->fminc > 0.0f) && (fabsf(p->fminc) < DCL_REFGEN_MIN_INC))
|
||||
{
|
||||
#ifdef DCL_ERROR_HANDLING_ENABLED
|
||||
p->css->err = ERR_COMPUTATION;
|
||||
DCL_GET_ERROR_LOC(p->css);
|
||||
DCL_RUN_ERROR_HANDLER(p->css);
|
||||
#endif
|
||||
if (signbit(p->fminc))
|
||||
{
|
||||
p->fminc = -DCL_REFGEN_MIN_INC;
|
||||
}
|
||||
else
|
||||
{
|
||||
p->fminc = DCL_REFGEN_MIN_INC;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
//! \brief Loads the REFGEN pulse duty cycle
|
||||
//! \param[in] p Pointer to the DCL_REFGEN structure
|
||||
//! \param[in] duty The new per-unit duty cycle
|
||||
//! \return None
|
||||
//!
|
||||
static inline void DCL_setRefgenDuty(DCL_REFGEN *p, float32_t duty)
|
||||
{
|
||||
#ifdef DCL_ERROR_HANDLING_ENABLED
|
||||
p->css->err |= ((duty < 0.0f) || (duty > 1.0f)) ? ERR_PARAM_RANGE : ERR_NONE;
|
||||
if (p->css->err)
|
||||
{
|
||||
DCL_GET_ERROR_LOC(p->css);
|
||||
DCL_RUN_ERROR_HANDLER(p->css);
|
||||
}
|
||||
#endif
|
||||
|
||||
p->duty = duty;
|
||||
}
|
||||
|
||||
//! \brief Loads the REFGEN output clam limits
|
||||
//! \param[in] p Pointer to the DCL_REFGEN structure
|
||||
//! \param[in] max The upper limit
|
||||
//! \param[in] min The lower limit
|
||||
//! \return None
|
||||
//!
|
||||
static inline void DCL_setRefgenClamp(DCL_REFGEN *p, float32_t max, float32_t min)
|
||||
{
|
||||
#ifdef DCL_ERROR_HANDLING_ENABLED
|
||||
p->css->err |= (max < min) ? ERR_PARAM_RANGE : ERR_NONE;
|
||||
if (p->css->err)
|
||||
{
|
||||
DCL_GET_ERROR_LOC(p->css);
|
||||
DCL_RUN_ERROR_HANDLER(p->css);
|
||||
}
|
||||
#endif
|
||||
|
||||
p->umax = max;
|
||||
p->umin = min;
|
||||
}
|
||||
|
||||
|
||||
//! \brief Sets the REFGEN operating mode
|
||||
//! \param[in] p Pointer to the DCL_REFGEN structure
|
||||
//! \param[in] mode The new operating mode
|
||||
//! \return None
|
||||
//!
|
||||
static inline void DCL_setRefgenMode(DCL_REFGEN *p, int16_t mode)
|
||||
{
|
||||
p->mode = mode;
|
||||
}
|
||||
|
||||
|
||||
//! \brief Runs the REFGEN module
|
||||
//! \param[in] p Pointer to the DCL_REFGEN structure
|
||||
//! \return None
|
||||
//!
|
||||
static inline void DCL_runRefgen(DCL_REFGEN *p)
|
||||
{
|
||||
#ifdef DCL_ERROR_HANDLING_ENABLED
|
||||
float32_t v;
|
||||
#endif
|
||||
|
||||
// static offset generator
|
||||
if (!F32_IS_ZERO(p->rinc))
|
||||
{
|
||||
if (fabsf(p->rinc) > fabsf(p->rtgt - p->yr))
|
||||
{
|
||||
p->yr = p->rtgt;
|
||||
p->rinc = 0.0f;
|
||||
DCL_ADJUSTMENT_COMPLETE(p);
|
||||
}
|
||||
else
|
||||
{
|
||||
#ifdef DCL_ERROR_HANDLING_ENABLED
|
||||
v = p->yr;
|
||||
#endif
|
||||
p->yr += p->rinc;
|
||||
#ifdef DCL_ERROR_HANDLING_ENABLED
|
||||
if (F32_IS_ZERO(v - p->yr))
|
||||
{
|
||||
p->css->err = ERR_COMPUTATION;
|
||||
DCL_GET_ERROR_LOC(p->css);
|
||||
DCL_RUN_ERROR_HANDLER(p->css);
|
||||
}
|
||||
#endif
|
||||
DCL_ADJUSTMENT_RUNNING(p);
|
||||
}
|
||||
}
|
||||
|
||||
// amplitude modulator
|
||||
if (!F32_IS_ZERO(p->aminc))
|
||||
{
|
||||
if (fabsf(p->aminc) > fabsf(p->amtgt - p->ampl))
|
||||
{
|
||||
p->ampl = p->amtgt;
|
||||
p->aminc = 0.0f;
|
||||
}
|
||||
else
|
||||
{
|
||||
#ifdef DCL_ERROR_HANDLING_ENABLED
|
||||
v = p->ampl;
|
||||
#endif
|
||||
p->ampl += p->aminc;
|
||||
#ifdef DCL_ERROR_HANDLING_ENABLED
|
||||
if (F32_IS_ZERO(v - p->ampl))
|
||||
{
|
||||
p->css->err = ERR_COMPUTATION;
|
||||
DCL_GET_ERROR_LOC(p->css);
|
||||
DCL_RUN_ERROR_HANDLER(p->css);
|
||||
}
|
||||
#endif
|
||||
}
|
||||
}
|
||||
|
||||
// frequency modulator
|
||||
if (!F32_IS_ZERO(p->fminc))
|
||||
{
|
||||
if (fabsf(p->fminc) > fabsf(p->fmtgt - p->freq))
|
||||
{
|
||||
p->freq = p->fmtgt;
|
||||
p->fminc = 0.0f;
|
||||
}
|
||||
else
|
||||
{
|
||||
#ifdef DCL_ERROR_HANDLING_ENABLED
|
||||
v = p->freq;
|
||||
#endif
|
||||
p->freq += p->fminc;
|
||||
#ifdef DCL_ERROR_HANDLING_ENABLED
|
||||
if (F32_IS_ZERO(v - p->freq))
|
||||
{
|
||||
p->css->err = ERR_COMPUTATION;
|
||||
DCL_GET_ERROR_LOC(p->css);
|
||||
DCL_RUN_ERROR_HANDLER(p->css);
|
||||
}
|
||||
#endif
|
||||
}
|
||||
}
|
||||
|
||||
// angle increment
|
||||
if (p->freq > 0.0f)
|
||||
{
|
||||
p->thinc = p->css->T * p->freq;
|
||||
if (p->thinc < DCL_REFGEN_MIN_INC)
|
||||
{
|
||||
#ifdef DCL_ERROR_HANDLING_ENABLED
|
||||
p->css->err = ERR_COMPUTATION;
|
||||
DCL_GET_ERROR_LOC(p->css);
|
||||
DCL_RUN_ERROR_HANDLER(p->css);
|
||||
#endif
|
||||
p->thinc = DCL_REFGEN_MIN_INC;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
p->thinc = 0.0f;
|
||||
}
|
||||
|
||||
p->theta += p->thinc;
|
||||
p->theta -= (p->theta >= 1.0f) ? 1.0f : 0.0f;
|
||||
|
||||
// dynamic signal generator
|
||||
switch (p->mode) {
|
||||
|
||||
case REFGEN_STATIC:
|
||||
p->ya = 0.0f;
|
||||
p->yb = 0.0f;
|
||||
p->yc = 0.0f;
|
||||
break;
|
||||
|
||||
case REFGEN_SINE:
|
||||
#ifdef __TMS320C28XX_TMU__
|
||||
p->ya = __sinpuf32(p->theta);
|
||||
#else
|
||||
p->ya = sinf(CONST_2PI_32 * p->theta);
|
||||
#endif
|
||||
p->yb = 0.0f;
|
||||
p->yc = 0.0f;
|
||||
break;
|
||||
|
||||
case REFGEN_SQUARE:
|
||||
p->ya = (p->theta > 0.5f) ? 1.0f : 0.0f;
|
||||
p->yb = 0.0f;
|
||||
p->yc = 0.0f;
|
||||
break;
|
||||
|
||||
case REFGEN_SAW:
|
||||
p->ya = p->theta;
|
||||
p->yb = 0.0f;
|
||||
p->yc = 0.0f;
|
||||
break;
|
||||
|
||||
case REFGEN_TRIANGLE:
|
||||
if (p->theta < 0.5f)
|
||||
{
|
||||
p->ya = 2.0f * p->theta;
|
||||
}
|
||||
else
|
||||
{
|
||||
p->ya = 1.0f - 2.0f * (p->theta - 0.5f);
|
||||
}
|
||||
p->yb = 0.0f;
|
||||
p->yc = 0.0f;
|
||||
break;
|
||||
|
||||
case REFGEN_PULSE:
|
||||
p->ya = (p->theta > p->duty) ? 0.0f : 1.0f;
|
||||
p->yb = 0.0f;
|
||||
p->yc = 0.0f;
|
||||
break;
|
||||
|
||||
case REFGEN_SINE2:
|
||||
#ifdef __TMS320C28XX_TMU__
|
||||
p->ya = __sinpuf32(p->theta);
|
||||
p->yb = __cospuf32(p->theta);
|
||||
#else
|
||||
p->ya = sinf(CONST_2PI_32 * p->theta);
|
||||
p->yb = cosf(CONST_2PI_32 * p->theta);
|
||||
#endif
|
||||
p->yc = 0.0f;
|
||||
break;
|
||||
|
||||
case REFGEN_SINE3:
|
||||
p->thetb = p->theta + 0.3333333333333f;
|
||||
p->thetc = p->theta + 0.6666666666667f;
|
||||
p->thetb -= (p->thetb >= 1.0f) ? 1.0f : 0.0f;
|
||||
p->thetc -= (p->thetc >= 1.0f) ? 1.0f : 0.0f;
|
||||
|
||||
#ifdef __TMS320C28XX_TMU__
|
||||
p->ya = __sinpuf32(p->theta);
|
||||
p->yb = __sinpuf32(p->thetb);
|
||||
p->yc = __sinpuf32(p->thetc);
|
||||
#else
|
||||
p->ya = sinf(CONST_2PI_32 * p->theta);
|
||||
p->yb = sinf(CONST_2PI_32 * p->thetb);
|
||||
p->yc = sinf(CONST_2PI_32 * p->thetc);
|
||||
#endif
|
||||
break;
|
||||
|
||||
case REFGEN_OFF:
|
||||
default:
|
||||
p->yr = 0.0f;
|
||||
p->ya = 0.0f;
|
||||
p->yb = 0.0f;
|
||||
p->yc = 0.0f;
|
||||
}
|
||||
|
||||
// output sum & saturation
|
||||
p->ya = __fsat(p->ampl * p->ya + p->yr, p->umax, p->umin);
|
||||
p->yb = __fsat(p->ampl * p->yb + p->yr, p->umax, p->umin);
|
||||
p->yc = __fsat(p->ampl * p->yc + p->yr, p->umax, p->umin);
|
||||
}
|
||||
|
||||
|
||||
//! \brief Returns the phase reference output
|
||||
//! \param[in] p Pointer to the active DCL_REFGEN structure
|
||||
//! \return The phase A reference output
|
||||
//!
|
||||
static inline float32_t DCL_getRefgenPhaseA(DCL_REFGEN *p)
|
||||
{
|
||||
return(p->ya);
|
||||
}
|
||||
|
||||
|
||||
//! \brief Returns the phase reference output
|
||||
//! \param[in] p Pointer to the active DCL_REFGEN structure
|
||||
//! \return The phase B reference output
|
||||
//!
|
||||
static inline float32_t DCL_getRefgenPhaseB(DCL_REFGEN *p)
|
||||
{
|
||||
return(p->yb);
|
||||
}
|
||||
|
||||
|
||||
//! \brief Returns the phase reference output
|
||||
//! \param[in] p Pointer to the active DCL_REFGEN structure
|
||||
//! \return The phase C reference output
|
||||
//!
|
||||
static inline float32_t DCL_getRefgenPhaseC(DCL_REFGEN *p)
|
||||
{
|
||||
return(p->yc);
|
||||
}
|
||||
|
||||
//----------------------------------------------------------------------------
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif // extern "C"
|
||||
|
||||
#endif // _C_DCL_REFGEN_H
|
||||
|
||||
/* end of file */
|
||||
@@ -0,0 +1,565 @@
|
||||
/* DCL_refgen64.h - Reference generator module header file (double precision)
|
||||
*
|
||||
*/
|
||||
//#############################################################################
|
||||
//!
|
||||
//! Copyright: Copyright (C) 2023 Texas Instruments Incorporated -
|
||||
//! All rights reserved not granted herein.
|
||||
//! Limited License.
|
||||
//!
|
||||
//! Texas Instruments Incorporated grants a world-wide, royalty-free,
|
||||
//! non-exclusive license under copyrights and patents it now or hereafter
|
||||
//! owns or controls to make, have made, use, import, offer to sell and sell
|
||||
//! ("Utilize") this software subject to the terms herein. With respect to the
|
||||
//! foregoing patent license, such license is granted solely to the extent that
|
||||
//! any such patent is necessary to Utilize the software alone. The patent
|
||||
//! license shall not apply to any combinations which include this software,
|
||||
//! other than combinations with devices manufactured by or for TI
|
||||
//! ("TI Devices").
|
||||
//! No hardware patent is licensed hereunder.
|
||||
//!
|
||||
//! Redistributions must preserve existing copyright notices and reproduce this
|
||||
//! license (including the above copyright notice and the disclaimer and
|
||||
//! (if applicable) source code license limitations below) in the documentation
|
||||
//! and/or other materials provided with the distribution.
|
||||
//!
|
||||
//! Redistribution and use in binary form, without modification, are permitted
|
||||
//! provided that the following conditions are met:
|
||||
//!
|
||||
//! * No reverse engineering, decompilation, or disassembly of this software is
|
||||
//! permitted with respect to any software provided in binary form.
|
||||
//! * Any redistribution and use are licensed by TI for use only
|
||||
//! with TI Devices.
|
||||
//! * Nothing shall obligate TI to provide you with source code for the
|
||||
//! software licensed and provided to you in object code.
|
||||
//!
|
||||
//! If software source code is provided to you, modification and redistribution
|
||||
//! of the source code are permitted provided that the following conditions
|
||||
//! are met:
|
||||
//!
|
||||
//! * any redistribution and use of the source code, including any resulting
|
||||
//! derivative works, are licensed by TI for use only with TI Devices.
|
||||
//! * any redistribution and use of any object code compiled from the source
|
||||
//! code and any resulting derivative works, are licensed by TI for use
|
||||
//! only with TI Devices.
|
||||
//!
|
||||
//! Neither the name of Texas Instruments Incorporated nor the names of its
|
||||
//! suppliers may be used to endorse or promote products derived from this
|
||||
//! software without specific prior written permission.
|
||||
//#############################################################################
|
||||
|
||||
#ifndef _C_DCL_REFGEN64_H
|
||||
#define _C_DCL_REFGEN64_H
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
#include "DCL.h"
|
||||
|
||||
//! \brief Region related symbols for function placement
|
||||
//
|
||||
#pragma CODE_SECTION(DCL_runRefgen64,"dclfuncs")
|
||||
#pragma CODE_SECTION(DCL_getRefgen64PhaseA,"dclfuncs")
|
||||
#pragma CODE_SECTION(DCL_getRefgen64PhaseB,"dclfuncs")
|
||||
#pragma CODE_SECTION(DCL_getRefgen64PhaseC,"dclfuncs")
|
||||
|
||||
//! \brief Defines the minimum normalized increment
|
||||
//!
|
||||
#define DCL_REFGEN64_MIN_INC 1.0e-10
|
||||
|
||||
//! \brief Defines the REFGEN operating modes
|
||||
//!
|
||||
enum dcl_rgen64_modes {
|
||||
REFGEN64_OFF = 0,
|
||||
REFGEN64_STATIC,
|
||||
REFGEN64_SINE,
|
||||
REFGEN64_SQUARE,
|
||||
REFGEN64_SAW,
|
||||
REFGEN64_TRIANGLE,
|
||||
REFGEN64_PULSE,
|
||||
REFGEN64_SINE2,
|
||||
REFGEN64_SINE3
|
||||
};
|
||||
|
||||
//! \brief Defines the DCL_REFGEN64 structure
|
||||
//!
|
||||
typedef volatile struct dcl_refgen64 {
|
||||
float64_t rtgt; //!< Target ramp value
|
||||
float64_t rinc; //!< Ramp increment
|
||||
float64_t amtgt; //!< Target amplitude value
|
||||
float64_t aminc; //!< Amplitude increment
|
||||
float64_t fmtgt; //!< Frequency ramp value
|
||||
float64_t fminc; //!< Frequency increment
|
||||
float64_t thinc; //!< Angular increment
|
||||
float64_t duty; //!< Pulse duty cycle
|
||||
float64_t umax; //!< Maximum allowable output
|
||||
float64_t umin; //!< Minimum allowable output
|
||||
float64_t yr; //!< Ramp generator output
|
||||
float64_t ampl; //!< Dynamic amplitude
|
||||
float64_t freq; //!< Dynamic frequency
|
||||
float64_t theta; //!< Normalized angle - phase A
|
||||
float64_t thetb; //!< Normalized angle - phase B
|
||||
float64_t thetc; //!< Normalized angle - phase C
|
||||
float64_t ya; //!< Phase A output
|
||||
float64_t yb; //!< Phase B output
|
||||
float64_t yc; //!< Phase C output
|
||||
int16_t mode; //!< Operating mode
|
||||
int16_t spare; //!< Spare for alignment
|
||||
DCL_CSS *css; //!< Pointer to the common support structure
|
||||
} DCL_REFGEN64;
|
||||
|
||||
//! \brief Defines default values to initialize the DCL_REFGEN64 structure
|
||||
//!
|
||||
#define DCL_REFGEN64_DEFAULTS { 0.0, 0.0, \
|
||||
0.0, 0.0, \
|
||||
0.0, 0.0, 0.0, \
|
||||
0.0, 1.0, 1.0, 1.0, -1.0, \
|
||||
0.0, 0.0, 0.0, 0.0, \
|
||||
0.0, 0.0, 0.0, \
|
||||
REFGEN64_OFF, 0, NULL_ADDR }
|
||||
|
||||
//----------------------------------------------------------------------------
|
||||
|
||||
//! \brief Resets DCL_REFGEN64 dynamic data
|
||||
//! \param[in] p Pointer to the DCL_REFGEN64 structure
|
||||
//! \return None
|
||||
//!
|
||||
static inline void DCL_resetRefgen64(DCL_REFGEN64 *p)
|
||||
{
|
||||
p->ampl = 0.0;
|
||||
p->freq = 0.0;
|
||||
p->rinc = 0.0;
|
||||
p->theta = 0.0;
|
||||
p->thetb = 0.0;
|
||||
p->thetc = 0.0;
|
||||
p->thinc = 0.0;
|
||||
p->yr = 0.0;
|
||||
p->ya = 0.0;
|
||||
p->yb = 0.0;
|
||||
p->yc = 0.0;
|
||||
}
|
||||
|
||||
|
||||
//! \brief Loads the REFGEN64 ramp parameters
|
||||
//!
|
||||
//! \param[in] p Pointer to the DCL_REFGEN64 structure
|
||||
//! \param[in] tgt The new static reference target
|
||||
//! \param[in] tr The time interval to reach the new target
|
||||
//! \return Void
|
||||
//!
|
||||
static inline void DCL_setRefgen64Ramp(DCL_REFGEN64 *p, float64_t tgt, float64_t tr)
|
||||
{
|
||||
#ifdef DCL_ERROR_HANDLING_ENABLED
|
||||
p->css->err |= (tr < 0.0) ? ERR_PARAM_RANGE : ERR_NONE;
|
||||
if (p->css->err)
|
||||
{
|
||||
DCL_GET_ERROR_LOC(p->css);
|
||||
DCL_RUN_ERROR_HANDLER(p->css);
|
||||
}
|
||||
#endif
|
||||
|
||||
// compute ramp increment
|
||||
tr = (tr < p->css->T) ? p->css->T : tr;
|
||||
p->rtgt = tgt;
|
||||
p->rinc = p->css->T * (tgt - p->yr) / tr;
|
||||
|
||||
// clamp minimum ramp increment
|
||||
if (!(0.0 == p->rinc) && (fabs(p->rinc) < DCL_REFGEN64_MIN_INC))
|
||||
{
|
||||
#ifdef DCL_ERROR_HANDLING_ENABLED
|
||||
p->css->err = ERR_COMPUTATION;
|
||||
DCL_GET_ERROR_LOC(p->css);
|
||||
DCL_RUN_ERROR_HANDLER(p->css);
|
||||
#endif
|
||||
if (signbit(p->rinc))
|
||||
{
|
||||
p->rinc = -DCL_REFGEN64_MIN_INC;
|
||||
}
|
||||
else
|
||||
{
|
||||
p->rinc = DCL_REFGEN64_MIN_INC;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
//! \brief Loads the REFGEN dynamic amplitude
|
||||
//!
|
||||
//! \param[in] p Pointer to the DCL_REFGEN64 structure
|
||||
//! \param[in] ampl The new target amplitude
|
||||
//! \param[in] tr The time interval to reach the new target
|
||||
//! \return Void
|
||||
//!
|
||||
static inline void DCL_setRefgen64Ampl(DCL_REFGEN64 *p, float64_t ampl, float64_t tr)
|
||||
{
|
||||
float64_t v;
|
||||
|
||||
#ifdef DCL_ERROR_HANDLING_ENABLED
|
||||
p->css->err |= (tr < 0.0) ? ERR_PARAM_RANGE : ERR_NONE;
|
||||
if (p->css->err)
|
||||
{
|
||||
DCL_GET_ERROR_LOC(p->css);
|
||||
DCL_RUN_ERROR_HANDLER(p->css);
|
||||
}
|
||||
#endif
|
||||
|
||||
// compute amplitude increment
|
||||
v = (float64_t) p->css->T;
|
||||
tr = (tr < v) ? v : tr;
|
||||
p->amtgt = ampl;
|
||||
p->aminc = v * (ampl - p->ampl) / tr;
|
||||
|
||||
// clamp minimum amplitude increment
|
||||
if ((p->aminc > 0.0) && (fabs(p->aminc) < DCL_REFGEN64_MIN_INC))
|
||||
{
|
||||
#ifdef DCL_ERROR_HANDLING_ENABLED
|
||||
p->css->err = ERR_COMPUTATION;
|
||||
DCL_GET_ERROR_LOC(p->css);
|
||||
DCL_RUN_ERROR_HANDLER(p->css);
|
||||
#endif
|
||||
if (signbit(p->aminc))
|
||||
{
|
||||
p->aminc = -DCL_REFGEN64_MIN_INC;
|
||||
}
|
||||
else
|
||||
{
|
||||
p->aminc = DCL_REFGEN64_MIN_INC;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
//! \brief Loads the REFGEN64 frequency
|
||||
//!
|
||||
//! \param[in] p Pointer to the DCL_REFGEN64 structure
|
||||
//! \param[in] freq The new frequency in Hz
|
||||
//! \param[in] tr The time interval to reach the new target
|
||||
//! \return Void
|
||||
//!
|
||||
static inline void DCL_setRefgen64Freq(DCL_REFGEN64 *p, float64_t freq, float64_t tr)
|
||||
{
|
||||
float64_t v;
|
||||
|
||||
#ifdef DCL_ERROR_HANDLING_ENABLED
|
||||
p->css->err |= (tr < 0.0) ? ERR_PARAM_RANGE : ERR_NONE;
|
||||
if (p->css->err)
|
||||
{
|
||||
DCL_GET_ERROR_LOC(p->css);
|
||||
DCL_RUN_ERROR_HANDLER(p->css);
|
||||
}
|
||||
#endif
|
||||
|
||||
// compute frequency increment
|
||||
v = (float64_t) p->css->T;
|
||||
tr = (tr < v) ? v : tr;
|
||||
p->fmtgt = freq;
|
||||
p->fminc = v * (freq - p->freq) / tr;
|
||||
|
||||
// clamp minimum frequency increment
|
||||
if ((p->fminc > 0.0) && (fabs(p->fminc) < DCL_REFGEN64_MIN_INC))
|
||||
{
|
||||
#ifdef DCL_ERROR_HANDLING_ENABLED
|
||||
p->css->err = ERR_COMPUTATION;
|
||||
DCL_GET_ERROR_LOC(p->css);
|
||||
DCL_RUN_ERROR_HANDLER(p->css);
|
||||
#endif
|
||||
if (signbit(p->fminc))
|
||||
{
|
||||
p->fminc = -DCL_REFGEN64_MIN_INC;
|
||||
}
|
||||
else
|
||||
{
|
||||
p->fminc = DCL_REFGEN64_MIN_INC;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
//! \brief Loads the REFGEN64 pulse duty cycle
|
||||
//! \param[in] p Pointer to the DCL_REFGEN64 structure
|
||||
//! \param[in] duty The new per-unit duty cycle
|
||||
//! \return None
|
||||
//!
|
||||
static inline void DCL_setRefgen64Duty(DCL_REFGEN64 *p, float64_t duty)
|
||||
{
|
||||
#ifdef DCL_ERROR_HANDLING_ENABLED
|
||||
p->css->err |= ((duty < 0.0) || (duty > 1.0)) ? ERR_PARAM_RANGE : ERR_NONE;
|
||||
if (p->css->err)
|
||||
{
|
||||
DCL_GET_ERROR_LOC(p->css);
|
||||
DCL_RUN_ERROR_HANDLER(p->css);
|
||||
}
|
||||
#endif
|
||||
|
||||
p->duty = duty;
|
||||
}
|
||||
|
||||
//! \brief Loads the REFGEN64 output clam limits
|
||||
//! \param[in] p Pointer to the DCL_REFGEN64 structure
|
||||
//! \param[in] max The upper limit
|
||||
//! \param[in] min The lower limit
|
||||
//! \return None
|
||||
//!
|
||||
static inline void DCL_setRefgen64Clamp(DCL_REFGEN64 *p, float64_t max, float64_t min)
|
||||
{
|
||||
#ifdef DCL_ERROR_HANDLING_ENABLED
|
||||
p->css->err |= (max < min) ? ERR_PARAM_RANGE : ERR_NONE;
|
||||
if (p->css->err)
|
||||
{
|
||||
DCL_GET_ERROR_LOC(p->css);
|
||||
DCL_RUN_ERROR_HANDLER(p->css);
|
||||
}
|
||||
#endif
|
||||
|
||||
p->umax = max;
|
||||
p->umin = min;
|
||||
}
|
||||
|
||||
|
||||
//! \brief Sets the REFGEN64 operating mode
|
||||
//! \param[in] p Pointer to the DCL_REFGEN64 structure
|
||||
//! \param[in] mode The new operating mode
|
||||
//! \return None
|
||||
//!
|
||||
static inline void DCL_setRefgen64Mode(DCL_REFGEN64 *p, int16_t mode)
|
||||
{
|
||||
p->mode = mode;
|
||||
}
|
||||
|
||||
|
||||
//! \brief Runs the REFGEN64 module
|
||||
//! \param[in] p Pointer to the DCL_REFGEN64 structure
|
||||
//! \return None
|
||||
//!
|
||||
static inline void DCL_runRefgen64(DCL_REFGEN64 *p)
|
||||
{
|
||||
float64_t v;
|
||||
|
||||
// static offset generator
|
||||
if (!F64_IS_ZERO(p->rinc))
|
||||
{
|
||||
if (fabs(p->rinc) > fabs(p->rtgt - p->yr))
|
||||
{
|
||||
p->yr = p->rtgt;
|
||||
p->rinc = 0.0;
|
||||
DCL_ADJUSTMENT_COMPLETE(p);
|
||||
}
|
||||
else
|
||||
{
|
||||
#ifdef DCL_ERROR_HANDLING_ENABLED
|
||||
v = p->yr;
|
||||
#endif
|
||||
p->yr += p->rinc;
|
||||
#ifdef DCL_ERROR_HANDLING_ENABLED
|
||||
if (F64_IS_ZERO(v - p->yr))
|
||||
{
|
||||
p->css->err = ERR_COMPUTATION;
|
||||
DCL_GET_ERROR_LOC(p->css);
|
||||
DCL_RUN_ERROR_HANDLER(p->css);
|
||||
}
|
||||
#endif
|
||||
DCL_ADJUSTMENT_RUNNING(p);
|
||||
}
|
||||
}
|
||||
|
||||
// amplitude modulator
|
||||
if (!F64_IS_ZERO(p->aminc))
|
||||
{
|
||||
if (fabs(p->aminc) > fabs(p->amtgt - p->ampl))
|
||||
{
|
||||
p->ampl = p->amtgt;
|
||||
p->aminc = 0.0;
|
||||
}
|
||||
else
|
||||
{
|
||||
#ifdef DCL_ERROR_HANDLING_ENABLED
|
||||
v = p->ampl;
|
||||
#endif
|
||||
p->ampl += p->aminc;
|
||||
#ifdef DCL_ERROR_HANDLING_ENABLED
|
||||
if (F64_IS_ZERO(v - p->ampl))
|
||||
{
|
||||
p->css->err = ERR_COMPUTATION;
|
||||
DCL_GET_ERROR_LOC(p->css);
|
||||
DCL_RUN_ERROR_HANDLER(p->css);
|
||||
}
|
||||
#endif
|
||||
}
|
||||
}
|
||||
|
||||
// frequency modulator
|
||||
if (!F64_IS_ZERO(p->fminc))
|
||||
{
|
||||
if (fabs(p->fminc) > fabs(p->fmtgt - p->freq))
|
||||
{
|
||||
p->freq = p->fmtgt;
|
||||
p->fminc = 0.0;
|
||||
}
|
||||
else
|
||||
{
|
||||
#ifdef DCL_ERROR_HANDLING_ENABLED
|
||||
v = p->freq;
|
||||
#endif
|
||||
p->freq += p->fminc;
|
||||
#ifdef DCL_ERROR_HANDLING_ENABLED
|
||||
if (F64_IS_ZERO(v - p->freq))
|
||||
{
|
||||
p->css->err = ERR_COMPUTATION;
|
||||
DCL_GET_ERROR_LOC(p->css);
|
||||
DCL_RUN_ERROR_HANDLER(p->css);
|
||||
}
|
||||
#endif
|
||||
}
|
||||
}
|
||||
|
||||
// angle increment
|
||||
if (p->freq > 0.0)
|
||||
{
|
||||
p->thinc = p->css->T * p->freq;
|
||||
if (p->thinc < DCL_REFGEN64_MIN_INC)
|
||||
{
|
||||
#ifdef DCL_ERROR_HANDLING_ENABLED
|
||||
p->css->err = ERR_COMPUTATION;
|
||||
DCL_GET_ERROR_LOC(p->css);
|
||||
DCL_RUN_ERROR_HANDLER(p->css);
|
||||
#endif
|
||||
p->thinc = DCL_REFGEN64_MIN_INC;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
p->thinc = 0.0;
|
||||
}
|
||||
|
||||
p->theta += p->thinc;
|
||||
p->theta -= (p->theta >= 1.0) ? 1.0 : 0.0;
|
||||
|
||||
// dynamic signal generator
|
||||
switch (p->mode) {
|
||||
|
||||
case REFGEN64_STATIC:
|
||||
p->ya = 0.0;
|
||||
p->yb = 0.0;
|
||||
p->yc = 0.0;
|
||||
break;
|
||||
|
||||
case REFGEN64_SINE:
|
||||
p->ya = sin(CONST_2PI_64 * p->theta);
|
||||
p->yb = 0.0;
|
||||
p->yc = 0.0;
|
||||
break;
|
||||
|
||||
case REFGEN64_SQUARE:
|
||||
p->ya = (p->theta > 0.5) ? 1.0 : 0.0;
|
||||
p->yb = 0.0;
|
||||
p->yc = 0.0;
|
||||
break;
|
||||
|
||||
case REFGEN64_SAW:
|
||||
p->ya = p->theta;
|
||||
p->yb = 0.0;
|
||||
p->yc = 0.0;
|
||||
break;
|
||||
|
||||
case REFGEN64_TRIANGLE:
|
||||
if (p->theta < 0.5)
|
||||
{
|
||||
p->ya = 2.0 * p->theta;
|
||||
}
|
||||
else
|
||||
{
|
||||
p->ya = 1.0 - 2.0 * (p->theta - 0.5);
|
||||
}
|
||||
p->yb = 0.0;
|
||||
p->yc = 0.0;
|
||||
break;
|
||||
|
||||
case REFGEN64_PULSE:
|
||||
p->ya = (p->theta > p->duty) ? 0.0 : 1.0;
|
||||
p->yb = 0.0;
|
||||
p->yc = 0.0;
|
||||
break;
|
||||
|
||||
case REFGEN64_SINE2:
|
||||
p->ya = sin(CONST_2PI_64 * p->theta);
|
||||
p->yb = cos(CONST_2PI_64 * p->theta);
|
||||
p->yc = 0.0;
|
||||
break;
|
||||
|
||||
case REFGEN64_SINE3:
|
||||
p->thetb = p->theta + 0.3333333333333;
|
||||
p->thetc = p->theta + 0.6666666666667;
|
||||
p->thetb -= (p->thetb >= 1.0) ? 1.0 : 0.0;
|
||||
p->thetc -= (p->thetc >= 1.0) ? 1.0 : 0.0;
|
||||
|
||||
p->ya = sin(CONST_2PI_64 * p->theta);
|
||||
p->yb = sin(CONST_2PI_64 * p->thetb);
|
||||
p->yc = sin(CONST_2PI_64 * p->thetc);
|
||||
break;
|
||||
|
||||
case REFGEN64_OFF:
|
||||
default:
|
||||
p->yr = 0.0;
|
||||
p->ya = 0.0;
|
||||
p->yb = 0.0;
|
||||
p->yc = 0.0;
|
||||
}
|
||||
|
||||
// output sum & saturation
|
||||
#if (__TI_COMPILER_VERSION__ > 19005000)
|
||||
v = __fmin64(p->ampl * p->ya + p->yr, p->umax);
|
||||
p->ya = __fmax64(v, p->umin);
|
||||
v = __fmin64(p->ampl * p->yb + p->yr, p->umax);
|
||||
p->yb = __fmax64(v, p->umin);
|
||||
v = __fmin64(p->ampl * p->yc + p->yr, p->umax);
|
||||
p->yc = __fmax64(v, p->umin);
|
||||
#else
|
||||
v = fmin(p->ampl * p->ya + p->yr, p->umax);
|
||||
p->ya = fmax(v, p->umin);
|
||||
v = fmin(p->ampl * p->yb + p->yr, p->umax);
|
||||
p->yb = fmax(v, p->umin);
|
||||
v = fmin(p->ampl * p->yc + p->yr, p->umax);
|
||||
p->yc = fmax(v, p->umin);
|
||||
#endif
|
||||
}
|
||||
|
||||
|
||||
//! \brief Returns the phase reference output
|
||||
//! \param[in] p Pointer to the active DCL_REFGEN64 structure
|
||||
//! \return The phase A reference output
|
||||
//!
|
||||
static inline float64_t DCL_getRefgen64PhaseA(DCL_REFGEN64 *p)
|
||||
{
|
||||
return(p->ya);
|
||||
}
|
||||
|
||||
|
||||
//! \brief Returns the phase reference output
|
||||
//! \param[in] p Pointer to the active DCL_REFGEN64 structure
|
||||
//! \return The phase B reference output
|
||||
//!
|
||||
static inline float64_t DCL_getRefgen64PhaseB(DCL_REFGEN64 *p)
|
||||
{
|
||||
return(p->yb);
|
||||
}
|
||||
|
||||
|
||||
//! \brief Returns the phase reference output
|
||||
//! \param[in] p Pointer to the active DCL_REFGEN64 structure
|
||||
//! \return The phase C reference output
|
||||
//!
|
||||
static inline float64_t DCL_getRefgen64PhaseC(DCL_REFGEN64 *p)
|
||||
{
|
||||
return(p->yc);
|
||||
}
|
||||
|
||||
//----------------------------------------------------------------------------
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif // extern "C"
|
||||
|
||||
#endif // _C_DCL_REFGEN64_H
|
||||
|
||||
/* end of file */
|
||||
Binary file not shown.
@@ -0,0 +1,88 @@
|
||||
% GSM_example.m - example script for the Gain Scheduler Module
|
||||
close all; clc; clear all;
|
||||
|
||||
% plot target function
|
||||
dx = 0.01;
|
||||
x = 0:dx:1;
|
||||
y = zeros(1, size(x,2));
|
||||
k = 1;
|
||||
for i = 0:dx:1
|
||||
y(k) = target(x(k));
|
||||
k = k+1;
|
||||
end
|
||||
plot(x,y)
|
||||
|
||||
%% find sector index
|
||||
N = 8;
|
||||
n = zeros(1,N);
|
||||
I = 1/N;
|
||||
i = 0;
|
||||
for k = 1:N
|
||||
i = i + I;
|
||||
n(k) = i;
|
||||
end
|
||||
|
||||
%% load LUT offsets
|
||||
c = zeros(1,N);
|
||||
for k = 1:N
|
||||
c(k) = target(n(k));
|
||||
end
|
||||
|
||||
%% load LUT slopes
|
||||
m = zeros(1,N);
|
||||
m(1) = c(1) / I;
|
||||
for k = 2:N
|
||||
m(k) = (c(k) - c(k-1)) / I;
|
||||
end
|
||||
|
||||
%% plot GSM segments
|
||||
L = fix(size(x,2)/N);
|
||||
y1 = zeros(1,L);
|
||||
y2 = zeros(1,L);
|
||||
y3 = zeros(1,L);
|
||||
y4 = zeros(1,L);
|
||||
y5 = zeros(1,L);
|
||||
y6 = zeros(1,L);
|
||||
y7 = zeros(1,L);
|
||||
y8 = zeros(1,L);
|
||||
x1 = 0:dx:I;
|
||||
x2 = I:dx:2*I;
|
||||
x3 = 2*I:dx:3*I;
|
||||
x4 = 3*I:dx:4*I;
|
||||
x5 = 4*I:dx:5*I;
|
||||
x6 = 5*I:dx:6*I;
|
||||
x7 = 6*I:dx:7*I;
|
||||
x8 = 7*I:dx:8*I;
|
||||
|
||||
k = 1;
|
||||
for xi = 0:dx:I
|
||||
y1(k) = m(1)*xi;
|
||||
y2(k) = m(2)*xi + c(1);
|
||||
y3(k) = m(3)*xi + c(2);
|
||||
y4(k) = m(4)*xi + c(3);
|
||||
y5(k) = m(5)*xi + c(4);
|
||||
y6(k) = m(6)*xi + c(5);
|
||||
y7(k) = m(7)*xi + c(6);
|
||||
y8(k) = m(8)*xi + c(7);
|
||||
k = k + 1;
|
||||
end
|
||||
hold all
|
||||
plot(x1,y1)
|
||||
plot(x2,y2)
|
||||
plot(x3,y3)
|
||||
plot(x4,y4)
|
||||
plot(x5,y5)
|
||||
plot(x6,y6)
|
||||
plot(x7,y7)
|
||||
plot(x8,y8)
|
||||
|
||||
% target function
|
||||
function y = target(x)
|
||||
% y = sin(2*pi*x);
|
||||
% y = x*x;
|
||||
y = x*(3*x - 2);
|
||||
% y = exp(2*x) - 1;
|
||||
% y = -tan(pi*x/3);
|
||||
end
|
||||
|
||||
% end of file
|
||||
@@ -0,0 +1,73 @@
|
||||
% PID_config.m - 3rd order linear plant
|
||||
|
||||
endtime = 16; % test duration (sec)
|
||||
fs = 400; % sample rate in Hz
|
||||
T = 1 / fs; % sample period (sec)
|
||||
|
||||
%- Controller ------------------------------------------------------------
|
||||
|
||||
% controller parameters
|
||||
Kp = 7.5; % proportional loop gain
|
||||
Ki = 0.005; % integral gain
|
||||
Kd = 0.35; % differential gain
|
||||
Kr = 1; % set-point weight
|
||||
fc = 100; % cut-off frequency (Hz)
|
||||
|
||||
% controller output saturation
|
||||
Umax = inf;
|
||||
Umin = -inf;
|
||||
|
||||
%- Plant model -----------------------------------------------------------
|
||||
|
||||
% plant transfer function:
|
||||
%
|
||||
% s + 1
|
||||
% G(s) = ---------------------
|
||||
% s^3 + 3 s^2 + 5 s + 1
|
||||
|
||||
G = tf([1 1], [1 3 5 1]);
|
||||
[num_G,den_G] = tfdata(G,'v');
|
||||
G = tf(num_G,den_G); % save TF in workspace
|
||||
|
||||
% plant saturation limits
|
||||
Psatmax = inf;
|
||||
Psatmin = -inf;
|
||||
|
||||
% time delay
|
||||
Tdly = T/10;
|
||||
|
||||
% feedback path dynamics
|
||||
num_H = 1;
|
||||
den_H = 1;
|
||||
H = tf(num_H,den_H);
|
||||
|
||||
%- ADC model ------------------------------------------------------------
|
||||
|
||||
% ADC parameters
|
||||
Kn = 0; % feedback noise gain
|
||||
Vadc_max = inf; % positive input limit
|
||||
Vadc_min = -inf; % negative input limit
|
||||
Nadc = 16; % resolution in bits
|
||||
|
||||
% ADC quantizer interval
|
||||
if isfinite(Vadc_max) & isfinite(Vadc_min)
|
||||
Qadc = (Vadc_max - Vadc_min)/2^Nadc;
|
||||
else
|
||||
Qadc = 1/2^Nadc;
|
||||
end
|
||||
|
||||
%- DAC model ------------------------------------------------------------
|
||||
|
||||
% DAC parameters
|
||||
Umax = inf; % upper output saturation
|
||||
Umin = -inf; % lower output saturation
|
||||
Ndac = 16; % resolution in bits
|
||||
|
||||
% DAC quantizer interval
|
||||
if isfinite(Umax) & isfinite(Umin)
|
||||
Qdac = (Umax - Umin)/2^Ndac;
|
||||
else
|
||||
Qdac = 1/2^Ndac;
|
||||
end
|
||||
|
||||
% end of file
|
||||
File diff suppressed because it is too large.
Load diff
@@ -0,0 +1,96 @@
|
||||
% PID_example.m - C2000 Digital Control Library - PID control example
|
||||
clc; close all; clear;
|
||||
|
||||
%- Configuration ---------------------------------------------------------
|
||||
|
||||
% input stimulus
|
||||
% 0 : step
|
||||
% 1 : pulse (return step)
|
||||
% 2 : bi-directional pulse
|
||||
% 3 : reverse bi-directional pulse
|
||||
% 4 : chirp (oscillation burst)
|
||||
% 5 : unit pulse
|
||||
% 6 : static offset
|
||||
% 7 : triangle ramp
|
||||
input_config = 1;
|
||||
|
||||
%- Plots -----------------------------------------------------------------
|
||||
|
||||
% system plots: set to 1 to plot
|
||||
data.inp.plot = 0; % input stimulus
|
||||
data.rsp.plot = 1; % servo response
|
||||
data.act.plot = 0; % control effort
|
||||
data.fbk.plot = 0; % feedback
|
||||
data.err.plot = 0; % servo error
|
||||
data.sat.plot = 0; % saturation
|
||||
|
||||
% system data: set to 1 to save to file
|
||||
data.inp.save = 1; % input stimulus
|
||||
data.fbk.save = 1; % feedback
|
||||
data.sat.save = 1; % saturation limit
|
||||
data.act.save = 1; % control effort
|
||||
|
||||
%- Read configuration ----------------------------------------------------
|
||||
|
||||
filename = 'PID_config.m';
|
||||
open(filename);
|
||||
run(filename);
|
||||
run('PID_inputs.m')
|
||||
|
||||
%- Simulation ------------------------------------------------------------
|
||||
|
||||
open 'PID_sim.slx';
|
||||
sim('PID_sim', timespan, [], []);
|
||||
% note: inspect command window for assertions
|
||||
fprintf('Simulation complete.\n');
|
||||
|
||||
%- Results ---------------------------------------------------------------
|
||||
|
||||
% display selected plots
|
||||
run('PID_plots.m')
|
||||
|
||||
% compute performance indices & display in command window
|
||||
% IES = sum(ferror.^2)
|
||||
% IAE = norm(ferror,1)
|
||||
ITAE = T * sum(time.*abs(ferror))
|
||||
|
||||
%- Data export -----------------------------------------------------------
|
||||
|
||||
% write test data to text files for CCS access
|
||||
|
||||
% 1. input stimulus
|
||||
if data.inp.save == 1
|
||||
filename = strcat('PID_input.dat');
|
||||
File1 = fopen(filename,'w');
|
||||
fprintf(File1,'1651 9 c000 1 641 10\r\n'); % TI header
|
||||
fprintf(File1,'%12.8e\r\n',finput');
|
||||
fclose(File1);
|
||||
end
|
||||
|
||||
% 2. feedback data
|
||||
if data.fbk.save == 1
|
||||
filename = strcat('PID_fbk.dat');
|
||||
File2 = fopen(filename,'w');
|
||||
fprintf(File2,'1651 9 e000 1 641 10\r\n'); % TI header
|
||||
fprintf(File2,'%12.8e\r\n',ffeedback');
|
||||
fclose(File2);
|
||||
end
|
||||
|
||||
% 3. saturation data
|
||||
if data.sat.save == 1
|
||||
filename = strcat('PID_sat.dat');
|
||||
File3 = fopen(filename,'w');
|
||||
fprintf(File3,'1651 9 10000 1 641 10\r\n'); % TI header
|
||||
fprintf(File3,'%12.8e\r\n',fsat');
|
||||
fclose(File3);
|
||||
end
|
||||
|
||||
% 4. control data
|
||||
if data.act.save == 1
|
||||
filename = strcat('PID_ctl.dat');
|
||||
File4 = fopen(filename,'w');
|
||||
fprintf(File4,'%12.8e\r\n',fcontrol');
|
||||
fclose(File4);
|
||||
end
|
||||
|
||||
% end of file
|
||||
Loaded 100 of 14950 files, more files were not shown because too many files have changed in this diff.
Show more
Reference in new issue
Block a user