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,42 @@
|
||||
<projectSpec>
|
||||
<project
|
||||
name="cla_ex1_asin"
|
||||
device="TMS320F28388D"
|
||||
cgtVersion="22.6.1.LTS"
|
||||
products="sysconfig;C2000WARE"
|
||||
outputFormat="ELF"
|
||||
launchWizard="False"
|
||||
linkerCommandFile=""
|
||||
enableSysConfigTool="true"
|
||||
sysConfigBuildOptions="--product ${C2000WARE_ROOT}/.metadata/sdk.json --device F2838x --package 337bga --part F2838x_337bga"
|
||||
postBuildStep="
|
||||
echo "========= Build of the CLB simulation has moved to the CLB Tool. Click the '?' icon by the _Generate CLB Simulation File_ enable for more details (located in the Global Parameters of the Tile Design SysConfig module) ============="
|
||||
;if ${GENERATE_DIAGRAM} == 1 ${NODE_TOOL} "${C2000WARE_ROOT}/utilities/clb_tool/clb_syscfg/dot_file_libraries/clbDotUtility.js" "${C2000WARE_ROOT}/utilities/clb_tool/clb_syscfg/" "${BuildDirectory}/syscfg" "${BuildDirectory}/syscfg/clb.dot"
|
||||
;if ${GENERATE_DIAGRAM} == 1 mkdir "${BuildDirectory}/diagrams"
|
||||
;if ${GENERATE_DIAGRAM} == 1 ${NODE_TOOL} "${C2000WARE_ROOT}/driverlib/.meta/generate_diagrams.js" "${C2000WARE_ROOT}" "${BuildDirectory}/diagrams" "${BuildDirectory}/syscfg"
|
||||
"
|
||||
>
|
||||
<configuration name="CPU1_RAM" compilerBuildOptions= "--opt_level=off -I${C2000WARE_ROOT} -I${PROJECT_ROOT}/device -I${C2000WARE_DLIB_ROOT} -v28 -ml -mt --cla_support=cla2 --cla_background_task=off --cla_signed_compare_workaround=on --define=RAM --float_support=fpu64 --tmu_support=tmu0 --define=CPU1 --gen_func_subsections=on --diag_warning=225 --diag_suppress=10063" linkerBuildOptions="--entry_point code_start --stack_size=0x3F8 --heap_size=0x200 --define=RAM -i${C2000WARE_ROOT} -i${PROJECT_BUILD_DIR}/syscfg -lc2000ware_libraries.cmd.genlibs " />
|
||||
<configuration name="CPU1_FLASH" compilerBuildOptions="--opt_level=off -I${C2000WARE_ROOT} -I${PROJECT_ROOT}/device -I${C2000WARE_DLIB_ROOT} --define=_FLASH -v28 -ml -mt --cla_support=cla2 --cla_background_task=off --cla_signed_compare_workaround=on --float_support=fpu64 --tmu_support=tmu0 --define=CPU1 --gen_func_subsections=on --diag_warning=225 --diag_suppress=10063" linkerBuildOptions="--entry_point code_start --stack_size=0x3F8 --heap_size=0x200 --define=_FLASH -i${C2000WARE_ROOT} -i${PROJECT_BUILD_DIR}/syscfg -lc2000ware_libraries.cmd.genlibs " />
|
||||
|
||||
<pathVariable name="C2000WARE_DLIB_ROOT" path="../../../../../../driverlib/f2838x/driverlib/" scope="project" />
|
||||
<pathVariable name="C2000WARE_ROOT" path="../../../../../../" 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="GENERATE_DIAGRAM" value="0" scope="project" />
|
||||
<file action="copy" path="../../../../../../device_support/f2838x/common/include/driverlib.h" targetDirectory="device" />
|
||||
<file action="copy" path="../../../../../../device_support/f2838x/common/include/device.h" targetDirectory="device" />
|
||||
<file action="copy" path="../../../../../../device_support/f2838x/common/source/device.c" targetDirectory="device" />
|
||||
<file action="copy" path="../../../../../../device_support/f2838x/common/targetConfigs/TMS320F28388D.ccxml" targetDirectory="targetConfigs" />
|
||||
<file action="copy" path="../../../../../../device_support/f2838x/common/cmd/2838x_RAM_CLA_lnk_cpu1.cmd" targetDirectory="" applicableConfigurations="CPU1_RAM" />
|
||||
<file action="copy" path="../../../../../../device_support/f2838x/common/cmd/2838x_FLASH_CLA_lnk_cpu1.cmd" targetDirectory="" applicableConfigurations="CPU1_FLASH" />
|
||||
<file action="copy" path="../../../../../../device_support/f2838x/common/source/f2838x_codestartbranch.asm" targetDirectory="device" />
|
||||
<file action="link" path="../../../../../../driverlib/f2838x/driverlib/ccs/Debug/driverlib.lib" targetDirectory="" />
|
||||
<file action="copy" path="../../../../../../driverlib/f2838x/driverlib/" targetDirectory="device" excludeFromBuild="True" />
|
||||
<file action="copy" path="../asin.cla" targetDirectory="" />
|
||||
<file action="copy" path="../cla_ex1_asin.c" targetDirectory="" />
|
||||
<file action="copy" path="../cla_ex1_asin_shared.h" targetDirectory="" />
|
||||
<file action="copy" path="../cla_ex1_asin.syscfg" targetDirectory="" />
|
||||
</project>
|
||||
</projectSpec>
|
||||
@@ -0,0 +1,42 @@
|
||||
<projectSpec>
|
||||
<project
|
||||
name="cla_ex2_atan"
|
||||
device="TMS320F28388D"
|
||||
cgtVersion="22.6.1.LTS"
|
||||
products="sysconfig;C2000WARE"
|
||||
outputFormat="ELF"
|
||||
launchWizard="False"
|
||||
linkerCommandFile=""
|
||||
enableSysConfigTool="true"
|
||||
sysConfigBuildOptions="--product ${C2000WARE_ROOT}/.metadata/sdk.json --device F2838x --package 337bga --part F2838x_337bga"
|
||||
postBuildStep="
|
||||
echo "========= Build of the CLB simulation has moved to the CLB Tool. Click the '?' icon by the _Generate CLB Simulation File_ enable for more details (located in the Global Parameters of the Tile Design SysConfig module) ============="
|
||||
;if ${GENERATE_DIAGRAM} == 1 ${NODE_TOOL} "${C2000WARE_ROOT}/utilities/clb_tool/clb_syscfg/dot_file_libraries/clbDotUtility.js" "${C2000WARE_ROOT}/utilities/clb_tool/clb_syscfg/" "${BuildDirectory}/syscfg" "${BuildDirectory}/syscfg/clb.dot"
|
||||
;if ${GENERATE_DIAGRAM} == 1 mkdir "${BuildDirectory}/diagrams"
|
||||
;if ${GENERATE_DIAGRAM} == 1 ${NODE_TOOL} "${C2000WARE_ROOT}/driverlib/.meta/generate_diagrams.js" "${C2000WARE_ROOT}" "${BuildDirectory}/diagrams" "${BuildDirectory}/syscfg"
|
||||
"
|
||||
>
|
||||
<configuration name="CPU1_RAM" compilerBuildOptions= "--opt_level=off -I${C2000WARE_ROOT} -I${PROJECT_ROOT}/device -I${C2000WARE_DLIB_ROOT} -v28 -ml -mt --cla_support=cla2 --cla_background_task=off --cla_signed_compare_workaround=on --define=RAM --float_support=fpu64 --tmu_support=tmu0 --define=CPU1 --gen_func_subsections=on --diag_warning=225 --diag_suppress=10063" linkerBuildOptions="--entry_point code_start --stack_size=0x3F8 --heap_size=0x200 --define=RAM -i${C2000WARE_ROOT} -i${PROJECT_BUILD_DIR}/syscfg -lc2000ware_libraries.cmd.genlibs " />
|
||||
<configuration name="CPU1_FLASH" compilerBuildOptions="--opt_level=off -I${C2000WARE_ROOT} -I${PROJECT_ROOT}/device -I${C2000WARE_DLIB_ROOT} --define=_FLASH -v28 -ml -mt --cla_support=cla2 --cla_background_task=off --cla_signed_compare_workaround=on --float_support=fpu64 --tmu_support=tmu0 --define=CPU1 --gen_func_subsections=on --diag_warning=225 --diag_suppress=10063" linkerBuildOptions="--entry_point code_start --stack_size=0x3F8 --heap_size=0x200 --define=_FLASH -i${C2000WARE_ROOT} -i${PROJECT_BUILD_DIR}/syscfg -lc2000ware_libraries.cmd.genlibs " />
|
||||
|
||||
<pathVariable name="C2000WARE_DLIB_ROOT" path="../../../../../../driverlib/f2838x/driverlib/" scope="project" />
|
||||
<pathVariable name="C2000WARE_ROOT" path="../../../../../../" 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="GENERATE_DIAGRAM" value="0" scope="project" />
|
||||
<file action="copy" path="../../../../../../device_support/f2838x/common/include/driverlib.h" targetDirectory="device" />
|
||||
<file action="copy" path="../../../../../../device_support/f2838x/common/include/device.h" targetDirectory="device" />
|
||||
<file action="copy" path="../../../../../../device_support/f2838x/common/source/device.c" targetDirectory="device" />
|
||||
<file action="copy" path="../../../../../../device_support/f2838x/common/targetConfigs/TMS320F28388D.ccxml" targetDirectory="targetConfigs" />
|
||||
<file action="copy" path="../../../../../../device_support/f2838x/common/cmd/2838x_RAM_CLA_lnk_cpu1.cmd" targetDirectory="" applicableConfigurations="CPU1_RAM" />
|
||||
<file action="copy" path="../../../../../../device_support/f2838x/common/cmd/2838x_FLASH_CLA_lnk_cpu1.cmd" targetDirectory="" applicableConfigurations="CPU1_FLASH" />
|
||||
<file action="copy" path="../../../../../../device_support/f2838x/common/source/f2838x_codestartbranch.asm" targetDirectory="device" />
|
||||
<file action="link" path="../../../../../../driverlib/f2838x/driverlib/ccs/Debug/driverlib.lib" targetDirectory="" />
|
||||
<file action="copy" path="../../../../../../driverlib/f2838x/driverlib/" targetDirectory="device" excludeFromBuild="True" />
|
||||
<file action="copy" path="../atan.cla" targetDirectory="" />
|
||||
<file action="copy" path="../cla_ex2_atan.c" targetDirectory="" />
|
||||
<file action="copy" path="../cla_ex2_atan_shared.h" targetDirectory="" />
|
||||
<file action="copy" path="../cla_ex2_atan.syscfg" targetDirectory="" />
|
||||
</project>
|
||||
</projectSpec>
|
||||
+42
@@ -0,0 +1,42 @@
|
||||
<projectSpec>
|
||||
<project
|
||||
name="cla_ex3_background_nesting_task"
|
||||
device="TMS320F28388D"
|
||||
cgtVersion="22.6.1.LTS"
|
||||
products="sysconfig;C2000WARE"
|
||||
outputFormat="ELF"
|
||||
launchWizard="False"
|
||||
linkerCommandFile=""
|
||||
enableSysConfigTool="true"
|
||||
sysConfigBuildOptions="--product ${C2000WARE_ROOT}/.metadata/sdk.json --device F2838x --package 337bga --part F2838x_337bga"
|
||||
postBuildStep="
|
||||
echo "========= Build of the CLB simulation has moved to the CLB Tool. Click the '?' icon by the _Generate CLB Simulation File_ enable for more details (located in the Global Parameters of the Tile Design SysConfig module) ============="
|
||||
;if ${GENERATE_DIAGRAM} == 1 ${NODE_TOOL} "${C2000WARE_ROOT}/utilities/clb_tool/clb_syscfg/dot_file_libraries/clbDotUtility.js" "${C2000WARE_ROOT}/utilities/clb_tool/clb_syscfg/" "${BuildDirectory}/syscfg" "${BuildDirectory}/syscfg/clb.dot"
|
||||
;if ${GENERATE_DIAGRAM} == 1 mkdir "${BuildDirectory}/diagrams"
|
||||
;if ${GENERATE_DIAGRAM} == 1 ${NODE_TOOL} "${C2000WARE_ROOT}/driverlib/.meta/generate_diagrams.js" "${C2000WARE_ROOT}" "${BuildDirectory}/diagrams" "${BuildDirectory}/syscfg"
|
||||
"
|
||||
>
|
||||
<configuration name="CPU1_RAM" compilerBuildOptions= "--opt_level=0 -I${C2000WARE_ROOT} -I${PROJECT_ROOT}/device -I${C2000WARE_DLIB_ROOT} -v28 -ml -mt --cla_support=cla2 --cla_background_task=on --cla_signed_compare_workaround=on --define=RAM --float_support=fpu64 --tmu_support=tmu0 --define=CPU1 --gen_func_subsections=on --diag_warning=225 --diag_suppress=10063" linkerBuildOptions="--entry_point code_start --stack_size=0x3F8 --heap_size=0x200 --define=RAM -i${C2000WARE_ROOT} -i${PROJECT_BUILD_DIR}/syscfg -lc2000ware_libraries.cmd.genlibs " />
|
||||
<configuration name="CPU1_FLASH" compilerBuildOptions="--opt_level=0 -I${C2000WARE_ROOT} -I${PROJECT_ROOT}/device -I${C2000WARE_DLIB_ROOT} --define=_FLASH -v28 -ml -mt --cla_support=cla2 --cla_background_task=on --cla_signed_compare_workaround=on --float_support=fpu64 --tmu_support=tmu0 --define=CPU1 --gen_func_subsections=on --diag_warning=225 --diag_suppress=10063" linkerBuildOptions="--entry_point code_start --stack_size=0x3F8 --heap_size=0x200 --define=_FLASH -i${C2000WARE_ROOT} -i${PROJECT_BUILD_DIR}/syscfg -lc2000ware_libraries.cmd.genlibs " />
|
||||
|
||||
<pathVariable name="C2000WARE_DLIB_ROOT" path="../../../../../../driverlib/f2838x/driverlib/" scope="project" />
|
||||
<pathVariable name="C2000WARE_ROOT" path="../../../../../../" 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="GENERATE_DIAGRAM" value="0" scope="project" />
|
||||
<file action="copy" path="../../../../../../device_support/f2838x/common/include/driverlib.h" targetDirectory="device" />
|
||||
<file action="copy" path="../../../../../../device_support/f2838x/common/include/device.h" targetDirectory="device" />
|
||||
<file action="copy" path="../../../../../../device_support/f2838x/common/source/device.c" targetDirectory="device" />
|
||||
<file action="copy" path="../../../../../../device_support/f2838x/common/targetConfigs/TMS320F28388D.ccxml" targetDirectory="targetConfigs" />
|
||||
<file action="copy" path="../../../../../../device_support/f2838x/common/cmd/2838x_RAM_CLA_lnk_cpu1.cmd" targetDirectory="" applicableConfigurations="CPU1_RAM" />
|
||||
<file action="copy" path="../../../../../../device_support/f2838x/common/cmd/2838x_FLASH_CLA_lnk_cpu1.cmd" targetDirectory="" applicableConfigurations="CPU1_FLASH" />
|
||||
<file action="copy" path="../../../../../../device_support/f2838x/common/source/f2838x_codestartbranch.asm" targetDirectory="device" />
|
||||
<file action="link" path="../../../../../../driverlib/f2838x/driverlib/ccs/Debug/driverlib.lib" targetDirectory="" />
|
||||
<file action="copy" path="../../../../../../driverlib/f2838x/driverlib/" targetDirectory="device" excludeFromBuild="True" />
|
||||
<file action="copy" path="../cla_ex3_background_nesting_task.c" targetDirectory="" />
|
||||
<file action="copy" path="../cla_ex3_background_nesting_task_cla.cla" targetDirectory="" />
|
||||
<file action="copy" path="../cla_ex3_background_nesting_task_shared.h" targetDirectory="" />
|
||||
<file action="copy" path="../cla_ex3_background_nesting_task.syscfg" targetDirectory="" />
|
||||
</project>
|
||||
</projectSpec>
|
||||
@@ -0,0 +1,42 @@
|
||||
<projectSpec>
|
||||
<project
|
||||
name="cla_ex4_pwm_control"
|
||||
device="TMS320F28388D"
|
||||
cgtVersion="22.6.1.LTS"
|
||||
products="sysconfig;C2000WARE"
|
||||
outputFormat="ELF"
|
||||
launchWizard="False"
|
||||
linkerCommandFile=""
|
||||
enableSysConfigTool="true"
|
||||
sysConfigBuildOptions="--product ${C2000WARE_ROOT}/.metadata/sdk.json --device F2838x --package 337bga --part F2838x_337bga"
|
||||
postBuildStep="
|
||||
echo "========= Build of the CLB simulation has moved to the CLB Tool. Click the '?' icon by the _Generate CLB Simulation File_ enable for more details (located in the Global Parameters of the Tile Design SysConfig module) ============="
|
||||
;if ${GENERATE_DIAGRAM} == 1 ${NODE_TOOL} "${C2000WARE_ROOT}/utilities/clb_tool/clb_syscfg/dot_file_libraries/clbDotUtility.js" "${C2000WARE_ROOT}/utilities/clb_tool/clb_syscfg/" "${BuildDirectory}/syscfg" "${BuildDirectory}/syscfg/clb.dot"
|
||||
;if ${GENERATE_DIAGRAM} == 1 mkdir "${BuildDirectory}/diagrams"
|
||||
;if ${GENERATE_DIAGRAM} == 1 ${NODE_TOOL} "${C2000WARE_ROOT}/driverlib/.meta/generate_diagrams.js" "${C2000WARE_ROOT}" "${BuildDirectory}/diagrams" "${BuildDirectory}/syscfg"
|
||||
"
|
||||
>
|
||||
<configuration name="CPU1_RAM" compilerBuildOptions= "--opt_level=off -I${C2000WARE_ROOT} -I${PROJECT_ROOT}/device -I${C2000WARE_DLIB_ROOT} -v28 -ml -mt --cla_support=cla2 --cla_background_task=off --cla_signed_compare_workaround=on --define=RAM --float_support=fpu64 --tmu_support=tmu0 --define=CPU1 --gen_func_subsections=on --diag_warning=225 --diag_suppress=10063" linkerBuildOptions="--entry_point code_start --stack_size=0x3F8 --heap_size=0x200 --define=RAM -i${C2000WARE_ROOT} -i${PROJECT_BUILD_DIR}/syscfg -lc2000ware_libraries.cmd.genlibs " />
|
||||
<configuration name="CPU1_FLASH" compilerBuildOptions="--opt_level=off -I${C2000WARE_ROOT} -I${PROJECT_ROOT}/device -I${C2000WARE_DLIB_ROOT} --define=_FLASH -v28 -ml -mt --cla_support=cla2 --cla_background_task=off --cla_signed_compare_workaround=on --float_support=fpu64 --tmu_support=tmu0 --define=CPU1 --gen_func_subsections=on --diag_warning=225 --diag_suppress=10063" linkerBuildOptions="--entry_point code_start --stack_size=0x3F8 --heap_size=0x200 --define=_FLASH -i${C2000WARE_ROOT} -i${PROJECT_BUILD_DIR}/syscfg -lc2000ware_libraries.cmd.genlibs " />
|
||||
|
||||
<pathVariable name="C2000WARE_DLIB_ROOT" path="../../../../../../driverlib/f2838x/driverlib/" scope="project" />
|
||||
<pathVariable name="C2000WARE_ROOT" path="../../../../../../" 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="GENERATE_DIAGRAM" value="0" scope="project" />
|
||||
<file action="copy" path="../../../../../../device_support/f2838x/common/include/driverlib.h" targetDirectory="device" />
|
||||
<file action="copy" path="../../../../../../device_support/f2838x/common/include/device.h" targetDirectory="device" />
|
||||
<file action="copy" path="../../../../../../device_support/f2838x/common/source/device.c" targetDirectory="device" />
|
||||
<file action="copy" path="../../../../../../device_support/f2838x/common/targetConfigs/TMS320F28388D.ccxml" targetDirectory="targetConfigs" />
|
||||
<file action="copy" path="../../../../../../device_support/f2838x/common/cmd/2838x_RAM_CLA_lnk_cpu1.cmd" targetDirectory="" applicableConfigurations="CPU1_RAM" />
|
||||
<file action="copy" path="../../../../../../device_support/f2838x/common/cmd/2838x_FLASH_CLA_lnk_cpu1.cmd" targetDirectory="" applicableConfigurations="CPU1_FLASH" />
|
||||
<file action="copy" path="../../../../../../device_support/f2838x/common/source/f2838x_codestartbranch.asm" targetDirectory="device" />
|
||||
<file action="link" path="../../../../../../driverlib/f2838x/driverlib/ccs/Debug/driverlib.lib" targetDirectory="" />
|
||||
<file action="copy" path="../../../../../../driverlib/f2838x/driverlib/" targetDirectory="device" excludeFromBuild="True" />
|
||||
<file action="copy" path="../cla_ex4_pwm_control.c" targetDirectory="" />
|
||||
<file action="copy" path="../cla_ex4_pwm_control_cla.cla" targetDirectory="" />
|
||||
<file action="copy" path="../cla_ex4_pwm_control_shared.h" targetDirectory="" />
|
||||
<file action="copy" path="../cla_ex4_pwm_control.syscfg" targetDirectory="" />
|
||||
</project>
|
||||
</projectSpec>
|
||||
@@ -0,0 +1,42 @@
|
||||
<projectSpec>
|
||||
<project
|
||||
name="cla_ex5_adc_just_in_time"
|
||||
device="TMS320F28388D"
|
||||
cgtVersion="22.6.1.LTS"
|
||||
products="sysconfig;C2000WARE"
|
||||
outputFormat="ELF"
|
||||
launchWizard="False"
|
||||
linkerCommandFile=""
|
||||
enableSysConfigTool="true"
|
||||
sysConfigBuildOptions="--product ${C2000WARE_ROOT}/.metadata/sdk.json --device F2838x --package 337bga --part F2838x_337bga"
|
||||
postBuildStep="
|
||||
echo "========= Build of the CLB simulation has moved to the CLB Tool. Click the '?' icon by the _Generate CLB Simulation File_ enable for more details (located in the Global Parameters of the Tile Design SysConfig module) ============="
|
||||
;if ${GENERATE_DIAGRAM} == 1 ${NODE_TOOL} "${C2000WARE_ROOT}/utilities/clb_tool/clb_syscfg/dot_file_libraries/clbDotUtility.js" "${C2000WARE_ROOT}/utilities/clb_tool/clb_syscfg/" "${BuildDirectory}/syscfg" "${BuildDirectory}/syscfg/clb.dot"
|
||||
;if ${GENERATE_DIAGRAM} == 1 mkdir "${BuildDirectory}/diagrams"
|
||||
;if ${GENERATE_DIAGRAM} == 1 ${NODE_TOOL} "${C2000WARE_ROOT}/driverlib/.meta/generate_diagrams.js" "${C2000WARE_ROOT}" "${BuildDirectory}/diagrams" "${BuildDirectory}/syscfg"
|
||||
"
|
||||
>
|
||||
<configuration name="CPU1_RAM" compilerBuildOptions= "--opt_level=off -I${C2000WARE_ROOT} -I${PROJECT_ROOT}/device -I${C2000WARE_DLIB_ROOT} -v28 -ml -mt --cla_support=cla2 --cla_background_task=off --cla_signed_compare_workaround=on --define=RAM --float_support=fpu64 --tmu_support=tmu0 --define=CPU1 --gen_func_subsections=on --diag_warning=225 --diag_suppress=10063" linkerBuildOptions="--entry_point code_start --stack_size=0x3F8 --heap_size=0x200 --define=RAM -i${C2000WARE_ROOT} -i${PROJECT_BUILD_DIR}/syscfg -lc2000ware_libraries.cmd.genlibs " />
|
||||
<configuration name="CPU1_FLASH" compilerBuildOptions="--opt_level=off -I${C2000WARE_ROOT} -I${PROJECT_ROOT}/device -I${C2000WARE_DLIB_ROOT} --define=_FLASH -v28 -ml -mt --cla_support=cla2 --cla_background_task=off --cla_signed_compare_workaround=on --float_support=fpu64 --tmu_support=tmu0 --define=CPU1 --gen_func_subsections=on --diag_warning=225 --diag_suppress=10063" linkerBuildOptions="--entry_point code_start --stack_size=0x3F8 --heap_size=0x200 --define=_FLASH -i${C2000WARE_ROOT} -i${PROJECT_BUILD_DIR}/syscfg -lc2000ware_libraries.cmd.genlibs " />
|
||||
|
||||
<pathVariable name="C2000WARE_DLIB_ROOT" path="../../../../../../driverlib/f2838x/driverlib/" scope="project" />
|
||||
<pathVariable name="C2000WARE_ROOT" path="../../../../../../" 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="GENERATE_DIAGRAM" value="0" scope="project" />
|
||||
<file action="copy" path="../../../../../../device_support/f2838x/common/include/driverlib.h" targetDirectory="device" />
|
||||
<file action="copy" path="../../../../../../device_support/f2838x/common/include/device.h" targetDirectory="device" />
|
||||
<file action="copy" path="../../../../../../device_support/f2838x/common/source/device.c" targetDirectory="device" />
|
||||
<file action="copy" path="../../../../../../device_support/f2838x/common/targetConfigs/TMS320F28388D.ccxml" targetDirectory="targetConfigs" />
|
||||
<file action="copy" path="../../../../../../device_support/f2838x/common/cmd/2838x_RAM_CLA_lnk_cpu1.cmd" targetDirectory="" applicableConfigurations="CPU1_RAM" />
|
||||
<file action="copy" path="../../../../../../device_support/f2838x/common/cmd/2838x_FLASH_CLA_lnk_cpu1.cmd" targetDirectory="" applicableConfigurations="CPU1_FLASH" />
|
||||
<file action="copy" path="../../../../../../device_support/f2838x/common/source/f2838x_codestartbranch.asm" targetDirectory="device" />
|
||||
<file action="link" path="../../../../../../driverlib/f2838x/driverlib/ccs/Debug/driverlib.lib" targetDirectory="" />
|
||||
<file action="copy" path="../../../../../../driverlib/f2838x/driverlib/" targetDirectory="device" excludeFromBuild="True" />
|
||||
<file action="copy" path="../cla_ex5_adc_just_in_time.c" targetDirectory="" />
|
||||
<file action="copy" path="../cla_ex5_adc_just_in_time_cla.cla" targetDirectory="" />
|
||||
<file action="copy" path="../cla_ex5_adc_just_in_time_shared.h" targetDirectory="" />
|
||||
<file action="copy" path="../cla_ex5_adc_just_in_time.syscfg" targetDirectory="" />
|
||||
</project>
|
||||
</projectSpec>
|
||||
@@ -0,0 +1,43 @@
|
||||
<projectSpec>
|
||||
<project
|
||||
name="cla_ex6_cpu_offloading"
|
||||
device="TMS320F28388D"
|
||||
cgtVersion="22.6.1.LTS"
|
||||
products="sysconfig;C2000WARE"
|
||||
outputFormat="ELF"
|
||||
launchWizard="False"
|
||||
linkerCommandFile=""
|
||||
enableSysConfigTool="true"
|
||||
sysConfigBuildOptions="--product ${C2000WARE_ROOT}/.metadata/sdk.json --device F2838x --package 337bga --part F2838x_337bga"
|
||||
postBuildStep="
|
||||
echo "========= Build of the CLB simulation has moved to the CLB Tool. Click the '?' icon by the _Generate CLB Simulation File_ enable for more details (located in the Global Parameters of the Tile Design SysConfig module) ============="
|
||||
;if ${GENERATE_DIAGRAM} == 1 ${NODE_TOOL} "${C2000WARE_ROOT}/utilities/clb_tool/clb_syscfg/dot_file_libraries/clbDotUtility.js" "${C2000WARE_ROOT}/utilities/clb_tool/clb_syscfg/" "${BuildDirectory}/syscfg" "${BuildDirectory}/syscfg/clb.dot"
|
||||
;if ${GENERATE_DIAGRAM} == 1 mkdir "${BuildDirectory}/diagrams"
|
||||
;if ${GENERATE_DIAGRAM} == 1 ${NODE_TOOL} "${C2000WARE_ROOT}/driverlib/.meta/generate_diagrams.js" "${C2000WARE_ROOT}" "${BuildDirectory}/diagrams" "${BuildDirectory}/syscfg"
|
||||
"
|
||||
>
|
||||
<configuration name="CPU1_RAM" compilerBuildOptions= "--opt_level=off -I${C2000WARE_ROOT} -I${PROJECT_ROOT}/device -I${C2000WARE_DLIB_ROOT} -I${C2000WARE_DCL_ROOT}/c28/include --define=run_loop1_cla=1 -v28 -ml -mt --cla_support=cla2 --cla_background_task=off --cla_signed_compare_workaround=on --define=RAM --float_support=fpu64 --tmu_support=tmu0 --define=CPU1 --gen_func_subsections=on --diag_warning=225 --diag_suppress=10063" linkerBuildOptions="--entry_point code_start --stack_size=0x3F8 --heap_size=0x200 --define=RAM -i${C2000WARE_ROOT} -i${PROJECT_BUILD_DIR}/syscfg -lc2000ware_libraries.cmd.genlibs " />
|
||||
<configuration name="CPU1_FLASH" compilerBuildOptions="--opt_level=off -I${C2000WARE_ROOT} -I${PROJECT_ROOT}/device -I${C2000WARE_DLIB_ROOT} --define=_FLASH -I${C2000WARE_DCL_ROOT}/c28/include --define=run_loop1_cla=1 -v28 -ml -mt --cla_support=cla2 --cla_background_task=off --cla_signed_compare_workaround=on --float_support=fpu64 --tmu_support=tmu0 --define=CPU1 --gen_func_subsections=on --diag_warning=225 --diag_suppress=10063" linkerBuildOptions="--entry_point code_start --stack_size=0x3F8 --heap_size=0x200 --define=_FLASH -i${C2000WARE_ROOT} -i${PROJECT_BUILD_DIR}/syscfg -lc2000ware_libraries.cmd.genlibs " />
|
||||
|
||||
<pathVariable name="C2000WARE_DLIB_ROOT" path="../../../../../../driverlib/f2838x/driverlib/" scope="project" />
|
||||
<pathVariable name="C2000WARE_ROOT" path="../../../../../../" 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="GENERATE_DIAGRAM" value="0" scope="project" />
|
||||
<pathVariable name="C2000WARE_DCL_ROOT" path="../../../../../../libraries/control/DCL/" scope="project" />
|
||||
<file action="copy" path="../../../../../../device_support/f2838x/common/include/driverlib.h" targetDirectory="device" />
|
||||
<file action="copy" path="../../../../../../device_support/f2838x/common/include/device.h" targetDirectory="device" />
|
||||
<file action="copy" path="../../../../../../device_support/f2838x/common/source/device.c" targetDirectory="device" />
|
||||
<file action="copy" path="../../../../../../device_support/f2838x/common/targetConfigs/TMS320F28388D.ccxml" targetDirectory="targetConfigs" />
|
||||
<file action="copy" path="../../../../../../device_support/f2838x/common/cmd/2838x_RAM_CLA_lnk_cpu1.cmd" targetDirectory="" applicableConfigurations="CPU1_RAM" />
|
||||
<file action="copy" path="../../../../../../device_support/f2838x/common/cmd/2838x_FLASH_CLA_lnk_cpu1.cmd" targetDirectory="" applicableConfigurations="CPU1_FLASH" />
|
||||
<file action="copy" path="../../../../../../device_support/f2838x/common/source/f2838x_codestartbranch.asm" targetDirectory="device" />
|
||||
<file action="link" path="../../../../../../driverlib/f2838x/driverlib/ccs/Debug/driverlib.lib" targetDirectory="" />
|
||||
<file action="copy" path="../../../../../../driverlib/f2838x/driverlib/" targetDirectory="device" excludeFromBuild="True" />
|
||||
<file action="copy" path="../cla_ex6_cpu_offloading.c" targetDirectory="" />
|
||||
<file action="copy" path="../cla_ex6_cpu_offloading_cla.cla" targetDirectory="" />
|
||||
<file action="copy" path="../cla_ex6_cpu_offloading_shared.h" targetDirectory="" />
|
||||
<file action="copy" path="../cla_ex6_cpu_offloading.syscfg" targetDirectory="" />
|
||||
</project>
|
||||
</projectSpec>
|
||||
+42
@@ -0,0 +1,42 @@
|
||||
<projectSpec>
|
||||
<project
|
||||
name="cla_ex7_shared_resource_handling"
|
||||
device="TMS320F28388D"
|
||||
cgtVersion="22.6.1.LTS"
|
||||
products="sysconfig;C2000WARE"
|
||||
outputFormat="ELF"
|
||||
launchWizard="False"
|
||||
linkerCommandFile=""
|
||||
enableSysConfigTool="true"
|
||||
sysConfigBuildOptions="--product ${C2000WARE_ROOT}/.metadata/sdk.json --device F2838x --package 337bga --part F2838x_337bga"
|
||||
postBuildStep="
|
||||
echo "========= Build of the CLB simulation has moved to the CLB Tool. Click the '?' icon by the _Generate CLB Simulation File_ enable for more details (located in the Global Parameters of the Tile Design SysConfig module) ============="
|
||||
;if ${GENERATE_DIAGRAM} == 1 ${NODE_TOOL} "${C2000WARE_ROOT}/utilities/clb_tool/clb_syscfg/dot_file_libraries/clbDotUtility.js" "${C2000WARE_ROOT}/utilities/clb_tool/clb_syscfg/" "${BuildDirectory}/syscfg" "${BuildDirectory}/syscfg/clb.dot"
|
||||
;if ${GENERATE_DIAGRAM} == 1 mkdir "${BuildDirectory}/diagrams"
|
||||
;if ${GENERATE_DIAGRAM} == 1 ${NODE_TOOL} "${C2000WARE_ROOT}/driverlib/.meta/generate_diagrams.js" "${C2000WARE_ROOT}" "${BuildDirectory}/diagrams" "${BuildDirectory}/syscfg"
|
||||
"
|
||||
>
|
||||
<configuration name="CPU1_RAM" compilerBuildOptions= "--opt_level=2 -I${C2000WARE_ROOT} -I${PROJECT_ROOT}/device -I${C2000WARE_DLIB_ROOT} -v28 -ml -mt --cla_support=cla2 --cla_background_task=off --cla_signed_compare_workaround=on --define=RAM --float_support=fpu64 --tmu_support=tmu0 --define=CPU1 --gen_func_subsections=on --diag_warning=225 --diag_suppress=10063" linkerBuildOptions="--entry_point code_start --stack_size=0x3F8 --heap_size=0x200 --define=RAM -i${C2000WARE_ROOT} -i${PROJECT_BUILD_DIR}/syscfg -lc2000ware_libraries.cmd.genlibs " />
|
||||
<configuration name="CPU1_FLASH" compilerBuildOptions="--opt_level=2 -I${C2000WARE_ROOT} -I${PROJECT_ROOT}/device -I${C2000WARE_DLIB_ROOT} --define=_FLASH -v28 -ml -mt --cla_support=cla2 --cla_background_task=off --cla_signed_compare_workaround=on --float_support=fpu64 --tmu_support=tmu0 --define=CPU1 --gen_func_subsections=on --diag_warning=225 --diag_suppress=10063" linkerBuildOptions="--entry_point code_start --stack_size=0x3F8 --heap_size=0x200 --define=_FLASH -i${C2000WARE_ROOT} -i${PROJECT_BUILD_DIR}/syscfg -lc2000ware_libraries.cmd.genlibs " />
|
||||
|
||||
<pathVariable name="C2000WARE_DLIB_ROOT" path="../../../../../../driverlib/f2838x/driverlib/" scope="project" />
|
||||
<pathVariable name="C2000WARE_ROOT" path="../../../../../../" 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="GENERATE_DIAGRAM" value="0" scope="project" />
|
||||
<file action="copy" path="../../../../../../device_support/f2838x/common/include/driverlib.h" targetDirectory="device" />
|
||||
<file action="copy" path="../../../../../../device_support/f2838x/common/include/device.h" targetDirectory="device" />
|
||||
<file action="copy" path="../../../../../../device_support/f2838x/common/source/device.c" targetDirectory="device" />
|
||||
<file action="copy" path="../../../../../../device_support/f2838x/common/targetConfigs/TMS320F28388D.ccxml" targetDirectory="targetConfigs" />
|
||||
<file action="copy" path="../../../../../../device_support/f2838x/common/cmd/2838x_RAM_CLA_lnk_cpu1.cmd" targetDirectory="" applicableConfigurations="CPU1_RAM" />
|
||||
<file action="copy" path="../../../../../../device_support/f2838x/common/cmd/2838x_FLASH_CLA_lnk_cpu1.cmd" targetDirectory="" applicableConfigurations="CPU1_FLASH" />
|
||||
<file action="copy" path="../../../../../../device_support/f2838x/common/source/f2838x_codestartbranch.asm" targetDirectory="device" />
|
||||
<file action="link" path="../../../../../../driverlib/f2838x/driverlib/ccs/Debug/driverlib.lib" targetDirectory="" />
|
||||
<file action="copy" path="../../../../../../driverlib/f2838x/driverlib/" targetDirectory="device" excludeFromBuild="True" />
|
||||
<file action="copy" path="../cla_ex7_shared_resource_handling.c" targetDirectory="" />
|
||||
<file action="copy" path="../cla_ex7_shared_resource_handling_cla.cla" targetDirectory="" />
|
||||
<file action="copy" path="../cla_ex7_shared_resource_handling.h" targetDirectory="" />
|
||||
<file action="copy" path="../cla_ex7_shared_resource_handling.syscfg" targetDirectory="" />
|
||||
</project>
|
||||
</projectSpec>
|
||||
@@ -0,0 +1,164 @@
|
||||
//#############################################################################
|
||||
// \file asin.cla
|
||||
//
|
||||
// \brief Arc Sine Example
|
||||
//
|
||||
//#############################################################################
|
||||
//
|
||||
// C2000Ware v5.04.00.00
|
||||
//
|
||||
// Copyright (C) 2024 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 "cla_ex1_asin_shared.h"
|
||||
|
||||
//
|
||||
// Defines
|
||||
//
|
||||
|
||||
//
|
||||
// Globals
|
||||
//
|
||||
// Note that the globals defined in the .cla source are global to the cla source
|
||||
// file. i.e. they may be shared across tasks. All of the data shared between
|
||||
// the CLA and the C28x CPU must be defined in the C (or C++) code, and not the
|
||||
// CLA code.
|
||||
//
|
||||
|
||||
//
|
||||
// Function Definitions
|
||||
//
|
||||
//Task 1 : Calculate asin(X)
|
||||
// Description:
|
||||
// Step(1): Calculate absolute of the input X
|
||||
//
|
||||
// Step(2): Use the upper 6-bits of input "X" value as an
|
||||
// index into the table to obtain the coefficients
|
||||
// for a second order equation:
|
||||
//
|
||||
// _FPUasinTable:
|
||||
// CoeffA0[0]
|
||||
// CoeffA1[0]
|
||||
// CoeffA2[0]
|
||||
// .
|
||||
// .
|
||||
// CoeffA0[63]
|
||||
// CoeffA1[63]
|
||||
// CoeffA2[63]
|
||||
//
|
||||
// Step(3): Calculate the angle using the following equation:
|
||||
//
|
||||
// arctan(Ratio) = A0 + A1*Ratio + A2*Ratio*Ratio
|
||||
// arctan(Ratio) = A0 + Ratio(A1 + A2*Ratio)
|
||||
//
|
||||
// Step(4): The final angle is determined as follows:
|
||||
//
|
||||
// if( X < 0 )
|
||||
// Angle = -Angle
|
||||
__interrupt void Cla1Task1 ( void )
|
||||
{
|
||||
//
|
||||
//Local Variables
|
||||
//
|
||||
int xTblIdx; //integer valued Table index
|
||||
float A0,A1,A2; //Table coefficients
|
||||
float *entry;
|
||||
float result;
|
||||
|
||||
//
|
||||
//Preprocessing
|
||||
//
|
||||
__mdebugstop();
|
||||
xTblIdx = fVal * TABLE_SIZE_M_1; //convert table index to u16-bits
|
||||
xTblIdx = xTblIdx * 3; //Table is ordered as 3 32-bit coefficients, the
|
||||
//index points to these triplets, hence the *3*sizeof(float)
|
||||
entry = &CLAasinTable[xTblIdx];
|
||||
A0 = *entry++;
|
||||
A1 = *entry++;
|
||||
A2 = *entry;
|
||||
|
||||
|
||||
result = A0 + fVal*(A1 + A2*fVal);
|
||||
|
||||
//
|
||||
//Post processing
|
||||
//
|
||||
if(fVal < 0)
|
||||
{
|
||||
result = - result;
|
||||
}
|
||||
|
||||
fResult = result;
|
||||
}
|
||||
|
||||
interrupt void Cla1Task2 ( void )
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
interrupt void Cla1Task3 ( void )
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
interrupt void Cla1Task4 ( void )
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
interrupt void Cla1Task5 ( void )
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
interrupt void Cla1Task6 ( void )
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
interrupt void Cla1Task7 ( void )
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
interrupt void Cla1Task8 ( void )
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
//
|
||||
// End of file
|
||||
//
|
||||
@@ -0,0 +1,189 @@
|
||||
//#############################################################################
|
||||
// \file atan.cla
|
||||
//
|
||||
// \brief Arc Tangent Example
|
||||
//
|
||||
//#############################################################################
|
||||
//
|
||||
// C2000Ware v5.04.00.00
|
||||
//
|
||||
// Copyright (C) 2024 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 "cla_ex2_atan_shared.h"
|
||||
|
||||
//
|
||||
// Defines
|
||||
//
|
||||
|
||||
//
|
||||
// Globals
|
||||
//
|
||||
// Note that the globals defined in the .cla source are global to the cla source
|
||||
// file. i.e. they may be shared across tasks. All of the data shared between
|
||||
// the CLA and the C28x CPU must be defined in the C (or C++) code, and not the
|
||||
// CLA code.
|
||||
//
|
||||
|
||||
//
|
||||
// Function Definitions
|
||||
//
|
||||
//Task 1 : Calculate atan(Y)
|
||||
// Description:
|
||||
// Step(1): if( 1.0 >= abs(Y) )
|
||||
// Numerator = abs(Y)
|
||||
// Denominator = 1.0
|
||||
// else
|
||||
// Numerator = 1.0
|
||||
// Denominator = abs(Y)
|
||||
//
|
||||
// Step(2): Ratio = Numerator/Denominator
|
||||
//
|
||||
// Note: Ratio range = 0.0 to 1.0
|
||||
//
|
||||
// Step(3): Use the upper 6-bits of the "Ratio" value as an
|
||||
// index into the table to obtain the coefficients
|
||||
// for a second order equation:
|
||||
//
|
||||
// _FPUatan2Table:
|
||||
// CoeffA0[0]
|
||||
// CoeffA1[0]
|
||||
// CoeffA2[0]
|
||||
// .
|
||||
// .
|
||||
// CoeffA0[63]
|
||||
// CoeffA1[63]
|
||||
// CoeffA2[63]
|
||||
//
|
||||
// Step(4): Calculate the angle using the following equation:
|
||||
//
|
||||
// arctan(Ratio) = A0 + A1*Ratio + A2*Ratio*Ratio
|
||||
// arctan(Ratio) = A0 + Ratio(A1 + A2*Ratio)
|
||||
//
|
||||
// Step(5): The final angle is determined as follows:
|
||||
//
|
||||
// if( Y >= 0 and 1.0 >= abs(Y) )
|
||||
// Angle = arctan(abs(Y)/1.0)
|
||||
// if( Y >= 0 and 1.0 < abs(Y) )
|
||||
// Angle = PI/2 - arctan(1.0/abs(Y))
|
||||
// if( Y < 0 )
|
||||
// Angle = -Angle
|
||||
__interrupt void Cla1Task1 ( void )
|
||||
{
|
||||
//
|
||||
//Local Variables
|
||||
//
|
||||
unsigned int uxTblIdx; //unsigned integer valued Table index
|
||||
float ratio;
|
||||
float num,den;
|
||||
float A0,A1,A2; //Table coefficients
|
||||
float *base;
|
||||
float result;
|
||||
|
||||
//
|
||||
//Preprocessing
|
||||
//
|
||||
__mdebugstop();
|
||||
num = __mminf32(fabsf(fVal),1.0f);
|
||||
den = __mmaxf32(fabsf(fVal),1.0f);
|
||||
|
||||
ratio = (num/den); //Expected the newton raphson algo for better
|
||||
//accuracy on the divide
|
||||
uxTblIdx = ratio * TABLE_SIZE_M_1 * 3; //convert table index to u16-bits
|
||||
uxTblIdx = uxTblIdx * 3; //Table is ordered as 3 32-bit coefficients, the
|
||||
//index points to these triplets, hence the *3*sizeof(float)
|
||||
|
||||
base = &CLAatan2Table[uxTblIdx];
|
||||
A0 = *base++;
|
||||
A1 = *base++;
|
||||
A2 = *base;
|
||||
|
||||
result = A0 + ratio*(A1 + A2*ratio);
|
||||
|
||||
//
|
||||
//Post processing
|
||||
//
|
||||
if(fabsf(fVal) > 1.0f)
|
||||
{
|
||||
result = PIBYTWO - result;
|
||||
}
|
||||
|
||||
if(fVal < 0.0f)
|
||||
{
|
||||
result = -result;
|
||||
}
|
||||
|
||||
fResult = result;
|
||||
}
|
||||
|
||||
interrupt void Cla1Task2 ( void )
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
interrupt void Cla1Task3 ( void )
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
interrupt void Cla1Task4 ( void )
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
interrupt void Cla1Task5 ( void )
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
interrupt void Cla1Task6 ( void )
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
interrupt void Cla1Task7 ( void )
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
interrupt void Cla1Task8 ( void )
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
//
|
||||
// End of file
|
||||
//
|
||||
|
||||
@@ -0,0 +1,424 @@
|
||||
//###########################################################################
|
||||
//
|
||||
// FILE: cla_ex1_asin.c
|
||||
//
|
||||
// TITLE: CLA Arcsine Example
|
||||
//
|
||||
//! \addtogroup driver_example_list
|
||||
//! <h1>CLA \f$arcsine(x)\f$ using a lookup table (cla_asin_cpu01)</h1>
|
||||
//!
|
||||
//! In this example, Task 1 of the CLA will calculate the arcsine of
|
||||
//! an input argument in the range (-1.0 to 1.0) using a lookup table.
|
||||
//!
|
||||
//! Note that since this example does not use background CLA task, the compile
|
||||
//! flag cla_background_task is turned off for this project. Set this flag as
|
||||
//! on to enable background CLA task. The option is available in Project
|
||||
//! Properties -> C2000 Build -> C2000 Compiler -> Advanced Options -> Runtime
|
||||
//! Model Options.
|
||||
//!
|
||||
//! \b Memory \b Allocation \n
|
||||
//! - CLA1 Math Tables (RAMLS0)
|
||||
//! - CLAasinTable - Lookup table
|
||||
//! - CLA1 to CPU Message RAM
|
||||
//! - fResult - Result of the lookup algorithm
|
||||
//! - CPU to CLA1 Message RAM
|
||||
//! - fVal - Sample input to the lookup algorithm
|
||||
//!
|
||||
//! \b Watch \b Variables \n
|
||||
//! - fVal - Argument to task 1
|
||||
//! - fResult - Result of \f$arcsin(fVal)\f$
|
||||
//!
|
||||
//
|
||||
//###########################################################################
|
||||
//
|
||||
// C2000Ware v5.04.00.00
|
||||
//
|
||||
// Copyright (C) 2024 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 "driverlib.h"
|
||||
#include "device.h"
|
||||
#include "cla_ex1_asin_shared.h"
|
||||
#include "board.h"
|
||||
|
||||
//
|
||||
// Defines
|
||||
//
|
||||
#define WAITSTEP asm(" RPT #255 || NOP")
|
||||
|
||||
//
|
||||
// Globals
|
||||
//
|
||||
|
||||
//
|
||||
//Task 1 (C) Variables
|
||||
// NOTE: Do not initialize the Message RAM variables globally, they will be
|
||||
// reset during the message ram initialization phase in the CLA memory
|
||||
// configuration routine
|
||||
//
|
||||
#ifdef __cplusplus
|
||||
#pragma DATA_SECTION("CpuToCla1MsgRAM");
|
||||
float fVal;
|
||||
#pragma DATA_SECTION("Cla1ToCpuMsgRAM");
|
||||
float fResult;
|
||||
#else
|
||||
#pragma DATA_SECTION(fVal,"CpuToCla1MsgRAM");
|
||||
float fVal;
|
||||
#pragma DATA_SECTION(fResult,"Cla1ToCpuMsgRAM");
|
||||
float fResult;
|
||||
#endif //__cplusplus
|
||||
float y[BUFFER_SIZE];
|
||||
|
||||
//
|
||||
//Task 2 (C) Variables
|
||||
//
|
||||
|
||||
//
|
||||
//Task 3 (C) Variables
|
||||
//
|
||||
|
||||
//
|
||||
//Task 4 (C) Variables
|
||||
//
|
||||
|
||||
//
|
||||
//Task 5 (C) Variables
|
||||
//
|
||||
|
||||
//
|
||||
//Task 6 (C) Variables
|
||||
//
|
||||
|
||||
//
|
||||
//Task 7 (C) Variables
|
||||
//
|
||||
|
||||
//
|
||||
//Task 8 (C) Variables
|
||||
//
|
||||
|
||||
//
|
||||
//Common (C) Variables
|
||||
//The Exponential table
|
||||
//
|
||||
#ifdef __cplusplus
|
||||
#pragma DATA_SECTION("CLADataLS0")
|
||||
#else
|
||||
#pragma DATA_SECTION(CLAasinTable,"CLADataLS0")
|
||||
#endif //__cplusplus
|
||||
float CLAasinTable[]={
|
||||
0.0, 1.0, 0.0,
|
||||
0.000000636202, 0.999877862610, 0.007815361896,
|
||||
0.000005099694, 0.999510644409, 0.015647916155,
|
||||
0.000017268312, 0.998895919094, 0.023514960332,
|
||||
0.000041121765, 0.998029615282, 0.031434003631,
|
||||
0.000080794520, 0.996905974725, 0.039422875916,
|
||||
0.000140631089, 0.995517492804, 0.047499840611,
|
||||
0.000225244584, 0.993854840311, 0.055683712914,
|
||||
0.000339579512, 0.991906765146, 0.063993984848,
|
||||
0.000488979852, 0.989659972212, 0.072450958820,
|
||||
0.000679263611, 0.987098979366, 0.081075891529,
|
||||
0.000916805182, 0.984205946802, 0.089891150305,
|
||||
0.001208627040, 0.980960476685, 0.098920384204,
|
||||
0.001562502549, 0.977339379243, 0.108188712551,
|
||||
0.001987071928, 0.973316400729, 0.117722933997,
|
||||
0.002491973784, 0.968861907789, 0.127551759665,
|
||||
0.003087995053, 0.963942521723, 0.137706074532,
|
||||
0.003787242692, 0.958520694794, 0.148219231941,
|
||||
0.004603341138, 0.952554219267, 0.159127386977,
|
||||
0.005551660294, 0.945995657913, 0.170469875522,
|
||||
0.006649579796, 0.938791682505, 0.182289647088,
|
||||
0.007916796475, 0.930882303984, 0.194633761132,
|
||||
0.009375683410, 0.922199974574, 0.207553958472,
|
||||
0.011051710808, 0.912668537890, 0.221107321885,
|
||||
0.012973941175, 0.902201997769, 0.235357042896,
|
||||
0.015175614174, 0.890703070035, 0.250373315541,
|
||||
0.017694840102, 0.878061473098, 0.266234382514,
|
||||
0.020575425537, 0.864151902887, 0.283027765009,
|
||||
0.023867860513, 0.848831624374, 0.300851714968,
|
||||
0.027630504055, 0.831937595031, 0.319816937941,
|
||||
0.031931014547, 0.813283013821, 0.340048646894,
|
||||
0.036848083955, 0.792653161200, 0.361689022958,
|
||||
0.042473551274, 0.769800358920, 0.384900179460,
|
||||
0.048914992206, 0.744437830278, 0.409867752228,
|
||||
0.056298910750, 0.716232177740, 0.436805274317,
|
||||
0.064774696786, 0.684794109766, 0.465959540059,
|
||||
0.074519565699, 0.649666934178, 0.497617226179,
|
||||
0.085744766889, 0.610312179660, 0.532113122767,
|
||||
0.098703445606, 0.566091493186, 0.569840443472,
|
||||
0.113700678529, 0.516243664372, 0.611263845480,
|
||||
0.131106395009, 0.459855210927, 0.656936015611,
|
||||
0.151372169232, 0.395822366759, 0.707518998893,
|
||||
0.175053263659, 0.322801460177, 0.763811905770,
|
||||
0.202837883870, 0.239143420888, 0.826787304376,
|
||||
0.235586468765, 0.142806299514, 0.897639596948,
|
||||
0.274385149825, 0.031236880585, 0.977850174820,
|
||||
0.320619535938, -0.098791845166, 1.069276441800,
|
||||
0.376078169620, -0.251407364538, 1.174275392129,
|
||||
0.443100143614, -0.431959397725, 1.295878193174,
|
||||
0.524789871827, -0.647485610469, 1.438041695773,
|
||||
0.625336471263, -0.907400624736, 1.606018804842,
|
||||
0.750500589935, -1.224540947101, 1.806917563896,
|
||||
0.908377657341, -1.616794995066, 2.050569262035,
|
||||
1.110633894185, -2.109729648039, 2.350920816737,
|
||||
1.374584721437, -2.740985157716, 2.728353889708,
|
||||
1.726848242753, -3.567962877198, 3.213722960014,
|
||||
2.210117561056, -4.682006534082, 3.855770086891,
|
||||
2.896554011854, -6.236312386687, 4.735651038017,
|
||||
3.916505715382, -8.505488022524, 5.997790945975,
|
||||
5.526855868703, -12.026617159136, 7.922628470498,
|
||||
8.298197116322, -17.983705080358, 11.123941286820,
|
||||
13.741706072449, -29.488929624542, 17.203344479111,
|
||||
27.202707817485, -57.466598393615, 31.741016484669,
|
||||
83.158101335898, -171.803399517566, 90.149831709374
|
||||
};
|
||||
|
||||
float asin_expected[BUFFER_SIZE]={
|
||||
1.570796, 1.393789, 1.320141, 1.263401, 1.215375,
|
||||
1.172892, 1.134327, 1.098718, 1.065436, 1.034046,
|
||||
1.004232, 0.9757544, 0.9484279, 0.9221048, 0.8966658,
|
||||
0.8720123, 0.8480621, 0.8247454, 0.8020028, 0.7797828,
|
||||
0.7580408, 0.7367374, 0.7158381, 0.6953120, 0.6751316,
|
||||
0.6552721, 0.6357113, 0.6164289, 0.5974064, 0.5786270,
|
||||
0.5600753, 0.5417370, 0.5235988, 0.5056486, 0.4878751,
|
||||
0.4702678, 0.4528166, 0.4355124, 0.4183464, 0.4013104,
|
||||
0.3843968, 0.3675981, 0.3509074, 0.3343180, 0.3178237,
|
||||
0.3014185, 0.2850964, 0.2688521, 0.2526802, 0.2365756,
|
||||
0.2205333, 0.2045484, 0.1886164, 0.1727327, 0.1568929,
|
||||
0.1410927, 0.1253278, 0.1095943, 0.09388787, 0.07820469,
|
||||
0.06254076, 0.04689218, 0.03125509, 0.01562564
|
||||
};
|
||||
|
||||
uint16_t pass = 0;
|
||||
uint16_t fail = 0;
|
||||
|
||||
//
|
||||
// Function Prototypes
|
||||
//
|
||||
void CLA_runTest(void);
|
||||
__interrupt void cla1Isr1();
|
||||
__interrupt void cla1Isr2();
|
||||
__interrupt void cla1Isr3();
|
||||
__interrupt void cla1Isr4();
|
||||
__interrupt void cla1Isr5();
|
||||
__interrupt void cla1Isr6();
|
||||
__interrupt void cla1Isr7();
|
||||
__interrupt void cla1Isr8();
|
||||
|
||||
//
|
||||
// Main
|
||||
//
|
||||
void main(void)
|
||||
{
|
||||
|
||||
//
|
||||
// Intialize device clock and peripherals
|
||||
//
|
||||
Device_init();
|
||||
|
||||
//
|
||||
// Disable pin locks and enable internal pullups.
|
||||
//
|
||||
//Device_initGPIO(); //skipped for this example
|
||||
|
||||
//
|
||||
// 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();
|
||||
|
||||
//
|
||||
// Initialize resources
|
||||
//
|
||||
Board_init();
|
||||
|
||||
//
|
||||
// Enable Global Interrupt (INTM) and realtime interrupt (DBGM)
|
||||
//
|
||||
EINT;
|
||||
ERTM;
|
||||
|
||||
//
|
||||
// Run the test
|
||||
//
|
||||
CLA_runTest();
|
||||
|
||||
for(;;)
|
||||
{
|
||||
}
|
||||
}
|
||||
|
||||
//
|
||||
// CLA_runTest - Execute CLA task tests for specified vectors
|
||||
//
|
||||
void CLA_runTest(void)
|
||||
{
|
||||
int16_t i;
|
||||
float error;
|
||||
|
||||
for(i = 0; i < BUFFER_SIZE; i++)
|
||||
{
|
||||
fVal= (float)(BUFFER_SIZE - i)/(float)BUFFER_SIZE;
|
||||
CLA_forceTasks(CLA1_BASE,CLA_TASKFLAG_1);
|
||||
WAITSTEP;
|
||||
y[i] = fResult;
|
||||
error = fabsf(asin_expected[i]-y[i]);
|
||||
|
||||
if(error < 0.1f)
|
||||
{
|
||||
pass++;
|
||||
}
|
||||
else
|
||||
{
|
||||
fail++;
|
||||
}
|
||||
}
|
||||
|
||||
#if 0
|
||||
|
||||
CLA_forceTasks(CLA1_BASE,CLA_TASKFLAG_2);
|
||||
WAITSTEP;
|
||||
|
||||
CLA_forceTasks(CLA1_BASE,CLA_TASKFLAG_3);
|
||||
WAITSTEP;
|
||||
|
||||
CLA_forceTasks(CLA1_BASE,CLA_TASKFLAG_4);
|
||||
WAITSTEP;
|
||||
|
||||
CLA_forceTasks(CLA1_BASE,CLA_TASKFLAG_5);
|
||||
WAITSTEP;
|
||||
|
||||
CLA_forceTasks(CLA1_BASE,CLA_TASKFLAG_6);
|
||||
WAITSTEP;
|
||||
|
||||
CLA_forceTasks(CLA1_BASE,CLA_TASKFLAG_7);
|
||||
WAITSTEP;
|
||||
|
||||
CLA_forceTasks(CLA1_BASE,CLA_TASKFLAG_8);
|
||||
WAITSTEP;
|
||||
#endif
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
//
|
||||
// cla1Isr1 - CLA1 ISR 1
|
||||
//
|
||||
|
||||
__interrupt void cla1Isr1 ()
|
||||
{
|
||||
//
|
||||
// Acknowledge the end-of-task interrupt for task 1
|
||||
//
|
||||
Interrupt_clearACKGroup(INTERRUPT_ACK_GROUP11);
|
||||
|
||||
//
|
||||
// Uncomment to halt debugger and stop here
|
||||
//
|
||||
// asm(" ESTOP0");
|
||||
}
|
||||
|
||||
//
|
||||
// cla1Isr2 - CLA1 ISR 2
|
||||
//
|
||||
__interrupt void cla1Isr2 ()
|
||||
{
|
||||
asm(" ESTOP0");
|
||||
}
|
||||
|
||||
//
|
||||
// cla1Isr3 - CLA1 ISR 3
|
||||
//
|
||||
__interrupt void cla1Isr3 ()
|
||||
{
|
||||
asm(" ESTOP0");
|
||||
}
|
||||
|
||||
//
|
||||
// cla1Isr4 - CLA1 ISR 4
|
||||
//
|
||||
__interrupt void cla1Isr4 ()
|
||||
{
|
||||
asm(" ESTOP0");
|
||||
}
|
||||
|
||||
//
|
||||
// cla1Isr5 - CLA1 ISR 5
|
||||
//
|
||||
__interrupt void cla1Isr5 ()
|
||||
{
|
||||
asm(" ESTOP0");
|
||||
}
|
||||
|
||||
//
|
||||
// cla1Isr6 - CLA1 ISR 6
|
||||
//
|
||||
__interrupt void cla1Isr6 ()
|
||||
{
|
||||
asm(" ESTOP0");
|
||||
}
|
||||
|
||||
//
|
||||
// cla1Isr7 - CLA1 ISR 7
|
||||
//
|
||||
__interrupt void cla1Isr7 ()
|
||||
{
|
||||
asm(" ESTOP0");
|
||||
}
|
||||
|
||||
//
|
||||
// cla1Isr8 - CLA1 ISR 8
|
||||
//
|
||||
__interrupt void cla1Isr8 ()
|
||||
{
|
||||
//
|
||||
// Acknowledge the end-of-task interrupt for task 8
|
||||
//
|
||||
Interrupt_clearACKGroup(INTERRUPT_ACK_GROUP11);
|
||||
//
|
||||
// Uncomment to halt debugger and stop here
|
||||
//
|
||||
// asm(" ESTOP0");
|
||||
}
|
||||
|
||||
//
|
||||
// End of file
|
||||
//
|
||||
@@ -0,0 +1,19 @@
|
||||
|
||||
/**
|
||||
* Import the modules used in this configuration.
|
||||
*/
|
||||
const cla = scripting.addModule("/driverlib/cla.js", {}, false);
|
||||
const cla1 = cla.addInstance();
|
||||
const memcfg = scripting.addModule("/driverlib/memcfg.js");
|
||||
|
||||
/**
|
||||
* Write custom configuration values to the imported modules.
|
||||
*/
|
||||
cla1.$name = "myCLA0";
|
||||
|
||||
|
||||
memcfg.config_MEMCFG_SECT_LS5 = "CLA_prog";
|
||||
memcfg.config_MEMCFG_SECT_LS0 = "CLA_data";
|
||||
memcfg.config_MEMCFG_SECT_LS1 = "CLA_data";
|
||||
memcfg.init_MEMCFG_SECT_MSGCPUTOCLA1 = true;
|
||||
memcfg.init_MEMCFG_SECT_MSGCLA1TOCPU = true;
|
||||
@@ -0,0 +1,133 @@
|
||||
#ifndef _CLA_ASIN_SHARED_H_
|
||||
#define _CLA_ASIN_SHARED_H_
|
||||
//#############################################################################
|
||||
//
|
||||
// FILE: cla_ex1_asin_shared.h
|
||||
//
|
||||
// TITLE: CLA arcsine example header file.
|
||||
//
|
||||
//#############################################################################
|
||||
//
|
||||
// C2000Ware v5.04.00.00
|
||||
//
|
||||
// Copyright (C) 2024 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 <stdint.h>
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
//
|
||||
// Defines
|
||||
//
|
||||
#define BUFFER_SIZE 64
|
||||
#define TABLE_SIZE 64
|
||||
#define TABLE_SIZE_M_1 TABLE_SIZE-1
|
||||
#define PIBYTWO 1.570796327
|
||||
#define PI 3.141592653589
|
||||
#define INV2PI 0.159154943
|
||||
|
||||
//
|
||||
// Globals
|
||||
//
|
||||
|
||||
//
|
||||
//Task 1 (C) Variables
|
||||
//
|
||||
extern float y[]; //Result vector
|
||||
extern float fVal; //Holds the input argument to the task
|
||||
extern float fResult; //The arsine of the input argument
|
||||
|
||||
//
|
||||
//Task 2 (C) Variables
|
||||
//
|
||||
|
||||
//
|
||||
//Task 3 (C) Variables
|
||||
//
|
||||
|
||||
//
|
||||
//Task 4 (C) Variables
|
||||
//
|
||||
|
||||
//
|
||||
//Task 5 (C) Variables
|
||||
//
|
||||
|
||||
//
|
||||
//Task 6 (C) Variables
|
||||
//
|
||||
|
||||
//
|
||||
//Task 7 (C) Variables
|
||||
//
|
||||
|
||||
//
|
||||
//Task 8 (C) Variables
|
||||
//
|
||||
|
||||
//
|
||||
//Common (C) Variables
|
||||
//
|
||||
extern float CLAasinTable[]; //The arcsine lookup table
|
||||
|
||||
//
|
||||
// Function Prototypes
|
||||
//
|
||||
// The following are symbols defined in the CLA assembly code
|
||||
// Including them in the shared header file makes them
|
||||
// .global and the main CPU can make use of them.
|
||||
//
|
||||
__interrupt void Cla1Task1();
|
||||
__interrupt void Cla1Task2();
|
||||
__interrupt void Cla1Task3();
|
||||
__interrupt void Cla1Task4();
|
||||
__interrupt void Cla1Task5();
|
||||
__interrupt void Cla1Task6();
|
||||
__interrupt void Cla1Task7();
|
||||
__interrupt void Cla1Task8();
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif // extern "C"
|
||||
|
||||
#endif //end of _CLA_ASIN_SHARED_H_ definition
|
||||
|
||||
//
|
||||
// End of file
|
||||
//
|
||||
@@ -0,0 +1,441 @@
|
||||
//###########################################################################
|
||||
//
|
||||
// FILE: cla_ex2_atan.c
|
||||
//
|
||||
// TITLE: CLA ArcTan Example for F2837xD.
|
||||
//
|
||||
//! \addtogroup driver_example_list
|
||||
//! <h1>CLA \f$arctangent(x)\f$ using a lookup table (cla_atan_cpu01)</h1>
|
||||
//!
|
||||
//! In this example, Task 1 of the CLA will calculate the arctangent of
|
||||
//! an input argument using a lookup table.
|
||||
//!
|
||||
//! Note that since this example does not use background CLA task, the compile
|
||||
//! flag cla_background_task is turned off for this project. Set this flag as
|
||||
//! on to enable background CLA task. The option is available in Project
|
||||
//! Properties -> C2000 Build -> C2000 Compiler -> Advanced Options -> Runtime
|
||||
//! Model Options.
|
||||
//!
|
||||
//! \b Memory \b Allocation \n
|
||||
//! - CLA1 Math Tables (RAMLS0)
|
||||
//! - CLAatan2Table - Lookup table
|
||||
//! - CLA1 to CPU Message RAM
|
||||
//! - fResult - Result of the lookup algorithm
|
||||
//! - CPU to CLA1 Message RAM
|
||||
//! - fNum - Numerator of sample input
|
||||
//! - fDen - Denominator of sample input
|
||||
//!
|
||||
//! \b Watch \b Variables \n
|
||||
//! - fVal - Argument to task 1
|
||||
//! - fResult - Result of \f$arctan(fVal)\f$
|
||||
//!
|
||||
//
|
||||
//###########################################################################
|
||||
//
|
||||
//
|
||||
//
|
||||
// C2000Ware v5.04.00.00
|
||||
//
|
||||
// Copyright (C) 2024 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 "driverlib.h"
|
||||
#include "device.h"
|
||||
#include "cla_ex2_atan_shared.h"
|
||||
#include "board.h"
|
||||
//
|
||||
// Defines
|
||||
//
|
||||
#define WAITSTEP asm(" RPT #255 || NOP")
|
||||
|
||||
//
|
||||
// Globals
|
||||
//
|
||||
|
||||
//
|
||||
//Task 1 (C) Variables
|
||||
// NOTE: Do not initialize the Message RAM variables globally, they will be
|
||||
// reset during the message ram initialization phase in the CLA memory
|
||||
// configuration routine
|
||||
//
|
||||
#ifdef __cplusplus
|
||||
|
||||
#pragma DATA_SECTION("CpuToCla1MsgRAM");
|
||||
float fVal;
|
||||
#pragma DATA_SECTION("CpuToCla1MsgRAM")
|
||||
float PIBYTWO;
|
||||
#pragma DATA_SECTION("Cla1ToCpuMsgRAM");
|
||||
float fResult;
|
||||
|
||||
#else
|
||||
|
||||
#pragma DATA_SECTION(fVal,"CpuToCla1MsgRAM");
|
||||
float fVal;
|
||||
#pragma DATA_SECTION(PIBYTWO,"CpuToCla1MsgRAM")
|
||||
float PIBYTWO = 1.570796327;
|
||||
#pragma DATA_SECTION(fResult,"Cla1ToCpuMsgRAM");
|
||||
float fResult;
|
||||
#endif //__cplusplus
|
||||
float y[BUFFER_SIZE];
|
||||
|
||||
//
|
||||
//Task 2 (C) Variables
|
||||
//
|
||||
|
||||
//
|
||||
//Task 3 (C) Variables
|
||||
//
|
||||
|
||||
//
|
||||
//Task 4 (C) Variables
|
||||
//
|
||||
|
||||
//
|
||||
//Task 5 (C) Variables
|
||||
//
|
||||
|
||||
//
|
||||
//Task 6 (C) Variables
|
||||
//
|
||||
|
||||
//
|
||||
//Task 7 (C) Variables
|
||||
//
|
||||
|
||||
//
|
||||
//Task 8 (C) Variables
|
||||
//
|
||||
|
||||
//
|
||||
//Common (C) Variables
|
||||
//The Exponential table
|
||||
//
|
||||
#ifdef __cplusplus
|
||||
#pragma DATA_SECTION("CLADataLS0")
|
||||
#else
|
||||
#pragma DATA_SECTION(CLAatan2Table,"CLADataLS0")
|
||||
#endif //__cplusplus
|
||||
float CLAatan2Table[]={
|
||||
0.000000000000, 1.000040679675, -0.007811069750,
|
||||
-0.000003807022, 1.000528067772, -0.023410345493,
|
||||
-0.000018968310, 1.001498568106, -0.038941197075,
|
||||
-0.000052831927, 1.002943680965, -0.054358563160,
|
||||
-0.000112417996, 1.004850785788, -0.069618206649,
|
||||
-0.000204295885, 1.007203293243, -0.084677028723,
|
||||
-0.000334469493, 1.009980843501, -0.099493367628,
|
||||
-0.000508272606, 1.013159547023, -0.114027278430,
|
||||
-0.000730276035, 1.016712263449, -0.128240790343,
|
||||
-0.001004207980, 1.020608913557, -0.142098138715,
|
||||
-0.001332888717, 1.024816818801, -0.155565969259,
|
||||
-0.001718180431, 1.029301062569, -0.168613512667,
|
||||
-0.002160952612, 1.034024867135, -0.181212728329,
|
||||
-0.002661063159, 1.038949980222, -0.193338416410,
|
||||
-0.003217354977, 1.044037065160, -0.204968298146,
|
||||
-0.003827667546, 1.049246088868, -0.216083064706,
|
||||
-0.004488862702, 1.054536702192, -0.226666395507,
|
||||
-0.005196863579, 1.059868607573, -0.236704947279,
|
||||
-0.005946705500, 1.065201909527, -0.246188315613,
|
||||
-0.006732597422, 1.070497443994, -0.255108971022,
|
||||
-0.007547992413, 1.075717083222, -0.263462171840,
|
||||
-0.008385665599, 1.080824013499, -0.271245856476,
|
||||
-0.009237797924, 1.085782983693, -0.278460517693,
|
||||
-0.010096064139, 1.090560523211, -0.285109061650,
|
||||
-0.010951723407, 1.095125128557, -0.291196654447,
|
||||
-0.011795711029, 1.099447418304, -0.296730558920,
|
||||
-0.012618729873, 1.103500256784, -0.301719964310,
|
||||
-0.013411340199, 1.107258847274, -0.306175811325,
|
||||
-0.014164046711, 1.110700795887, -0.310110614947,
|
||||
-0.014867381831, 1.113806147717, -0.313538287176,
|
||||
-0.015511984298, 1.116557397059, -0.316473961655,
|
||||
-0.016088672395, 1.118939473766, -0.318933821948,
|
||||
-0.016588511229, 1.120939707956, -0.320934934991,
|
||||
-0.017002873645, 1.122547775367, -0.322495091022,
|
||||
-0.017323494499, 1.123755625749, -0.323632651068,
|
||||
-0.017542518140, 1.124557396633, -0.324366402860,
|
||||
-0.017652539065, 1.124949314810, -0.324715425833,
|
||||
-0.017646635823, 1.124929587773, -0.324698965683,
|
||||
-0.017518398344, 1.124498287266, -0.324336318787,
|
||||
-0.017261948920, 1.123657226955, -0.323646726613,
|
||||
-0.016871957164, 1.122409836098, -0.322649280139,
|
||||
-0.016343649294, 1.120761030918, -0.321362834119,
|
||||
-0.015672812166, 1.118717085258, -0.319805931024,
|
||||
-0.014855792451, 1.116285501852, -0.317996734279,
|
||||
-0.013889491441, 1.113474885484, -0.315952970460,
|
||||
-0.012771355912, 1.110294819035, -0.313691879968,
|
||||
-0.011499365513, 1.106755743329, -0.311230175714,
|
||||
-0.010072017131, 1.102868841531, -0.308584009287,
|
||||
-0.008488306656, 1.098645928648, -0.305768944066,
|
||||
-0.006747708579, 1.094099346648, -0.302799934724,
|
||||
-0.004850153815, 1.089241865523, -0.299691312610,
|
||||
-0.002796006119, 1.084086590517, -0.296456776409,
|
||||
-0.000586037441, 1.078646875666, -0.293109387609,
|
||||
0.001778597452, 1.072936243727, -0.289661570229,
|
||||
0.004296386804, 1.066968312440, -0.286125114351,
|
||||
0.006965487894, 1.060756727064, -0.282511182960,
|
||||
0.009783753017, 1.054315099009, -0.278830321668,
|
||||
0.012748755207, 1.047656950440, -0.275092470943,
|
||||
0.015857813546, 1.040795664582, -0.271306980411,
|
||||
0.019108017893, 1.033744441476, -0.267482624928,
|
||||
0.022496252887, 1.026516258989, -0.263627622089,
|
||||
0.026019221162, 1.019123838651, -0.259749650860,
|
||||
0.029673465636, 1.011579616186, -0.255855871106,
|
||||
0.033455390838, 1.003895716322, -0.251952943763,
|
||||
0.037361283212, 0.996083931611, -0.248047051426
|
||||
};
|
||||
|
||||
float atan_expected[BUFFER_SIZE]={
|
||||
1.5395565, 1.5385494, 1.5374753, 1.5363272,
|
||||
1.5350972, 1.5337762, 1.5323538, 1.5308176,
|
||||
1.5291537, 1.5273454, 1.5253731, 1.5232133,
|
||||
1.5208379, 1.5182133, 1.5152978, 1.5120405,
|
||||
1.5083776, 1.5042281, 1.4994888, 1.4940244,
|
||||
1.4876550, 1.4801364, 1.4711276, 1.4601392,
|
||||
1.4464413, 1.4288993, 1.4056476, 1.3734008,
|
||||
1.3258177, 1.2490457, 1.1071488, 0.7853982,
|
||||
0.0000000, -0.7853982, -1.1071488, -1.2490457,
|
||||
-1.3258177, -1.3734008, -1.4056476, -1.4288993,
|
||||
-1.4464413, -1.4601392, -1.4711276, -1.4801364,
|
||||
-1.4876550, -1.4940244, -1.4994888, -1.5042281,
|
||||
-1.5083776, -1.5120405, -1.5152978, -1.5182133,
|
||||
-1.5208379, -1.5232133, -1.5253731, -1.5273454,
|
||||
-1.5291537, -1.5308176, -1.5323538, -1.5337762,
|
||||
-1.5350972, -1.5363272, -1.5374753, -1.5385494
|
||||
};
|
||||
|
||||
uint16_t pass = 0;
|
||||
uint16_t fail = 0;
|
||||
|
||||
//
|
||||
// Function Prototypes
|
||||
//
|
||||
void CLA_runTest(void);
|
||||
__interrupt void cla1Isr1();
|
||||
__interrupt void cla1Isr2();
|
||||
__interrupt void cla1Isr3();
|
||||
__interrupt void cla1Isr4();
|
||||
__interrupt void cla1Isr5();
|
||||
__interrupt void cla1Isr6();
|
||||
__interrupt void cla1Isr7();
|
||||
__interrupt void cla1Isr8();
|
||||
|
||||
//
|
||||
// Main
|
||||
//
|
||||
void main(void)
|
||||
{
|
||||
//
|
||||
// Initialize device clock and peripherals
|
||||
//
|
||||
Device_init();
|
||||
|
||||
//
|
||||
// Disable pin locks and enable internal pullups.
|
||||
//
|
||||
//Device_initGPIO(); //skipped for this example
|
||||
|
||||
//
|
||||
// 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();
|
||||
|
||||
//
|
||||
// Initialize resources
|
||||
//
|
||||
Board_init();
|
||||
|
||||
//
|
||||
// Enable Global Interrupts (INTM) and realtime interrupt (DGBM)
|
||||
//
|
||||
EINT;
|
||||
ERTM;
|
||||
|
||||
//
|
||||
// Run the test
|
||||
//
|
||||
CLA_runTest();
|
||||
|
||||
for(;;)
|
||||
{
|
||||
}
|
||||
}
|
||||
|
||||
//
|
||||
// CLA_runTest - Execute CLA task tests for specified vectors
|
||||
//
|
||||
void CLA_runTest(void)
|
||||
{
|
||||
int16_t i;
|
||||
float error;
|
||||
|
||||
//
|
||||
// Initialize the CPUToCLA1MsgRam variables here
|
||||
//
|
||||
PIBYTWO = 1.570796327;
|
||||
|
||||
for(i = 0; i < BUFFER_SIZE; i++)
|
||||
{
|
||||
fVal = (float)((BUFFER_SIZE/2) - i);
|
||||
|
||||
CLA_forceTasks(CLA1_BASE,CLA_TASKFLAG_1);
|
||||
WAITSTEP;
|
||||
y[i] = fResult;
|
||||
error = fabsf(atan_expected[i]-y[i]);
|
||||
|
||||
if(error < 0.001f)
|
||||
{
|
||||
pass++;
|
||||
}
|
||||
else
|
||||
{
|
||||
fail++;
|
||||
}
|
||||
}
|
||||
|
||||
#if 0
|
||||
|
||||
CLA_forceTasks(CLA1_BASE,CLA_TASKFLAG_2);
|
||||
WAITSTEP;
|
||||
|
||||
CLA_forceTasks(CLA1_BASE,CLA_TASKFLAG_3);
|
||||
WAITSTEP;
|
||||
|
||||
CLA_forceTasks(CLA1_BASE,CLA_TASKFLAG_4);
|
||||
WAITSTEP;
|
||||
|
||||
CLA_forceTasks(CLA1_BASE,CLA_TASKFLAG_5);
|
||||
WAITSTEP;
|
||||
|
||||
CLA_forceTasks(CLA1_BASE,CLA_TASKFLAG_6);
|
||||
WAITSTEP;
|
||||
|
||||
CLA_forceTasks(CLA1_BASE,CLA_TASKFLAG_7);
|
||||
WAITSTEP;
|
||||
|
||||
CLA_forceTasks(CLA1_BASE,CLA_TASKFLAG_8);
|
||||
WAITSTEP;
|
||||
#endif
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
//
|
||||
// cla1Isr1 - CLA1 ISR 1
|
||||
//
|
||||
__interrupt void cla1Isr1 ()
|
||||
{
|
||||
//
|
||||
// Acknowledge the end-of-task interrupt for task 1
|
||||
//
|
||||
Interrupt_clearACKGroup(INTERRUPT_ACK_GROUP11);
|
||||
|
||||
//
|
||||
// Uncomment to halt debugger and stop here
|
||||
//
|
||||
// asm(" ESTOP0");
|
||||
}
|
||||
|
||||
//
|
||||
// cla1Isr2 - CLA1 ISR 2
|
||||
//
|
||||
__interrupt void cla1Isr2 ()
|
||||
{
|
||||
asm(" ESTOP0");
|
||||
}
|
||||
|
||||
//
|
||||
// cla1Isr3 - CLA1 ISR 3
|
||||
//
|
||||
__interrupt void cla1Isr3 ()
|
||||
{
|
||||
asm(" ESTOP0");
|
||||
}
|
||||
|
||||
//
|
||||
// cla1Isr4 - CLA1 ISR 4
|
||||
//
|
||||
__interrupt void cla1Isr4 ()
|
||||
{
|
||||
asm(" ESTOP0");
|
||||
}
|
||||
|
||||
//
|
||||
// cla1Isr5 - CLA1 ISR 5
|
||||
//
|
||||
__interrupt void cla1Isr5 ()
|
||||
{
|
||||
asm(" ESTOP0");
|
||||
}
|
||||
|
||||
//
|
||||
// cla1Isr6 - CLA1 ISR 6
|
||||
//
|
||||
__interrupt void cla1Isr6 ()
|
||||
{
|
||||
asm(" ESTOP0");
|
||||
}
|
||||
|
||||
//
|
||||
// cla1Isr7 - CLA1 ISR 7
|
||||
//
|
||||
__interrupt void cla1Isr7 ()
|
||||
{
|
||||
asm(" ESTOP0");
|
||||
}
|
||||
|
||||
//
|
||||
// cla1Isr8 - CLA1 ISR 8
|
||||
//
|
||||
__interrupt void cla1Isr8 ()
|
||||
{
|
||||
//
|
||||
// Acknowledge the end-of-task interrupt for task 8
|
||||
//
|
||||
Interrupt_clearACKGroup(INTERRUPT_ACK_GROUP11);
|
||||
//
|
||||
// Uncomment to halt debugger and stop here
|
||||
//
|
||||
// asm(" ESTOP0");
|
||||
}
|
||||
|
||||
//
|
||||
// End of file
|
||||
//
|
||||
@@ -0,0 +1,19 @@
|
||||
|
||||
/**
|
||||
* Import the modules used in this configuration.
|
||||
*/
|
||||
const cla = scripting.addModule("/driverlib/cla.js", {}, false);
|
||||
const cla1 = cla.addInstance();
|
||||
const memcfg = scripting.addModule("/driverlib/memcfg.js");
|
||||
|
||||
/**
|
||||
* Write custom configuration values to the imported modules.
|
||||
*/
|
||||
cla1.$name = "myCLA0";
|
||||
|
||||
|
||||
memcfg.config_MEMCFG_SECT_LS5 = "CLA_prog";
|
||||
memcfg.config_MEMCFG_SECT_LS0 = "CLA_data";
|
||||
memcfg.config_MEMCFG_SECT_LS1 = "CLA_data";
|
||||
memcfg.init_MEMCFG_SECT_MSGCPUTOCLA1 = true;
|
||||
memcfg.init_MEMCFG_SECT_MSGCLA1TOCPU = true;
|
||||
@@ -0,0 +1,130 @@
|
||||
#ifndef _CLA_ATAN_SHARED_H_
|
||||
#define _CLA_ATAN_SHARED_H_
|
||||
//#############################################################################
|
||||
//
|
||||
// FILE: cla_ex2_atan_shared.h
|
||||
//
|
||||
// TITLE: CLA arctangent example header file.
|
||||
//
|
||||
//#############################################################################
|
||||
//
|
||||
// C2000Ware v5.04.00.00
|
||||
//
|
||||
// Copyright (C) 2024 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 <stdint.h>
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
//
|
||||
// Defines
|
||||
//
|
||||
#define BUFFER_SIZE 64
|
||||
#define TABLE_SIZE 64
|
||||
#define TABLE_SIZE_M_1 TABLE_SIZE-1
|
||||
#define INV2PI 0.159154943
|
||||
|
||||
//
|
||||
// Globals
|
||||
//
|
||||
|
||||
//
|
||||
//Task 1 (C) Variables
|
||||
//
|
||||
extern float y[]; //Result vector
|
||||
extern float fVal; //Holds the input argument to the task
|
||||
extern float fResult; //The arsine of the input argument
|
||||
|
||||
//
|
||||
//Task 2 (C) Variables
|
||||
//
|
||||
|
||||
//
|
||||
//Task 3 (C) Variables
|
||||
//
|
||||
|
||||
//
|
||||
//Task 4 (C) Variables
|
||||
//
|
||||
|
||||
//
|
||||
//Task 5 (C) Variables
|
||||
//
|
||||
|
||||
//
|
||||
//Task 6 (C) Variables
|
||||
//
|
||||
|
||||
//
|
||||
//Task 7 (C) Variables
|
||||
//
|
||||
|
||||
//
|
||||
//Task 8 (C) Variables
|
||||
//
|
||||
|
||||
//
|
||||
//Common (C) Variables
|
||||
//
|
||||
extern float PIBYTWO;
|
||||
extern float CLAatan2Table[];
|
||||
|
||||
//
|
||||
// Function Prototypes
|
||||
//
|
||||
// The following are symbols defined in the CLA assembly code
|
||||
// Including them in the shared header file makes them
|
||||
// .global and the main CPU can make use of them.
|
||||
//
|
||||
__interrupt void Cla1Task1();
|
||||
__interrupt void Cla1Task2();
|
||||
__interrupt void Cla1Task3();
|
||||
__interrupt void Cla1Task4();
|
||||
__interrupt void Cla1Task5();
|
||||
__interrupt void Cla1Task6();
|
||||
__interrupt void Cla1Task7();
|
||||
__interrupt void Cla1Task8();
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif // extern "C"
|
||||
|
||||
#endif //end of _CLA_ATAN_SHARED_H_ definition
|
||||
|
||||
//
|
||||
// End of file
|
||||
//
|
||||
@@ -0,0 +1,206 @@
|
||||
//#############################################################################
|
||||
//
|
||||
// FILE: cla_ex3_background_nesting_task.c
|
||||
//
|
||||
// TITLE: CLA background nesting task
|
||||
//
|
||||
//! \addtogroup driver_example_list
|
||||
//! <h1> CLA background nesting task </h1>
|
||||
//!
|
||||
//! This example configures CLA task 1 to be triggered by EPWM1 running at
|
||||
//! 2 Hz (period = 0.5s). A background task is configured to be triggered by CPU
|
||||
//! timer running at .5 Hz (period = 2s).
|
||||
//! CLA task 1 toggles LED1 at the start and end of the task and the background
|
||||
//! task toggles LED2 at the start and end of the task. Background task will be
|
||||
//! preempted by Task1 and hence LED1 will be toggling even while LED2 is ON.
|
||||
//!
|
||||
//! Note that the compile flag cla_background_task is turned on in this project.
|
||||
//! Enabling background task adds additional context save/restore cycles during
|
||||
//! task switching thus increasing the overall trigger-to-task latency.
|
||||
//! If the application does not use the background CLA task, it is recommended
|
||||
//! to turn this flag off for better performance.
|
||||
//! The option is available in Project Properties -> C2000 Build ->
|
||||
//! C2000 Compiler -> Advanced Options -> Runtime Model Options.
|
||||
//!
|
||||
//! \b External \b Connections \n
|
||||
//! - None
|
||||
//!
|
||||
//! \b Watch \b Variables \n
|
||||
//! - None
|
||||
//!
|
||||
//###########################################################################
|
||||
//
|
||||
// C2000Ware v5.04.00.00
|
||||
//
|
||||
// Copyright (C) 2024 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 "driverlib.h"
|
||||
#include "device.h"
|
||||
#include "cla_ex3_background_nesting_task_shared.h"
|
||||
#include "board.h"
|
||||
|
||||
//
|
||||
// Defines
|
||||
//
|
||||
#define EPWM_CLKDIV 1792UL
|
||||
#define EPWM1_FREQ 2UL
|
||||
#define EPWM1_PERIOD (uint16_t)(DEVICE_SYSCLK_FREQ /(2 * EPWM_CLKDIV * EPWM1_FREQ))
|
||||
|
||||
//
|
||||
// Defines
|
||||
//
|
||||
#define WAITSTEP __asm(" RPT #255||NOP")
|
||||
#define EPSILON 1e-1
|
||||
|
||||
//
|
||||
// Globals
|
||||
//
|
||||
|
||||
//
|
||||
// Function Prototypes
|
||||
//
|
||||
void initEPWM(void);
|
||||
|
||||
//
|
||||
// Main
|
||||
//
|
||||
void main(void)
|
||||
{
|
||||
//
|
||||
// Initialize device clock and peripherals
|
||||
//
|
||||
Device_init();
|
||||
|
||||
//
|
||||
// Disable pin locks and enable internal pullups.
|
||||
//
|
||||
Device_initGPIO();
|
||||
|
||||
//
|
||||
// Configure the LEDs
|
||||
//
|
||||
GPIO_setDirectionMode(DEVICE_GPIO_PIN_LED1, GPIO_DIR_MODE_OUT);
|
||||
GPIO_setDirectionMode(DEVICE_GPIO_PIN_LED2, GPIO_DIR_MODE_OUT);
|
||||
GPIO_setQualificationMode(DEVICE_GPIO_PIN_LED1, GPIO_QUAL_SYNC);
|
||||
GPIO_setQualificationMode(DEVICE_GPIO_PIN_LED2, GPIO_QUAL_SYNC);
|
||||
GPIO_setPinConfig(DEVICE_GPIO_CFG_LED1);
|
||||
GPIO_setPinConfig(DEVICE_GPIO_CFG_LED2);
|
||||
|
||||
GPIO_setControllerCore(DEVICE_GPIO_PIN_LED1, GPIO_CORE_CPU1_CLA1);
|
||||
GPIO_setControllerCore(DEVICE_GPIO_PIN_LED2, GPIO_CORE_CPU1_CLA1);
|
||||
|
||||
//
|
||||
// Initialize PIE and clear PIE registers. Disables CPU interrupts.
|
||||
//
|
||||
Interrupt_initModule();
|
||||
|
||||
// initialize CPU timers
|
||||
|
||||
// Initialize timer period : 2 seconds
|
||||
|
||||
CPUTimer_setPeriod(CPUTIMER1_BASE, DEVICE_SYSCLK_FREQ * 2);
|
||||
|
||||
// Initialize pre-scale counter to divide by 1 (SYSCLKOUT)
|
||||
CPUTimer_setPreScaler(CPUTIMER1_BASE, 0);
|
||||
// Make sure timer is stopped
|
||||
CPUTimer_stopTimer(CPUTIMER1_BASE);
|
||||
CPUTimer_setEmulationMode(CPUTIMER1_BASE,
|
||||
CPUTIMER_EMULATIONMODE_RUNFREE);
|
||||
// Enables CPU timer interrupt.
|
||||
CPUTimer_enableInterrupt(CPUTIMER1_BASE);
|
||||
// Starts(restarts) CPU timer.
|
||||
CPUTimer_startTimer(CPUTIMER1_BASE);
|
||||
|
||||
//
|
||||
// Initialize resources
|
||||
//
|
||||
Board_init();
|
||||
|
||||
//
|
||||
// Disable sync(Freeze clock to PWM as well)
|
||||
//
|
||||
SysCtl_disablePeripheral(SYSCTL_PERIPH_CLK_TBCLKSYNC);
|
||||
initEPWM();
|
||||
|
||||
//
|
||||
// Enable sync and clock to PWM
|
||||
//
|
||||
SysCtl_enablePeripheral(SYSCTL_PERIPH_CLK_TBCLKSYNC);
|
||||
|
||||
for(;;)
|
||||
{
|
||||
}
|
||||
}
|
||||
|
||||
//
|
||||
// EPWM Initialization
|
||||
//
|
||||
// Description: EPWM1A will run at EPWM1_FREQ Hz and trigger CLA Task1
|
||||
// The default time base for the EPWM module is half the system clock i.e.
|
||||
// TBCLK = SYSCLKOUT
|
||||
// EPWM1A will be setup in count-up mode and an event generated every period
|
||||
//
|
||||
void initEPWM(void)
|
||||
{
|
||||
//
|
||||
// Set up EPWM1 to
|
||||
// - run on a base clock of SYSCLK/128 / 14
|
||||
// - have a period of EPWM1_PERIOD
|
||||
// - run in count up mode
|
||||
//
|
||||
EPWM_setClockPrescaler(EPWM1_BASE, EPWM_CLOCK_DIVIDER_128,
|
||||
EPWM_HSCLOCK_DIVIDER_14);
|
||||
EPWM_setTimeBasePeriod(EPWM1_BASE, EPWM1_PERIOD);
|
||||
EPWM_setTimeBaseCounterMode(EPWM1_BASE, EPWM_COUNTER_MODE_UP);
|
||||
EPWM_setTimeBaseCounter(EPWM1_BASE, 0U);
|
||||
|
||||
//
|
||||
// Enable INT, generate INT on 1st event
|
||||
//
|
||||
EPWM_setInterruptSource(EPWM1_BASE, EPWM_INT_TBCTR_ZERO);
|
||||
EPWM_enableInterrupt(EPWM1_BASE);
|
||||
EPWM_setInterruptEventCount(EPWM1_BASE, 1U);
|
||||
|
||||
//
|
||||
// EPWM 1 should Stop when counter completes whole cycle in emulation mode
|
||||
//
|
||||
EPWM_setEmulationMode(EPWM1_BASE, EPWM_EMULATION_STOP_AFTER_FULL_CYCLE);
|
||||
}
|
||||
|
||||
|
||||
//
|
||||
// End of File
|
||||
//
|
||||
@@ -0,0 +1,31 @@
|
||||
|
||||
/**
|
||||
* Import the modules used in this configuration.
|
||||
*/
|
||||
const cla = scripting.addModule("/driverlib/cla.js", {}, false);
|
||||
const cla1 = cla.addInstance();
|
||||
const memcfg = scripting.addModule("/driverlib/memcfg.js");
|
||||
|
||||
/**
|
||||
* Write custom configuration values to the imported modules.
|
||||
*/
|
||||
cla1.$name = "myCLA0";
|
||||
cla1.trigger_CLA_TASK_1 = "CLA_TRIGGER_EPWM1INT";
|
||||
cla1.trigger_CLA_TASK_8 = "CLA_TRIGGER_TINT1";
|
||||
cla1.name_CLA_TASK_8 = "Cla1BackgroundTask";
|
||||
cla1.background_CLA_TASK_8 = true;
|
||||
cla1.cpuint_CLA_TASK_1 = false;
|
||||
cla1.cpuint_CLA_TASK_2 = false;
|
||||
cla1.cpuint_CLA_TASK_3 = false;
|
||||
cla1.cpuint_CLA_TASK_4 = false;
|
||||
cla1.cpuint_CLA_TASK_5 = false;
|
||||
cla1.cpuint_CLA_TASK_6 = false;
|
||||
cla1.cpuint_CLA_TASK_7 = false;
|
||||
cla1.cpuint_CLA_TASK_8 = false;
|
||||
|
||||
|
||||
memcfg.config_MEMCFG_SECT_LS5 = "CLA_prog";
|
||||
memcfg.config_MEMCFG_SECT_LS0 = "CLA_data";
|
||||
memcfg.config_MEMCFG_SECT_LS1 = "CLA_data";
|
||||
memcfg.init_MEMCFG_SECT_MSGCPUTOCLA1 = true;
|
||||
memcfg.init_MEMCFG_SECT_MSGCLA1TOCPU = true;
|
||||
@@ -0,0 +1,206 @@
|
||||
//#############################################################################
|
||||
//
|
||||
// FILE: cla_ex3_background_nesting_task_cla.cla
|
||||
//
|
||||
// TITLE: CLA Task1 nesting in a Background Task
|
||||
//
|
||||
// Task 1 turns on and turns off D1 every 0.5 seconds
|
||||
// Background task turns on and turns off D2 every 2 seconds
|
||||
// due to the nesting time of task 1, maybe longer for real period.
|
||||
|
||||
//#############################################################################
|
||||
//
|
||||
//
|
||||
//
|
||||
// C2000Ware v5.04.00.00
|
||||
//
|
||||
// Copyright (C) 2024 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 <stdint.h>
|
||||
#include "device.h"
|
||||
#include "cla_ex3_background_nesting_task_shared.h"
|
||||
#include "driverlib.h"
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
//
|
||||
// Task 1
|
||||
//
|
||||
//-----------------------------------------------------------------------------
|
||||
__attribute__((interrupt)) void Cla1Task1 ( void )
|
||||
{
|
||||
//
|
||||
// Turn on LED1
|
||||
//
|
||||
GPIO_writePin(DEVICE_GPIO_PIN_LED1, 0);
|
||||
|
||||
//__mdebugstop();
|
||||
int32_t i;
|
||||
for(i = 250000; i>=0; i--)
|
||||
{
|
||||
__asm(" MNOP");
|
||||
__asm(" MNOP");
|
||||
__asm(" MNOP");
|
||||
__asm(" MNOP");
|
||||
__asm(" MNOP");
|
||||
__asm(" MNOP");
|
||||
__asm(" MNOP");
|
||||
__asm(" MNOP");
|
||||
__asm(" MNOP");
|
||||
__asm(" MNOP");
|
||||
}
|
||||
|
||||
//
|
||||
// Turn off LED1
|
||||
//
|
||||
GPIO_writePin(DEVICE_GPIO_PIN_LED1, 1);
|
||||
|
||||
//
|
||||
// Clear EPWM interrupt flag
|
||||
//
|
||||
EPWM_clearEventTriggerInterruptFlag(EPWM1_BASE);
|
||||
}
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
//
|
||||
// Task 2 - Title Here
|
||||
//
|
||||
// Description: Description/steps here.
|
||||
//
|
||||
//-----------------------------------------------------------------------------
|
||||
__attribute__((interrupt)) void Cla1Task2 ( void )
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
//
|
||||
// Task 3 - Title Here
|
||||
//
|
||||
// Description: Description/steps here.
|
||||
//
|
||||
//-----------------------------------------------------------------------------
|
||||
__attribute__((interrupt)) void Cla1Task3 ( void )
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
//
|
||||
// Task 4 - Title Here
|
||||
//
|
||||
// Description: Description/steps here.
|
||||
//
|
||||
//-----------------------------------------------------------------------------
|
||||
__attribute__((interrupt)) void Cla1Task4 ( void )
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
//
|
||||
// Task 5 - Title Here
|
||||
//
|
||||
// Description: Description/steps here.
|
||||
//
|
||||
//-----------------------------------------------------------------------------
|
||||
__attribute__((interrupt)) void Cla1Task5 ( void )
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
//
|
||||
// Task 6 - Title Here
|
||||
//
|
||||
// Description: Description/steps here.
|
||||
//
|
||||
//-----------------------------------------------------------------------------
|
||||
__attribute__((interrupt)) void Cla1Task6 ( void )
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
//
|
||||
// Task 7 - One Time Initialization Task
|
||||
//
|
||||
// Description: This task will clear out the delay line and reset the index
|
||||
// and any flags
|
||||
//
|
||||
//-----------------------------------------------------------------------------
|
||||
__attribute__((interrupt)) void Cla1Task7 ( void )
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
//
|
||||
// Background Task
|
||||
//
|
||||
//-----------------------------------------------------------------------------
|
||||
__attribute__((interrupt("background"))) void Cla1BackgroundTask ( void )
|
||||
{
|
||||
//
|
||||
// Turn on LED2
|
||||
//
|
||||
GPIO_writePin(DEVICE_GPIO_PIN_LED2, 0);
|
||||
|
||||
__mdebugstop();
|
||||
int32_t i;
|
||||
|
||||
for(i = 2000000; i>=0; i--)
|
||||
{
|
||||
__asm(" MNOP");
|
||||
__asm(" MNOP");
|
||||
__asm(" MNOP");
|
||||
__asm(" MNOP");
|
||||
__asm(" MNOP");
|
||||
__asm(" MNOP");
|
||||
__asm(" MNOP");
|
||||
__asm(" MNOP");
|
||||
__asm(" MNOP");
|
||||
__asm(" MNOP");
|
||||
}
|
||||
|
||||
//
|
||||
// Turn off LED2
|
||||
//
|
||||
GPIO_writePin(DEVICE_GPIO_PIN_LED2, 1);
|
||||
}
|
||||
|
||||
//
|
||||
// End of File
|
||||
//
|
||||
+103
@@ -0,0 +1,103 @@
|
||||
//#############################################################################
|
||||
//
|
||||
// FILE: cla_ex3_background_nesting_task_shared.h
|
||||
//
|
||||
// TITLE: CLA ADC Sampling and Filtering with Buffering in a Background Task
|
||||
//
|
||||
// This header file contains defines, variables and prototypes that are shared
|
||||
// among the C28x and the CLA
|
||||
//
|
||||
//#############################################################################
|
||||
//
|
||||
//
|
||||
//
|
||||
// C2000Ware v5.04.00.00
|
||||
//
|
||||
// Copyright (C) 2024 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 _CLA_EX3_BACKGROUND_NESTING_TASK_H_
|
||||
#define _CLA_EX3_BACKGROUND_NESTING_TASK_H_
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
//
|
||||
// Included Files
|
||||
//
|
||||
|
||||
//
|
||||
// Globals
|
||||
//
|
||||
//Task 1 (C) Variables
|
||||
|
||||
//Task 2 (C) Variables
|
||||
|
||||
//Task 3 (C) Variables
|
||||
|
||||
//Task 4 (C) Variables
|
||||
|
||||
//Task 5 (C) Variables
|
||||
|
||||
//Task 6 (C) Variables
|
||||
|
||||
//Task 7 (C) Variables
|
||||
|
||||
//Background Task (C) Variables
|
||||
|
||||
//Common (C) Variables
|
||||
|
||||
//
|
||||
// Function Prototypes
|
||||
//
|
||||
//CLA C Tasks defined in Cla1Tasks_C.cla
|
||||
__attribute__((interrupt)) void Cla1Task1();
|
||||
__attribute__((interrupt)) void Cla1Task2();
|
||||
__attribute__((interrupt)) void Cla1Task3();
|
||||
__attribute__((interrupt)) void Cla1Task4();
|
||||
__attribute__((interrupt)) void Cla1Task5();
|
||||
__attribute__((interrupt)) void Cla1Task6();
|
||||
__attribute__((interrupt)) void Cla1Task7();
|
||||
#if defined(__TMS320C28XX__)
|
||||
__attribute__((interrupt)) void Cla1BackgroundTask();
|
||||
#else
|
||||
__attribute__((interrupt("background"))) void Cla1BackgroundTask();
|
||||
#endif
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif // extern "C"
|
||||
#endif //_CLA_EX3_BACKGROUND_NESTING_TASK_H_
|
||||
|
||||
//
|
||||
// End of File
|
||||
//
|
||||
@@ -0,0 +1,225 @@
|
||||
//#############################################################################
|
||||
//
|
||||
// FILE: cla_ex4_pwm_control.c
|
||||
//
|
||||
// TITLE: Controlling PWM output using CLA
|
||||
//
|
||||
//! \addtogroup driver_example_list
|
||||
//! <h1> Controlling PWM output using CLA </h1>
|
||||
//!
|
||||
//! This example showcases how to update PWM signal output using CLA.
|
||||
//! EPWM1 is configured to generate complementary signals on both of its
|
||||
//! channels of fixed frequency 100 KHz. EPWM4 is configured to trigger
|
||||
//! a periodic CLA control task of frequency 10 KHz. The CLA task implements
|
||||
//! a very simple logic to vary the duty of the EPWM1 outputs by increasing it
|
||||
//! by 0.1 in every iteration and maintaining it in the range of 0.1-0.9. For
|
||||
//! actual use-cases, the control logic could be modified to much more complex
|
||||
//! depending upon the application. The other CLA task (CLA task 8) is
|
||||
//! triggered by software at beginning to initialize the CLA global variables
|
||||
//!
|
||||
//! \b External \b Connections \n
|
||||
//! - Observe GPIO0 (EPWM1A) on oscilloscope
|
||||
//! - Observe GPIO1 (EPWM1B) on oscilloscope
|
||||
//!
|
||||
//! \b Watch \b Variables \n
|
||||
//! - duty
|
||||
//!
|
||||
//
|
||||
//#############################################################################
|
||||
//
|
||||
//
|
||||
//
|
||||
// C2000Ware v5.04.00.00
|
||||
//
|
||||
// Copyright (C) 2024 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 <cla_ex4_pwm_control_shared.h>
|
||||
#include "driverlib.h"
|
||||
#include "device.h"
|
||||
#include "board.h"
|
||||
|
||||
//
|
||||
// Function Prototypes
|
||||
//
|
||||
void initEPWM(void);
|
||||
void initCLA(void);
|
||||
|
||||
//
|
||||
// Main
|
||||
//
|
||||
void main(void)
|
||||
{
|
||||
//
|
||||
// Initialize device clock and peripherals
|
||||
//
|
||||
Device_init();
|
||||
|
||||
//
|
||||
// Disable pin locks and enable internal pullups.
|
||||
//
|
||||
Device_initGPIO();
|
||||
|
||||
//
|
||||
// GPIO0 is set to EPWM1A
|
||||
// GPIO1 is set to EPWM1B
|
||||
//
|
||||
GPIO_setControllerCore(0, GPIO_CORE_CPU1);
|
||||
GPIO_setPadConfig(0,GPIO_PIN_TYPE_STD);
|
||||
GPIO_setPinConfig(GPIO_0_EPWM1A);
|
||||
GPIO_setControllerCore(1, GPIO_CORE_CPU1);
|
||||
GPIO_setPadConfig(1,GPIO_PIN_TYPE_STD);
|
||||
GPIO_setPinConfig(GPIO_1_EPWM1B);
|
||||
|
||||
//
|
||||
// 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();
|
||||
|
||||
//
|
||||
// Disable sync(Freeze clock to PWM as well)
|
||||
//
|
||||
SysCtl_disablePeripheral(SYSCTL_PERIPH_CLK_TBCLKSYNC);
|
||||
|
||||
//
|
||||
// Initialize EPWM module
|
||||
//
|
||||
initEPWM();
|
||||
|
||||
//
|
||||
// Initialize resources
|
||||
//
|
||||
Board_init();
|
||||
initCLA();
|
||||
|
||||
//
|
||||
// Enable global interrupts.
|
||||
//
|
||||
EINT;
|
||||
|
||||
//
|
||||
// Enable sync and clock to PWM
|
||||
//
|
||||
SysCtl_enablePeripheral(SYSCTL_PERIPH_CLK_TBCLKSYNC);
|
||||
|
||||
for(;;)
|
||||
{
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
//
|
||||
// EPWM Initialization
|
||||
// EPWM1 : generates output of frequency EPWM1_FREQ (100 KHz)
|
||||
// EPWM4 : Triggers CLA task at frequency EPWM4_FREQ (10 KHz)
|
||||
//
|
||||
void initEPWM(void)
|
||||
{
|
||||
//
|
||||
// Set up EPWM1 to
|
||||
// - run on a base clock of SYSCLK
|
||||
// - have a period of EPWM1_PERIOD
|
||||
// - run in count up-down mode
|
||||
//
|
||||
EPWM_setClockPrescaler(EPWM1_BASE, EPWM_CLOCK_DIVIDER_1,
|
||||
EPWM_HSCLOCK_DIVIDER_1);
|
||||
EPWM_setTimeBasePeriod(EPWM1_BASE, EPWM1_PERIOD);
|
||||
EPWM_setCounterCompareValue(EPWM1_BASE, EPWM_COUNTER_COMPARE_A, EPWM1_PERIOD/10U);
|
||||
EPWM_setTimeBaseCounterMode(EPWM1_BASE, EPWM_COUNTER_MODE_UP_DOWN);
|
||||
EPWM_setTimeBaseCounter(EPWM1_BASE, 0U);
|
||||
|
||||
//
|
||||
// Configuring action-qualifiers for EPWM1 to generate symmetric
|
||||
// and complementary outputs on channel A and B
|
||||
//
|
||||
EPWM_setActionQualifierAction(EPWM1_BASE, EPWM_AQ_OUTPUT_A,
|
||||
EPWM_AQ_OUTPUT_LOW, EPWM_AQ_OUTPUT_ON_TIMEBASE_UP_CMPA);
|
||||
EPWM_setActionQualifierAction(EPWM1_BASE, EPWM_AQ_OUTPUT_A,
|
||||
EPWM_AQ_OUTPUT_HIGH, EPWM_AQ_OUTPUT_ON_TIMEBASE_DOWN_CMPA);
|
||||
EPWM_setActionQualifierAction(EPWM1_BASE, EPWM_AQ_OUTPUT_B,
|
||||
EPWM_AQ_OUTPUT_HIGH, EPWM_AQ_OUTPUT_ON_TIMEBASE_UP_CMPA);
|
||||
EPWM_setActionQualifierAction(EPWM1_BASE, EPWM_AQ_OUTPUT_B,
|
||||
EPWM_AQ_OUTPUT_LOW, EPWM_AQ_OUTPUT_ON_TIMEBASE_DOWN_CMPA);
|
||||
|
||||
//
|
||||
// Enabling Counter Compare shadow mode
|
||||
//
|
||||
EPWM_setCounterCompareShadowLoadMode(EPWM1_BASE, EPWM_COUNTER_COMPARE_A, EPWM_COMP_LOAD_ON_SYNC_CNTR_ZERO);
|
||||
|
||||
//
|
||||
// Set up EPWM4 to
|
||||
// - run on a base clock of SYSCLK
|
||||
// - have a period of EPWM4_PERIOD
|
||||
// - run in count up mode
|
||||
EPWM_setClockPrescaler(EPWM4_BASE, EPWM_CLOCK_DIVIDER_1,
|
||||
EPWM_HSCLOCK_DIVIDER_1);
|
||||
EPWM_setTimeBasePeriod(EPWM4_BASE, EPWM4_PERIOD);
|
||||
EPWM_setTimeBaseCounterMode(EPWM4_BASE, EPWM_COUNTER_MODE_UP);
|
||||
EPWM_setTimeBaseCounter(EPWM4_BASE, 0U);
|
||||
|
||||
//
|
||||
// Enabling EPWM4 interrupt at TBCTR = 0 to trigger
|
||||
// CLA task
|
||||
//
|
||||
EPWM_setInterruptSource(EPWM4_BASE, EPWM_INT_TBCTR_ZERO);
|
||||
EPWM_enableInterrupt(EPWM4_BASE);
|
||||
EPWM_setInterruptEventCount(EPWM4_BASE, 1U);
|
||||
|
||||
//
|
||||
// EPWM 1 and 4 should run freely in emulation mode
|
||||
//
|
||||
EPWM_setEmulationMode(EPWM1_BASE, EPWM_EMULATION_FREE_RUN);
|
||||
EPWM_setEmulationMode(EPWM4_BASE, EPWM_EMULATION_FREE_RUN);
|
||||
}
|
||||
|
||||
//
|
||||
// CLA Initialization
|
||||
//
|
||||
void initCLA(void)
|
||||
{
|
||||
//
|
||||
// Force task 8, the one time initialization task
|
||||
//
|
||||
CLA_forceTasks(CLA1_BASE, CLA_TASKFLAG_8);
|
||||
}
|
||||
|
||||
|
||||
@@ -0,0 +1,28 @@
|
||||
|
||||
/**
|
||||
* Import the modules used in this configuration.
|
||||
*/
|
||||
const cla = scripting.addModule("/driverlib/cla.js", {}, false);
|
||||
const cla1 = cla.addInstance();
|
||||
const memcfg = scripting.addModule("/driverlib/memcfg.js");
|
||||
|
||||
/**
|
||||
* Write custom configuration values to the imported modules.
|
||||
*/
|
||||
cla1.$name = "myCLA0";
|
||||
cla1.cpuint_CLA_TASK_1 = false;
|
||||
cla1.cpuint_CLA_TASK_2 = false;
|
||||
cla1.cpuint_CLA_TASK_3 = false;
|
||||
cla1.cpuint_CLA_TASK_4 = false;
|
||||
cla1.cpuint_CLA_TASK_5 = false;
|
||||
cla1.cpuint_CLA_TASK_6 = false;
|
||||
cla1.cpuint_CLA_TASK_7 = false;
|
||||
cla1.cpuint_CLA_TASK_8 = false;
|
||||
cla1.trigger_CLA_TASK_1 = "CLA_TRIGGER_EPWM4INT";
|
||||
|
||||
|
||||
memcfg.config_MEMCFG_SECT_LS5 = "CLA_prog";
|
||||
memcfg.config_MEMCFG_SECT_LS0 = "CLA_data";
|
||||
memcfg.config_MEMCFG_SECT_LS1 = "CLA_data";
|
||||
memcfg.init_MEMCFG_SECT_MSGCPUTOCLA1 = true;
|
||||
memcfg.init_MEMCFG_SECT_MSGCLA1TOCPU = true;
|
||||
@@ -0,0 +1,192 @@
|
||||
//#############################################################################
|
||||
//
|
||||
// FILE: cla_ex4_pwm_control_cla.cla
|
||||
//
|
||||
// TITLE: Controlling PWM output using CLA
|
||||
//
|
||||
// Task 8 initializes the global variables for CLA
|
||||
//
|
||||
// Task 1 implements control logic to update duty value of PWM output
|
||||
//
|
||||
//#############################################################################
|
||||
//
|
||||
//
|
||||
//
|
||||
// C2000Ware v5.04.00.00
|
||||
//
|
||||
// Copyright (C) 2024 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 <cla_ex4_pwm_control_shared.h>
|
||||
#include <stdint.h>
|
||||
#include "epwm.h"
|
||||
|
||||
|
||||
|
||||
//
|
||||
// Globals
|
||||
//
|
||||
// Note that the globals defined in the .cla source are global to the cla source
|
||||
// file. i.e. they may be shared across tasks. But they cannot be assigned an
|
||||
// initialized value here. To do so, one-time initialization task is used that
|
||||
// is triggered by software at the beginning
|
||||
//
|
||||
// Duty value
|
||||
float duty ;
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
//
|
||||
// Task 1 - PWM control loop
|
||||
//
|
||||
// Description: PWM control logic can be implemented here.
|
||||
//
|
||||
//-----------------------------------------------------------------------------
|
||||
__attribute__((interrupt)) void Cla1Task1 ( void )
|
||||
{
|
||||
//
|
||||
// Uncomment this to debug the CLA while connected to the debugger
|
||||
//
|
||||
//__mdebugstop();
|
||||
|
||||
//
|
||||
// Write to the COMPA register to realize a particular duty value
|
||||
//
|
||||
EPWM_setCounterCompareValue(EPWM1_BASE, EPWM_COUNTER_COMPARE_A,
|
||||
(uint16_t)(duty * EPWM1_PERIOD + 0.5f));
|
||||
|
||||
//
|
||||
// Update duty value and use the limiter
|
||||
//
|
||||
duty += 0.1f;
|
||||
duty = (duty > 0.9f) ? 0.1f : duty;
|
||||
|
||||
//
|
||||
// Clear EPWM4 interrupt flag so that next interrupt can come in
|
||||
//
|
||||
EPWM_clearEventTriggerInterruptFlag(EPWM4_BASE);
|
||||
}
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
//
|
||||
// Task 2 - Title Here
|
||||
//
|
||||
// Description: Description/steps here.
|
||||
//
|
||||
//-----------------------------------------------------------------------------
|
||||
__attribute__((interrupt)) void Cla1Task2 ( void )
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
//
|
||||
// Task 3 - Title Here
|
||||
//
|
||||
// Description: Description/steps here.
|
||||
//
|
||||
//-----------------------------------------------------------------------------
|
||||
__attribute__((interrupt)) void Cla1Task3 ( void )
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
//
|
||||
// Task 4 - Title Here
|
||||
//
|
||||
// Description: Description/steps here.
|
||||
//
|
||||
//-----------------------------------------------------------------------------
|
||||
__attribute__((interrupt)) void Cla1Task4 ( void )
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
//
|
||||
// Task 5 - Title Here
|
||||
//
|
||||
// Description: Description/steps here.
|
||||
//
|
||||
//-----------------------------------------------------------------------------
|
||||
__attribute__((interrupt)) void Cla1Task5 ( void )
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
//
|
||||
// Task 6 - Title Here
|
||||
//
|
||||
// Description: Description/steps here.
|
||||
//
|
||||
//-----------------------------------------------------------------------------
|
||||
__attribute__((interrupt)) void Cla1Task6 ( void )
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
//
|
||||
// Task 7 - Title Here
|
||||
//
|
||||
// Description: Description/steps here.
|
||||
//
|
||||
//-----------------------------------------------------------------------------
|
||||
__attribute__((interrupt)) void Cla1Task7 ( void )
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
//
|
||||
// Task 8 - One Time Initialization Task
|
||||
//
|
||||
// Description: This task will initialize the CLA global variables
|
||||
//
|
||||
//-----------------------------------------------------------------------------
|
||||
__attribute__((interrupt)) void Cla1Task8 ( void )
|
||||
{
|
||||
//
|
||||
// Uncomment this to debug the CLA while connected to the debugger
|
||||
//
|
||||
//__mdebugstop();
|
||||
|
||||
duty = 0.1f;
|
||||
}
|
||||
|
||||
//
|
||||
// End of File
|
||||
//
|
||||
@@ -0,0 +1,111 @@
|
||||
//#############################################################################
|
||||
//
|
||||
// FILE: cla_ex4_pwm_control_shared.h
|
||||
//
|
||||
// TITLE: Controlling PWM output using CLA
|
||||
//
|
||||
// This header file contains defines, variables and prototypes that are shared
|
||||
// among the C28x and the CLA
|
||||
//
|
||||
//#############################################################################
|
||||
//
|
||||
//
|
||||
//
|
||||
// C2000Ware v5.04.00.00
|
||||
//
|
||||
// Copyright (C) 2024 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 _CLA_EX4_PWMCONTROL_SHARED_H_
|
||||
#define _CLA_EX4_PWMCONTROL_SHARED_H_
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
//
|
||||
// Included Files
|
||||
//
|
||||
#include "driverlib.h"
|
||||
#include "device.h"
|
||||
|
||||
//
|
||||
// Defines
|
||||
//
|
||||
#define EPWM1_FREQ 100000UL // 100 KHz
|
||||
#define EPWM4_FREQ 10000UL // 10 KHz
|
||||
#define EPWM1_PERIOD (uint16_t)(DEVICE_SYSCLK_FREQ / (2 * 2 * EPWM1_FREQ))
|
||||
#define EPWM4_PERIOD (uint16_t)(DEVICE_SYSCLK_FREQ / (2 * EPWM4_FREQ))
|
||||
|
||||
//
|
||||
// Globals
|
||||
//
|
||||
//Task 1 (C) Variables
|
||||
extern float duty;
|
||||
|
||||
//Task 2 (C) Variables
|
||||
|
||||
//Task 3 (C) Variables
|
||||
|
||||
//Task 4 (C) Variables
|
||||
|
||||
//Task 5 (C) Variables
|
||||
|
||||
//Task 6 (C) Variables
|
||||
|
||||
//Task 7 (C) Variables
|
||||
|
||||
//Task 8 (C) Variables
|
||||
|
||||
//Common (C) Variables
|
||||
|
||||
|
||||
//
|
||||
// Function Prototypes
|
||||
//
|
||||
__attribute__((interrupt)) void Cla1Task1();
|
||||
__attribute__((interrupt)) void Cla1Task2();
|
||||
__attribute__((interrupt)) void Cla1Task3();
|
||||
__attribute__((interrupt)) void Cla1Task4();
|
||||
__attribute__((interrupt)) void Cla1Task5();
|
||||
__attribute__((interrupt)) void Cla1Task6();
|
||||
__attribute__((interrupt)) void Cla1Task7();
|
||||
__attribute__((interrupt)) void Cla1Task8();
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif // extern "C"
|
||||
#endif //_CLA_EX4_PWMCONTROL_SHARED_H_
|
||||
|
||||
//
|
||||
// End of File
|
||||
//
|
||||
@@ -0,0 +1,337 @@
|
||||
//#############################################################################
|
||||
//
|
||||
// FILE: cla_ex5_adc_just_in_time.c
|
||||
//
|
||||
// TITLE: Just-in-time ADC sampling with CLA
|
||||
//
|
||||
//! \addtogroup driver_example_list
|
||||
//! <h1> Just-in-time ADC sampling with CLA </h1>
|
||||
//!
|
||||
//! This example showcases how to utilize early-interrupt feature of ADC
|
||||
//! in combination with the low interrupt response of CLA to enable faster
|
||||
//! system response and achieve high frequency control loops. EPWM1 is
|
||||
//! configured to generate a PWM output signal of frequency 1 MHz and this
|
||||
//! is also used to trigger the ADC sampling at each cycle. ADCA is
|
||||
//! configured to sample the input on Channel 0 and to generate the early
|
||||
//! interrupt at the end of S/H + offset cycles. This interrupt is used to
|
||||
//! trigger the CLA control task. The CLA task implements the control logic
|
||||
//! to update the duty of the PWM output based on reading the ADC sample data
|
||||
//! just-in-time i.e. as soon as the ADC results gets latched.The early
|
||||
//! interrupt feature and low interrupt latency of CLA allows to do some
|
||||
//! pre-processing as well before reading the ADC data and still completes
|
||||
//! updating the PWM output before the next interrupts comes in i.e. data read
|
||||
//! and PWM update is done within a 1 MHz cycle. For illustration purposes,
|
||||
//! 3-point moving average filter is used to simulate some processing and few
|
||||
//! steps of the filtering code are done before reading the ADC result which
|
||||
//! we consider as pre-processing code. The ADC interrupt offset is programmed
|
||||
//! based on the cycles consumed by the pre-processing code.
|
||||
//!
|
||||
//! The calculation for interrupt offset value is as follows :-
|
||||
//! -ADC acquisition cycles programmed = 10 SYSCLKS
|
||||
//! -Conversion time for 12-bit data = 10.5 ADCCLKS = N = 42 SYSCLKS
|
||||
//! -CLA task trigger to first instruction in Fetch delay = 4
|
||||
//! -Let the interrupt offset value be 'x'
|
||||
//! -The code inside CLA control task before ADC read takes below cycles :
|
||||
//! Setting up profiling gpio : 3 cycles
|
||||
//! Pre-processing : 13 cycles
|
||||
//! Total = 3 + 13 = 16 cycles
|
||||
//!
|
||||
//! As described in device TRM, in order to read just-in-time the total delay
|
||||
//! before reading ADC should be (N-2) cycles = 40 i.e.
|
||||
//! : x + 4 + 16 = 40
|
||||
//! : x = 20
|
||||
//!
|
||||
//! NOTE :- The optimization is off for this project and the cycles quoted above
|
||||
//! corresponds to that case.
|
||||
//!
|
||||
//! GPIO2 is used for profiling purposes. GPIO2 is set at the beginning of
|
||||
//! CLA task 1 and is reset at the end of the task. Thus ON time of GPIO2
|
||||
//! indicates the CLA activity. In order to validate the example functionality
|
||||
//! , observe the GPIO0 (PWM output) and GPIO2 (profiling GPIO) on CRO.
|
||||
//! The cycles difference between the rising edge of the GPIO0 and GPIO2
|
||||
//! indicate the total delay from the time of ADC trigger to setting up of
|
||||
//! profiling GPIO inside CLA task which should be around 44 cycles (220 ns)
|
||||
//! based on the above calculation.
|
||||
//!
|
||||
//! \b External \b Connections \n
|
||||
//! - Provide constant DC input on ADCA0 for quick validation.
|
||||
//! GND -> Should observe PWM output duty = 0.1
|
||||
//! 3.3V -> Should observe PWM output duty = 0.9
|
||||
//! Can also provide analog input in range 0 - 3.3V upto fs / 10 = 100 KHz for
|
||||
//! observing continuous duty variations
|
||||
//!
|
||||
//! - Observe GPIO0 on oscilloscope
|
||||
//! - Observe GPIO2 on oscilloscope
|
||||
//!
|
||||
//! \b Watch \b Variables \n
|
||||
//! - None
|
||||
//!
|
||||
//
|
||||
//#############################################################################
|
||||
//
|
||||
//
|
||||
//
|
||||
// C2000Ware v5.04.00.00
|
||||
//
|
||||
// Copyright (C) 2024 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 "driverlib.h"
|
||||
#include "device.h"
|
||||
#include "cla_ex5_adc_just_in_time_shared.h"
|
||||
#include "board.h"
|
||||
|
||||
//
|
||||
// Function Prototypes
|
||||
//
|
||||
void initEPWM(void);
|
||||
void initCLA(void);
|
||||
void initADC(void);
|
||||
void initADCSOC(void);
|
||||
void setupProfileGpio(void);
|
||||
__attribute__((interrupt)) void cla1Isr1(void);
|
||||
|
||||
//
|
||||
// Main
|
||||
//
|
||||
void main(void)
|
||||
{
|
||||
//
|
||||
// Initialize device clock and peripherals
|
||||
//
|
||||
Device_init();
|
||||
|
||||
//
|
||||
// Disable pin locks and enable internal pullups.
|
||||
//
|
||||
Device_initGPIO();
|
||||
|
||||
//
|
||||
// GPIO0 is set to EPWM1A
|
||||
//
|
||||
GPIO_setControllerCore(0, GPIO_CORE_CPU1);
|
||||
GPIO_setPadConfig(0,GPIO_PIN_TYPE_STD);
|
||||
GPIO_setPinConfig(GPIO_0_EPWM1A);
|
||||
|
||||
//
|
||||
// GPIO2 is configured as output and CLA is assigned its controller
|
||||
//
|
||||
setupProfileGpio();
|
||||
|
||||
//
|
||||
// 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();
|
||||
|
||||
//
|
||||
// Initialize resources
|
||||
//
|
||||
Board_init();
|
||||
initCLA();
|
||||
|
||||
//
|
||||
// Disable sync(Freeze clock to PWM as well)
|
||||
//
|
||||
SysCtl_disablePeripheral(SYSCTL_PERIPH_CLK_TBCLKSYNC);
|
||||
|
||||
//
|
||||
// Initialize EPWM1 module
|
||||
//
|
||||
initEPWM();
|
||||
|
||||
//
|
||||
// Initialize ADC
|
||||
//
|
||||
initADC();
|
||||
initADCSOC();
|
||||
|
||||
//
|
||||
// Enable global interrupts.
|
||||
//
|
||||
EINT;
|
||||
|
||||
//
|
||||
// Enable sync and clock to PWM
|
||||
//
|
||||
SysCtl_enablePeripheral(SYSCTL_PERIPH_CLK_TBCLKSYNC);
|
||||
|
||||
for(;;)
|
||||
{
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
// ADC Initialization
|
||||
//
|
||||
// Function to configure and power up ADC A
|
||||
//
|
||||
void initADC(void)
|
||||
{
|
||||
//
|
||||
// Set ADCCLK divider to /4
|
||||
//
|
||||
ADC_setPrescaler(ADCA_BASE, ADC_CLK_DIV_4_0);
|
||||
|
||||
//
|
||||
// Set pulse positions to late
|
||||
//
|
||||
ADC_setInterruptPulseMode(ADCA_BASE, ADC_PULSE_END_OF_ACQ_WIN);
|
||||
|
||||
//
|
||||
// Set interrupt offset delay as 20 cycles based on the calculation
|
||||
// shown in example header
|
||||
//
|
||||
ADC_setInterruptCycleOffset(ADCA_BASE, 20);
|
||||
|
||||
//
|
||||
// Power up the ADCs and then delay for 1 ms
|
||||
//
|
||||
ADC_enableConverter(ADCA_BASE);
|
||||
|
||||
DEVICE_DELAY_US(1000);
|
||||
}
|
||||
|
||||
//
|
||||
// ADC SOC Initialization
|
||||
//
|
||||
// Description: This function will configure the ADC, channel A0 to start
|
||||
// its conversion on a trigger from EPWM1 (EPMW1SOCA). The ADC will sample this
|
||||
// channel continuously. After each conversion it will assert ADCINT1, which
|
||||
// is then used to trigger task 1 of the CLA
|
||||
//
|
||||
void initADCSOC(void)
|
||||
{
|
||||
//
|
||||
// Configure SOC0 of ADCA
|
||||
// - SOC0 will be triggered by EPWM1SOCA
|
||||
// - SOC0 will convert pin A0 with a sample window of 10 SYSCLK cycles.
|
||||
// - EOC0 will be generated at the end of conversion
|
||||
// - SOC0 will sample on each trigger regardless of the interrupt flag
|
||||
//
|
||||
ADC_setupSOC(ADCA_BASE, ADC_SOC_NUMBER0, ADC_TRIGGER_EPWM1_SOCA,
|
||||
ADC_CH_ADCIN0, 10);
|
||||
ADC_enableContinuousMode(ADCA_BASE, ADC_INT_NUMBER1);
|
||||
|
||||
//
|
||||
// Set SOC0 to set the interrupt 1 flag. Enable the interrupt and make
|
||||
// sure its flag is cleared.
|
||||
//
|
||||
ADC_setInterruptSource(ADCA_BASE, ADC_INT_NUMBER1, ADC_SOC_NUMBER0);
|
||||
ADC_enableInterrupt(ADCA_BASE, ADC_INT_NUMBER1);
|
||||
ADC_clearInterruptStatus(ADCA_BASE, ADC_INT_NUMBER1);
|
||||
}
|
||||
|
||||
//
|
||||
// EPWM Initialization
|
||||
//
|
||||
// Description: EPWM1A will run at EPWM1_FREQ (1 MHz) and is used to generate
|
||||
// the PWM output. It also serves as the sampling clock for ADC channel A0
|
||||
// The default time base for the EPWM module is half the system clock
|
||||
//
|
||||
void initEPWM(void)
|
||||
{
|
||||
//
|
||||
// Set up EPWM1 to
|
||||
// - run on a base clock of SYSCLK
|
||||
// - have a period of EPWM1_PERIOD
|
||||
// - run in count up mode
|
||||
// - initialize the COMPA register to realize 0.1 duty
|
||||
//
|
||||
EPWM_setClockPrescaler(EPWM1_BASE, EPWM_CLOCK_DIVIDER_1,
|
||||
EPWM_HSCLOCK_DIVIDER_1);
|
||||
EPWM_setTimeBasePeriod(EPWM1_BASE, EPWM1_PERIOD - 1U);
|
||||
EPWM_setCounterCompareValue(EPWM1_BASE, EPWM_COUNTER_COMPARE_A, (0.1f * EPWM1_PERIOD));
|
||||
EPWM_setTimeBaseCounterMode(EPWM1_BASE, EPWM_COUNTER_MODE_UP);
|
||||
EPWM_setTimeBaseCounter(EPWM1_BASE, 0U);
|
||||
|
||||
//
|
||||
// Configuring action-qualifiers for EPWM1
|
||||
//
|
||||
EPWM_setActionQualifierAction(EPWM1_BASE, EPWM_AQ_OUTPUT_A,
|
||||
EPWM_AQ_OUTPUT_LOW, EPWM_AQ_OUTPUT_ON_TIMEBASE_UP_CMPA);
|
||||
EPWM_setActionQualifierAction(EPWM1_BASE, EPWM_AQ_OUTPUT_A,
|
||||
EPWM_AQ_OUTPUT_HIGH, EPWM_AQ_OUTPUT_ON_TIMEBASE_ZERO);
|
||||
|
||||
//
|
||||
// Enabling Shadow mode
|
||||
//
|
||||
EPWM_setCounterCompareShadowLoadMode(EPWM1_BASE, EPWM_COUNTER_COMPARE_A,
|
||||
EPWM_COMP_LOAD_ON_SYNC_CNTR_ZERO);
|
||||
|
||||
//
|
||||
// Enable SOC-A and set it to assert when the counter hits
|
||||
// zero. It asserts on every event
|
||||
//
|
||||
EPWM_enableADCTrigger(EPWM1_BASE, EPWM_SOC_A);
|
||||
EPWM_setADCTriggerSource(EPWM1_BASE, EPWM_SOC_A, EPWM_SOC_TBCTR_ZERO);
|
||||
EPWM_setADCTriggerEventPrescale(EPWM1_BASE, EPWM_SOC_A, 1U);
|
||||
|
||||
//
|
||||
// EPWM 1 should run freely in emulation mode
|
||||
//
|
||||
EPWM_setEmulationMode(EPWM1_BASE, EPWM_EMULATION_FREE_RUN);
|
||||
|
||||
}
|
||||
|
||||
//
|
||||
// CLA Initialization
|
||||
//
|
||||
//
|
||||
void initCLA(void)
|
||||
{
|
||||
//
|
||||
// Force task 8, the one time initialization task to initialize
|
||||
// the CLA global variables
|
||||
//
|
||||
CLA_forceTasks(CLA1_BASE, CLA_TASKFLAG_8);
|
||||
}
|
||||
|
||||
//
|
||||
// Setting up GPIO2 for profiling and set CLA as its controller
|
||||
//
|
||||
void setupProfileGpio(void)
|
||||
{
|
||||
GPIO_setDirectionMode(2,GPIO_DIR_MODE_OUT);
|
||||
GPIO_setQualificationMode(2,GPIO_QUAL_SYNC);
|
||||
GPIO_setPinConfig(GPIO_2_GPIO2);
|
||||
GPIO_writePin(2,0);
|
||||
GPIO_setControllerCore(2, GPIO_CORE_CPU1_CLA1);
|
||||
}
|
||||
@@ -0,0 +1,28 @@
|
||||
|
||||
/**
|
||||
* Import the modules used in this configuration.
|
||||
*/
|
||||
const cla = scripting.addModule("/driverlib/cla.js", {}, false);
|
||||
const cla1 = cla.addInstance();
|
||||
const memcfg = scripting.addModule("/driverlib/memcfg.js");
|
||||
|
||||
/**
|
||||
* Write custom configuration values to the imported modules.
|
||||
*/
|
||||
cla1.$name = "myCLA0";
|
||||
cla1.cpuint_CLA_TASK_1 = false;
|
||||
cla1.cpuint_CLA_TASK_2 = false;
|
||||
cla1.cpuint_CLA_TASK_3 = false;
|
||||
cla1.cpuint_CLA_TASK_4 = false;
|
||||
cla1.cpuint_CLA_TASK_5 = false;
|
||||
cla1.cpuint_CLA_TASK_6 = false;
|
||||
cla1.cpuint_CLA_TASK_7 = false;
|
||||
cla1.cpuint_CLA_TASK_8 = false;
|
||||
cla1.trigger_CLA_TASK_1 = "CLA_TRIGGER_ADCA1";
|
||||
|
||||
|
||||
memcfg.config_MEMCFG_SECT_LS5 = "CLA_prog";
|
||||
memcfg.config_MEMCFG_SECT_LS0 = "CLA_data";
|
||||
memcfg.config_MEMCFG_SECT_LS1 = "CLA_data";
|
||||
memcfg.init_MEMCFG_SECT_MSGCPUTOCLA1 = true;
|
||||
memcfg.init_MEMCFG_SECT_MSGCLA1TOCPU = true;
|
||||
@@ -0,0 +1,226 @@
|
||||
//#############################################################################
|
||||
//
|
||||
// FILE: cla_ex5_adc_just_in_time_cla.cla
|
||||
//
|
||||
// TITLE: Just-in-time ADC sampling with CLA
|
||||
//
|
||||
// Task 1 reads ADC result, do filtering and updates the duty of PWM output
|
||||
//
|
||||
//
|
||||
// Task 8 initializes the global variables used in CLA
|
||||
//
|
||||
//#############################################################################
|
||||
//
|
||||
//
|
||||
//
|
||||
// C2000Ware v5.04.00.00
|
||||
//
|
||||
// Copyright (C) 2024 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 <stdint.h>
|
||||
#include "cla_ex5_adc_just_in_time_shared.h"
|
||||
|
||||
//
|
||||
// Globals
|
||||
//
|
||||
float duty ; // duty of PWM output
|
||||
//
|
||||
// Variables used to read ADC result and implement 3-point filter
|
||||
//
|
||||
uint16_t data_read, data_read_prev, data_read_prev2, data_read_total;
|
||||
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
//
|
||||
// Task 1
|
||||
//
|
||||
// Description : Task 1 reads the ADC result just-in-time and implements a
|
||||
// 3-point moving average filter on it. The filtered output is used to compute
|
||||
// the duty value based on linear conversion in the range of 0.1-0.9
|
||||
//
|
||||
//-----------------------------------------------------------------------------
|
||||
__attribute__((interrupt)) void Cla1Task1 ( void )
|
||||
{
|
||||
//
|
||||
// Setting Profiling GPIO2 : Takes 3 cycles
|
||||
//
|
||||
HWREG(GPIODATA_BASE + GPIO_O_GPASET) = 4;
|
||||
|
||||
//
|
||||
// Uncomment this to debug the CLA while connected to the debugger
|
||||
//
|
||||
//__mdebugstop();
|
||||
|
||||
//
|
||||
// Pre-processing for implementing moving average filter, takes 13 cycles
|
||||
// This is just to illustrate how cycles can be utilized to do some pre-
|
||||
// processing before ADC result latches. Based on the cycles taken by
|
||||
// pre-processing code, ADC interrupt offset need to be programmed
|
||||
//
|
||||
data_read_total = data_read + data_read_prev;
|
||||
data_read_prev2 = data_read_prev;
|
||||
data_read_prev = data_read;
|
||||
|
||||
//
|
||||
// Reading ADC just-in-time
|
||||
//
|
||||
data_read = HWREGH(ADCARESULT_BASE + ADC_RESULTx_OFFSET_BASE + ADC_SOC_NUMBER0);
|
||||
|
||||
//
|
||||
// "data_read_total" stores the cumulative sum of current and last 2 data elements
|
||||
//
|
||||
data_read_total += data_read;
|
||||
|
||||
//
|
||||
// Taking average of 3 elements, normalizing for 12-bit and mapping to output duty
|
||||
// linearly in the range 0.1-0.9
|
||||
// duty = 0.1 + (0.9-0.1) * ((data_read_total / 3) / 2^12 )
|
||||
//
|
||||
duty = 0.1f + (data_read_total / (15360.0f));
|
||||
|
||||
//
|
||||
// Writing to the COMPA register for realizing computed duty value
|
||||
//
|
||||
__meallow();
|
||||
HWREGH(EPWM1_BASE + EPWM_O_CMPA + 0x1U) = (uint16_t)(duty * EPWM1_PERIOD + 0.5f);
|
||||
__medis();
|
||||
|
||||
//
|
||||
// Resetting Profiling GPIO2
|
||||
//
|
||||
HWREG(GPIODATA_BASE + GPIO_O_GPACLEAR) = 4;
|
||||
}
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
//
|
||||
// Task 2 - Title Here
|
||||
//
|
||||
// Description: Description/steps here.
|
||||
//
|
||||
//-----------------------------------------------------------------------------
|
||||
__attribute__((interrupt)) void Cla1Task2 ( void )
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
//
|
||||
// Task 3 - Title Here
|
||||
//
|
||||
// Description: Description/steps here.
|
||||
//
|
||||
//-----------------------------------------------------------------------------
|
||||
__attribute__((interrupt)) void Cla1Task3 ( void )
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
//
|
||||
// Task 4 - Title Here
|
||||
//
|
||||
// Description: Description/steps here.
|
||||
//
|
||||
//-----------------------------------------------------------------------------
|
||||
__attribute__((interrupt)) void Cla1Task4 ( void )
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
//
|
||||
// Task 5 - Title Here
|
||||
//
|
||||
// Description: Description/steps here.
|
||||
//
|
||||
//-----------------------------------------------------------------------------
|
||||
__attribute__((interrupt)) void Cla1Task5 ( void )
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
//
|
||||
// Task 6 - Title Here
|
||||
//
|
||||
// Description: Description/steps here.
|
||||
//
|
||||
//-----------------------------------------------------------------------------
|
||||
__attribute__((interrupt)) void Cla1Task6 ( void )
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
//
|
||||
// Task 7 - Title Here
|
||||
//
|
||||
// Description: Description/steps here.
|
||||
//
|
||||
//-----------------------------------------------------------------------------
|
||||
__attribute__((interrupt)) void Cla1Task7 ( void )
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
//
|
||||
// Task 8 - One Time Initialization Task
|
||||
//
|
||||
// Description: This task initialize the CLA global variables used in Task 1
|
||||
//
|
||||
//-----------------------------------------------------------------------------
|
||||
__attribute__((interrupt)) void Cla1Task8 ( void )
|
||||
{
|
||||
|
||||
//
|
||||
// Uncomment this to debug the CLA while connected to the debugger
|
||||
//
|
||||
//__mdebugstop();
|
||||
|
||||
//
|
||||
// Initializing CLA global variables
|
||||
//
|
||||
data_read = 0;
|
||||
data_read_total = 0;
|
||||
data_read_prev = 0;
|
||||
data_read_prev2 = 0;
|
||||
duty = 0.1f;
|
||||
}
|
||||
|
||||
//
|
||||
// End of File
|
||||
//
|
||||
@@ -0,0 +1,108 @@
|
||||
//#############################################################################
|
||||
//
|
||||
// FILE: cla_ex5_adc_just_in_time_shared.h
|
||||
//
|
||||
// TITLE: Just-in-time ADC sampling with CLA
|
||||
//
|
||||
// This header file contains defines, variables and prototypes that are shared
|
||||
// among the C28x and the CLA
|
||||
//
|
||||
//#############################################################################
|
||||
//
|
||||
//
|
||||
//
|
||||
// C2000Ware v5.04.00.00
|
||||
//
|
||||
// Copyright (C) 2024 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 _CLA_EX5_ADCJUSTINTIME_SHARED_H_
|
||||
#define _CLA_EX5_ADCJUSTINTIME_SHARED_H_
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
//
|
||||
// Included Files
|
||||
//
|
||||
#include "driverlib.h"
|
||||
#include "device.h"
|
||||
|
||||
//
|
||||
// Defines
|
||||
//
|
||||
#define EPWM1_FREQ 1000000UL // 1 MHz
|
||||
#define EPWM1_PERIOD (uint16_t)(DEVICE_SYSCLK_FREQ / (2 * EPWM1_FREQ))
|
||||
|
||||
//
|
||||
// Globals
|
||||
//
|
||||
//Task 1 (C) Variables
|
||||
|
||||
//Task 2 (C) Variables
|
||||
|
||||
//Task 3 (C) Variables
|
||||
|
||||
//Task 4 (C) Variables
|
||||
|
||||
//Task 5 (C) Variables
|
||||
|
||||
//Task 6 (C) Variables
|
||||
|
||||
//Task 7 (C) Variables
|
||||
|
||||
//Task 8 (C) Variables
|
||||
|
||||
//Common (C) Variables
|
||||
|
||||
|
||||
//
|
||||
// Function Prototypes
|
||||
//
|
||||
__attribute__((interrupt)) void Cla1Task1();
|
||||
__attribute__((interrupt)) void Cla1Task2();
|
||||
__attribute__((interrupt)) void Cla1Task3();
|
||||
__attribute__((interrupt)) void Cla1Task4();
|
||||
__attribute__((interrupt)) void Cla1Task5();
|
||||
__attribute__((interrupt)) void Cla1Task6();
|
||||
__attribute__((interrupt)) void Cla1Task7();
|
||||
__attribute__((interrupt)) void Cla1Task8();
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif // extern "C"
|
||||
#endif //_CLA_EX5_ADCJUSTINTIME_SHARED_H_
|
||||
|
||||
//
|
||||
// End of File
|
||||
//
|
||||
@@ -0,0 +1,651 @@
|
||||
//#############################################################################
|
||||
//
|
||||
// FILE: cla_ex6_cpu_offloading.c
|
||||
//
|
||||
// TITLE: Optimal offloading of control algorithms to CLA
|
||||
//
|
||||
//! \addtogroup driver_example_list
|
||||
//! <h1> Optimal offloading of control algorithms to CLA </h1>
|
||||
//!
|
||||
//! This example showcases how to optimally offload the control algorithms from
|
||||
//! CPU to CLA in order to meet the system requirements. In this example, two
|
||||
//! control loops are simulated, the faster one (loop1) running at 200 KHz
|
||||
//! and the slower one (loop2) running at 20 KHz. Loop1 senses the first
|
||||
//! parameter at ADCA Channel 0, runs the PI controller to achieve the target
|
||||
//! and contributes to the duty of EPWM1A output with 80% weightage. Loop2
|
||||
//! senses the second parameter at ADCB Channel 2, runs the PI controller and
|
||||
//! contributes to the duty of EPWM1A output with 20% weightage. It is important
|
||||
//! to note that since these are just software simulated control loops but there
|
||||
//! is no actual physical process involved and hence updating the duty is not going
|
||||
//! to have any affect on sampled inputs. ADCA is configured to oversample the first
|
||||
//! parameter using SOCs 0-3 to suppress the noise and similarly ADCB is used to
|
||||
//! oversample the second parameter. EPWM4 and EPWM5 are configured to trigger the
|
||||
//! ADCA and ADCB sampling at loop1 and loop2 frequencies respectively. Once the
|
||||
//! conversion of all 4 SOCs complete, a CPU ISR or a CLA task is triggered based on
|
||||
//! the user-configuration. There is also a background task running in the main loop
|
||||
//! which disables the entire system including PWM output and the control loops when
|
||||
//! "system_OFF" is set to 1. The system gets enabled again once "system_OFF" is
|
||||
//! restored back to 0. By default system_OFF is set to 0 but it's value can be updated
|
||||
//! dynamically by adding it to expression window and writing to it. DCL library is
|
||||
//! included in the project to make use of optimal PI controllers used in both the loops.
|
||||
//! User-configurable pre-defined symbol "run_loop1_cla" has been added to the project
|
||||
//! options in order to specify whether to run the loop1 on C28x or CLA. GPIO2 and GPIO3
|
||||
//! are used to profile the execution of loop1 and loop2.
|
||||
//!
|
||||
//!
|
||||
//! For run_loop1_cla == 0 i.e. both loops running on CPU
|
||||
//!
|
||||
//! -> Loop1 Utilization = ~77.5% (measured using profiling GPIO2)
|
||||
//! -> Loop2 Utilization = ~6% (measured using profiling GPIO3)
|
||||
//! -> Background task in a while loop
|
||||
//! -> Total CPU utilization is greater than Utilization bound (UB)
|
||||
//! Hence the system is non-schedulable, lower priority task (Loop2)
|
||||
//! execution never completes (no toggling observed on GPIO3)
|
||||
//! and also background task never gets chance to execute
|
||||
//!
|
||||
//!
|
||||
//! For run_loop1_cla == 1 i.e. high frequency control loop (loop1) is offloaded
|
||||
//! to CLA while loop2 runs on CPU
|
||||
//!
|
||||
//! -> Loop1 Utilization (CLA) = ~73%
|
||||
//! -> Loop2 Utilization (CPU)= ~6%
|
||||
//! -> Total CPU utilization has come down to just ~6%
|
||||
//! Hence the system is perfectly schedulable, no miss happens for any
|
||||
//! of the loops and offloading of loop1 to CLA saves CPU bandwidth to
|
||||
//! execute background tasks as well
|
||||
//!
|
||||
//!
|
||||
//! For quick inspection of the example functionality, constant DC HIGH/LOW inputs
|
||||
//! can be provided to the analog channels instead of varying analog voltages. The
|
||||
//! target value for both the loops are set as some intermediate value i.e. 3500
|
||||
//! corresponds to ~2.8V. Now since the sensed inputs are constant and not same
|
||||
//! as target so the controller outputs will get saturated soon to either 1
|
||||
//! or 0. Thus the "duty" variable can take only fixed values based on the
|
||||
//! equations used in the loops. Infact the duty output would be very intutive,
|
||||
//! for instance if both inputs are LOW(GND), the controller will try to produce
|
||||
//! the maximum duty as the target is higher than sensed value hence the duty should
|
||||
//! be 1.0(0.2 + 0.8) but will get saturated to 0.9(the maximum value defined). Similarly
|
||||
//! if both inputs are made HIGH, the duty will be 0.1 (the minimum saturation value
|
||||
//! defined). The final duty table is shown below :
|
||||
//!
|
||||
//!
|
||||
//! \b External \b Connections \n
|
||||
//! - Observe GPIO2 (Loop1 Profiling) on oscilloscope
|
||||
//! - Observe GPIO3 (Loop2 Profiling) on oscilloscope
|
||||
//! - Observe GPIO0 (EPWM1A Output) on oscilloscope
|
||||
//!
|
||||
//! - Provide constant HIGH(3.3V)/LOW(0V) on both ADCA Ch0 and ADCB Ch2
|
||||
//! for quick validation, the following duty value should be observable
|
||||
//! at EPWM1A for various combinations if the system is perfectly
|
||||
//! schedulable i.e. both loops gets chance to execute properly :-
|
||||
//!
|
||||
//! A0 B2 duty
|
||||
//! GND GND 0.9
|
||||
//! 3.3V GND 0.2
|
||||
//! GND 3.3V 0.8
|
||||
//! 3.3V 3.3V 0.1
|
||||
//!
|
||||
//! Note :- The optimization is OFF for this project and all the profiling data
|
||||
//! quoted above corresponds to this case.
|
||||
//!
|
||||
//
|
||||
//#############################################################################
|
||||
//
|
||||
//
|
||||
//
|
||||
// C2000Ware v5.04.00.00
|
||||
//
|
||||
// Copyright (C) 2024 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 <cla_ex6_cpu_offloading_shared.h>
|
||||
#include "DCLF32.h"
|
||||
#include "board.h"
|
||||
|
||||
bool system_OFF = false; // Input used to shut down the system
|
||||
bool shut_down_flag = false; // Shut down status flag
|
||||
|
||||
//
|
||||
// Allocate all the below shared variables across C28x and CLA to a
|
||||
// "cla_shared" section. This section is allocated to RAMLS1 in linker
|
||||
// cmd file
|
||||
//
|
||||
#pragma SET_DATA_SECTION("cla_shared")
|
||||
volatile reference ref_data = {3500,3500}; // Target digital values for loops
|
||||
volatile sensed sense_data = {0,0}; // ADC sensed data for both loops
|
||||
volatile control_out control_out_data = {0.0,0.0}; // Outputs of controllers
|
||||
#if run_loop1_cla == 1
|
||||
volatile DCL_PI_CLA pi_loop1 = PI_CLA_DEFAULTS; // Controller definition
|
||||
#else
|
||||
volatile DCL_PI pi_loop1 = PI_DEFAULTS;
|
||||
#endif
|
||||
volatile DCL_PI pi_loop2 = PI_DEFAULTS;
|
||||
volatile float32_t duty = 0.0f, duty_loop1 = 0.0f, duty_loop2 = 0.0f; // Denotes duty of EPWM1 output
|
||||
#pragma SET_DATA_SECTION() // Reset section to default
|
||||
|
||||
//
|
||||
// Function Prototypes
|
||||
//
|
||||
void initEPWM(void);
|
||||
void setupADCSOC_trigger(void);
|
||||
void initADC(void);
|
||||
void initADCSOC(void);
|
||||
void controller_initialize(void);
|
||||
void setuploop1ProfileGpio(void);
|
||||
void setuploop2ProfileGpio(void);
|
||||
|
||||
|
||||
#if run_loop1_cla == 0
|
||||
#if defined(_FLASH)
|
||||
#pragma CODE_SECTION(loop1ISR,".TI.ramfunc");
|
||||
#endif
|
||||
__interrupt void loop1ISR(void);
|
||||
#endif
|
||||
#if defined(_FLASH)
|
||||
#pragma CODE_SECTION(loop2ISR,".TI.ramfunc");
|
||||
#endif
|
||||
__interrupt void loop2ISR(void);
|
||||
|
||||
|
||||
//
|
||||
// Main
|
||||
//
|
||||
void main(void)
|
||||
{
|
||||
//
|
||||
// Initialize device clock and peripherals
|
||||
//
|
||||
Device_init();
|
||||
|
||||
//
|
||||
// Disable pin locks and enable internal pullups.
|
||||
//
|
||||
Device_initGPIO();
|
||||
|
||||
//
|
||||
// GPIO0 is set to EPWM1A
|
||||
//
|
||||
GPIO_setControllerCore(0, GPIO_CORE_CPU1);
|
||||
GPIO_setPadConfig(0,GPIO_PIN_TYPE_STD);
|
||||
GPIO_setPinConfig(GPIO_0_EPWM1A);
|
||||
|
||||
//
|
||||
// Setup Profiling GPIOs for loop1 and loop2
|
||||
//
|
||||
setuploop1ProfileGpio();
|
||||
setuploop2ProfileGpio();
|
||||
|
||||
//
|
||||
// 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();
|
||||
|
||||
//
|
||||
// Disable sync(Freeze clock to PWM as well)
|
||||
//
|
||||
SysCtl_disablePeripheral(SYSCTL_PERIPH_CLK_TBCLKSYNC);
|
||||
|
||||
//
|
||||
// Set up ADCA and ADCB, initialize the SOsC and configure EPWM4 and EPWM5
|
||||
// as trigger sources
|
||||
//
|
||||
initADC();
|
||||
initADCSOC();
|
||||
setupADCSOC_trigger();
|
||||
|
||||
//
|
||||
// Initialize EPWM1 module to generate the PWM waveform
|
||||
//
|
||||
initEPWM();
|
||||
|
||||
//
|
||||
// Initialize the PI controllers with the desired constants for
|
||||
// both the loops
|
||||
//
|
||||
controller_initialize();
|
||||
|
||||
#if run_loop1_cla == 1
|
||||
//
|
||||
// Setup the CLA if loop1 is offloaded to CLA
|
||||
//
|
||||
Board_init();
|
||||
#endif
|
||||
|
||||
//
|
||||
// Register the ADC interrupts for the control loops
|
||||
//
|
||||
#if run_loop1_cla == 0U
|
||||
Interrupt_register(INT_ADCA1, &loop1ISR);
|
||||
#endif
|
||||
Interrupt_register(INT_ADCB1, &loop2ISR);
|
||||
|
||||
//
|
||||
// Enable ADCA and ADCB interrupts
|
||||
//
|
||||
#if run_loop1_cla == 0U
|
||||
Interrupt_enable(INT_ADCA1);
|
||||
#endif
|
||||
Interrupt_enable(INT_ADCB1);
|
||||
|
||||
//
|
||||
// Enable global interrupts.
|
||||
//
|
||||
EINT;
|
||||
|
||||
//
|
||||
// Enable sync and clock to PWM
|
||||
//
|
||||
SysCtl_enablePeripheral(SYSCTL_PERIPH_CLK_TBCLKSYNC);
|
||||
|
||||
for(;;)
|
||||
{
|
||||
if(system_OFF == true)
|
||||
{
|
||||
//
|
||||
// Force One-shot Trip EPWM1A output and disable the
|
||||
// control loops if it's not already shut down
|
||||
//
|
||||
if (shut_down_flag == false)
|
||||
{
|
||||
EPWM_forceTripZoneEvent(EPWM1_BASE, EPWM_TZ_FORCE_EVENT_OST);
|
||||
ADC_disableInterrupt(ADCB_BASE, ADC_INT_NUMBER1);
|
||||
#if run_loop1_cla == 0U
|
||||
ADC_disableInterrupt(ADCA_BASE, ADC_INT_NUMBER1);
|
||||
#else
|
||||
CLA_disableTasks(CLA1_BASE, CLA_TASKFLAG_1);
|
||||
#endif
|
||||
shut_down_flag = true;
|
||||
}
|
||||
}
|
||||
|
||||
else
|
||||
{
|
||||
//
|
||||
// Clear the one-shot trip for EPWM1 and enable the control
|
||||
// loops back only if it's shut down
|
||||
//
|
||||
if (shut_down_flag == true)
|
||||
{
|
||||
EPWM_clearTripZoneFlag(EPWM1_BASE, EPWM_TZ_FLAG_OST);
|
||||
ADC_enableInterrupt(ADCB_BASE, ADC_INT_NUMBER1);
|
||||
#if run_loop1_cla == 0U
|
||||
ADC_enableInterrupt(ADCA_BASE, ADC_INT_NUMBER1);
|
||||
#else
|
||||
CLA_enableTasks(CLA1_BASE, CLA_TASKFLAG_1);
|
||||
#endif
|
||||
shut_down_flag = false;
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
//
|
||||
// ADCA and ADCB initialization
|
||||
// Function to configure and power up ADCs
|
||||
//
|
||||
void initADC(void)
|
||||
{
|
||||
//
|
||||
// Set ADCCLK divider to /4
|
||||
//
|
||||
ADC_setPrescaler(ADCA_BASE, ADC_CLK_DIV_4_0);
|
||||
ADC_setPrescaler(ADCB_BASE, ADC_CLK_DIV_4_0);
|
||||
|
||||
//
|
||||
// Set pulse positions to late
|
||||
//
|
||||
ADC_setInterruptPulseMode(ADCA_BASE, ADC_PULSE_END_OF_CONV);
|
||||
ADC_setInterruptPulseMode(ADCB_BASE, ADC_PULSE_END_OF_CONV);
|
||||
|
||||
//
|
||||
// Power up the ADCs and then delay for 1 ms
|
||||
//
|
||||
ADC_enableConverter(ADCA_BASE);
|
||||
ADC_enableConverter(ADCB_BASE);
|
||||
|
||||
DEVICE_DELAY_US(1000);
|
||||
}
|
||||
|
||||
//
|
||||
// ADCA and ADCB SOC Initialization
|
||||
//
|
||||
// Description: ADCA and ADCB will oversample the Ch0 and Ch2 inputs
|
||||
// on reception of a trigger from EPWM4 (EPMW4SOCA) and EPWM5 (EPMW5SOCA).
|
||||
// Both ADCs are configured to sample the channels continuously.
|
||||
//
|
||||
void initADCSOC(void)
|
||||
{
|
||||
//
|
||||
// First input parameter oversampling configuration using ADCA
|
||||
// - SOC0 will convert pin A0 with a sample window of 10 SYSCLK cycles.
|
||||
// - SOC1 will convert pin A0 with a sample window of 10 SYSCLK cycles.
|
||||
// - SOC2 will convert pin A0 with a sample window of 10 SYSCLK cycles.
|
||||
// - SOC3 will convert pin A0 with a sample window of 10 SYSCLK cycles.
|
||||
//
|
||||
ADC_setupSOC(ADCA_BASE, ADC_SOC_NUMBER0, ADC_TRIGGER_EPWM4_SOCA,
|
||||
ADC_CH_ADCIN0, 10);
|
||||
ADC_setupSOC(ADCA_BASE, ADC_SOC_NUMBER1, ADC_TRIGGER_EPWM4_SOCA,
|
||||
ADC_CH_ADCIN0, 10);
|
||||
ADC_setupSOC(ADCA_BASE, ADC_SOC_NUMBER2, ADC_TRIGGER_EPWM4_SOCA,
|
||||
ADC_CH_ADCIN0, 10);
|
||||
ADC_setupSOC(ADCA_BASE, ADC_SOC_NUMBER3, ADC_TRIGGER_EPWM4_SOCA,
|
||||
ADC_CH_ADCIN0, 10);
|
||||
|
||||
//
|
||||
// Second input parameter oversampling configuration using ADCB
|
||||
// - SOC0 will convert pin B2 with a sample window of 10 SYSCLK cycles.
|
||||
// - SOC1 will convert pin B2 with a sample window of 10 SYSCLK cycles.
|
||||
// - SOC2 will convert pin B2 with a sample window of 10 SYSCLK cycles.
|
||||
// - SOC3 will convert pin B2 with a sample window of 10 SYSCLK cycles.
|
||||
//
|
||||
ADC_setupSOC(ADCB_BASE, ADC_SOC_NUMBER0, ADC_TRIGGER_EPWM5_SOCA,
|
||||
ADC_CH_ADCIN2, 10);
|
||||
ADC_setupSOC(ADCB_BASE, ADC_SOC_NUMBER1, ADC_TRIGGER_EPWM5_SOCA,
|
||||
ADC_CH_ADCIN2, 10);
|
||||
ADC_setupSOC(ADCB_BASE, ADC_SOC_NUMBER2, ADC_TRIGGER_EPWM5_SOCA,
|
||||
ADC_CH_ADCIN2, 10);
|
||||
ADC_setupSOC(ADCB_BASE, ADC_SOC_NUMBER3, ADC_TRIGGER_EPWM5_SOCA,
|
||||
ADC_CH_ADCIN2, 10);
|
||||
|
||||
//
|
||||
// - SOCs will sample on each trigger regardless of the interrupt flag
|
||||
//
|
||||
ADC_enableContinuousMode(ADCA_BASE, ADC_INT_NUMBER1);
|
||||
ADC_enableContinuousMode(ADCB_BASE, ADC_INT_NUMBER1);
|
||||
|
||||
//
|
||||
// - EOC3 will be generated at the end of conversion of SOC3
|
||||
// - EOC3 will generate the ADCA interrupt 1
|
||||
//
|
||||
ADC_setInterruptSource(ADCA_BASE, ADC_INT_NUMBER1, ADC_SOC_NUMBER3);
|
||||
ADC_enableInterrupt(ADCA_BASE, ADC_INT_NUMBER1);
|
||||
ADC_clearInterruptStatus(ADCA_BASE, ADC_INT_NUMBER1);
|
||||
|
||||
//
|
||||
// - EOC3 will be generated at the end of conversion of SOC3
|
||||
// - EOC3 will generate the ADCB interrupt 1
|
||||
//
|
||||
ADC_setInterruptSource(ADCB_BASE, ADC_INT_NUMBER1, ADC_SOC_NUMBER3);
|
||||
ADC_enableInterrupt(ADCB_BASE, ADC_INT_NUMBER1);
|
||||
ADC_clearInterruptStatus(ADCB_BASE, ADC_INT_NUMBER1);
|
||||
}
|
||||
|
||||
//
|
||||
// Configuring EPWM4 and EPWM5 as trigger sources for ADCA and ADCB
|
||||
// Providing phase shift between the modules
|
||||
//
|
||||
void setupADCSOC_trigger(void)
|
||||
{
|
||||
//
|
||||
// Set up EPWM4 to
|
||||
// - run on a base clock of SYSCLK
|
||||
// - have a period of EPWM4_PERIOD (200 KHz)
|
||||
// - run in count up mode
|
||||
// - Start counting from 0
|
||||
EPWM_setClockPrescaler(EPWM4_BASE, EPWM_CLOCK_DIVIDER_1,
|
||||
EPWM_HSCLOCK_DIVIDER_1);
|
||||
EPWM_setTimeBasePeriod(EPWM4_BASE, EPWM4_PERIOD - 1U);
|
||||
EPWM_setTimeBaseCounterMode(EPWM4_BASE, EPWM_COUNTER_MODE_UP);
|
||||
EPWM_setTimeBaseCounter(EPWM4_BASE, 0U);
|
||||
|
||||
//
|
||||
// Enable SOC-A and set it to assert when the counter hits
|
||||
// zero. It asserts on every event
|
||||
//
|
||||
EPWM_enableADCTrigger(EPWM4_BASE, EPWM_SOC_A);
|
||||
EPWM_setADCTriggerSource(EPWM4_BASE, EPWM_SOC_A, EPWM_SOC_TBCTR_ZERO);
|
||||
EPWM_setADCTriggerEventPrescale(EPWM4_BASE, EPWM_SOC_A, 1U);
|
||||
|
||||
//
|
||||
// Set up EPWM5 to
|
||||
// - run on a base clock of SYSCLK
|
||||
// - have a period of EPWM5_PERIOD (20 KHz)
|
||||
// - run in count up mode
|
||||
// - Start counting from 0
|
||||
EPWM_setClockPrescaler(EPWM5_BASE, EPWM_CLOCK_DIVIDER_1,
|
||||
EPWM_HSCLOCK_DIVIDER_1);
|
||||
EPWM_setTimeBasePeriod(EPWM5_BASE, EPWM5_PERIOD - 1U);
|
||||
EPWM_setTimeBaseCounterMode(EPWM5_BASE, EPWM_COUNTER_MODE_UP);
|
||||
EPWM_setTimeBaseCounter(EPWM5_BASE, 0U);
|
||||
|
||||
//
|
||||
// Enable SOC-A and set it to assert when the counter hits
|
||||
// zero. It asserts on every event
|
||||
//
|
||||
EPWM_enableADCTrigger(EPWM5_BASE, EPWM_SOC_A);
|
||||
EPWM_setADCTriggerSource(EPWM5_BASE, EPWM_SOC_A, EPWM_SOC_TBCTR_ZERO);
|
||||
EPWM_setADCTriggerEventPrescale(EPWM5_BASE, EPWM_SOC_A, 1U);
|
||||
|
||||
//
|
||||
// EPWM 4 and 5 should run freely in emulation mode
|
||||
//
|
||||
EPWM_setEmulationMode(EPWM4_BASE, EPWM_EMULATION_FREE_RUN);
|
||||
EPWM_setEmulationMode(EPWM5_BASE, EPWM_EMULATION_FREE_RUN);
|
||||
}
|
||||
|
||||
//
|
||||
// EPWM1 Initialization
|
||||
// EPWM1 : generates output of frequency EPWM1_FREQ (1 MHz)
|
||||
//
|
||||
void initEPWM(void)
|
||||
{
|
||||
//
|
||||
// Set up EPWM1 to
|
||||
// - run on a base clock of SYSCLK
|
||||
// - have a period of EPWM1_PERIOD
|
||||
// - run in count up-down mode
|
||||
//
|
||||
EPWM_setClockPrescaler(EPWM1_BASE, EPWM_CLOCK_DIVIDER_1,
|
||||
EPWM_HSCLOCK_DIVIDER_1);
|
||||
EPWM_setTimeBasePeriod(EPWM1_BASE, EPWM1_PERIOD);
|
||||
EPWM_setCounterCompareValue(EPWM1_BASE, EPWM_COUNTER_COMPARE_A, EPWM1_PERIOD/10U);
|
||||
EPWM_setTimeBaseCounterMode(EPWM1_BASE, EPWM_COUNTER_MODE_UP_DOWN);
|
||||
EPWM_setTimeBaseCounter(EPWM1_BASE, 0U);
|
||||
|
||||
//
|
||||
// Configuring action-qualifiers for EPWM1 to generate symmetric
|
||||
// waveform on channel A
|
||||
//
|
||||
EPWM_setActionQualifierAction(EPWM1_BASE, EPWM_AQ_OUTPUT_A,
|
||||
EPWM_AQ_OUTPUT_HIGH, EPWM_AQ_OUTPUT_ON_TIMEBASE_UP_CMPA);
|
||||
EPWM_setActionQualifierAction(EPWM1_BASE, EPWM_AQ_OUTPUT_A,
|
||||
EPWM_AQ_OUTPUT_LOW, EPWM_AQ_OUTPUT_ON_TIMEBASE_DOWN_CMPA);
|
||||
EPWM_setActionQualifierAction(EPWM1_BASE, EPWM_AQ_OUTPUT_B,
|
||||
EPWM_AQ_OUTPUT_HIGH, EPWM_AQ_OUTPUT_ON_TIMEBASE_UP_CMPA);
|
||||
EPWM_setActionQualifierAction(EPWM1_BASE, EPWM_AQ_OUTPUT_B,
|
||||
EPWM_AQ_OUTPUT_LOW, EPWM_AQ_OUTPUT_ON_TIMEBASE_DOWN_CMPA);
|
||||
|
||||
//
|
||||
// Enabling Counter Compare shadow mode
|
||||
//
|
||||
EPWM_setCounterCompareShadowLoadMode(EPWM1_BASE, EPWM_COUNTER_COMPARE_A, EPWM_COMP_LOAD_ON_SYNC_CNTR_ZERO);
|
||||
|
||||
//
|
||||
// Enable TZ1 as one shot trip sources
|
||||
//
|
||||
EPWM_enableTripZoneSignals(EPWM1_BASE, EPWM_TZ_SIGNAL_OSHT1);
|
||||
|
||||
//
|
||||
// Action on TZ1
|
||||
//
|
||||
EPWM_setTripZoneAction(EPWM1_BASE,
|
||||
EPWM_TZ_ACTION_EVENT_TZA,
|
||||
EPWM_TZ_ACTION_LOW);
|
||||
//
|
||||
// Run freely in emulation mode
|
||||
//
|
||||
EPWM_setEmulationMode(EPWM1_BASE, EPWM_EMULATION_FREE_RUN);
|
||||
}
|
||||
|
||||
//
|
||||
// Configuring the loop1 and loop2 controllers with desired values
|
||||
//
|
||||
void controller_initialize(void)
|
||||
{
|
||||
pi_loop1.Kp = 0.7;
|
||||
pi_loop1.Ki = 0.01;
|
||||
pi_loop1.Umax = 1.0;
|
||||
pi_loop1.Umin = 0.0;
|
||||
|
||||
pi_loop2.Kp = 0.7;
|
||||
pi_loop2.Ki = 0.01;
|
||||
pi_loop2.Umax = 1.0;
|
||||
pi_loop2.Umin = 0.0;
|
||||
}
|
||||
|
||||
//
|
||||
// Setting up GPIO2 for profiling loop1
|
||||
// Also set it's controller to CLA if loop1 is running on CLA
|
||||
//
|
||||
void setuploop1ProfileGpio(void)
|
||||
{
|
||||
GPIO_setDirectionMode(2,GPIO_DIR_MODE_OUT);
|
||||
GPIO_setQualificationMode(2,GPIO_QUAL_SYNC);
|
||||
GPIO_setPinConfig(GPIO_2_GPIO2);
|
||||
GPIO_writePin(2,0);
|
||||
#if run_loop1_cla == 1
|
||||
GPIO_setControllerCore(2, GPIO_CORE_CPU1_CLA1);
|
||||
#endif
|
||||
}
|
||||
|
||||
//
|
||||
// Setting up GPIO3 for profiling loop2
|
||||
//
|
||||
void setuploop2ProfileGpio(void)
|
||||
{
|
||||
GPIO_setDirectionMode(3,GPIO_DIR_MODE_OUT);
|
||||
GPIO_setQualificationMode(3,GPIO_QUAL_SYNC);
|
||||
GPIO_setPinConfig(GPIO_3_GPIO3);
|
||||
GPIO_writePin(3,0);
|
||||
}
|
||||
|
||||
#if run_loop1_cla == 0
|
||||
//
|
||||
// Loop1 control ISR
|
||||
//
|
||||
__interrupt void loop1ISR(void)
|
||||
{
|
||||
//
|
||||
// Turn ON Loop1 Profiling GPIO
|
||||
//
|
||||
GPIO_writePin(2,1);
|
||||
|
||||
//
|
||||
// Run the core loop1 logic
|
||||
//
|
||||
loop1_task();
|
||||
|
||||
//
|
||||
// Turn OFF Loop1 Profiling GPIO
|
||||
//
|
||||
GPIO_writePin(2,0);
|
||||
|
||||
//
|
||||
// Acknowledge the interrupt
|
||||
//
|
||||
Interrupt_clearACKGroup(INTERRUPT_ACK_GROUP1);
|
||||
|
||||
|
||||
}
|
||||
#endif
|
||||
|
||||
//
|
||||
// Loop2 control ISR
|
||||
//
|
||||
__interrupt void loop2ISR(void)
|
||||
{
|
||||
//
|
||||
// Turn ON Loop2 Profiling GPIO
|
||||
//
|
||||
GPIO_writePin(3,1);
|
||||
|
||||
#if run_loop1_cla == 0
|
||||
//
|
||||
// Code to enable nesting of high priority loop1 interrupt
|
||||
//
|
||||
uint16_t temp_Pieier = HWREGH(PIECTRL_BASE + PIE_O_IER1);
|
||||
IER |= 0x1U;
|
||||
IER &= 0x1U;
|
||||
HWREGH(PIECTRL_BASE + PIE_O_IER1) &= 0x1U;
|
||||
Interrupt_clearACKGroup(INTERRUPT_ACK_GROUP1);
|
||||
NOP;
|
||||
EINT;
|
||||
#endif
|
||||
|
||||
//
|
||||
// Read the oversampled input captured by 4 SOCs and calculate
|
||||
// the average
|
||||
//
|
||||
sense_data.loop2 = (ADC_readResult(ADCBRESULT_BASE,ADC_SOC_NUMBER0) +
|
||||
ADC_readResult(ADCBRESULT_BASE,ADC_SOC_NUMBER1) +
|
||||
ADC_readResult(ADCBRESULT_BASE,ADC_SOC_NUMBER2) +
|
||||
ADC_readResult(ADCBRESULT_BASE,ADC_SOC_NUMBER3)) >> 2;
|
||||
|
||||
//
|
||||
// Run the parallel form PI controller
|
||||
//
|
||||
control_out_data.loop2 = DCL_runPI_C3(&pi_loop2, __divf32(ref_data.loop2, 4096.0f),
|
||||
__divf32(sense_data.loop2, 4096.0f));
|
||||
|
||||
//
|
||||
// Calculate the duty contribution based on the controller output with 20% weightage
|
||||
//
|
||||
duty_loop2 = 0.2f * control_out_data.loop2;
|
||||
|
||||
//
|
||||
// Turn OFF Loop2 Profiling GPIO
|
||||
//
|
||||
GPIO_writePin(3,0);
|
||||
|
||||
#if run_loop1_cla == 0
|
||||
//
|
||||
// Disabling global interrupt and restoring PIEIER1 register
|
||||
//
|
||||
DINT;
|
||||
HWREGH(PIECTRL_BASE + PIE_O_IER1) = temp_Pieier;
|
||||
#endif
|
||||
|
||||
//
|
||||
// Acknowledge the interrupt
|
||||
//
|
||||
Interrupt_clearACKGroup(INTERRUPT_ACK_GROUP1);
|
||||
}
|
||||
@@ -0,0 +1,28 @@
|
||||
|
||||
/**
|
||||
* Import the modules used in this configuration.
|
||||
*/
|
||||
const cla = scripting.addModule("/driverlib/cla.js", {}, false);
|
||||
const cla1 = cla.addInstance();
|
||||
const memcfg = scripting.addModule("/driverlib/memcfg.js");
|
||||
|
||||
/**
|
||||
* Write custom configuration values to the imported modules.
|
||||
*/
|
||||
cla1.$name = "myCLA0";
|
||||
cla1.cpuint_CLA_TASK_1 = false;
|
||||
cla1.cpuint_CLA_TASK_2 = false;
|
||||
cla1.cpuint_CLA_TASK_3 = false;
|
||||
cla1.cpuint_CLA_TASK_4 = false;
|
||||
cla1.cpuint_CLA_TASK_5 = false;
|
||||
cla1.cpuint_CLA_TASK_6 = false;
|
||||
cla1.cpuint_CLA_TASK_7 = false;
|
||||
cla1.cpuint_CLA_TASK_8 = false;
|
||||
cla1.trigger_CLA_TASK_1 = "CLA_TRIGGER_ADCA1";
|
||||
|
||||
|
||||
memcfg.config_MEMCFG_SECT_LS5 = "CLA_prog";
|
||||
memcfg.config_MEMCFG_SECT_LS0 = "CLA_data";
|
||||
memcfg.config_MEMCFG_SECT_LS1 = "CLA_data";
|
||||
memcfg.init_MEMCFG_SECT_MSGCPUTOCLA1 = true;
|
||||
memcfg.init_MEMCFG_SECT_MSGCLA1TOCPU = true;
|
||||
@@ -0,0 +1,183 @@
|
||||
//#############################################################################
|
||||
//
|
||||
// FILE: cla_ex6_cpu_offloading_cla.cla
|
||||
//
|
||||
// TITLE: Optimal offloading of control algorithms to CLA
|
||||
//
|
||||
// Task 1 implements loop1 control logic
|
||||
//
|
||||
//#############################################################################
|
||||
//
|
||||
//
|
||||
//
|
||||
// C2000Ware v5.04.00.00
|
||||
//
|
||||
// Copyright (C) 2024 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
|
||||
//
|
||||
#if run_loop1_cla == 1
|
||||
#include <cla_ex6_cpu_offloading_shared.h>
|
||||
#endif
|
||||
#include <stdint.h>
|
||||
|
||||
//
|
||||
// Globals
|
||||
//
|
||||
// Note that the globals defined in the .cla source are global to the cla source
|
||||
// file. i.e. they may be shared across tasks. But they cannot be assigned an
|
||||
// initialized value here. To do so, one-time initialization task is used that
|
||||
// is triggered by software at the beginning
|
||||
//
|
||||
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
//
|
||||
// Task 1 - PWM control loop
|
||||
//
|
||||
// Description: PWM control logic can be implemented here.
|
||||
//
|
||||
//-----------------------------------------------------------------------------
|
||||
__attribute__((interrupt)) void Cla1Task1 ( void )
|
||||
{
|
||||
//
|
||||
// Uncomment this to debug the CLA while connected to the debugger
|
||||
//
|
||||
//__mdebugstop();
|
||||
|
||||
#if run_loop1_cla == 1
|
||||
//
|
||||
// Turn ON Loop1 Profiling GPIO
|
||||
//
|
||||
GPIO_writePin(2,1);
|
||||
|
||||
//
|
||||
// Run the core loop1 logic
|
||||
//
|
||||
loop1_task();
|
||||
|
||||
//
|
||||
// Turn OFF Loop1 Profiling GPIO
|
||||
//
|
||||
GPIO_writePin(2,0);
|
||||
#endif
|
||||
}
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
//
|
||||
// Task 2 - Title Here
|
||||
//
|
||||
// Description: Description/steps here.
|
||||
//
|
||||
//-----------------------------------------------------------------------------
|
||||
__attribute__((interrupt)) void Cla1Task2 ( void )
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
//
|
||||
// Task 3 - Title Here
|
||||
//
|
||||
// Description: Description/steps here.
|
||||
//
|
||||
//-----------------------------------------------------------------------------
|
||||
__attribute__((interrupt)) void Cla1Task3 ( void )
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
//
|
||||
// Task 4 - Title Here
|
||||
//
|
||||
// Description: Description/steps here.
|
||||
//
|
||||
//-----------------------------------------------------------------------------
|
||||
__attribute__((interrupt)) void Cla1Task4 ( void )
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
//
|
||||
// Task 5 - Title Here
|
||||
//
|
||||
// Description: Description/steps here.
|
||||
//
|
||||
//-----------------------------------------------------------------------------
|
||||
__attribute__((interrupt)) void Cla1Task5 ( void )
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
//
|
||||
// Task 6 - Title Here
|
||||
//
|
||||
// Description: Description/steps here.
|
||||
//
|
||||
//-----------------------------------------------------------------------------
|
||||
__attribute__((interrupt)) void Cla1Task6 ( void )
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
//
|
||||
// Task 7 - Title Here
|
||||
//
|
||||
// Description: Description/steps here.
|
||||
//
|
||||
//-----------------------------------------------------------------------------
|
||||
__attribute__((interrupt)) void Cla1Task7 ( void )
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
//
|
||||
// Task 8 - One Time Initialization Task
|
||||
//
|
||||
// Description: This task will initialize the CLA global variables
|
||||
//
|
||||
//-----------------------------------------------------------------------------
|
||||
__attribute__((interrupt)) void Cla1Task8 ( void )
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
//
|
||||
// End of File
|
||||
//
|
||||
@@ -0,0 +1,175 @@
|
||||
//#############################################################################
|
||||
//
|
||||
// FILE: cla_ex6_cpu_offloading_shared.h
|
||||
//
|
||||
// TITLE: Optimal offloading of control algorithms to CLA
|
||||
//
|
||||
// This header file contains defines, variables and prototypes that are shared
|
||||
// among the C28x and the CLA
|
||||
//
|
||||
//#############################################################################
|
||||
//
|
||||
//
|
||||
//
|
||||
// C2000Ware v5.04.00.00
|
||||
//
|
||||
// Copyright (C) 2024 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 _CLA_EX6_CPUOFFLOADING_SHARED_H_
|
||||
#define _CLA_EX6_CPUOFFLOADING_SHARED_H_
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
//
|
||||
// Included Files
|
||||
//
|
||||
#include "driverlib.h"
|
||||
#include "device.h"
|
||||
|
||||
#if run_loop1_cla == 1
|
||||
#include "DCLCLA.h"
|
||||
#else
|
||||
#include "DCLF32.h"
|
||||
#endif
|
||||
|
||||
//
|
||||
// Structure definitions
|
||||
//
|
||||
|
||||
typedef struct {
|
||||
uint16_t loop1;
|
||||
uint16_t loop2;
|
||||
}reference;
|
||||
|
||||
typedef struct {
|
||||
uint16_t loop1;
|
||||
uint16_t loop2;
|
||||
}sensed;
|
||||
|
||||
typedef struct {
|
||||
float32_t loop1;
|
||||
float32_t loop2;
|
||||
}control_out;
|
||||
|
||||
//
|
||||
// Defines
|
||||
//
|
||||
#define EPWM1_FREQ 1000000UL // 1 MHz
|
||||
#define EPWM4_FREQ 200000UL // 200 KHz
|
||||
#define EPWM5_FREQ 20000UL // 20 KHz
|
||||
#define EPWM1_PERIOD (uint16_t)(DEVICE_SYSCLK_FREQ / (2 * 2 * EPWM1_FREQ))
|
||||
#define EPWM4_PERIOD (uint16_t)(DEVICE_SYSCLK_FREQ / (2 * EPWM4_FREQ))
|
||||
#define EPWM5_PERIOD (uint16_t)(DEVICE_SYSCLK_FREQ / (2 * EPWM5_FREQ))
|
||||
|
||||
//
|
||||
// Globals
|
||||
//
|
||||
extern volatile reference ref_data;
|
||||
extern volatile sensed sense_data;
|
||||
extern volatile control_out control_out_data;
|
||||
#if run_loop1_cla == 1
|
||||
extern volatile DCL_PI_CLA pi_loop1;
|
||||
#else
|
||||
extern volatile DCL_PI pi_loop1;
|
||||
#endif
|
||||
extern volatile float32_t duty, duty_loop1, duty_loop2;
|
||||
|
||||
//
|
||||
// Loop1 control task defined in a shared file so that can be used both
|
||||
// by CPU and CLA in order avoid code duplication
|
||||
//
|
||||
static inline void loop1_task(void)
|
||||
{
|
||||
//
|
||||
// Read the oversampled input captured by 4 SOCs and calculate
|
||||
// the average
|
||||
//
|
||||
sense_data.loop1 = (ADC_readResult(ADCARESULT_BASE,ADC_SOC_NUMBER0) +
|
||||
ADC_readResult(ADCARESULT_BASE,ADC_SOC_NUMBER1) +
|
||||
ADC_readResult(ADCARESULT_BASE,ADC_SOC_NUMBER2) +
|
||||
ADC_readResult(ADCARESULT_BASE,ADC_SOC_NUMBER3)) >> 2;
|
||||
|
||||
//
|
||||
// Run the parallel form PI controller
|
||||
//
|
||||
#if run_loop1_cla == 1
|
||||
control_out_data.loop1 = DCL_runPI_L4(&pi_loop1, (ref_data.loop1 / 4096.0f),
|
||||
(sense_data.loop1 / 4096.0f));
|
||||
#else
|
||||
control_out_data.loop1 = DCL_runPI_C3(&pi_loop1, __divf32(ref_data.loop1, 4096.0f),
|
||||
__divf32(sense_data.loop1, 4096.0f));
|
||||
#endif
|
||||
|
||||
//
|
||||
// Calculate the duty contribution based on the controller output with 20% weightage
|
||||
//
|
||||
duty_loop1 = 0.8f * control_out_data.loop1;
|
||||
|
||||
//
|
||||
// Computing final duty value by summing up the contribution of both loops
|
||||
//
|
||||
duty = duty_loop1 + duty_loop2;
|
||||
|
||||
//
|
||||
// Check for upper(0.9) and lower(0.1) saturation values
|
||||
//
|
||||
duty = (duty > 0.9f) ? 0.9f : duty;
|
||||
duty = (duty < 0.1f) ? 0.1f : duty;
|
||||
|
||||
//
|
||||
// Write to the COMPA register
|
||||
//
|
||||
EPWM_setCounterCompareValue(EPWM1_BASE, EPWM_COUNTER_COMPARE_A,
|
||||
(uint16_t)((1.0f - duty) * EPWM1_PERIOD + 0.5f));
|
||||
}
|
||||
|
||||
//CLA C Tasks defined in Cla1Tasks_C.cla
|
||||
__attribute__((interrupt)) void Cla1Task1();
|
||||
__attribute__((interrupt)) void Cla1Task2();
|
||||
__attribute__((interrupt)) void Cla1Task3();
|
||||
__attribute__((interrupt)) void Cla1Task4();
|
||||
__attribute__((interrupt)) void Cla1Task5();
|
||||
__attribute__((interrupt)) void Cla1Task6();
|
||||
__attribute__((interrupt)) void Cla1Task7();
|
||||
__attribute__((interrupt)) void Cla1Task8();
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif // extern "C"
|
||||
#endif //_CLA_EX6_CPUOFFLOADING_SHARED_H_
|
||||
|
||||
//
|
||||
// End of File
|
||||
//
|
||||
@@ -0,0 +1,355 @@
|
||||
//#############################################################################
|
||||
//
|
||||
// FILE: cla_ex7_shared_resource_handling.c
|
||||
//
|
||||
// TITLE: Handling shared resources across C28x and CLA
|
||||
//
|
||||
//! \addtogroup driver_example_list
|
||||
//! <h1> Handling shared resources across C28x and CLA </h1>
|
||||
//!
|
||||
//! This example showcases how to handle shared resource challenges across
|
||||
//! C28x and CLA. As the peripherals are shared between CLA and the CPU,
|
||||
//! overlapping read-modify-write to the registers by them can lead to data
|
||||
//! race conditions ultimately leading to data violation or incorrect
|
||||
//! functionality. In this example, CPU ISR and CLA tasks runs independently.
|
||||
//! CPU ISR gets triggered by EPWM4 @10KHz and toggles the EPWM1B output via
|
||||
//! software by controlling CSFB bits of AQCSFRC. CLA task gets triggered by
|
||||
//! EPWM5 @100Khz and toggles the EPWM1A output via software by controlling
|
||||
//! CSFA bits of AQCSFRC. Thus in this process both CPU and CLA do read-modify
|
||||
//! -write to AQCSFRC register independently at different frequencies so there
|
||||
//! is chance of race condition and updates due to one of them can get lost/.
|
||||
//! overwritten. This can be clearly observed by updating "phase_shift_ON" to
|
||||
//! 0U and probing the EPWM1A and 1B outputs on a scope.
|
||||
//!
|
||||
//! This is a standard critical section problem and can be handled by software
|
||||
//! handshaking mechanism like mutex etc. But most of the real-time control
|
||||
//! applications are time-sensitive and cannot afford addition software overhead
|
||||
//! hence this example suggests an alternative hardware based technique to avoid
|
||||
//! shared resource conflicts between CPU and CLA. The phase shifting mechanism
|
||||
//! of the EPWM modules is utilized to schedule the CLA task and CPU ISR as
|
||||
//! desired. EPWM4 generates a synchronous pulse every ZERO event and provides
|
||||
//! a phase shift of 20 cycles to EPWM5. This way both CLA task and C28x ISR
|
||||
//! runs at original frequencies i.e. 100KHz and 10KHz but CLA task leads with
|
||||
//! a phase offset of 20 cycles wrt CPU ISR. Hence concurrent read-modify-writes
|
||||
//! to AQCSFRC never happens and the EPWM1A and EPWM1B outputs behave as desired
|
||||
//! i.e. consistent 50 KHz PWM output on EPWM1A and 5 KHz PWM output on EPWM1B
|
||||
//! with a duty ~50% on both should be generated. In order to utilize this phase
|
||||
//! shifting mechanism in this example, please make sure "phase_shift_ON" is
|
||||
//! set to 1.
|
||||
//!
|
||||
//!
|
||||
//! \b External \b Connections \n
|
||||
//! - Observe GPIO0 (EPWM1A Output) on oscilloscope
|
||||
//! - Observe GPIO1 (EPWM1B Output) on oscilloscope
|
||||
//! - Observe GPIO2 (CLA Task Profiling) on oscilloscope
|
||||
//! - Observe GPIO3 (CPU ISR Profiling) on oscilloscope
|
||||
//!
|
||||
//!
|
||||
//! Note :- The phase offset value can easily be configured by updating TBPHS
|
||||
//! register to schedule the CLA task and C28x ISR as desired depending
|
||||
//! upon the application need so as to avoid overlapping register writes
|
||||
//! by CPU and CLA
|
||||
//!
|
||||
//! Note :- The optimization is on and set to O2 for the project and all the results
|
||||
//! quoted correspond to this case.
|
||||
//!
|
||||
//
|
||||
//#############################################################################
|
||||
//
|
||||
//
|
||||
//
|
||||
// C2000Ware v5.04.00.00
|
||||
//
|
||||
// Copyright (C) 2024 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 <cla_ex7_shared_resource_handling.h>
|
||||
#include "board.h"
|
||||
//
|
||||
// Defines
|
||||
//
|
||||
#define phase_shift_ON 1U
|
||||
|
||||
//
|
||||
// Global variables
|
||||
//
|
||||
volatile uint16_t cpu_flag = 0; // Flag used in ISR to implement toggle of
|
||||
// EPWM1B output
|
||||
|
||||
//
|
||||
// Function Prototypes
|
||||
//
|
||||
void initEPWM(void);
|
||||
void setupADCSOC_trigger(void);
|
||||
void setuploop1ProfileGpio(void);
|
||||
void setuploop2ProfileGpio(void);
|
||||
void initCLA(void);
|
||||
__interrupt void cpuISR(void);
|
||||
|
||||
|
||||
#if defined(_FLASH)
|
||||
#pragma CODE_SECTION(cpuISR,".TI.ramfunc");
|
||||
#endif
|
||||
|
||||
|
||||
//
|
||||
// Main
|
||||
//
|
||||
void main(void)
|
||||
{
|
||||
//
|
||||
// Initialize device clock and peripherals
|
||||
//
|
||||
Device_init();
|
||||
|
||||
//
|
||||
// Disable pin locks and enable internal pullups.
|
||||
//
|
||||
Device_initGPIO();
|
||||
|
||||
//
|
||||
// GPIO0 is set to EPWM1A and GPIO1 is set to EPWM1B
|
||||
//
|
||||
GPIO_setControllerCore(0, GPIO_CORE_CPU1);
|
||||
GPIO_setPadConfig(0,GPIO_PIN_TYPE_STD);
|
||||
GPIO_setPinConfig(GPIO_0_EPWM1A);
|
||||
GPIO_setControllerCore(1, GPIO_CORE_CPU1);
|
||||
GPIO_setPadConfig(1,GPIO_PIN_TYPE_STD);
|
||||
GPIO_setPinConfig(GPIO_1_EPWM1B);
|
||||
|
||||
//
|
||||
// Setup Profiling GPIOs for loop1 and loop2
|
||||
//
|
||||
setuploop1ProfileGpio();
|
||||
setuploop2ProfileGpio();
|
||||
|
||||
//
|
||||
// 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();
|
||||
|
||||
//
|
||||
// Disable sync(Freeze clock to PWM as well)
|
||||
//
|
||||
SysCtl_disablePeripheral(SYSCTL_PERIPH_CLK_TBCLKSYNC);
|
||||
|
||||
//
|
||||
// Initialize EPWM1, EPWM4 and EPWM5 modules
|
||||
//
|
||||
initEPWM();
|
||||
|
||||
//
|
||||
// Initialize resources
|
||||
//
|
||||
Board_init();
|
||||
initCLA();
|
||||
|
||||
//
|
||||
// Register the EPWM4 interrupt
|
||||
//
|
||||
Interrupt_register(INT_EPWM4, &cpuISR);
|
||||
|
||||
//
|
||||
// Enable EPWM4 CPU interrupt
|
||||
//
|
||||
Interrupt_enable(INT_EPWM4);
|
||||
|
||||
//
|
||||
// Enable global interrupts.
|
||||
//
|
||||
EINT;
|
||||
|
||||
//
|
||||
// Enable sync and clock to PWM
|
||||
//
|
||||
SysCtl_enablePeripheral(SYSCTL_PERIPH_CLK_TBCLKSYNC);
|
||||
|
||||
for(;;)
|
||||
{
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
//
|
||||
// EPWM Initialization
|
||||
// EPWM1 : generates software controlled outputs at A & B
|
||||
// EPWM4 : triggers CPU interrupt @ 10KHz
|
||||
// EPWM5 : triggers CLA task 1 @ 100KHz
|
||||
//
|
||||
void initEPWM(void)
|
||||
{
|
||||
//
|
||||
// Set up EPWM1 to
|
||||
// - run on a base clock of SYSCLK
|
||||
// - run in count up-down mode
|
||||
// - Max period
|
||||
// - Immediate load of SW actions
|
||||
//
|
||||
EPWM_setClockPrescaler(EPWM1_BASE, EPWM_CLOCK_DIVIDER_1,
|
||||
EPWM_HSCLOCK_DIVIDER_1);
|
||||
EPWM_setTimeBasePeriod(EPWM1_BASE, 0xFFFF);
|
||||
EPWM_setTimeBaseCounterMode(EPWM1_BASE, EPWM_COUNTER_MODE_UP_DOWN);
|
||||
EPWM_setTimeBaseCounter(EPWM1_BASE, 0U);
|
||||
EPWM_setActionQualifierContSWForceShadowMode(EPWM1_BASE, EPWM_AQ_SW_IMMEDIATE_LOAD);
|
||||
|
||||
//
|
||||
// Run freely in emulation mode
|
||||
//
|
||||
EPWM_setEmulationMode(EPWM1_BASE, EPWM_EMULATION_FREE_RUN);
|
||||
|
||||
|
||||
//
|
||||
// Set up EPWM4 to
|
||||
// - run on a base clock of SYSCLK
|
||||
// - have a period of EPWM4_PERIOD (10 KHz)
|
||||
// - run in count up mode
|
||||
// - Generate a SYNCOUT pulse if phase shifting is used
|
||||
// - Generate an interrupt to CPU on very TBCTR=ZERO event
|
||||
EPWM_setClockPrescaler(EPWM4_BASE, EPWM_CLOCK_DIVIDER_1,
|
||||
EPWM_HSCLOCK_DIVIDER_1);
|
||||
EPWM_setTimeBasePeriod(EPWM4_BASE, EPWM4_PERIOD - 1U);
|
||||
EPWM_setTimeBaseCounterMode(EPWM4_BASE, EPWM_COUNTER_MODE_UP);
|
||||
EPWM_setTimeBaseCounter(EPWM4_BASE, 0U);
|
||||
#if phase_shift_ON == 1U
|
||||
EPWM_enableSyncOutPulseSource(EPWM4_BASE, EPWM_SYNC_OUT_PULSE_ON_CNTR_ZERO);
|
||||
#endif
|
||||
EPWM_setInterruptSource(EPWM4_BASE, EPWM_INT_TBCTR_ZERO);
|
||||
EPWM_enableInterrupt(EPWM4_BASE);
|
||||
EPWM_setInterruptEventCount(EPWM4_BASE, 1U);
|
||||
|
||||
//
|
||||
// Set up EPWM5 to
|
||||
// - run on a base clock of SYSCLK
|
||||
// - have a period of EPWM4_PERIOD (100 KHz)
|
||||
// - run in count up mode
|
||||
// - Enable phase shift of 20 cycles on receiving a
|
||||
// - SYNC pulse if phase shifting is used
|
||||
// - Trigger a CLA task on every TBCTR=ZERO event
|
||||
EPWM_setClockPrescaler(EPWM5_BASE, EPWM_CLOCK_DIVIDER_1,
|
||||
EPWM_HSCLOCK_DIVIDER_1);
|
||||
EPWM_setTimeBasePeriod(EPWM5_BASE, EPWM5_PERIOD - 1U);
|
||||
EPWM_setTimeBaseCounterMode(EPWM5_BASE, EPWM_COUNTER_MODE_UP);
|
||||
EPWM_setTimeBaseCounter(EPWM5_BASE, 0U);
|
||||
#if phase_shift_ON == 1U
|
||||
EPWM_enablePhaseShiftLoad(EPWM5_BASE);
|
||||
EPWM_setSyncInPulseSource(EPWM5_BASE, EPWM_SYNC_IN_PULSE_SRC_SYNCOUT_EPWM4);
|
||||
EPWM_setPhaseShift(EPWM5_BASE, 20U);
|
||||
EPWM_enableOneShotSync(EPWM5_BASE);
|
||||
#endif
|
||||
EPWM_setInterruptSource(EPWM5_BASE, EPWM_INT_TBCTR_ZERO);
|
||||
EPWM_enableInterrupt(EPWM5_BASE);
|
||||
EPWM_setInterruptEventCount(EPWM5_BASE, 1U);
|
||||
}
|
||||
|
||||
//
|
||||
// CLA Initialization
|
||||
//
|
||||
void initCLA(void)
|
||||
{
|
||||
//
|
||||
// Force task 8, the one time initialization task
|
||||
//
|
||||
CLA_forceTasks(CLA1_BASE, CLA_TASKFLAG_8);
|
||||
}
|
||||
|
||||
//
|
||||
// Setting up GPIO2 for profiling cla Task
|
||||
//
|
||||
void setuploop1ProfileGpio(void)
|
||||
{
|
||||
GPIO_setDirectionMode(2,GPIO_DIR_MODE_OUT);
|
||||
GPIO_setQualificationMode(2,GPIO_QUAL_SYNC);
|
||||
GPIO_setPinConfig(GPIO_2_GPIO2);
|
||||
GPIO_writePin(2,0);
|
||||
GPIO_setControllerCore(2, GPIO_CORE_CPU1_CLA1);
|
||||
}
|
||||
|
||||
//
|
||||
// Setting up GPIO3 for profiling cpuISR
|
||||
//
|
||||
void setuploop2ProfileGpio(void)
|
||||
{
|
||||
GPIO_setDirectionMode(3,GPIO_DIR_MODE_OUT);
|
||||
GPIO_setQualificationMode(3,GPIO_QUAL_SYNC);
|
||||
GPIO_setPinConfig(GPIO_3_GPIO3);
|
||||
GPIO_writePin(3,0);
|
||||
}
|
||||
|
||||
//
|
||||
// CPU ISR
|
||||
//
|
||||
__interrupt void cpuISR(void)
|
||||
{
|
||||
//
|
||||
// Turn ON Profiling GPIO3
|
||||
//
|
||||
GPIO_writePin(3,1);
|
||||
|
||||
//
|
||||
// Toggle the EPWM1B output using SW Force Action
|
||||
//
|
||||
if (cpu_flag == 1)
|
||||
{
|
||||
EPWM_setActionQualifierContSWForceAction(EPWM1_BASE, EPWM_AQ_OUTPUT_B, EPWM_AQ_SW_OUTPUT_HIGH);
|
||||
cpu_flag = 0;
|
||||
}
|
||||
|
||||
else
|
||||
{
|
||||
EPWM_setActionQualifierContSWForceAction(EPWM1_BASE, EPWM_AQ_OUTPUT_B, EPWM_AQ_SW_OUTPUT_LOW);
|
||||
cpu_flag = 1;
|
||||
}
|
||||
|
||||
//
|
||||
// Turn OFF Profiling GPIO3
|
||||
//
|
||||
GPIO_writePin(3,0);
|
||||
|
||||
//
|
||||
// Clear EPWM4 interrupt flag so that next interrupt can come in
|
||||
//
|
||||
EPWM_clearEventTriggerInterruptFlag(EPWM4_BASE);
|
||||
|
||||
//
|
||||
// Acknowledge the interrupt
|
||||
//
|
||||
Interrupt_clearACKGroup(INTERRUPT_ACK_GROUP3);
|
||||
}
|
||||
@@ -0,0 +1,86 @@
|
||||
//#############################################################################
|
||||
//
|
||||
// FILE: cla_ex7_shared_resource_handling.h
|
||||
//
|
||||
// TITLE: Handling shared resources across C28x and CLA
|
||||
//
|
||||
// This header file contains defines, variables and prototypes that are shared
|
||||
// among the C28x and the CLA
|
||||
//
|
||||
//#############################################################################
|
||||
//
|
||||
//
|
||||
//
|
||||
// C2000Ware v5.04.00.00
|
||||
//
|
||||
// Copyright (C) 2024 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 _CLA_EX7_SHARED_RESOURCE_HANDLING__H_
|
||||
#define _CLA_EX7_SHARED_RESOURCE_HANDLING__H_
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
//
|
||||
// Included Files
|
||||
//
|
||||
#include "driverlib.h"
|
||||
#include "device.h"
|
||||
|
||||
//
|
||||
// Defines
|
||||
//
|
||||
#define EPWM4_FREQ 10000UL // 10 KHz
|
||||
#define EPWM5_FREQ 100000UL // 100 KHz
|
||||
#define EPWM4_PERIOD (uint16_t)(DEVICE_SYSCLK_FREQ / (2 * EPWM4_FREQ))
|
||||
#define EPWM5_PERIOD (uint16_t)(DEVICE_SYSCLK_FREQ / (2 * EPWM5_FREQ))
|
||||
|
||||
//CLA C Tasks defined in Cla1Tasks_C.cla
|
||||
__attribute__((interrupt)) void Cla1Task1();
|
||||
__attribute__((interrupt)) void Cla1Task2();
|
||||
__attribute__((interrupt)) void Cla1Task3();
|
||||
__attribute__((interrupt)) void Cla1Task4();
|
||||
__attribute__((interrupt)) void Cla1Task5();
|
||||
__attribute__((interrupt)) void Cla1Task6();
|
||||
__attribute__((interrupt)) void Cla1Task7();
|
||||
__attribute__((interrupt)) void Cla1Task8();
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif // extern "C"
|
||||
#endif //_CLA_EX7_SHARED_RESOURCE_HANDLING__H_
|
||||
|
||||
//
|
||||
// End of File
|
||||
//
|
||||
@@ -0,0 +1,28 @@
|
||||
|
||||
/**
|
||||
* Import the modules used in this configuration.
|
||||
*/
|
||||
const cla = scripting.addModule("/driverlib/cla.js", {}, false);
|
||||
const cla1 = cla.addInstance();
|
||||
const memcfg = scripting.addModule("/driverlib/memcfg.js");
|
||||
|
||||
/**
|
||||
* Write custom configuration values to the imported modules.
|
||||
*/
|
||||
cla1.$name = "myCLA0";
|
||||
cla1.cpuint_CLA_TASK_1 = false;
|
||||
cla1.cpuint_CLA_TASK_2 = false;
|
||||
cla1.cpuint_CLA_TASK_3 = false;
|
||||
cla1.cpuint_CLA_TASK_4 = false;
|
||||
cla1.cpuint_CLA_TASK_5 = false;
|
||||
cla1.cpuint_CLA_TASK_6 = false;
|
||||
cla1.cpuint_CLA_TASK_7 = false;
|
||||
cla1.cpuint_CLA_TASK_8 = false;
|
||||
cla1.trigger_CLA_TASK_1 = "CLA_TRIGGER_EPWM5INT";
|
||||
|
||||
|
||||
memcfg.config_MEMCFG_SECT_LS5 = "CLA_prog";
|
||||
memcfg.config_MEMCFG_SECT_LS0 = "CLA_data";
|
||||
memcfg.config_MEMCFG_SECT_LS1 = "CLA_data";
|
||||
memcfg.init_MEMCFG_SECT_MSGCPUTOCLA1 = true;
|
||||
memcfg.init_MEMCFG_SECT_MSGCLA1TOCPU = true;
|
||||
+199
@@ -0,0 +1,199 @@
|
||||
//#############################################################################
|
||||
//
|
||||
// FILE: cla_ex7_shared_resource_handling_cla.cla
|
||||
//
|
||||
// TITLE: Handling shared resources across C28x and CLA
|
||||
//
|
||||
// Task 1 toggles the EPWM1A output using Software force
|
||||
// Task 8 initializes the CLA flag
|
||||
//
|
||||
//#############################################################################
|
||||
//
|
||||
//
|
||||
//
|
||||
// C2000Ware v5.04.00.00
|
||||
//
|
||||
// Copyright (C) 2024 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 <cla_ex7_shared_resource_handling.h>
|
||||
#include <stdint.h>
|
||||
|
||||
//
|
||||
// Globals
|
||||
//
|
||||
// Note that the globals defined in the .cla source are global to the cla source
|
||||
// file. i.e. they may be shared across tasks. But they cannot be assigned an
|
||||
// initialized value here. To do so, one-time initialization task is used that
|
||||
// is triggered by software at the beginning
|
||||
//
|
||||
volatile uint16_t cla_flag; // Flag used in task to implement toggle of
|
||||
// EPWM1A output
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
//
|
||||
// Task 1 - PWM output control via software
|
||||
//
|
||||
//-----------------------------------------------------------------------------
|
||||
__attribute__((interrupt)) void Cla1Task1 ( void )
|
||||
{
|
||||
//
|
||||
// Uncomment this to debug the CLA while connected to the debugger
|
||||
//
|
||||
//__mdebugstop();
|
||||
|
||||
//
|
||||
// Turn ON Profiling GPIO2
|
||||
//
|
||||
GPIO_writePin(2,1);
|
||||
|
||||
//
|
||||
// Toggle the EPWM1A output using SW Force Action
|
||||
//
|
||||
if (cla_flag == 1)
|
||||
{
|
||||
EPWM_setActionQualifierContSWForceAction(EPWM1_BASE, EPWM_AQ_OUTPUT_A, EPWM_AQ_SW_OUTPUT_HIGH);
|
||||
cla_flag = 0;
|
||||
}
|
||||
|
||||
else
|
||||
{
|
||||
EPWM_setActionQualifierContSWForceAction(EPWM1_BASE, EPWM_AQ_OUTPUT_A, EPWM_AQ_SW_OUTPUT_LOW);
|
||||
cla_flag = 1;
|
||||
}
|
||||
|
||||
//
|
||||
// Turn OFF Profiling GPIO2
|
||||
//
|
||||
GPIO_writePin(2,0);
|
||||
|
||||
//
|
||||
// Clear EPWM5 interrupt flag so that next interrupt can come in
|
||||
//
|
||||
EPWM_clearEventTriggerInterruptFlag(EPWM5_BASE);
|
||||
}
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
//
|
||||
// Task 2 - Title Here
|
||||
//
|
||||
// Description: Description/steps here.
|
||||
//
|
||||
//-----------------------------------------------------------------------------
|
||||
__attribute__((interrupt)) void Cla1Task2 ( void )
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
//
|
||||
// Task 3 - Title Here
|
||||
//
|
||||
// Description: Description/steps here.
|
||||
//
|
||||
//-----------------------------------------------------------------------------
|
||||
__attribute__((interrupt)) void Cla1Task3 ( void )
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
//
|
||||
// Task 4 - Title Here
|
||||
//
|
||||
// Description: Description/steps here.
|
||||
//
|
||||
//-----------------------------------------------------------------------------
|
||||
__attribute__((interrupt)) void Cla1Task4 ( void )
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
//
|
||||
// Task 5 - Title Here
|
||||
//
|
||||
// Description: Description/steps here.
|
||||
//
|
||||
//-----------------------------------------------------------------------------
|
||||
__attribute__((interrupt)) void Cla1Task5 ( void )
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
//
|
||||
// Task 6 - Title Here
|
||||
//
|
||||
// Description: Description/steps here.
|
||||
//
|
||||
//-----------------------------------------------------------------------------
|
||||
__attribute__((interrupt)) void Cla1Task6 ( void )
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
//
|
||||
// Task 7 - Title Here
|
||||
//
|
||||
// Description: Description/steps here.
|
||||
//
|
||||
//-----------------------------------------------------------------------------
|
||||
__attribute__((interrupt)) void Cla1Task7 ( void )
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
///-----------------------------------------------------------------------------
|
||||
//
|
||||
// Task 8 - One Time Initialization Task
|
||||
//
|
||||
// Description: This task will initialize the CLA global variables
|
||||
//
|
||||
//-----------------------------------------------------------------------------
|
||||
__attribute__((interrupt)) void Cla1Task8 ( void )
|
||||
{
|
||||
//
|
||||
// Uncomment this to debug the CLA while connected to the debugger
|
||||
//
|
||||
//__mdebugstop();
|
||||
|
||||
cla_flag = 0;
|
||||
}
|
||||
|
||||
//
|
||||
// End of File
|
||||
//
|
||||
Reference in new issue
Block a user