Update repo

This commit is contained in:
hangpersonal committed 2026-08-30 23:04:35 -07:00
1 parent 749dab5721
commit ce65a0f59a
14950 files changed
+4408250 -1

No files matched your search

@@ -0,0 +1,42 @@
<projectSpec>
<project
name="erad_ex1_profile_function"
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 &quot;========= 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) =============&quot;
;if ${GENERATE_DIAGRAM} == 1 ${NODE_TOOL} &quot;${C2000WARE_ROOT}/utilities/clb_tool/clb_syscfg/dot_file_libraries/clbDotUtility.js&quot; &quot;${C2000WARE_ROOT}/utilities/clb_tool/clb_syscfg/&quot; &quot;${BuildDirectory}/syscfg&quot; &quot;${BuildDirectory}/syscfg/clb.dot&quot;
;if ${GENERATE_DIAGRAM} == 1 mkdir &quot;${BuildDirectory}/diagrams&quot;
;if ${GENERATE_DIAGRAM} == 1 ${NODE_TOOL} &quot;${C2000WARE_ROOT}/driverlib/.meta/generate_diagrams.js&quot; &quot;${C2000WARE_ROOT}&quot; &quot;${BuildDirectory}/diagrams&quot; &quot;${BuildDirectory}/syscfg&quot;
"
>
<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 --define=RAM --float_support=fpu64 --tmu_support=tmu0 --define=DEBUG --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 --float_support=fpu64 --tmu_support=tmu0 --define=DEBUG --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_lnk_cpu1.cmd" targetDirectory="" applicableConfigurations="CPU1_RAM" />
<file action="copy" path="../../../../../../../device_support/f2838x/common/cmd/2838x_FLASH_lnk_cpu1.cmd" targetDirectory="" applicableConfigurations="CPU1_FLASH" />
<file action="copy" path="../erad_ex1_sections.cmd" targetDirectory="" />
<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="../erad_ex1_profile_function.c" targetDirectory="" />
<file action="copy" path="../../../empty_projects/c2000.syscfg" targetDirectory="" />
</project>
</projectSpec>
@@ -0,0 +1,41 @@
<projectSpec>
<project
name="erad_ex1_profile_function_syscfg"
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 &quot;========= 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) =============&quot;
;if ${GENERATE_DIAGRAM} == 1 ${NODE_TOOL} &quot;${C2000WARE_ROOT}/utilities/clb_tool/clb_syscfg/dot_file_libraries/clbDotUtility.js&quot; &quot;${C2000WARE_ROOT}/utilities/clb_tool/clb_syscfg/&quot; &quot;${BuildDirectory}/syscfg&quot; &quot;${BuildDirectory}/syscfg/clb.dot&quot;
;if ${GENERATE_DIAGRAM} == 1 mkdir &quot;${BuildDirectory}/diagrams&quot;
;if ${GENERATE_DIAGRAM} == 1 ${NODE_TOOL} &quot;${C2000WARE_ROOT}/driverlib/.meta/generate_diagrams.js&quot; &quot;${C2000WARE_ROOT}&quot; &quot;${BuildDirectory}/diagrams&quot; &quot;${BuildDirectory}/syscfg&quot;
"
>
<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 --define=RAM --float_support=fpu64 --tmu_support=tmu0 --define=DEBUG --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 --float_support=fpu64 --tmu_support=tmu0 --define=DEBUG --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_lnk_cpu1.cmd" targetDirectory="" applicableConfigurations="CPU1_RAM" />
<file action="copy" path="../../../../../../../device_support/f2838x/common/cmd/2838x_FLASH_lnk_cpu1.cmd" targetDirectory="" applicableConfigurations="CPU1_FLASH" />
<file action="copy" path="../erad_ex1_sections.cmd" targetDirectory="" />
<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="../erad_ex1_profile_function_syscfg.c" targetDirectory="" />
<file action="copy" path="../erad_ex1_profile_function.syscfg" targetDirectory="" />
</project>
</projectSpec>
@@ -0,0 +1,40 @@
<projectSpec>
<project
name="erad_ex2_bus_monitor"
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 &quot;========= 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) =============&quot;
;if ${GENERATE_DIAGRAM} == 1 ${NODE_TOOL} &quot;${C2000WARE_ROOT}/utilities/clb_tool/clb_syscfg/dot_file_libraries/clbDotUtility.js&quot; &quot;${C2000WARE_ROOT}/utilities/clb_tool/clb_syscfg/&quot; &quot;${BuildDirectory}/syscfg&quot; &quot;${BuildDirectory}/syscfg/clb.dot&quot;
;if ${GENERATE_DIAGRAM} == 1 mkdir &quot;${BuildDirectory}/diagrams&quot;
;if ${GENERATE_DIAGRAM} == 1 ${NODE_TOOL} &quot;${C2000WARE_ROOT}/driverlib/.meta/generate_diagrams.js&quot; &quot;${C2000WARE_ROOT}&quot; &quot;${BuildDirectory}/diagrams&quot; &quot;${BuildDirectory}/syscfg&quot;
"
>
<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 --define=RAM --float_support=fpu64 --tmu_support=tmu0 --define=DEBUG --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 --float_support=fpu64 --tmu_support=tmu0 --define=DEBUG --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_lnk_cpu1.cmd" targetDirectory="" applicableConfigurations="CPU1_RAM" />
<file action="copy" path="../../../../../../../device_support/f2838x/common/cmd/2838x_FLASH_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="../erad_ex2_bus_monitor.c" targetDirectory="" />
<file action="copy" path="../../../empty_projects/c2000.syscfg" targetDirectory="" />
</project>
</projectSpec>
@@ -0,0 +1,40 @@
<projectSpec>
<project
name="erad_ex2_bus_monitor_syscfg"
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 &quot;========= 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) =============&quot;
;if ${GENERATE_DIAGRAM} == 1 ${NODE_TOOL} &quot;${C2000WARE_ROOT}/utilities/clb_tool/clb_syscfg/dot_file_libraries/clbDotUtility.js&quot; &quot;${C2000WARE_ROOT}/utilities/clb_tool/clb_syscfg/&quot; &quot;${BuildDirectory}/syscfg&quot; &quot;${BuildDirectory}/syscfg/clb.dot&quot;
;if ${GENERATE_DIAGRAM} == 1 mkdir &quot;${BuildDirectory}/diagrams&quot;
;if ${GENERATE_DIAGRAM} == 1 ${NODE_TOOL} &quot;${C2000WARE_ROOT}/driverlib/.meta/generate_diagrams.js&quot; &quot;${C2000WARE_ROOT}&quot; &quot;${BuildDirectory}/diagrams&quot; &quot;${BuildDirectory}/syscfg&quot;
"
>
<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 --define=RAM --float_support=fpu64 --tmu_support=tmu0 --define=DEBUG --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 --float_support=fpu64 --tmu_support=tmu0 --define=DEBUG --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_lnk_cpu1.cmd" targetDirectory="" applicableConfigurations="CPU1_RAM" />
<file action="copy" path="../../../../../../../device_support/f2838x/common/cmd/2838x_FLASH_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="../erad_ex2_bus_monitor_syscfg.c" targetDirectory="" />
<file action="copy" path="../erad_ex2_bus_monitor.syscfg" targetDirectory="" />
</project>
</projectSpec>
@@ -0,0 +1,40 @@
<projectSpec>
<project
name="erad_ex3_stack_overflow_detect"
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 &quot;========= 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) =============&quot;
;if ${GENERATE_DIAGRAM} == 1 ${NODE_TOOL} &quot;${C2000WARE_ROOT}/utilities/clb_tool/clb_syscfg/dot_file_libraries/clbDotUtility.js&quot; &quot;${C2000WARE_ROOT}/utilities/clb_tool/clb_syscfg/&quot; &quot;${BuildDirectory}/syscfg&quot; &quot;${BuildDirectory}/syscfg/clb.dot&quot;
;if ${GENERATE_DIAGRAM} == 1 mkdir &quot;${BuildDirectory}/diagrams&quot;
;if ${GENERATE_DIAGRAM} == 1 ${NODE_TOOL} &quot;${C2000WARE_ROOT}/driverlib/.meta/generate_diagrams.js&quot; &quot;${C2000WARE_ROOT}&quot; &quot;${BuildDirectory}/diagrams&quot; &quot;${BuildDirectory}/syscfg&quot;
"
>
<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 --define=RAM --float_support=fpu64 --tmu_support=tmu0 --define=DEBUG --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 --float_support=fpu64 --tmu_support=tmu0 --define=DEBUG --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_lnk_cpu1.cmd" targetDirectory="" applicableConfigurations="CPU1_RAM" />
<file action="copy" path="../../../../../../../device_support/f2838x/common/cmd/2838x_FLASH_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="../erad_ex3_stack_overflow_detect.c" targetDirectory="" />
<file action="copy" path="../../../empty_projects/c2000.syscfg" targetDirectory="" />
</project>
</projectSpec>
@@ -0,0 +1,40 @@
<projectSpec>
<project
name="erad_ex3_stack_overflow_detect_syscfg"
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 &quot;========= 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) =============&quot;
;if ${GENERATE_DIAGRAM} == 1 ${NODE_TOOL} &quot;${C2000WARE_ROOT}/utilities/clb_tool/clb_syscfg/dot_file_libraries/clbDotUtility.js&quot; &quot;${C2000WARE_ROOT}/utilities/clb_tool/clb_syscfg/&quot; &quot;${BuildDirectory}/syscfg&quot; &quot;${BuildDirectory}/syscfg/clb.dot&quot;
;if ${GENERATE_DIAGRAM} == 1 mkdir &quot;${BuildDirectory}/diagrams&quot;
;if ${GENERATE_DIAGRAM} == 1 ${NODE_TOOL} &quot;${C2000WARE_ROOT}/driverlib/.meta/generate_diagrams.js&quot; &quot;${C2000WARE_ROOT}&quot; &quot;${BuildDirectory}/diagrams&quot; &quot;${BuildDirectory}/syscfg&quot;
"
>
<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 --define=RAM --float_support=fpu64 --tmu_support=tmu0 --define=DEBUG --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 --float_support=fpu64 --tmu_support=tmu0 --define=DEBUG --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_lnk_cpu1.cmd" targetDirectory="" applicableConfigurations="CPU1_RAM" />
<file action="copy" path="../../../../../../../device_support/f2838x/common/cmd/2838x_FLASH_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="../erad_ex3_stack_overflow_detect_syscfg.c" targetDirectory="" />
<file action="copy" path="../erad_ex3_stack_overflow_detect.syscfg" targetDirectory="" />
</project>
</projectSpec>
@@ -0,0 +1,40 @@
<projectSpec>
<project
name="erad_ex4_profile_interrupt"
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 &quot;========= 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) =============&quot;
;if ${GENERATE_DIAGRAM} == 1 ${NODE_TOOL} &quot;${C2000WARE_ROOT}/utilities/clb_tool/clb_syscfg/dot_file_libraries/clbDotUtility.js&quot; &quot;${C2000WARE_ROOT}/utilities/clb_tool/clb_syscfg/&quot; &quot;${BuildDirectory}/syscfg&quot; &quot;${BuildDirectory}/syscfg/clb.dot&quot;
;if ${GENERATE_DIAGRAM} == 1 mkdir &quot;${BuildDirectory}/diagrams&quot;
;if ${GENERATE_DIAGRAM} == 1 ${NODE_TOOL} &quot;${C2000WARE_ROOT}/driverlib/.meta/generate_diagrams.js&quot; &quot;${C2000WARE_ROOT}&quot; &quot;${BuildDirectory}/diagrams&quot; &quot;${BuildDirectory}/syscfg&quot;
"
>
<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 --define=RAM --float_support=fpu64 --tmu_support=tmu0 --define=DEBUG --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 --float_support=fpu64 --tmu_support=tmu0 --define=DEBUG --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_lnk_cpu1.cmd" targetDirectory="" applicableConfigurations="CPU1_RAM" />
<file action="copy" path="../../../../../../../device_support/f2838x/common/cmd/2838x_FLASH_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="../erad_ex4_profile_interrupt.c" targetDirectory="" />
<file action="copy" path="../../../empty_projects/c2000.syscfg" targetDirectory="" />
</project>
</projectSpec>
@@ -0,0 +1,40 @@
<projectSpec>
<project
name="erad_ex4_profile_interrupt_syscfg"
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 &quot;========= 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) =============&quot;
;if ${GENERATE_DIAGRAM} == 1 ${NODE_TOOL} &quot;${C2000WARE_ROOT}/utilities/clb_tool/clb_syscfg/dot_file_libraries/clbDotUtility.js&quot; &quot;${C2000WARE_ROOT}/utilities/clb_tool/clb_syscfg/&quot; &quot;${BuildDirectory}/syscfg&quot; &quot;${BuildDirectory}/syscfg/clb.dot&quot;
;if ${GENERATE_DIAGRAM} == 1 mkdir &quot;${BuildDirectory}/diagrams&quot;
;if ${GENERATE_DIAGRAM} == 1 ${NODE_TOOL} &quot;${C2000WARE_ROOT}/driverlib/.meta/generate_diagrams.js&quot; &quot;${C2000WARE_ROOT}&quot; &quot;${BuildDirectory}/diagrams&quot; &quot;${BuildDirectory}/syscfg&quot;
"
>
<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 --define=RAM --float_support=fpu64 --tmu_support=tmu0 --define=DEBUG --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 --float_support=fpu64 --tmu_support=tmu0 --define=DEBUG --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_lnk_cpu1.cmd" targetDirectory="" applicableConfigurations="CPU1_RAM" />
<file action="copy" path="../../../../../../../device_support/f2838x/common/cmd/2838x_FLASH_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="../erad_ex4_profile_interrupt_syscfg.c" targetDirectory="" />
<file action="copy" path="../erad_ex4_profile_interrupt.syscfg" targetDirectory="" />
</project>
</projectSpec>
@@ -0,0 +1,41 @@
<projectSpec>
<project
name="erad_ex5_restricted_write_detect"
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 &quot;========= 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) =============&quot;
;if ${GENERATE_DIAGRAM} == 1 ${NODE_TOOL} &quot;${C2000WARE_ROOT}/utilities/clb_tool/clb_syscfg/dot_file_libraries/clbDotUtility.js&quot; &quot;${C2000WARE_ROOT}/utilities/clb_tool/clb_syscfg/&quot; &quot;${BuildDirectory}/syscfg&quot; &quot;${BuildDirectory}/syscfg/clb.dot&quot;
;if ${GENERATE_DIAGRAM} == 1 mkdir &quot;${BuildDirectory}/diagrams&quot;
;if ${GENERATE_DIAGRAM} == 1 ${NODE_TOOL} &quot;${C2000WARE_ROOT}/driverlib/.meta/generate_diagrams.js&quot; &quot;${C2000WARE_ROOT}&quot; &quot;${BuildDirectory}/diagrams&quot; &quot;${BuildDirectory}/syscfg&quot;
"
>
<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 --define=RAM --float_support=fpu64 --tmu_support=tmu0 --define=DEBUG --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 --float_support=fpu64 --tmu_support=tmu0 --define=DEBUG --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_lnk_cpu1.cmd" targetDirectory="" applicableConfigurations="CPU1_RAM" />
<file action="copy" path="../../../../../../../device_support/f2838x/common/cmd/2838x_FLASH_lnk_cpu1.cmd" targetDirectory="" applicableConfigurations="CPU1_FLASH" />
<file action="copy" path="../erad_ex5_sections.cmd" targetDirectory="" />
<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="../erad_ex5_restricted_write_detect.c" targetDirectory="" />
<file action="copy" path="../../../empty_projects/c2000.syscfg" targetDirectory="" />
</project>
</projectSpec>
@@ -0,0 +1,40 @@
<projectSpec>
<project
name="erad_ex6_interrupt_order"
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 &quot;========= 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) =============&quot;
;if ${GENERATE_DIAGRAM} == 1 ${NODE_TOOL} &quot;${C2000WARE_ROOT}/utilities/clb_tool/clb_syscfg/dot_file_libraries/clbDotUtility.js&quot; &quot;${C2000WARE_ROOT}/utilities/clb_tool/clb_syscfg/&quot; &quot;${BuildDirectory}/syscfg&quot; &quot;${BuildDirectory}/syscfg/clb.dot&quot;
;if ${GENERATE_DIAGRAM} == 1 mkdir &quot;${BuildDirectory}/diagrams&quot;
;if ${GENERATE_DIAGRAM} == 1 ${NODE_TOOL} &quot;${C2000WARE_ROOT}/driverlib/.meta/generate_diagrams.js&quot; &quot;${C2000WARE_ROOT}&quot; &quot;${BuildDirectory}/diagrams&quot; &quot;${BuildDirectory}/syscfg&quot;
"
>
<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 --define=RAM --float_support=fpu64 --tmu_support=tmu0 --define=DEBUG --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 --float_support=fpu64 --tmu_support=tmu0 --define=DEBUG --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_lnk_cpu1.cmd" targetDirectory="" applicableConfigurations="CPU1_RAM" />
<file action="copy" path="../../../../../../../device_support/f2838x/common/cmd/2838x_FLASH_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="../erad_ex6_interrupt_order.c" targetDirectory="" />
<file action="copy" path="../../../empty_projects/c2000.syscfg" targetDirectory="" />
</project>
</projectSpec>
@@ -0,0 +1,40 @@
<projectSpec>
<project
name="erad_ex7_reg_write_clb"
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 &quot;========= 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) =============&quot;
;if ${GENERATE_DIAGRAM} == 1 ${NODE_TOOL} &quot;${C2000WARE_ROOT}/utilities/clb_tool/clb_syscfg/dot_file_libraries/clbDotUtility.js&quot; &quot;${C2000WARE_ROOT}/utilities/clb_tool/clb_syscfg/&quot; &quot;${BuildDirectory}/syscfg&quot; &quot;${BuildDirectory}/syscfg/clb.dot&quot;
;if ${GENERATE_DIAGRAM} == 1 mkdir &quot;${BuildDirectory}/diagrams&quot;
;if ${GENERATE_DIAGRAM} == 1 ${NODE_TOOL} &quot;${C2000WARE_ROOT}/driverlib/.meta/generate_diagrams.js&quot; &quot;${C2000WARE_ROOT}&quot; &quot;${BuildDirectory}/diagrams&quot; &quot;${BuildDirectory}/syscfg&quot;
"
>
<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 --define=RAM --float_support=fpu64 --tmu_support=tmu0 --define=DEBUG --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 --float_support=fpu64 --tmu_support=tmu0 --define=DEBUG --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_lnk_cpu1.cmd" targetDirectory="" applicableConfigurations="CPU1_RAM" />
<file action="copy" path="../../../../../../../device_support/f2838x/common/cmd/2838x_FLASH_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="../erad_ex7_reg_write_clb.c" targetDirectory="" />
<file action="copy" path="../erad_ex7_reg_write_clb.syscfg" targetDirectory="" />
</project>
</projectSpec>
@@ -0,0 +1,40 @@
<projectSpec>
<project
name="erad_ex8_pwm_protection"
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 &quot;========= 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) =============&quot;
;if ${GENERATE_DIAGRAM} == 1 ${NODE_TOOL} &quot;${C2000WARE_ROOT}/utilities/clb_tool/clb_syscfg/dot_file_libraries/clbDotUtility.js&quot; &quot;${C2000WARE_ROOT}/utilities/clb_tool/clb_syscfg/&quot; &quot;${BuildDirectory}/syscfg&quot; &quot;${BuildDirectory}/syscfg/clb.dot&quot;
;if ${GENERATE_DIAGRAM} == 1 mkdir &quot;${BuildDirectory}/diagrams&quot;
;if ${GENERATE_DIAGRAM} == 1 ${NODE_TOOL} &quot;${C2000WARE_ROOT}/driverlib/.meta/generate_diagrams.js&quot; &quot;${C2000WARE_ROOT}&quot; &quot;${BuildDirectory}/diagrams&quot; &quot;${BuildDirectory}/syscfg&quot;
"
>
<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 --define=RAM --float_support=fpu64 --tmu_support=tmu0 --define=DEBUG --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 --float_support=fpu64 --tmu_support=tmu0 --define=DEBUG --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_lnk_cpu1.cmd" targetDirectory="" applicableConfigurations="CPU1_RAM" />
<file action="copy" path="../../../../../../../device_support/f2838x/common/cmd/2838x_FLASH_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="../erad_ex8_pwm_protection.c" targetDirectory="" />
<file action="copy" path="../erad_ex8_pwm_protection.syscfg" targetDirectory="" />
</project>
</projectSpec>
@@ -0,0 +1,175 @@
//#############################################################################
//
// FILE: erad_ex1_profile_function.c
//
// TITLE: ERAD Profile Function.
//
//! \addtogroup driver_example_list
//! <h1>ERAD Profile Function</h1>
//!
//! This example uses BUSCOMP1, BUSCOMP2 and COUNTER1 of the ERAD module to
//! profile a function (delayFunction). It calculates the CPU cycles taken
//! between the the start address of the function to the end address of the
//! function
//!
//! Two dummy variable are written to inside the function - startCount and
//! endCount. BUSCOMP3, BUSCOMP4 and COUNTER2 are used to profile the time
//! taken between the access to startCount variable till the access to
//! endCount variable.
//!
//! Both the counters are setup to operate in START-STOP mode and count the
//! number of CPU cycles spend between the respective bus comparator events.
//!
//! \b Watch \b Variables \n
//! - cycles_Function - the maximum number of cycles between the start of
//! function to the end of function
//! - cycles_Data - the maximum number of cycles taken between
//! accessing startCount variable to endCount variable
//!
//! \b External \b Connections \n
//! None
//
//#############################################################################
//
// Included Files
//
#include "driverlib.h"
#include "device.h"
//
// Global Variables
//
//
// Start and end address of the function delayFunction.
// This value comes from the linker command file.
//
extern uint32_t delayFuncStart, delayFuncEnd;
//
// The variables used in the function which are monitored by bus comparators
// 3 and 4.
//
volatile uint32_t startCount = 0;
volatile uint32_t endCount = 0;
//
// Watch variables with the number of CPU cycles elapsed.
//
volatile uint32_t cycles_Function = 0;
volatile uint32_t cycles_Data = 0;
//
// Function Prototypes
//
void delayFunction(uint16_t);
//
// Main
//
void main(void)
{
uint16_t i;
ERAD_Profile_Params params;
//
// Initializes device clock and peripherals
//
Device_init();
//
// Configures the GPIO pin as a push-pull output
//
Device_initGPIO();
//
// Initializes the ERAD module with the owner set as
// the APPLICATION
//
ERAD_initModule(ERAD_OWNER_APPLICATION);
//
// Parameters for profiling function.
// The PC value is being monitored here.
//
params.start_address = (uint32_t)&delayFuncStart;
params.end_address = (uint32_t)&delayFuncEnd - 1U;
params.bus_sel = ERAD_BUSCOMP_BUS_VPC;
params.busComp_base1 = ERAD_HWBP1_BASE;
params.busComp_base2 = ERAD_HWBP2_BASE;
params.counter_base = ERAD_COUNTER1_BASE;
//
// Configuring the required ERAD submodules
//
ERAD_profile(params);
//
// Parameters for profiling the time between the accesses
// to startCount and endCount variables.
// The address in the Data Write Address Bus is monitored here.
//
params.start_address = (uint32_t)&startCount;
params.end_address = (uint32_t)&endCount;
params.bus_sel = ERAD_BUSCOMP_BUS_DWAB;
params.busComp_base1 = ERAD_HWBP3_BASE;
params.busComp_base2 = ERAD_HWBP4_BASE;
params.counter_base = ERAD_COUNTER2_BASE;
//
// Configuring the required ERAD submodules
//
ERAD_profile(params);
//
// Loop to call the delay function repeatedly with different delays
//
for(i=0; i<10; i++)
{
delayFunction(i % 5);
//
// View these two variables in CCS view
// Note that calling the function ERAD_getCurrentValue here will
// return 0 since the stop events have already been occurred.
//
cycles_Function = ERAD_getMaxCount(ERAD_COUNTER1_BASE);
cycles_Data = ERAD_getMaxCount(ERAD_COUNTER2_BASE);
ESTOP0;
//
// Uncomment the code below to clear the maximum count
//
// ERAD_setMaxCount(ERAD_COUNTER1_BASE, 0);
// ERAD_setMaxCount(ERAD_COUNTER2_BASE, 0);
}
ESTOP0;
while(1);
}
//
// delay function
//
#pragma CODE_SECTION(delayFunction, ".delayFunc")
void delayFunction(uint16_t delay)
{
startCount++;
uint16_t i=0;
for (; i<delay; i++)
{
NOP;
NOP;
NOP;
NOP;
}
endCount++;
}
//
// End of File
//
@@ -0,0 +1,34 @@
/**
* Import the modules used in this configuration.
*/
const erad = scripting.addModule("/driverlib/erad.js", {}, false);
const erad1 = erad.addInstance();
/**
* Write custom configuration values to the imported modules.
*/
erad1.$name = "myERAD0";
erad1.hwbpsUsed = ["BUSCOMP1","BUSCOMP2","BUSCOMP3","BUSCOMP4"];
erad1.ctmsUsed = ["COUNTER1","COUNTER2"];
erad1.eradBUSCOMP1.$name = "ERAD_HWBP0";
erad1.eradBUSCOMP1.hwbpAddressInputMode = "CODE";
erad1.eradBUSCOMP1.hwbpRefCodeName = "addr_delayFuncStart";
erad1.eradBUSCOMP2.$name = "ERAD_HWBP1";
erad1.eradBUSCOMP2.hwbpAddressInputMode = "CODE";
erad1.eradBUSCOMP2.hwbpRefCodeName = "addr_delayFuncEnd";
erad1.eradBUSCOMP3.$name = "ERAD_HWBP2";
erad1.eradBUSCOMP3.hwbpBusSel = "ERAD_BUSCOMP_BUS_DWAB";
erad1.eradBUSCOMP3.hwbpAddressInputMode = "CODE";
erad1.eradBUSCOMP3.hwbpRefCodeName = "addr_startCount";
erad1.eradBUSCOMP4.$name = "ERAD_HWBP3";
erad1.eradBUSCOMP4.hwbpBusSel = "ERAD_BUSCOMP_BUS_DWAB";
erad1.eradBUSCOMP4.hwbpAddressInputMode = "CODE";
erad1.eradBUSCOMP4.hwbpRefCodeName = "addr_endCount";
erad1.eradCOUNTER1.$name = "ERAD_CTM0";
erad1.eradCOUNTER1.ctmMode = "1";
erad1.eradCOUNTER2.swStart = "ERAD_EVENT_HWBP1";
erad1.eradCOUNTER1.swStop = "ERAD_EVENT_HWBP2";
erad1.eradCOUNTER2.$name = "ERAD_CTM1";
erad1.eradCOUNTER2.ctmMode = "1";
erad1.eradCOUNTER2.swStart = "ERAD_EVENT_HWBP3";
erad1.eradCOUNTER2.swStop = "ERAD_EVENT_HWBP4";
@@ -0,0 +1,144 @@
//#############################################################################
//
// FILE: erad_ex1_profile_function.c
//
// TITLE: ERAD Profile Function.
//
//! \addtogroup driver_example_list
//! <h1>ERAD Profile Function</h1>
//!
//! This example uses BUSCOMP1, BUSCOMP2 and COUNTER1 of the ERAD module to
//! profile a function (delayFunction). It calculates the CPU cycles taken
//! between the the start address of the function to the end address of the
//! function
//!
//! Two dummy variable are written to inside the function - startCount and
//! endCount. BUSCOMP3, BUSCOMP4 and COUNTER2 are used to profile the time
//! taken between the access to startCount variable till the access to
//! endCount variable.
//!
//! Both the counters are setup to operate in START-STOP mode and count the
//! number of CPU cycles spend between the respective bus comparator events.
//!
//! \b Watch \b Variables \n
//! - cycles_Function - the maximum number of cycles between the start of
//! function to the end of function
//! - cycles_Data - the maximum number of cycles taken between
//! accessing startCount variable to endCount variable
//!
//! \b External \b Connections \n
//! None
//
//#############################################################################
//
// Included Files
//
#include "driverlib.h"
#include "device.h"
#include "board.h"
//
// Global Variables
//
//
// Start and end address of the function delayFunction.
// This value comes from the linker command file.
//
extern uint32_t delayFuncStart, delayFuncEnd;
void *addr_delayFuncStart = (void *)&delayFuncStart;
void *addr_delayFuncEnd = (void *)((uint32_t)&delayFuncEnd - 1);
//
// The variables used in the function which are monitored by bus comparators
// 3 and 4.
//
volatile uint32_t startCount = 0;
volatile uint32_t endCount = 0;
void *addr_startCount = (void *)&startCount;
void *addr_endCount = (void *)&endCount;
//
// Watch variables with the number of CPU cycles elapsed.
//
volatile uint32_t cycles_Function = 0;
volatile uint32_t cycles_Data = 0;
//
// Function Prototypes
//
void delayFunction(uint16_t);
//
// Main
//
void main(void)
{
int i;
//
// Initializes device clock and peripherals
//
Device_init();
//
// Configures the GPIO pin as a push-pull output
//
Device_initGPIO();
//
// Board initialization
//
Board_init();
//
// Loop to call the delay function repeatedly with different delays
//
for(i=0; i<10; i++)
{
delayFunction(i % 5);
//
// View these two variables in CCS view
// Note that calling the function ERAD_getCurrentValue here will
// return 0 since the stop events have already been occurred.
//
cycles_Function = ERAD_getMaxCount(ERAD_COUNTER1_BASE);
cycles_Data = ERAD_getMaxCount(ERAD_COUNTER2_BASE);
ESTOP0;
//
// Uncomment the code below to clear the maximum count
//
// ERAD_setMaxCount(ERAD_COUNTER1_BASE, 0);
// ERAD_setMaxCount(ERAD_COUNTER2_BASE, 0);
}
ESTOP0;
while(1);
}
//
// delay function
//
#pragma CODE_SECTION(delayFunction, ".delayFunc")
void delayFunction(uint16_t delay)
{
startCount++;
uint16_t i=0;
for (; i<delay; i++)
{
NOP;
NOP;
NOP;
NOP;
}
endCount++;
}
//
// End of File
//
@@ -0,0 +1,29 @@
SECTIONS
{
#if defined (_FLASH)
#if defined(__TI_EABI__)
.delayFunc :> FLASH0
LOAD_START(delayFuncStart),
LOAD_END(delayFuncEnd)
#else
.delayFunc :> FLASH0
LOAD_START(_delayFuncStart),
LOAD_END(_delayFuncEnd)
#endif
#else
#if defined(__TI_EABI__)
.delayFunc :> RAMLS4
LOAD_START(delayFuncStart),
LOAD_END(delayFuncEnd)
#else
.delayFunc :> RAMLS4
LOAD_START(_delayFuncStart),
LOAD_END(_delayFuncEnd)
#endif
#endif
}
@@ -0,0 +1,194 @@
//#############################################################################
//
// FILE: erad_ex2_bus_monitor.c
//
// TITLE: ERAD Monotoring instruction and data address buses.
//
//! \addtogroup driver_example_list
//! <h1>ERAD HWBP Monitor Program Counter</h1>
//!
//! In this example, the function delayFunction is called multiple times.
//! The function does read and writes to the global variables startCount and
//! endCount.
//!
//! The BUSCOMP1 and COUNTER1 is used to count the number of times the function
//! delayFunction was invoked. BUSCOMP2 is used to generate an interrupt when
//! there is read access to the startCount variable and BUSCOMP3 is used to
//! generate an interrupt when there is a write access to the endCount variable
//!
//! \b Watch \b Variables \n
//! - funcCount - number of times the function delayFunction was invoked
//! - isrCount - number of times the ISR was invoked
//!
//! \b External \b Connections \n
//! - None
//
//#############################################################################
//
//Included Files
//
#include "driverlib.h"
#include "device.h"
//
// Globals
//
uint32_t isrCount = 0;
uint32_t funcCount = 0;
volatile uint32_t startCount, endCount;
//
// Function prototypes
//
interrupt void RTOSISR(void);
void delayFunction();
//
// Main
//
void main(void)
{
ERAD_AddressHit_Params addr_params;
int i;
//
// Initializes device clock and peripherals
//
Device_init();
//
// Configures the GPIO pin as a push-pull output
//
Device_initGPIO();
//
// Initialise the ERAD module with the APPLICATION as the owner
//
ERAD_initModule(ERAD_OWNER_APPLICATION);
//
// Initializes PIE and clears PIE registers. Disables CPU interrupts.
//
Interrupt_initModule();
//
// Initializes the PIE vector table with pointers to the shell Interrupt
// Service Routines (ISR).
//
Interrupt_initVectorTable();
//
// ISRs for each RTOS interrupt
//
Interrupt_register(INT_RTOS, &RTOSISR);
Interrupt_enableInCPU(INTERRUPT_CPU_RTOSINT);
//
// Enable RTOS Interrupt
//
Interrupt_enable(INT_RTOS);
//
// Configure BUSCOMP1 and COUNTER1 to count the number of times the
// delayFunction was invoked.
// The PC value is being monitored here.
//
addr_params.address = (uint32_t)&delayFunction;
addr_params.mask = 0x0;
addr_params.bus_sel = ERAD_BUSCOMP_BUS_VPC;
ERAD_countAddressHits(addr_params, ERAD_HWBP1_BASE, ERAD_COUNTER1_BASE);
//
// Configure BUSCOMP2 to generate an interrupt when the startCount variable
// is read.
// The Data Read Address Bus is being monitored here.
//
addr_params.address = (uint32_t)&startCount;
addr_params.mask = 0x0;
addr_params.bus_sel = ERAD_BUSCOMP_BUS_DRAB;
ERAD_enableInterruptOnAddressHit(addr_params, ERAD_HWBP2_BASE);
//
// Configure BUSCOMP3 to generate an interrupt when the endCount variable
// is written.
// The Data Write Address Bus is being monitored here.
//
addr_params.address = (uint32_t)&endCount;
addr_params.mask = 0x0;
addr_params.bus_sel = ERAD_BUSCOMP_BUS_DWAB;
ERAD_enableInterruptOnAddressHit(addr_params, ERAD_HWBP3_BASE);
EINT;
ERTM;
//
// Loop to call the delay function multiple times
//
for(i = 0; i < 10; i++)
{
//
// Call the delay function
//
delayFunction();
//
// Get the current count of COUNTER1 to get the number of times
// function delayFunction was invoked
//
funcCount = ERAD_getCurrentCount(ERAD_COUNTER1_BASE);
}
ESTOP0;
while(1);
}
//
// delay function
//
void delayFunction()
{
uint32_t temp = startCount;
startCount = temp + 1;
uint16_t i=0;
for (; i<100; i++)
{
NOP;
}
endCount = temp + 1;
}
//
// ISR to be executed on RTOS generation
// Program will halt at this ESTOP0
//
interrupt void RTOSISR(void)
{
//
// Indicate that the ISR was executed
//
isrCount++;
if(ERAD_getBusCompStatus(ERAD_HWBP2_BASE) == ERAD_STATE_COMPLETED)
{
//
// ISR was raised because of BUSCOMP2 - Read to startCount variable
//
ESTOP0;
ERAD_clearBusCompEvent(ERAD_HWBP2_BASE);
}
if(ERAD_getBusCompStatus(ERAD_HWBP3_BASE) == ERAD_STATE_COMPLETED)
{
//
// ISR was raised because of BUSCOMP3 - Write to endCount variable
//
ESTOP0;
ERAD_clearBusCompEvent(ERAD_HWBP3_BASE);
}
}
@@ -0,0 +1,27 @@
/**
* Import the modules used in this configuration.
*/
const erad = scripting.addModule("/driverlib/erad.js", {}, false);
const erad1 = erad.addInstance();
/**
* Write custom configuration values to the imported modules.
*/
erad1.$name = "myERAD0";
erad1.ctmsUsed = ["COUNTER1"];
erad1.hwbpsUsed = ["BUSCOMP1","BUSCOMP2","BUSCOMP3"];
erad1.eradBUSCOMP1.$name = "ERAD_HWBP0";
erad1.eradBUSCOMP1.hwbpAddressInputMode = "CODE";
erad1.eradBUSCOMP1.hwbpRefCodeName = "addr_delayFunction";
erad1.eradCOUNTER1.$name = "ERAD_CTM0";
erad1.eradCOUNTER1.clockSource = "1";
erad1.eradBUSCOMP2.$name = "ERAD_HWBP1";
erad1.eradBUSCOMP2.hwbpBusSel = "ERAD_BUSCOMP_BUS_DRAB";
erad1.eradBUSCOMP2.hwbpAddressInputMode = "CODE";
erad1.eradBUSCOMP2.hwbpRefCodeName = "addr_startCount";
erad1.eradBUSCOMP2.rtosInterrupt = true;
erad1.eradBUSCOMP3.$name = "ERAD_HWBP2";
erad1.eradBUSCOMP3.hwbpBusSel = "ERAD_BUSCOMP_BUS_DWAB";
erad1.eradBUSCOMP3.hwbpAddressInputMode = "CODE";
erad1.eradBUSCOMP3.hwbpRefCodeName = "addr_endCount";
erad1.eradBUSCOMP3.rtosInterrupt = true;
@@ -0,0 +1,171 @@
//#############################################################################
//
// FILE: erad_ex2_bus_monitor.c
//
// TITLE: ERAD Monotoring instruction and data address buses.
//
//! \addtogroup driver_example_list
//! <h1>ERAD HWBP Monitor Program Counter</h1>
//!
//! In this example, the function delayFunction is called multiple times.
//! The function does read and writes to the global variables startCount and
//! endCount.
//!
//! The BUSCOMP1 and COUNTER1 is used to count the number of times the function
//! delayFunction was invoked. BUSCOMP2 is used to generate an interrupt when
//! there is read access to the startCount variable and BUSCOMP3 is used to
//! generate an interrupt when there is a write access to the endCount variable
//!
//! \b Watch \b Variables \n
//! - funcCount - number of times the function delayFunction was invoked
//! - isrCount - number of times the ISR was invoked
//!
//! \b External \b Connections \n
//! - None
//
//#############################################################################
//
//Included Files
//
#include "driverlib.h"
#include "device.h"
#include "board.h"
//
// Globals
//
uint32_t isrCount = 0;
uint32_t funcCount = 0;
volatile uint32_t startCount, endCount;
//
// Function prototypes
//
interrupt void RTOSISR(void);
void delayFunction();
//
// Addresses of the function and variables to be monitored
//
void *addr_startCount = (void *)&startCount;
void *addr_endCount = (void *)&endCount;
void *addr_delayFunction = (void *)&delayFunction;
//
// Main
//
void main(void)
{
int i;
//
// Initializes device clock and peripherals
//
Device_init();
//
// Board initialization
//
Board_init();
//
// Configures the GPIO pin as a push-pull output
//
Device_initGPIO();
//
// Initializes PIE and clears PIE registers. Disables CPU interrupts.
//
Interrupt_initModule();
//
// Initializes the PIE vector table with pointers to the shell Interrupt
// Service Routines (ISR).
//
Interrupt_initVectorTable();
//
// ISRs for each RTOS interrupt
//
Interrupt_register(INT_RTOS, &RTOSISR);
Interrupt_enableInCPU(INTERRUPT_CPU_RTOSINT);
//
// Enable RTOS Interrupt
//
Interrupt_enable(INT_RTOS);
EINT;
ERTM;
//
// Loop to call the delay function multiple times
//
for(i = 0; i < 10; i++)
{
//
// Call the delay function
//
delayFunction();
//
// Get the current count of COUNTER1 to get the number of times
// function delayFunction was invoked
//
funcCount = ERAD_getCurrentCount(ERAD_COUNTER1_BASE);
}
ESTOP0;
while(1);
}
//
// delay function
//
void delayFunction()
{
uint32_t temp = startCount;
startCount = temp + 1;
uint16_t i=0;
for (; i<100; i++)
{
NOP;
}
endCount = temp + 1;
}
//
// ISR to be executed on RTOS generation
// Program will halt at this ESTOP0
//
interrupt void RTOSISR(void)
{
//
// Indicate that the ISR was executed
//
isrCount++;
if(ERAD_getBusCompStatus(ERAD_HWBP2_BASE) == ERAD_STATE_COMPLETED)
{
//
// ISR was raised because of BUSCOMP2 - Read to startCount variable
//
ESTOP0;
ERAD_clearBusCompEvent(ERAD_HWBP2_BASE);
}
if(ERAD_getBusCompStatus(ERAD_HWBP3_BASE) == ERAD_STATE_COMPLETED)
{
//
// ISR was raised because of BUSCOMP3 - Write to endCount variable
//
ESTOP0;
ERAD_clearBusCompEvent(ERAD_HWBP3_BASE);
}
}
@@ -0,0 +1,157 @@
//#############################################################################
//
// FILE: erad_ex3_stack_overflow_detect.c
//
// TITLE: ERAD HWBP Stack Overflow Detection.
//
//! \addtogroup driver_example_list
//! <h1>ERAD HWBP Stack Overflow Detection</h1>
//!
//! This example uses BUSCOMP1 to monitor the stack. The Bus comparator
//! is set to monitor the data write access bus and generate an RTOS interrupt
//! CPU when a write is detected to end of the STACK within a threshold.
//!
//! \b Watch \b Variables \n
//! - functionCallCount - the number of times the recursive function
//! overflowing the STACK is called.
//! - x indicates that the ISR has been entered
//!
//! \b External \b Connections \n
//! None
//
//#############################################################################
//
//Included Files
//
#include "driverlib.h"
#include "device.h"
//
// Global Variables
//
//
// The stack end address
//
extern uint32_t __TI_STACK_END;
//
// A threshold value. An interrupt is generated when there is an access to
// StackEnd - threshold
//
uint32_t threshold = 10;
volatile uint32_t functionCallCount = 0;
uint32_t x = 0;
//
// Function Prototypes
//
interrupt void RTOSISR(void);
void recursiveFunction(uint32_t delay);
//
// Main
//
void main(void)
{
//
// Initializes device clock and peripherals
//
Device_init();
//
// Configures the GPIO pin as a push-pull output
//
Device_initGPIO();
//
// Initializes PIE and clears PIE registers. Disables CPU interrupts.
//
Interrupt_initModule();
//
// Initializes the PIE vector table with pointers to the shell Interrupt
// Service Routines (ISR).
//
Interrupt_initVectorTable();
//
// ISRs for each RTOS interrupt
//
Interrupt_register(INT_RTOS, &RTOSISR);
Interrupt_enableInCPU(INTERRUPT_CPU_RTOSINT);
//
// Enable RTOS Interrupt
//
Interrupt_enable(INT_RTOS);
//
// Initializes the ERAD module with the owner set as APPLICATION
//
ERAD_initModule(ERAD_OWNER_APPLICATION);
//
// Parameters for generating interrupt on a write access to the
// threshold address
//
ERAD_AddressHit_Params addr_params;
addr_params.address = (uint32_t)&__TI_STACK_END - threshold;
addr_params.mask = 0x0;
addr_params.bus_sel = ERAD_BUSCOMP_BUS_DWAB;
//
// Sets a watchpoint at the end address of the STACK
//
ERAD_enableInterruptOnAddressHit(addr_params, ERAD_HWBP1_BASE);
//
// Enable Global Interrupt (INTM) and realtime interrupt (DBGM)
//
EINT;
ERTM;
recursiveFunction(1);
//
// IDLE loop. Just sit and loop forever (optional)
//
while(1)
{
}
}
//
// recursive function to fill the stack
//
void recursiveFunction(uint32_t delay)
{
functionCallCount++;
//
// Recursive function
//
recursiveFunction(delay + 1UL);
}
//
// ISR to be executed on RTOS generation
// Program will halt at this ESTOP0
//
interrupt void
RTOSISR(void)
{
//
// Indicate that the ISR was executed
//
x++;
ESTOP0;
}
//
// End of File
//
@@ -0,0 +1,16 @@
/**
* Import the modules used in this configuration.
*/
const erad = scripting.addModule("/driverlib/erad.js", {}, false);
const erad1 = erad.addInstance();
/**
* Write custom configuration values to the imported modules.
*/
erad1.$name = "myERAD0";
erad1.hwbpsUsed = ["BUSCOMP1"];
erad1.eradBUSCOMP1.$name = "ERAD_HWBP0";
erad1.eradBUSCOMP1.hwbpBusSel = "ERAD_BUSCOMP_BUS_DWAB";
erad1.eradBUSCOMP1.hwbpAddressInputMode = "CODE";
erad1.eradBUSCOMP1.hwbpRefCodeName = "address";
erad1.eradBUSCOMP1.rtosInterrupt = true;
@@ -0,0 +1,145 @@
//#############################################################################
//
// FILE: erad_ex3_stack_overflow_detect.c
//
// TITLE: ERAD HWBP Stack Overflow Detection.
//
//! \addtogroup driver_example_list
//! <h1>ERAD HWBP Stack Overflow Detection</h1>
//!
//! This example uses BUSCOMP1 to monitor the stack. The Bus comparator
//! is set to monitor the data write access bus and generate an RTOS interrupt
//! CPU when a write is detected to end of the STACK within a threshold.
//!
//! \b Watch \b Variables \n
//! - functionCallCount - the number of times the recursive function
//! overflowing the STACK is called.
//! - x indicates that the ISR has been entered
//!
//! \b External \b Connections \n
//! None
//
//#############################################################################
//
//Included Files
//
#include "driverlib.h"
#include "device.h"
#include "board.h"
//
// Global Variables
//
//
// The stack end address
//
extern uint32_t __TI_STACK_END;
//
// A threshold value. An interrupt is generated when there is an access to
// StackEnd - threshold
//
#define THRESHOLD 10U
volatile uint32_t functionCallCount = 0;
uint32_t x = 0;
void *address = (void *)((uint32_t)&__TI_STACK_END - THRESHOLD);
//
// Function Prototypes
//
interrupt void RTOSISR(void);
void recursiveFunction(uint32_t delay);
//
// Main
//
void main(void)
{
//
// Initializes device clock and peripherals
//
Device_init();
//
// Configures the GPIO pin as a push-pull output
//
Device_initGPIO();
//
// Board initialization
//
Board_init();
//
// Initializes PIE and clears PIE registers. Disables CPU interrupts.
//
Interrupt_initModule();
//
// Initializes the PIE vector table with pointers to the shell Interrupt
// Service Routines (ISR).
//
Interrupt_initVectorTable();
//
// ISRs for each RTOS interrupt
//
Interrupt_register(INT_RTOS, &RTOSISR);
Interrupt_enableInCPU(INTERRUPT_CPU_RTOSINT);
//
// Enable RTOS Interrupt
//
Interrupt_enable(INT_RTOS);
//
// Enable Global Interrupt (INTM) and realtime interrupt (DBGM)
//
EINT;
ERTM;
recursiveFunction(1);
//
// IDLE loop. Just sit and loop forever (optional)
//
while(1)
{
}
}
//
// recursive function to fill the stack
//
void recursiveFunction(uint32_t delay)
{
functionCallCount++;
//
// Recursive function
//
recursiveFunction(delay + 1UL);
}
//
// ISR to be executed on RTOS generation
// Program will halt at this ESTOP0
//
interrupt void
RTOSISR(void)
{
//
// Indicate that the ISR was executed
//
x++;
ESTOP0;
}
//
// End of File
//
@@ -0,0 +1,420 @@
//#############################################################################
//
// FILE: erad_ex1_profile_interrupt.c
//
// TITLE: ERAD Profiling Interrupts Example
//
//! \addtogroup driver_example_list
//! <h1> ERAD Profiling Interrupts </h1>
//!
//! This example shows how an ISR can be profiled by ERAD. The CPU timer
//! generates interrupts periodically. We set up the counters to count the
//! CPU cycles elapsed while executing the ISR, to count the number of
//! interrupts, the number of ISR executions and the CPU cycles elapsed
//! between the interrupt and the execution of the ISR.
//!
//! This example uses 2 bus comparators and 4 counters:
//! - BUSCOMP_1 : PC = start address of cpuTimer1ISR
//! - BUSCOMP_2 : PC = address of cpuTimer1IntCount variable access. This
//! specifies the end address of the code of interest.
//! - COUNTER_1 : Used to count the cpuTimer1ISR execution cycles.
//! Configured in start-stop mode with start event as BUSCOMP_1
//! and stop event as BUSCOMP_2
//! - COUNTER_2 : Used to count the number of times the system event
//! TIMER1_TINT1 has occurred.
//! Configured in rising-edge count mode with counting input as
//! system event TIMER1_TINT1
//! - COUNTER_3 : Used to count the number of times cputTimer2ISR executes.
//! Configured in rising-edge count mode with counting input as
//! BUSCOMP_1
//! - COUNTER_4 : Used to count the latency from the system event TIMER1_TINT1
//! to cpuTimer1ISR entry.
//! Configured in start-stop mode with start event as
//! TIMER1_TINT1 and stop event as BUSCOMP_1
//!
//! We configure the COUNTER1 to generate an interrupt once it reaches a
//! threshold value.
//!
//! \b External \b Connections \n
//! - None
//!
//! \b Profiling \b Output
//! - Current ISR cycle count (COUNTER_1)
//! - Interrupt occurrence count (COUNTER_2)
//! - ISR execution count (COUNTER_3)
//! - ISR entry delay cycle count (maximum value of COUNTER_4)
//! - x - To show that the ISR executed
//!
//
//##############################################################################
//
// Included Files
//
#include "driverlib.h"
#include "device.h"
//
// Globals
//
//
// Threshold for COUNTER1 to generate interrupt
// Interrupt is invoked if the ISR takes more than 500 cycles to complete
//
const uint16_t threshold = 500;
//
// Variable accessed at the end of the ISR. We are interested in measuring the
// time between the start if ISR to the write to this variable
//
uint64_t cpuTimer1IntCount;
//
// Time taken by ISR to complete
//
uint32_t time_isr = 0;
//
// Number of interrupts generated
//
uint32_t number_of_interrupts = 0;
//
// Number of times the ISR actually gets executed
//
uint32_t number_of_executions = 0;
//
// Time elapsed between the interrupt and the execution of the ISR
//
uint32_t time_bw_int_ex = 0;
//
// Function Prototypes
//
interrupt void cpuTimer1ISR(void) __attribute__((ramfunc));
interrupt void RTOSISR(void) __attribute__((ramfunc));
void initCPUTimers(void);
void configERAD(void);
void configCPUTimer(uint32_t, float, float);
//
// Globals
//
//
// Variable to show RTOS interrupt was invoked
//
bool RTOSintCount = 0;
//
// Main
//
void main(void)
{
//
// Initializes device clock and peripherals
//
Device_init();
//
// Configures the GPIO pin as a push-pull output
//
Device_initGPIO();
//
// Initializes PIE and clears PIE registers. Disables CPU interrupts.
//
Interrupt_initModule();
//
// Initializes the PIE vector table with pointers to the shell Interrupt
// Service Routines (ISR).
//
Interrupt_initVectorTable();
//
// ISR for CPU Timer interrupt
//
Interrupt_register(INT_TIMER1, &cpuTimer1ISR);
//
// ISRs for RTOS interrupt
//
Interrupt_register(INT_RTOS, &RTOSISR);
Interrupt_enableInCPU(INTERRUPT_CPU_RTOSINT);
//
// Initializes the Device Peripheral. For this example, only initialize the
// Cpu Timer.
//
initCPUTimers();
//
// Configure CPU-Timer 1 to interrupt every 20000 cycles
//
configCPUTimer(CPUTIMER1_BASE, DEVICE_SYSCLK_FREQ, 200);
//
// To ensure precise timing, use write-only instructions to write to the
// entire register. Therefore, if any of the configuration bits are changed
// in configCPUTimer and initCPUTimers, the below settings must also
// be updated.
//
CPUTimer_enableInterrupt(CPUTIMER1_BASE);
//
// Enables CPU int13 which is connected to CPU-Timer 1
//
Interrupt_enable(INT_TIMER1);
//
// Configure the ERAD module
//
configERAD();
//
// Enable the necessary sub-modules in ERAD
//
ERAD_enableModules(ERAD_INST_BUSCOMP1 | ERAD_INST_BUSCOMP2 |
ERAD_INST_COUNTER1 | ERAD_INST_COUNTER2 |
ERAD_INST_COUNTER3 | ERAD_INST_COUNTER4);
//
// Starts CPU-Timer 1
//
CPUTimer_startTimer(CPUTIMER1_BASE);
//
// Enable Global Interrupt (INTM) and realtime interrupt (DBGM)
//
EINT;
ERTM;
//
// IDLE loop. Just sit and loop forever (optional)
//
while(1)
{
}
}
//
// initCPUTimers - This function initializes all three CPU timers
// to a known state.
//
void
initCPUTimers(void)
{
//
// Make sure timer is stopped
//
CPUTimer_stopTimer(CPUTIMER1_BASE);
//
// Initialize timer period to maximum
//
CPUTimer_setPeriod(CPUTIMER1_BASE, 0xFFFFFFFF);
//
// Initialize pre-scale counter to divide by 1 (SYSCLKOUT)
//
CPUTimer_setPreScaler(CPUTIMER1_BASE, 0);
//
// Reload all counter register with period value
//
CPUTimer_reloadTimerCounter(CPUTIMER1_BASE);
//
// Reset interrupt counter
//
cpuTimer1IntCount = 0;
}
void
configERAD(void)
{
ERAD_BusComp_Config buscomp_params;
ERAD_Counter_Config counter_params;
//
// Initialise the ERAD module with the APPLICATION as owner
//
ERAD_initModule(ERAD_OWNER_APPLICATION);
//
// Configure BUSCOMP1 to generate an event when the ISR begins
// execution
//
buscomp_params.bus_sel = ERAD_BUSCOMP_BUS_VPC;
buscomp_params.reference = (uint32_t)&cpuTimer1ISR;
buscomp_params.mask = 0x0;
buscomp_params.comp_mode = ERAD_BUSCOMP_COMPMODE_EQ;
buscomp_params.enable_stop = 0;
buscomp_params.enable_int = 0;
ERAD_configBusComp(ERAD_HWBP1_BASE, buscomp_params);
//
// Configure BUSCOMP2 to generate and event when there is write to
// cpuTimer1IntCount.
//
buscomp_params.bus_sel = ERAD_BUSCOMP_BUS_DWAB;
buscomp_params.reference = (uint32_t)&cpuTimer1IntCount;
buscomp_params.mask = 0x0;
buscomp_params.comp_mode = ERAD_BUSCOMP_COMPMODE_EQ;
buscomp_params.enable_stop = 0;
buscomp_params.enable_int = 0;
ERAD_configBusComp(ERAD_HWBP2_BASE, buscomp_params);
//
// Time spent between the start of execution and the write to
// cpuTimer1IntCount is what is of interest.
// Configure COUNTER1 to measure CPU cycles elapsed between them
// (between the BUSCOMP1 event to BUSCOMP2 event)
//
counter_params.event = ERAD_EVENT_NO_EVENT;
counter_params.event_mode = ERAD_COUNTER_MODE_ACTIVE;
counter_params.reference = threshold;
counter_params.rst_on_match = 0;
counter_params.enable_stop = 0;
counter_params.enable_int = 1;
ERAD_configCounterInStartStopMode(ERAD_COUNTER1_BASE, counter_params,
ERAD_EVENT_HWBP1, ERAD_EVENT_HWBP2);
//
// Configure COUNTER2 to count the number of interrupts that are raised
//
counter_params.event = ERAD_EVENT_TIMER1_TINT1;
counter_params.event_mode = ERAD_COUNTER_MODE_RISING_EDGE;
counter_params.reference = 0x0;
counter_params.rst_on_match = 0;
counter_params.enable_stop = 0;
counter_params.enable_int = 0;
ERAD_configCounterInCountingMode(ERAD_COUNTER2_BASE, counter_params);
//
// Configure COUNTER3 to count the number of times the ISR is executed
// (the number of times the BUSCOMP1 event has occurred)
//
counter_params.event = ERAD_EVENT_HWBP1;
counter_params.event_mode = ERAD_COUNTER_MODE_RISING_EDGE;
counter_params.reference = 0x0;
counter_params.rst_on_match = 0;
counter_params.enable_stop = 0;
counter_params.enable_int = 0;
ERAD_configCounterInCountingMode(ERAD_COUNTER3_BASE, counter_params);
//
// Configure COUNTER4 to count the number of CPU cycles that elapsed
// between the interrupt and the actual execution of the ISR
//
counter_params.event = ERAD_EVENT_NO_EVENT;
counter_params.event_mode = ERAD_COUNTER_MODE_ACTIVE;
counter_params.reference = 0x0;
counter_params.rst_on_match = 0;
counter_params.enable_stop = 0;
counter_params.enable_int = 0;
ERAD_configCounterInStartStopMode(ERAD_COUNTER4_BASE, counter_params, ERAD_EVENT_TIMER1_TINT1, ERAD_EVENT_HWBP1);
}
//
// configCPUTimer - This function initializes the selected timer to the
// period specified by the "Freq" and "Period" parameters. The "Freq" is
// entered as "Hz" and the period in "uSeconds". The timer is held in the
// stopped state after configuration.
//
void
configCPUTimer(uint32_t cpuTimer, float freq, float period)
{
uint32_t temp;
//
// Initialize timer period:
//
temp = (uint32_t) (freq / 1000000 * period);
CPUTimer_setPeriod(cpuTimer, temp - 1);
//
// Set pre-scale counter to divide by 1 (SYSCLKOUT):
//
CPUTimer_setPreScaler(cpuTimer, 0);
//
// Initializes timer control register. The timer is stopped, reloaded,
// free run disabled, and interrupt enabled.
// Additionally, the free and soft bits are set
//
CPUTimer_stopTimer(cpuTimer);
CPUTimer_reloadTimerCounter(cpuTimer);
CPUTimer_setEmulationMode(cpuTimer,
CPUTIMER_EMULATIONMODE_STOPAFTERNEXTDECREMENT);
CPUTimer_enableInterrupt(cpuTimer);
//
// Resets interrupt counters for the cpuTimer
//
cpuTimer1IntCount = 0;
}
//
// cpuTimer1ISR - Counter for CpuTimer2
//
interrupt void
cpuTimer1ISR(void)
{
//
// Simulate storing data to a location. "volatile" keyword ensures this is
// not optimized out by the compiler.
//
volatile uint32_t output;
//
// Simulate a task that can take some time to complete. Loop a "random"
// number of times and store values to a location.
//
uint32_t i;
for(i = 0; i < cpuTimer1IntCount; i++)
{
output = i;
}
//
// The CPU acknowledges the interrupt. We are interested in the ISR
// until here. Rest is to display the results.
//
cpuTimer1IntCount++;
//
// Get all the required values
//
time_isr = ERAD_getMaxCount(ERAD_COUNTER1_BASE);
number_of_interrupts = ERAD_getCurrentCount(ERAD_COUNTER2_BASE);
number_of_executions = ERAD_getCurrentCount(ERAD_COUNTER3_BASE);
time_bw_int_ex = ERAD_getMaxCount(ERAD_COUNTER4_BASE);
ERAD_setMaxCount(ERAD_COUNTER1_BASE, 0);
ERAD_setMaxCount(ERAD_COUNTER4_BASE, 0);
ESTOP0;
}
//
// ISR to be executed if counter generates RTOS interrupt
//
interrupt void
RTOSISR(void)
{
//
// Variable to show that ISR executed
//
RTOSintCount++;
ESTOP0;
}
//
// End of File
//
@@ -0,0 +1,32 @@
/**
* Import the modules used in this configuration.
*/
const erad = scripting.addModule("/driverlib/erad.js", {}, false);
const erad1 = erad.addInstance();
/**
* Write custom configuration values to the imported modules.
*/
erad1.$name = "myERAD0";
erad1.hwbpsUsed = ["BUSCOMP1","BUSCOMP2"];
erad1.ctmsUsed = ["COUNTER1","COUNTER2","COUNTER3","COUNTER4"];
erad1.eradBUSCOMP1.$name = "ERAD_HWBP0";
erad1.eradBUSCOMP1.hwbpAddressInputMode = "CODE";
erad1.eradBUSCOMP1.hwbpRefCodeName = "addr_cpuTimer1ISR";
erad1.eradBUSCOMP2.$name = "ERAD_HWBP1";
erad1.eradBUSCOMP2.hwbpBusSel = "ERAD_BUSCOMP_BUS_DWAB";
erad1.eradBUSCOMP2.hwbpAddressInputMode = "CODE";
erad1.eradBUSCOMP2.hwbpRefCodeName = "addr_cpuTimer1IntCount";
erad1.eradCOUNTER1.$name = "ERAD_CTM0";
erad1.eradCOUNTER1.ctmMode = "1";
erad1.eradCOUNTER1.swStop = "ERAD_EVENT_HWBP2";
erad1.eradCOUNTER1.rtosInterrupt = true;
erad1.eradCOUNTER1.swReferenceCount = 500;
erad1.eradCOUNTER2.$name = "ERAD_CTM1";
erad1.eradCOUNTER2.clockSource = "1";
erad1.eradCOUNTER2.externalClockSource = "ERAD_EVENT_TIMER1_TINT1";
erad1.eradCOUNTER3.$name = "ERAD_CTM2";
erad1.eradCOUNTER3.clockSource = "1";
erad1.eradCOUNTER4.$name = "ERAD_CTM3";
erad1.eradCOUNTER4.ctmMode = "1";
erad1.eradCOUNTER4.swStart = "ERAD_EVENT_TIMER1_TINT1";
@@ -0,0 +1,328 @@
//#############################################################################
//
// FILE: erad_ex1_profile_interrupt.c
//
// TITLE: ERAD Profiling Interrupts Example
//
//! \addtogroup driver_example_list
//! <h1> ERAD Profiling Interrupts </h1>
//!
//! This example shows how an ISR can be profiled by ERAD. The CPU timer
//! generates interrupts periodically. We set up the counters to count the
//! CPU cycles elapsed while executing the ISR, to count the number of
//! interrupts, the number of ISR executions and the CPU cycles elapsed
//! between the interrupt and the execution of the ISR.
//!
//! This example uses 2 bus comparators and 4 counters:
//! - BUSCOMP_1 : PC = start address of cpuTimer1ISR
//! - BUSCOMP_2 : PC = address of cpuTimer1IntCount variable access. This
//! specifies the end address of the code of interest.
//! - COUNTER_1 : Used to count the cpuTimer1ISR execution cycles.
//! Configured in start-stop mode with start event as BUSCOMP_1
//! and stop event as BUSCOMP_2
//! - COUNTER_2 : Used to count the number of times the system event
//! TIMER1_TINT1 has occurred.
//! Configured in rising-edge count mode with counting input as
//! system event TIMER1_TINT1
//! - COUNTER_3 : Used to count the number of times cputTimer2ISR executes.
//! Configured in rising-edge count mode with counting input as
//! BUSCOMP_1
//! - COUNTER_4 : Used to count the latency from the system event TIMER1_TINT1
//! to cpuTimer1ISR entry.
//! Configured in start-stop mode with start event as
//! TIMER1_TINT1 and stop event as BUSCOMP_1
//!
//! We configure the COUNTER1 to generate an interrupt once it reaches a
//! threshold value.
//!
//! \b External \b Connections \n
//! - None
//!
//! \b Profiling \b Output
//! - Current ISR cycle count (COUNTER_1)
//! - Interrupt occurrence count (COUNTER_2)
//! - ISR execution count (COUNTER_3)
//! - ISR entry delay cycle count (maximum value of COUNTER_4)
//! - x - To show that the ISR executed
//!
//
//##############################################################################
//
// Included Files
//
#include "driverlib.h"
#include "device.h"
#include "board.h"
//
// Globals
//
//
// Threshold for COUNTER1 to generate interrupt
// Interrupt is invoked if the ISR takes more than 500 cycles to complete
//
const uint16_t threshold = 500;
//
// Variable accessed at the end of the ISR. We are interested in measuring the
// time between the start if ISR to the write to this variable
//
uint64_t cpuTimer1IntCount;
//
// Time taken by ISR to complete
//
uint32_t time_isr = 0;
//
// Number of interrupts generated
//
uint32_t number_of_interrupts = 0;
//
// Number of times the ISR actually gets executed
//
uint32_t number_of_executions = 0;
//
// Time elapsed between the interrupt and the execution of the ISR
//
uint32_t time_bw_int_ex = 0;
//
// Function Prototypes
//
interrupt void cpuTimer1ISR(void) __attribute__((ramfunc));
interrupt void RTOSISR(void) __attribute__((ramfunc));
void initCPUTimers(void);
void configCPUTimer(uint32_t, float, float);
//
// Globals
//
void *addr_cpuTimer1ISR = (void *)&cpuTimer1ISR;
void *addr_cpuTimer1IntCount = (void *)&cpuTimer1IntCount;
//
// Variable to show RTOS interrupt was invoked
//
bool RTOSintCount = 0;
//
// Main
//
void main(void)
{
//
// Initializes device clock and peripherals
//
Device_init();
//
// Configures the GPIO pin as a push-pull output
//
Device_initGPIO();
//
// Board initialization
//
Board_init();
//
// Initializes PIE and clears PIE registers. Disables CPU interrupts.
//
Interrupt_initModule();
//
// Initializes the PIE vector table with pointers to the shell Interrupt
// Service Routines (ISR).
//
Interrupt_initVectorTable();
//
// ISR for CPU Timer interrupt
//
Interrupt_register(INT_TIMER1, &cpuTimer1ISR);
//
// ISRs for RTOS interrupt
//
Interrupt_register(INT_RTOS, &RTOSISR);
Interrupt_enableInCPU(INTERRUPT_CPU_RTOSINT);
//
// Initializes the Device Peripheral. For this example, only initialize the
// Cpu Timer.
//
initCPUTimers();
//
// Configure CPU-Timer 1 to interrupt every 20000 cycles
//
configCPUTimer(CPUTIMER1_BASE, DEVICE_SYSCLK_FREQ, 200);
//
// To ensure precise timing, use write-only instructions to write to the
// entire register. Therefore, if any of the configuration bits are changed
// in configCPUTimer and initCPUTimers, the below settings must also
// be updated.
//
CPUTimer_enableInterrupt(CPUTIMER1_BASE);
//
// Enables CPU int13 which is connected to CPU-Timer 1
//
Interrupt_enable(INT_TIMER1);
//
// Starts CPU-Timer 1
//
CPUTimer_startTimer(CPUTIMER1_BASE);
//
// Enable Global Interrupt (INTM) and realtime interrupt (DBGM)
//
EINT;
ERTM;
//
// IDLE loop. Just sit and loop forever (optional)
//
while(1)
{
}
}
//
// initCPUTimers - This function initializes all three CPU timers
// to a known state.
//
void
initCPUTimers(void)
{
//
// Make sure timer is stopped
//
CPUTimer_stopTimer(CPUTIMER1_BASE);
//
// Initialize timer period to maximum
//
CPUTimer_setPeriod(CPUTIMER1_BASE, 0xFFFFFFFF);
//
// Initialize pre-scale counter to divide by 1 (SYSCLKOUT)
//
CPUTimer_setPreScaler(CPUTIMER1_BASE, 0);
//
// Reload all counter register with period value
//
CPUTimer_reloadTimerCounter(CPUTIMER1_BASE);
//
// Reset interrupt counter
//
cpuTimer1IntCount = 0;
}
//
// configCPUTimer - This function initializes the selected timer to the
// period specified by the "Freq" and "Period" parameters. The "Freq" is
// entered as "Hz" and the period in "uSeconds". The timer is held in the
// stopped state after configuration.
//
void
configCPUTimer(uint32_t cpuTimer, float freq, float period)
{
uint32_t temp;
//
// Initialize timer period:
//
temp = (uint32_t) (freq / 1000000 * period);
CPUTimer_setPeriod(cpuTimer, temp - 1);
//
// Set pre-scale counter to divide by 1 (SYSCLKOUT):
//
CPUTimer_setPreScaler(cpuTimer, 0);
//
// Initializes timer control register. The timer is stopped, reloaded,
// free run disabled, and interrupt enabled.
// Additionally, the free and soft bits are set
//
CPUTimer_stopTimer(cpuTimer);
CPUTimer_reloadTimerCounter(cpuTimer);
CPUTimer_setEmulationMode(cpuTimer,
CPUTIMER_EMULATIONMODE_STOPAFTERNEXTDECREMENT);
CPUTimer_enableInterrupt(cpuTimer);
//
// Resets interrupt counters for the cpuTimer
//
cpuTimer1IntCount = 0;
}
//
// cpuTimer1ISR - Counter for CpuTimer2
//
interrupt void
cpuTimer1ISR(void)
{
//
// Simulate storing data to a location. "volatile" keyword ensures this is
// not optimized out by the compiler.
//
volatile uint32_t output;
//
// Simulate a task that can take some time to complete. Loop a "random"
// number of times and store values to a location.
//
uint32_t i;
for(i = 0; i < cpuTimer1IntCount; i++)
{
output = i;
}
//
// The CPU acknowledges the interrupt. We are interested in the ISR
// until here. Rest is to display the results.
//
cpuTimer1IntCount++;
//
// Get all the required values
//
time_isr = ERAD_getMaxCount(ERAD_COUNTER1_BASE);
number_of_interrupts = ERAD_getCurrentCount(ERAD_COUNTER2_BASE);
number_of_executions = ERAD_getCurrentCount(ERAD_COUNTER3_BASE);
time_bw_int_ex = ERAD_getMaxCount(ERAD_COUNTER4_BASE);
ERAD_setMaxCount(ERAD_COUNTER1_BASE, 0);
ERAD_setMaxCount(ERAD_COUNTER4_BASE, 0);
ESTOP0;
}
//
// ISR to be executed if counter generates RTOS interrupt
//
interrupt void
RTOSISR(void)
{
//
// Variable to show that ISR executed
//
RTOSintCount++;
ESTOP0;
}
//
// End of File
//
@@ -0,0 +1,285 @@
//#############################################################################
//!
//! FILE: erad_ex5_restricted_write_detect.c
//!
//! TITLE: erad_ex5_restrictedwrite_detect
//!
//! \addtogroup driver_example_list
//! <h1>ERAD MEMORY ACCESS RESTRICT</h1>
//!
//! This example uses BUSCOMP1 to monitor the Data Write Address Bus.
//! It monitors the bus and generates an RTOS interrupt if a certain
//! region of memory is accessed by the PC. The user may disable the Bus
//! Comparator to access that region.
//!
//! Use the COM port (Baud=9600) to try to write to the restricted area.
//!
//! \b Watch \b Variables \n
//! - x : stores the number of times the region of memory is accessed
//!
//! \b External \b Connections \n
//! - None
//
//#############################################################################
//
// Included Files
//
#include "driverlib.h"
#include "device.h"
#include <string.h>
#include <stdlib.h>
//
// Variable to detect if the restricted region was accessed
//
uint32_t x = 0, y=0;
//
// Function Prototypes
//
//
// This is the function stored in the memory region under
// consideration
//
void try_func(void);
//
// Initialising SCI
//
void initSCI(void);
//
// Configuring the ERAD module
//
void configERAD(void);
//
// ISR to be executed on RTOS generation
//
interrupt void RTOSISR(void);
//
// Main
//
void main(void)
{
//
// Initializes device clock and peripherals
//
Device_init();
//
// Configures the GPIO pin as a push-pull output
//
Device_initGPIO();
//
// Initializes PIE and clears PIE registers. Disables CPU interrupts.
//
Interrupt_initModule();
//
// Initializes the PIE vector table with pointers to the shell Interrupt
// Service Routines (ISR).
//
Interrupt_initVectorTable();
//
// ISRs for each RTOS interrupt
//
Interrupt_register(INT_RTOS, &RTOSISR);
Interrupt_enableInCPU(INTERRUPT_CPU_RTOSINT);
//
// Enable RTOS Interrupt
//
Interrupt_enable(INT_RTOS);
//
// Initialise SCI for interaction with user
//
initSCI();
//
// Configure the ERAD module as required
//
configERAD();
EINT;
ERTM;
//
// SCI COM port interface
//
uint16_t receivedChar;
char val;
char *msg, *msg_x, *msg_g;
msg = "\r\nHi!\0";
msg_x = "\r\nValue of x = \0";
msg_g = "\r\nAccess given.\0";
ltoa(x, &val, 10);
SCI_writeCharArray(SCIA_BASE, (uint16_t*)msg, strlen(msg));
SCI_writeCharArray(SCIA_BASE, (uint16_t*)msg_x, strlen(msg_x));
SCI_writeCharArray(SCIA_BASE, (uint16_t*)(&val), 1);
msg = "\r\nPress a to try to access the restricted region, g to get access or d to disable access:\0";
while(x < 5)
{
SCI_writeCharArray(SCIA_BASE, (uint16_t*)msg, strlen(msg));
receivedChar = SCI_readCharBlockingFIFO(SCIA_BASE);
//
// User enters 'a' to access the restricted region, i.e. try_func
//
if(receivedChar == 'a')
{
try_func();
}
//
// User enters 'd' to enable the bus comparator. An interrupt is
// generated when the restriction region is accessed.
//
else if(receivedChar == 'd')
{
ERAD_enableModules(ERAD_INST_BUSCOMP1);
}
//
// User enters 'd' to enable the bus comparator. No interrupt is
// generated when the restriction region is accessed.
//
else if(receivedChar == 'g')
{
SCI_writeCharArray(SCIA_BASE, (uint16_t*)msg_g, strlen(msg_g));
ERAD_disableModules(ERAD_INST_BUSCOMP1);
}
//
// Value of x denotes how many times try_func was accessed
//
SCI_writeCharArray(SCIA_BASE, (uint16_t*)msg_x, strlen(msg_x));
ltoa(x, &val,10);
SCI_writeCharArray(SCIA_BASE, (uint16_t*)(&val), 1);
}
//
// Loop exits after x becomes 5
//
msg = "\r\nGuess you've played enough.Bye!\0";
SCI_writeCharArray(SCIA_BASE, (uint16_t*)msg, strlen(msg));
ESTOP0;
while(1);
}
void
initSCI(void)
{
//
// GPIO28 is the SCI Rx pin.
//
GPIO_setControllerCore(DEVICE_GPIO_PIN_SCIRXDA, GPIO_CORE_CPU1);
GPIO_setPinConfig(DEVICE_GPIO_CFG_SCIRXDA);
GPIO_setDirectionMode(DEVICE_GPIO_PIN_SCIRXDA, GPIO_DIR_MODE_IN);
GPIO_setPadConfig(DEVICE_GPIO_PIN_SCIRXDA, GPIO_PIN_TYPE_STD);
GPIO_setQualificationMode(DEVICE_GPIO_PIN_SCIRXDA, GPIO_QUAL_ASYNC);
//
// GPIO29 is the SCI Tx pin.
//
GPIO_setControllerCore(DEVICE_GPIO_PIN_SCITXDA, GPIO_CORE_CPU1);
GPIO_setPinConfig(DEVICE_GPIO_CFG_SCITXDA);
GPIO_setDirectionMode(DEVICE_GPIO_PIN_SCITXDA, GPIO_DIR_MODE_OUT);
GPIO_setPadConfig(DEVICE_GPIO_PIN_SCITXDA, GPIO_PIN_TYPE_STD);
GPIO_setQualificationMode(DEVICE_GPIO_PIN_SCITXDA, GPIO_QUAL_ASYNC);
SCI_performSoftwareReset(SCIA_BASE);
//
// Configure SCIA for echoback.
//
SCI_setConfig(SCIA_BASE, DEVICE_LSPCLK_FREQ, 9600, (SCI_CONFIG_WLEN_8 |
SCI_CONFIG_STOP_ONE |
SCI_CONFIG_PAR_NONE));
SCI_resetChannels(SCIA_BASE);
SCI_resetRxFIFO(SCIA_BASE);
SCI_resetTxFIFO(SCIA_BASE);
SCI_clearInterruptStatus(SCIA_BASE, SCI_INT_TXFF | SCI_INT_RXFF);
SCI_enableFIFO(SCIA_BASE);
SCI_enableModule(SCIA_BASE);
SCI_performSoftwareReset(SCIA_BASE);
#ifdef AUTOBAUD
//
// Perform an autobaud lock.
// SCI expects an 'a' or 'A' to lock the baud rate.
//
SCI_lockAutobaud(SCIA_BASE);
#endif
}
void
configERAD(void)
{
//
// Initialise the ERAD module with the APPLICATION as owner
//
ERAD_initModule(ERAD_OWNER_APPLICATION);
//
// Configuring the bus comparator to generate an RTOS interrupt
// if the restricted region is accessed
//
ERAD_BusComp_Config buscomp_config;
buscomp_config.bus_sel = ERAD_BUSCOMP_BUS_VPC;
buscomp_config.reference = (uint32_t)&try_func;
buscomp_config.mask = 0x0;
buscomp_config.comp_mode = ERAD_BUSCOMP_COMPMODE_EQ;
buscomp_config.enable_int = 1;
buscomp_config.enable_stop = 0;
ERAD_configBusComp(ERAD_HWBP1_BASE, buscomp_config);
//
// Enabling the bus comparator
//
ERAD_enableModules(ERAD_INST_BUSCOMP1);
}
//
// ISR to be executed if bus comparator generates RTOS interrupt
//
interrupt void
RTOSISR(void)
{
char *msg;
msg = "\r\nEntering restricted region without getting access.\0";
SCI_writeCharArray(SCIA_BASE, (uint16_t*)msg, strlen(msg));
y += 1;
}
//
// This is the code stored in the restricted region
// The linker command file specifies where it is to be stored in memory
//
#pragma CODE_SECTION(try_func, ".try_sect")
void
try_func(void)
{
char *msg;
msg = "\r\nEntered restricted region \0";
SCI_writeCharArray(SCIA_BASE, (uint16_t*)msg, strlen(msg));
//
// Increment x to show that this code has executed.
//
x+=1;
}
//
// End of File
//
@@ -0,0 +1,13 @@
SECTIONS
{
#if defined (_FLASH)
.try_sect : > FLASH0
#else
.try_sect : > RAMLS4
#endif
}
@@ -0,0 +1,367 @@
///#############################################################################
//!
//! FILE: erad_ex6_interrupt_order.c
//!
//! TITLE: ERAD INTERRUPT ORDER
//!
//! \addtogroup driver_example_list
//! <h1>ERAD INTERRUPT ORDER</h1>
//!
//! This example uses a COUNTER to monitor the sequence of ISRs executed. An
//! interrupt is generated if the ISRs executed are not in the expected order.
//! The expected order is CPUTimer0 ,then CPUTimer1 and then CPUTimer2
//!
//! The counter is configured in Start-Stop Mode to count the number of times
//! CPUTimer2 interrupt occurs between the CPUTimer0 interrupt and CPUTimer1
//! ISRs. Ideally, this count should be zero if the interrupts are occurring
//! in the expected order. we configure a threshold value of 1 to generate an
//! RTOS interrupt. This indicates that the CPUTimer2 interrupt has come out
//! of order.
//!
//! For demonstration purposes, this example disables CPUTimer1 to simulate
//! this error.
//!
//! \b Watch \b Variables \n
//! - cpuTimer0IntCount: Number of executions of ISR0
//! - cpuTimer1IntCount: Number of executions of ISR1
//! - cpuTimer2IntCount: Number of executions of ISR2
//!
//! \b External \b Connections \n
//! - None
//
//#############################################################################
//
// Included Files
//
#include "driverlib.h"
#include "device.h"
//
// Globals
//
uint64_t cpuTimer0IntCount;
uint64_t cpuTimer1IntCount;
uint64_t cpuTimer2IntCount;
//
// Function Prototypes
//
interrupt void cpuTimer0ISR(void);
interrupt void cpuTimer1ISR(void);
interrupt void cpuTimer2ISR(void);
interrupt void RTOSISR(void);
void initCPUTimers(void);
void configERAD(void);
void configCPUTimer(uint32_t, float, float);
//
// Main
//
void main(void)
{
//
// Initializes device clock and peripherals
//
Device_init();
//
// Configures the GPIO pin as a push-pull output
//
Device_initGPIO();
GPIO_setPadConfig(DEVICE_GPIO_PIN_LED2, GPIO_PIN_TYPE_STD);
GPIO_setDirectionMode(DEVICE_GPIO_PIN_LED2, GPIO_DIR_MODE_OUT);
GPIO_writePin(DEVICE_GPIO_PIN_LED2,1);
//
// Initializes PIE and clears PIE registers. Disables CPU interrupts.
//
Interrupt_initModule();
//
// Initializes the PIE vector table with pointers to the shell Interrupt
// Service Routines (ISR).
//
Interrupt_initVectorTable();
//
// ISRs for each CPU Timer interrupt
//
Interrupt_register(INT_TIMER0, &cpuTimer0ISR);
Interrupt_register(INT_TIMER1, &cpuTimer1ISR);
Interrupt_register(INT_TIMER2, &cpuTimer2ISR);
Interrupt_register(INT_RTOS, &RTOSISR);
Interrupt_enableInCPU(INTERRUPT_CPU_RTOSINT);
//
// Initializes the Device Peripheral. For this example, only initialize the
// Cpu Timers.
//
initCPUTimers();
//
// Configure CPU-Timer 0, 1, and 2 to interrupt every 1000 cycles
//
configCPUTimer(CPUTIMER0_BASE, DEVICE_SYSCLK_FREQ, 10);
configCPUTimer(CPUTIMER1_BASE, DEVICE_SYSCLK_FREQ, 10);
configCPUTimer(CPUTIMER2_BASE, DEVICE_SYSCLK_FREQ, 10);
//
// To ensure precise timing, use write-only instructions to write to the
// entire register. Therefore, if any of the configuration bits are changed
// in configCPUTimer and initCPUTimers, the below settings must also
// be updated.
//
CPUTimer_enableInterrupt(CPUTIMER0_BASE);
CPUTimer_enableInterrupt(CPUTIMER1_BASE);
CPUTimer_enableInterrupt(CPUTIMER2_BASE);
//
// Enables CPU int1, int13, and int14 which are connected to CPU-Timer 0,
// CPU-Timer 1, and CPU-Timer 2 respectively.
// Enable TINT0 in the PIE: Group 1 interrupt 7
//
Interrupt_enable(INT_TIMER0);
Interrupt_enable(INT_TIMER1);
Interrupt_enable(INT_TIMER2);
Interrupt_enable(INT_RTOS);
configERAD();
ERAD_enableModules(ERAD_INST_BUSCOMP1 |
ERAD_INST_BUSCOMP2 |
ERAD_INST_COUNTER1);
//
// Starts CPU-Timer 0, CPU-Timer 1, and CPU-Timer 2.
//
CPUTimer_startTimer(CPUTIMER0_BASE);
CPUTimer_startTimer(CPUTIMER1_BASE);
CPUTimer_startTimer(CPUTIMER2_BASE);
//
// Enable Global Interrupt (INTM) and realtime interrupt (DBGM)
//
EINT;
ERTM;
//
// Loop for sometime
//
int i;
for(i = 0; i < 500; i++)
{
NOP;
}
//
// Now stop CPU - Timer 1. The ERAD will detect that the order of occurrence
// of interrupts is not maintained and generate an interrupt.
//
CPUTimer_stopTimer(CPUTIMER1_BASE);
while(1);
}
//
// initCPUTimers - This function initializes all three CPU timers
// to a known state.
//
void
initCPUTimers(void)
{
//
// Make sure timer is stopped
//
CPUTimer_stopTimer(CPUTIMER0_BASE);
CPUTimer_stopTimer(CPUTIMER1_BASE);
CPUTimer_stopTimer(CPUTIMER2_BASE);
//
// Initialize timer period to maximum
//
CPUTimer_setPeriod(CPUTIMER0_BASE, 0xFFFFFFFF);
CPUTimer_setPeriod(CPUTIMER1_BASE, 0xFFFFFFFF);
CPUTimer_setPeriod(CPUTIMER2_BASE, 0xFFFFFFFF);
//
// Initialize pre-scale counter to divide by 1 (SYSCLKOUT)
//
CPUTimer_setPreScaler(CPUTIMER0_BASE, 0);
CPUTimer_setPreScaler(CPUTIMER1_BASE, 0);
CPUTimer_setPreScaler(CPUTIMER2_BASE, 0);
//
// Reload all counter register with period value
//
CPUTimer_reloadTimerCounter(CPUTIMER0_BASE);
CPUTimer_reloadTimerCounter(CPUTIMER1_BASE);
CPUTimer_reloadTimerCounter(CPUTIMER2_BASE);
//
// Reset interrupt counter
//
cpuTimer0IntCount = 0;
cpuTimer1IntCount = 0;
cpuTimer2IntCount = 0;
}
//
// Configure the ERAD
//
void
configERAD(void)
{
ERAD_BusComp_Config buscomp_params;
ERAD_Counter_Config counter_params;
//
// Initialises the module with the APPLICATION as the owner
//
ERAD_initModule(ERAD_OWNER_APPLICATION);
//
// Configuring the bus comparators
// First one is set to monitor the execution of cpuTimer0ISR
//
buscomp_params.bus_sel = ERAD_BUSCOMP_BUS_VPC;
buscomp_params.reference = (uint32_t)&cpuTimer0ISR;
buscomp_params.mask = 0x0;
buscomp_params.comp_mode = ERAD_BUSCOMP_COMPMODE_EQ;
buscomp_params.enable_int = 0;
buscomp_params.enable_stop = 0;
ERAD_configBusComp(ERAD_HWBP1_BASE, buscomp_params);
//
// Second one is set to monitor the execution of cpuTimer1ISR
//
buscomp_params.bus_sel = ERAD_BUSCOMP_BUS_VPC;
buscomp_params.reference = (uint32_t)&cpuTimer1ISR;
buscomp_params.mask = 0x0;
buscomp_params.comp_mode = ERAD_BUSCOMP_COMPMODE_EQ;
buscomp_params.enable_int = 0;
buscomp_params.enable_stop = 0;
ERAD_configBusComp(ERAD_HWBP2_BASE, buscomp_params);
//
// Counter is set to monitor the number of interrupts from the 3rd
// Timer fired between the other 2 interrupts. Generates a RTOS as
// soon as even one fires
//
counter_params.event = ERAD_EVENT_TIMER2_TINT2;
counter_params.event_mode = ERAD_COUNTER_MODE_RISING_EDGE;
counter_params.reference = 0x1;
counter_params.rst_on_match = 0;
counter_params.enable_int = 1;
counter_params.enable_stop = 0;
ERAD_configCounterInStartStopMode(ERAD_COUNTER1_BASE, counter_params,
ERAD_EVENT_HWBP1, ERAD_EVENT_HWBP2);
}
//
// configCPUTimer - This function initializes the selected timer to the
// period specified by the "Freq" and "Period" parameters. The "Freq" is
// entered as "Hz" and the period in "uSeconds". The timer is held in the
// stopped state after configuration.
//
void
configCPUTimer(uint32_t cpuTimer, float freq, float period)
{
uint32_t temp;
//
// Initialize timer period:
//
temp = (uint32_t) (freq / 1000000 * period);
CPUTimer_setPeriod(cpuTimer, temp - 1);
//
// Set pre-scale counter to divide by 1 (SYSCLKOUT):
//
CPUTimer_setPreScaler(cpuTimer, 0);
//
// Initializes timer control register. The timer is stopped, reloaded,
// free run disabled, and interrupt enabled.
// Additionally, the free and soft bits are set
//
CPUTimer_stopTimer(cpuTimer);
CPUTimer_reloadTimerCounter(cpuTimer);
CPUTimer_setEmulationMode(cpuTimer,
CPUTIMER_EMULATIONMODE_STOPAFTERNEXTDECREMENT);
CPUTimer_enableInterrupt(cpuTimer);
//
// Resets interrupt counters for the three cpuTimers
//
if (cpuTimer == CPUTIMER0_BASE)
{
cpuTimer0IntCount = 0;
}
else if(cpuTimer == CPUTIMER1_BASE)
{
cpuTimer1IntCount = 0;
}
else if(cpuTimer == CPUTIMER2_BASE)
{
cpuTimer2IntCount = 0;
}
}
//
// cpuTimer0ISR - Counter for CpuTimer0
//
interrupt void
cpuTimer0ISR(void)
{
cpuTimer0IntCount++;
//
// Acknowledge this interrupt to receive more interrupts from group 1
//
Interrupt_clearACKGroup(INTERRUPT_ACK_GROUP1);
//ESTOP0;
}
//
// cpuTimer1ISR - Counter for CpuTimer1
//
interrupt void
cpuTimer1ISR(void)
{
//
// The CPU acknowledges the interrupt.
//
cpuTimer1IntCount++;
//ESTOP0;
}
//
// cpuTimer2ISR - Counter for CpuTimer2
//
interrupt void
cpuTimer2ISR(void)
{
//
// The CPU acknowledges the interrupt.
//
cpuTimer2IntCount++;
//ESTOP0;
}
//
// Interrupt is raised if CPUTimer2 occurs before CPUTimer1 and after
// CPUTimer0
//
interrupt void
RTOSISR(void)
{
GPIO_writePin(DEVICE_GPIO_PIN_LED2, 0);
ERAD_setCurrentCount(ERAD_COUNTER1_BASE, 0);
ESTOP0;
}
//
// End of file
//
@@ -0,0 +1,264 @@
//#############################################################################
//
// FILE: erad_ex7_reg_write_clb.c
//
// TITLE: ERAD AND CLB.
//
//! \addtogroup driver_example_list
//! <h1>ERAD AND CLB</h1>
//!
//! This example uses 4 BUS COMPARATORS of ERAD along with the CLB. One bus
//! comparator monitors a write to x, another one monitors a write to y. The
//! other two monitor a write of 0x1 and 0x0. By using the LUTs in the CLB1
//! tile, we can monitor a write of 0x1 to x or 0x0 to x. These are used to
//! change the state of FSM2 in the CLB1 tile. If y is accessed before writing
//! a 0x1 to x, an interrupt is generated and y is changed to 0x0 again.
//! The LED2 indicates when access to y is allowed(it is off at this point)
//! The LED1 indicates if an invalid access is attempted.
//! A COUNTER in ERAD is used to count the number of access attempts to y.
//!
//! \b Watch \b Variables \n
//! - y
//! - x
//! - a - counts the number of access attempts to y
//!
//! \b External \b Connections \n
//! None
//
//#############################################################################
//
// Included files
//
#include "driverlib.h"
#include "device.h"
#include "clb_config.h"
#include "board.h"
//
// Function prototypes
//
void config_XBar();
void config_CLB();
__interrupt void clb1ISR();
//
// global variables
//
volatile int x = 0, y = 0, a = 0;
void *addr_x = (void *)&x;
void *addr_y = (void *)&y;
void main(void)
{
//
// Initializes device clock and peripherals
//
Device_init();
//
// Configures the GPIO pin as a push-pull output
//
Device_initGPIO();
//
// Board initialization
//
Board_init();
//
// Initializes PIE and clears PIE registers. Disables CPU interrupts.
//
Interrupt_initModule();
//
// Initializes the PIE vector table with pointers to the shell Interrupt
// Service Routines (ISR).
//
Interrupt_initVectorTable();
//
// ISRs for each CLB interrupt
//
Interrupt_register(INT_CLB1, &clb1ISR);
Interrupt_enable(INT_CLB1);
//
// Configure the modules
//
config_XBar();
config_CLB();
EINT;
ERTM;
CLB_clearInterruptTag(CLB1_BASE);
ESTOP0;
// x = 0;
//
// First attempt to write into y does not work as x is not 1
//
y += 1;
a = ERAD_getCurrentCount(ERAD_COUNTER1_BASE);
ESTOP0;
//
// x is made 1
// Now we can write anything to y
//
x = 1;
ESTOP0;
y += 1;
a = ERAD_getCurrentCount(ERAD_COUNTER1_BASE);
ESTOP0;
//
// Making x 0 again
// y cannot be accessed now
//
x = 0;
ESTOP0;
y += 1;
a = ERAD_getCurrentCount(ERAD_COUNTER1_BASE);
ESTOP0;
}
//
// Configures the CLB module
//
void
config_CLB()
{
SysCtl_enablePeripheral(SYSCTL_PERIPH_CLK_CLB1);
CLB_enableCLB(CLB1_BASE);
initTILE1(CLB1_BASE);
//
// Select Global input instead of local input for all CLB IN
//
CLB_configLocalInputMux(CLB1_BASE, CLB_IN0, CLB_LOCAL_IN_MUX_GLOBAL_IN);
CLB_configLocalInputMux(CLB1_BASE, CLB_IN1, CLB_LOCAL_IN_MUX_GLOBAL_IN);
CLB_configLocalInputMux(CLB1_BASE, CLB_IN2, CLB_LOCAL_IN_MUX_GLOBAL_IN);
CLB_configLocalInputMux(CLB1_BASE, CLB_IN3, CLB_LOCAL_IN_MUX_GLOBAL_IN);
CLB_configLocalInputMux(CLB1_BASE, CLB_IN4, CLB_LOCAL_IN_MUX_GLOBAL_IN);
CLB_configLocalInputMux(CLB1_BASE, CLB_IN5, CLB_LOCAL_IN_MUX_GLOBAL_IN);
CLB_configLocalInputMux(CLB1_BASE, CLB_IN6, CLB_LOCAL_IN_MUX_GLOBAL_IN);
CLB_configLocalInputMux(CLB1_BASE, CLB_IN7, CLB_LOCAL_IN_MUX_GLOBAL_IN);
//
// Select ERAD Bus comparator 1 for CLB1, IN0
// Select ERAD Bus comparator 2 for CLB1, IN1
//
CLB_configGlobalInputMux(CLB1_BASE, CLB_IN0, CLB_GLOBAL_IN_MUX_CPU1_ERAD_EVENT0);
CLB_configGlobalInputMux(CLB1_BASE, CLB_IN1, CLB_GLOBAL_IN_MUX_CPU1_ERAD_EVENT1);
CLB_configGlobalInputMux(CLB1_BASE, CLB_IN2, CLB_GLOBAL_IN_MUX_CPU1_ERAD_EVENT2);
CLB_configGlobalInputMux(CLB1_BASE, CLB_IN3, CLB_GLOBAL_IN_MUX_CPU1_ERAD_EVENT3);
//
// Unused Inputs below
//
CLB_configGlobalInputMux(CLB1_BASE, CLB_IN4, CLB_GLOBAL_IN_MUX_EPWM1A);
CLB_configGlobalInputMux(CLB1_BASE, CLB_IN5, CLB_GLOBAL_IN_MUX_EPWM1A);
CLB_configGlobalInputMux(CLB1_BASE, CLB_IN6, CLB_GLOBAL_IN_MUX_EPWM1A);
CLB_configGlobalInputMux(CLB1_BASE, CLB_IN7, CLB_GLOBAL_IN_MUX_EPWM1A);
//
// Select External for CLB1, IN0
// Select External for CLB1, IN1
//
CLB_configGPInputMux(CLB1_BASE, CLB_IN0, CLB_GP_IN_MUX_EXTERNAL);
CLB_configGPInputMux(CLB1_BASE, CLB_IN1, CLB_GP_IN_MUX_EXTERNAL);
CLB_configGPInputMux(CLB1_BASE, CLB_IN2, CLB_GP_IN_MUX_EXTERNAL);
CLB_configGPInputMux(CLB1_BASE, CLB_IN3, CLB_GP_IN_MUX_EXTERNAL);
CLB_selectInputFilter(CLB1_BASE, CLB_IN0, CLB_FILTER_RISING_EDGE);
CLB_selectInputFilter(CLB1_BASE, CLB_IN1, CLB_FILTER_RISING_EDGE);
CLB_selectInputFilter(CLB1_BASE, CLB_IN2, CLB_FILTER_RISING_EDGE);
CLB_selectInputFilter(CLB1_BASE, CLB_IN3, CLB_FILTER_RISING_EDGE);
//
// Unused inputs to GP register
//
CLB_configGPInputMux(CLB1_BASE, CLB_IN4, CLB_GP_IN_MUX_GP_REG);
CLB_configGPInputMux(CLB1_BASE, CLB_IN5, CLB_GP_IN_MUX_GP_REG);
CLB_configGPInputMux(CLB1_BASE, CLB_IN6, CLB_GP_IN_MUX_GP_REG);
CLB_configGPInputMux(CLB1_BASE, CLB_IN7, CLB_GP_IN_MUX_GP_REG);
//
// Configure OUTPUT-XBAR OUTPUT1 as CLB1_OUT5
//
XBAR_setOutputMuxConfig(OUTPUTXBAR_BASE, XBAR_OUTPUT1, XBAR_OUT_MUX03_CLB1_OUT5);
XBAR_enableOutputMux(OUTPUTXBAR_BASE, XBAR_OUTPUT1, XBAR_MUX03);
CLB_setGPREG(CLB1_BASE, 0);
CLB_setOutputMask(CLB1_BASE, 1 << 0 | 1 << 2, true);
}
//
// Configures the Output X-bar and GPIOs to show output on LEDs
//
void
config_XBar()
{
//
// Turning off LED1
//
GPIO_setPadConfig(DEVICE_GPIO_PIN_LED1, GPIO_PIN_TYPE_STD);
GPIO_setDirectionMode(DEVICE_GPIO_PIN_LED1, GPIO_DIR_MODE_OUT);
GPIO_writePin(DEVICE_GPIO_PIN_LED1, 1);
//
// Routes the output from the X-Bar to LED2
// LED2 will turn on
//
GPIO_setPadConfig(DEVICE_GPIO_PIN_LED2, GPIO_PIN_TYPE_STD);
GPIO_setDirectionMode(DEVICE_GPIO_PIN_LED2, GPIO_DIR_MODE_OUT);
GPIO_setPinConfig(GPIO_34_OUTPUTXBAR1);
}
//
// ISR to be executed if there is access to y without writing 1 to x
//
__interrupt void clb1ISR(void)
{
//
// Makes LED1 glow when an invalid access is done
//
GPIO_writePin(DEVICE_GPIO_PIN_LED1, 0);
//
// Clear the interrupt to allow for further interrupts
//
CLB_clearInterruptTag(CLB1_BASE);
Interrupt_clearACKGroup(INTERRUPT_ACK_GROUP5);
//
// Disable the bus comparator before writing to y so that
// an interrupt is not generated. Enable it again after
// finishing the write.
//
ERAD_disableModules(ERAD_INST_BUSCOMP4);
y=0;
ERAD_enableModules(ERAD_INST_BUSCOMP4);
//
// Software breakpoint(optional)so that the LED can be seen turning on.
// May use delay instead
//
DEVICE_DELAY_US(1000000);// ESTOP0;
//
// Turn off the LED
//
GPIO_writePin(DEVICE_GPIO_PIN_LED1, 1);
}
//
// End of file
//
@@ -0,0 +1,77 @@
/**
* Import the modules used in this configuration.
*/
const erad = scripting.addModule("/driverlib/erad.js", {}, false);
const erad1 = erad.addInstance();
const TILE = scripting.addModule("/utilities/clb_tool/clb_syscfg/source/TILE");
const TILE1 = TILE.addInstance();
const clb_run_dynamic_template_clb_c = scripting.addModule("/utilities/clb_tool/clb_syscfg/source/clb_run_dynamic_template_clb_c.js");
const clb_run_dynamic_template_clb_dot = scripting.addModule("/utilities/clb_tool/clb_syscfg/source/clb_run_dynamic_template_clb_dot.js");
const clb_run_dynamic_template_clb_h = scripting.addModule("/utilities/clb_tool/clb_syscfg/source/clb_run_dynamic_template_clb_h.js");
const clb_run_dynamic_template_clb_sim = scripting.addModule("/utilities/clb_tool/clb_syscfg/source/clb_run_dynamic_template_clb_sim.js");
/**
* Write custom configuration values to the imported modules.
*/
erad1.$name = "myERAD0";
erad1.hwbpsUsed = ["BUSCOMP1","BUSCOMP2","BUSCOMP3","BUSCOMP4"];
erad1.ctmsUsed = ["COUNTER1"];
erad1.eradBUSCOMP1.$name = "ERAD_HWBP0";
erad1.eradBUSCOMP1.hwbpBusSel = "ERAD_BUSCOMP_BUS_DWAB";
erad1.eradBUSCOMP1.hwbpAddressInputMode = "CODE";
erad1.eradBUSCOMP1.hwbpRefCodeName = "addr_x";
erad1.eradBUSCOMP2.$name = "ERAD_HWBP1";
erad1.eradBUSCOMP2.hwbpBusSel = "ERAD_BUSCOMP_BUS_DWDB";
erad1.eradBUSCOMP2.hwbpRef = 1;
erad1.eradBUSCOMP3.$name = "ERAD_HWBP2";
erad1.eradBUSCOMP3.hwbpBusSel = "ERAD_BUSCOMP_BUS_DWDB";
erad1.eradBUSCOMP4.$name = "ERAD_HWBP3";
erad1.eradBUSCOMP4.hwbpBusSel = "ERAD_BUSCOMP_BUS_DRAB";
erad1.eradBUSCOMP4.hwbpAddressInputMode = "CODE";
erad1.eradBUSCOMP4.hwbpRefCodeName = "addr_y";
erad1.eradCOUNTER1.$name = "ERAD_CTM0";
erad1.eradCOUNTER1.clockSource = "1";
TILE1.$name = "TILE1";
TILE1.BOUNDARY.$name = "BOUNDARY0";
TILE1.BOUNDARY.in_period0 = 1000;
TILE1.BOUNDARY.in_repeat_count2 = 1000;
TILE1.BOUNDARY.in_period2 = 30;
TILE1.BOUNDARY.in_duty2 = 15;
TILE1.LUT_0.$name = "LUT_0";
TILE1.LUT_0.i0 = "BOUNDARY.in0";
TILE1.LUT_0.i1 = "BOUNDARY.in1";
TILE1.LUT_0.eqn = "i0&i1";
TILE1.LUT_1.$name = "LUT_1";
TILE1.LUT_1.eqn = "i0&i1";
TILE1.LUT_1.i1 = "BOUNDARY.in2";
TILE1.LUT_1.i0 = "BOUNDARY.in0";
TILE1.LUT_2.$name = "LUT_2";
TILE1.FSM_0.$name = "FSM_0";
TILE1.FSM_1.$name = "FSM_1";
TILE1.FSM_2.$name = "FSM_2";
TILE1.FSM_2.eqn_out = "!s0&xe1";
TILE1.FSM_2.e1 = "LUT_1.OUT";
TILE1.FSM_2.e0 = "LUT_0.OUT";
TILE1.FSM_2.eqn_s0 = "!e1&(s0|e0)";
TILE1.FSM_2.xe1 = "BOUNDARY.in3";
TILE1.COUNTER_0.$name = "COUNTER_0";
TILE1.COUNTER_1.$name = "COUNTER_1";
TILE1.COUNTER_2.$name = "COUNTER_2";
TILE1.OUTLUT_0.$name = "OUTLUT_0";
TILE1.OUTLUT_1.$name = "OUTLUT_1";
TILE1.OUTLUT_2.$name = "OUTLUT_2";
TILE1.OUTLUT_3.$name = "OUTLUT_3";
TILE1.OUTLUT_4.$name = "OUTLUT_4";
TILE1.OUTLUT_5.$name = "OUTLUT_5";
TILE1.OUTLUT_5.eqn = "i0";
TILE1.OUTLUT_5.i0 = "FSM_2.S0";
TILE1.OUTLUT_6.$name = "OUTLUT_6";
TILE1.OUTLUT_7.$name = "OUTLUT_7";
TILE1.HLC.$name = "HLC_0";
TILE1.HLC.e0 = "FSM_2.OUT";
TILE1.HLC.program0.$name = "HLCP_0";
TILE1.HLC.program0.instruct0 = "INTR 0";
TILE1.HLC.program1.$name = "HLCP_1";
TILE1.HLC.program2.$name = "HLCP_2";
TILE1.HLC.program3.$name = "HLCP_3";
@@ -0,0 +1,454 @@
//#############################################################################
//
// FILE: erad_ex8_pwm_protection.c
//
// TITLE: ERAD PWM PROTECTION.
//
//! \addtogroup driver_example_list
//! <h1>ERAD PWM PROTECTION</h1>
//!
//! This example uses a BUS COMPARATOR and the CLB to detect the event when
//! the delay between the interrupt and the ISR execution is longer than
//! expected. The PWM output is also tripped in this case.
//!
//! \b Watch \b Variables \n
//! - adcAResults stores the results of the conversions from the ADC
//!
//! \b External \b Connections \n
//! - Monitor the PWM output (GPIO0)
//
//#############################################################################
//
// Included files
//
#include "driverlib.h"
#include "device.h"
#include "clb_config.h"
#include "board.h"
//
// Macros for configuring the CLB
//
#define RESULTS_BUFFER_SIZE 256
//
// Function prototypes
//
void config_XBar();
void config_CLB();
__interrupt void clb1ISR();
void initADC(void);
void initEPWM(void);
void initADCSOC(void);
__interrupt void adcA1ISR(void);
__interrupt void epwm1TZISR(void);
//
// global variables
//
uint16_t adcAResults[RESULTS_BUFFER_SIZE]; // Buffer for results
uint16_t index; // Index into result buffer
volatile uint16_t bufferFull; // Flag to indicate buffer is full
uint16_t epwm1TZIntCount = 0; // Variable to indicate that trip interrupt executed
void *addr_adcA1ISR = (void *)&adcA1ISR;
//
// Main
//
void main(void)
{
//
// Initialize device clock and peripherals
//
Device_init();
//
// Disable pin locks and enable internal pullups.
//
Device_initGPIO();
//
// Initialize PIE and clear PIE registers. Disables CPU interrupts.
//
Interrupt_initModule();
//
// Initialize the PIE vector table with pointers to the shell Interrupt
// Service Routines (ISR).
//
Interrupt_initVectorTable();
//
// Interrupts that are used in this example are re-mapped to ISR functions
// found within this file.
//
Interrupt_register(INT_ADCA1, &adcA1ISR);
Interrupt_register(INT_EPWM1_TZ, &epwm1TZISR);
//
// Board initialization
//
Board_init();
//
// Set up the ADC and the ePWM and initialize the SOC
//
initADC();
initEPWM();
initADCSOC();
//
// Configure the modules
//
config_XBar();
config_CLB();
//
// Initialize results buffer
//
for(index = 0; index < RESULTS_BUFFER_SIZE; index++)
{
adcAResults[index] = 0;
}
index = 0;
bufferFull = 0;
//
// Enable ADC interrupt
//
Interrupt_enable(INT_ADCA1);
Interrupt_enable(INT_EPWM1_TZ);
CLB_clearInterruptTag(CLB1_BASE);
//
// Enable Global Interrupt (INTM) and realtime interrupt (DBGM)
//
EINT;
ERTM;
ESTOP0;
int i = 0;
//
// Loop indefinitely
//
for(;i<3;i++)
{
//
// Start ePWM1, enabling SOCA and putting the counter in up-count mode
//
EPWM_enableADCTrigger(EPWM1_BASE, EPWM_SOC_A);
EPWM_setTimeBaseCounterMode(EPWM1_BASE, EPWM_COUNTER_MODE_UP);
//
// Wait while ePWM1 causes ADC conversions which then cause interrupts.
// When the results buffer is filled, the bufferFull flag will be set.
//
while(bufferFull == 0)
{
}
bufferFull = 0; // Clear the buffer full flag
//
// Stop ePWM1, disabling SOCA and freezing the counter
//
EPWM_disableADCTrigger(EPWM1_BASE, EPWM_SOC_A);
EPWM_setTimeBaseCounterMode(EPWM1_BASE, EPWM_COUNTER_MODE_STOP_FREEZE);
//
// Software breakpoint. At this point, conversion results are stored in
// adcAResults.
//
// Hit run again to get updated conversions.
//
ESTOP0;
}
//
// Disable the interrupt from the ADC to simulate a longer time between
// interrupt generation and the ISR execution
//
Interrupt_disable(INT_ADCA1);
EPWM_setTimeBaseCounterMode(EPWM1_BASE, EPWM_COUNTER_MODE_UP);
while(1)
{
}
}
//
// initADC - Function to configure and power up ADCA.
//
void initADC(void)
{
//
// Set ADCCLK divider to /4
//
ADC_setPrescaler(ADCA_BASE, ADC_CLK_DIV_4_0);
//
// Set resolution and signal mode
//
ADC_setMode(ADCA_BASE, ADC_RESOLUTION_12BIT, ADC_MODE_SINGLE_ENDED);
//
// Set pulse positions to late
//
ADC_setInterruptPulseMode(ADCA_BASE, ADC_PULSE_END_OF_CONV);
//
// Power up the ADC and then delay for 1 ms
//
ADC_enableConverter(ADCA_BASE);
DEVICE_DELAY_US(1000);
}
//
// initEPWM - Function to configure ePWM1 to generate the SOC.
//
void initEPWM(void)
{
//
// Disable SOCA
//
EPWM_disableADCTrigger(EPWM1_BASE, EPWM_SOC_A);
//
// Configure the SOC to occur on the first up-count event
//
EPWM_setADCTriggerSource(EPWM1_BASE, EPWM_SOC_A, EPWM_SOC_TBCTR_U_CMPA);
EPWM_setADCTriggerEventPrescale(EPWM1_BASE, EPWM_SOC_A, 1);
//
// Set the compare A value to 2048 and the period to 4096
//
EPWM_setCounterCompareValue(EPWM1_BASE, EPWM_COUNTER_COMPARE_A, 0x0800);
EPWM_setTimeBasePeriod(EPWM1_BASE, 0x1000);
//
// Freeze the counter
//
EPWM_setTimeBaseCounterMode(EPWM1_BASE, EPWM_COUNTER_MODE_STOP_FREEZE);
//
// Enable and select trip input4 to the DCAL output
//
EPWM_enableDigitalCompareTripCombinationInput(EPWM1_BASE, EPWM_DC_COMBINATIONAL_TRIPIN4, EPWM_DC_TYPE_DCAL);
EPWM_selectDigitalCompareTripInput(EPWM1_BASE, EPWM_DC_TRIP_COMBINATION, EPWM_DC_TYPE_DCAL);
//
// Set event condition as DCAL going high
//
EPWM_setTripZoneDigitalCompareEventCondition(EPWM1_BASE, EPWM_TZ_DC_OUTPUT_A1, EPWM_TZ_EVENT_DCXL_HIGH);
//
// No filter required
//
EPWM_setDigitalCompareEventSource(EPWM1_BASE, EPWM_DC_MODULE_A, EPWM_DC_EVENT_1, EPWM_DC_EVENT_SOURCE_ORIG_SIGNAL);
//
// Make the PWM go low on trip
//
EPWM_setTripZoneAction(EPWM1_BASE, EPWM_TZ_ACTION_EVENT_DCAEVT1, EPWM_TZ_ACTION_LOW);
//
// Enable interrupt as well on trip
//
EPWM_enableTripZoneInterrupt(EPWM1_BASE, EPWM_TZ_INTERRUPT_DCAEVT1);
//
// Enable the trip zone signal as DCAEVT1
//
EPWM_enableTripZoneSignals(EPWM1_BASE, EPWM_TZ_SIGNAL_OSHT6);
//
// Monitor GPIO0 to see the PWM
//
GPIO_setPadConfig(0, GPIO_PIN_TYPE_STD);
GPIO_setPinConfig(GPIO_0_EPWM1A);
}
//
// initADCSOC - Function to configure ADCA's SOC0 to be triggered by ePWM1.
//
void initADCSOC(void)
{
//
// Configure SOC0 of ADCA to convert pin A0 with a sample window of 10
// SYSCLK cycles. The EPWM1SOCA signal will be the trigger.
//
ADC_setupSOC(ADCA_BASE, ADC_SOC_NUMBER0, ADC_TRIGGER_EPWM1_SOCA,
ADC_CH_ADCIN0, 10);
//
// 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);
}
//
// Configures the CLB module
//
void
config_CLB()
{
SysCtl_enablePeripheral(SYSCTL_PERIPH_CLK_CLB1);
CLB_enableCLB(CLB1_BASE);
initTILE1(CLB1_BASE);
//
// Select Global input instead of local input for all CLB IN
//
CLB_configLocalInputMux(CLB1_BASE, CLB_IN0, CLB_LOCAL_IN_MUX_GLOBAL_IN);
CLB_configLocalInputMux(CLB1_BASE, CLB_IN1, CLB_LOCAL_IN_MUX_GLOBAL_IN);
CLB_configLocalInputMux(CLB1_BASE, CLB_IN2, CLB_LOCAL_IN_MUX_GLOBAL_IN);
CLB_configLocalInputMux(CLB1_BASE, CLB_IN3, CLB_LOCAL_IN_MUX_GLOBAL_IN);
CLB_configLocalInputMux(CLB1_BASE, CLB_IN4, CLB_LOCAL_IN_MUX_GLOBAL_IN);
CLB_configLocalInputMux(CLB1_BASE, CLB_IN5, CLB_LOCAL_IN_MUX_GLOBAL_IN);
CLB_configLocalInputMux(CLB1_BASE, CLB_IN6, CLB_LOCAL_IN_MUX_GLOBAL_IN);
CLB_configLocalInputMux(CLB1_BASE, CLB_IN7, CLB_LOCAL_IN_MUX_GLOBAL_IN);
//
// Select the Comparator A in the EPWM 1 module for CLB1, IN0
// Select ERAD Bus comparator 2 for CLB1, IN1
//
CLB_configGlobalInputMux(CLB1_BASE, CLB_IN0, CLB_GLOBAL_IN_MUX_EPWM1_CTR_CMPA);
CLB_configGlobalInputMux(CLB1_BASE, CLB_IN1, CLB_GLOBAL_IN_MUX_CPU1_ERAD_EVENT0);
//
// Unused Inputs below
//
CLB_configGlobalInputMux(CLB1_BASE, CLB_IN2, CLB_GLOBAL_IN_MUX_EPWM1A);
CLB_configGlobalInputMux(CLB1_BASE, CLB_IN3, CLB_GLOBAL_IN_MUX_EPWM1A);
CLB_configGlobalInputMux(CLB1_BASE, CLB_IN4, CLB_GLOBAL_IN_MUX_EPWM1A);
CLB_configGlobalInputMux(CLB1_BASE, CLB_IN5, CLB_GLOBAL_IN_MUX_EPWM1A);
CLB_configGlobalInputMux(CLB1_BASE, CLB_IN6, CLB_GLOBAL_IN_MUX_EPWM1A);
CLB_configGlobalInputMux(CLB1_BASE, CLB_IN7, CLB_GLOBAL_IN_MUX_EPWM1A);
//
// Select External for CLB1, IN0
// Select External for CLB1, IN1
//
CLB_configGPInputMux(CLB1_BASE, CLB_IN0, CLB_GP_IN_MUX_EXTERNAL);
CLB_configGPInputMux(CLB1_BASE, CLB_IN1, CLB_GP_IN_MUX_EXTERNAL);
CLB_selectInputFilter(CLB1_BASE, CLB_IN0, CLB_FILTER_RISING_EDGE);
CLB_selectInputFilter(CLB1_BASE, CLB_IN1, CLB_FILTER_RISING_EDGE);
//
// Unused inputs to GP register
//
CLB_configGPInputMux(CLB1_BASE, CLB_IN2, CLB_GP_IN_MUX_GP_REG);
CLB_configGPInputMux(CLB1_BASE, CLB_IN3, CLB_GP_IN_MUX_GP_REG);
CLB_configGPInputMux(CLB1_BASE, CLB_IN4, CLB_GP_IN_MUX_GP_REG);
CLB_configGPInputMux(CLB1_BASE, CLB_IN5, CLB_GP_IN_MUX_GP_REG);
CLB_configGPInputMux(CLB1_BASE, CLB_IN6, CLB_GP_IN_MUX_GP_REG);
CLB_configGPInputMux(CLB1_BASE, CLB_IN7, CLB_GP_IN_MUX_GP_REG);
//
// Configure OUTPUT-XBAR OUTPUT1 as CLB1_OUT5
//
XBAR_setOutputMuxConfig(OUTPUTXBAR_BASE, XBAR_OUTPUT1, XBAR_OUT_MUX03_CLB1_OUT5);
XBAR_enableOutputMux(OUTPUTXBAR_BASE, XBAR_OUTPUT1, XBAR_MUX03);
//
// Routes the output of the CLB to the EPWM module
// through the EPWM X-Bar
//
XBAR_setEPWMMuxConfig(XBAR_TRIP4, XBAR_EPWM_MUX01_CLB1_OUT4);
XBAR_enableEPWMMux(XBAR_TRIP4, XBAR_MUX01);
CLB_setGPREG(CLB1_BASE, 0);
CLB_setOutputMask(CLB1_BASE, CLB_OUTPUT_04|CLB_OUTPUT_05, true);
}
//
// Configures the Output X-bar and GPIOs to show output on LEDs
//
void
config_XBar()
{
GPIO_setPadConfig(DEVICE_GPIO_PIN_LED1, GPIO_PIN_TYPE_STD);
GPIO_setDirectionMode(DEVICE_GPIO_PIN_LED1, GPIO_DIR_MODE_OUT);
GPIO_writePin(DEVICE_GPIO_PIN_LED1, 1);
//
// Routes the output from the Output X-Bar to LED2
// LED2 will turn on
//
GPIO_setPadConfig(DEVICE_GPIO_PIN_LED2, GPIO_PIN_TYPE_STD);
GPIO_setDirectionMode(DEVICE_GPIO_PIN_LED2, GPIO_DIR_MODE_OUT);
GPIO_setPinConfig(GPIO_34_OUTPUTXBAR1);
}
//
// epwm1TZISR - ePWM1 TZ ISR
//
__interrupt void epwm1TZISR(void)
{
epwm1TZIntCount++;
//
// Makes LED1 glow
//
GPIO_writePin(DEVICE_GPIO_PIN_LED1, 0);
//
// To re-enable the OST Interrupt, uncomment the below code:
//
// EPWM_clearTripZoneFlag(EPWM1_BASE,
// (EPWM_TZ_INTERRUPT | EPWM_TZ_FLAG_OST));
//
// Acknowledge this interrupt to receive more interrupts from group 2
//
Interrupt_clearACKGroup(INTERRUPT_ACK_GROUP2);
ESTOP0;
}
//
// adcA1ISR - ADC A Interrupt 1 ISR
//
__interrupt void adcA1ISR(void)
{
//
// Add the latest result to the buffer
//
adcAResults[index++] = ADC_readResult(ADCARESULT_BASE, ADC_SOC_NUMBER0);
//
// Set the bufferFull flag if the buffer is full
//
if(RESULTS_BUFFER_SIZE <= index)
{
index = 0;
bufferFull = 1;
}
//
// Clear the interrupt flag
//
ADC_clearInterruptStatus(ADCA_BASE, ADC_INT_NUMBER1);
//
// Check if overflow has occurred
//
if(true == ADC_getInterruptOverflowStatus(ADCA_BASE, ADC_INT_NUMBER1))
{
ADC_clearInterruptOverflowStatus(ADCA_BASE, ADC_INT_NUMBER1);
ADC_clearInterruptStatus(ADCA_BASE, ADC_INT_NUMBER1);
}
//
// Acknowledge the interrupt
//
Interrupt_clearACKGroup(INTERRUPT_ACK_GROUP1);
}
@@ -0,0 +1,60 @@
/**
* Import the modules used in this configuration.
*/
const erad = scripting.addModule("/driverlib/erad.js", {}, false);
const erad1 = erad.addInstance();
const TILE = scripting.addModule("/utilities/clb_tool/clb_syscfg/source/TILE");
const TILE1 = TILE.addInstance();
const clb_run_dynamic_template_clb_c = scripting.addModule("/utilities/clb_tool/clb_syscfg/source/clb_run_dynamic_template_clb_c.js");
const clb_run_dynamic_template_clb_dot = scripting.addModule("/utilities/clb_tool/clb_syscfg/source/clb_run_dynamic_template_clb_dot.js");
const clb_run_dynamic_template_clb_h = scripting.addModule("/utilities/clb_tool/clb_syscfg/source/clb_run_dynamic_template_clb_h.js");
const clb_run_dynamic_template_clb_sim = scripting.addModule("/utilities/clb_tool/clb_syscfg/source/clb_run_dynamic_template_clb_sim.js");
/**
* Write custom configuration values to the imported modules.
*/
erad1.$name = "myERAD0";
erad1.hwbpsUsed = ["BUSCOMP1"];
erad1.eradBUSCOMP1.$name = "ERAD_HWBP0";
erad1.eradBUSCOMP1.hwbpAddressInputMode = "CODE";
erad1.eradBUSCOMP1.hwbpRefCodeName = "addr_adcA1ISR";
TILE1.$name = "TILE1";
TILE1.BOUNDARY.$name = "BOUNDARY0";
TILE1.BOUNDARY.in_period0 = 1000;
TILE1.BOUNDARY.in_repeat_count2 = 1000;
TILE1.BOUNDARY.in_period2 = 30;
TILE1.BOUNDARY.in_duty2 = 15;
TILE1.LUT_0.$name = "LUT_0";
TILE1.LUT_1.$name = "LUT_1";
TILE1.LUT_2.$name = "LUT_2";
TILE1.FSM_0.$name = "FSM_0";
TILE1.FSM_1.$name = "FSM_1";
TILE1.FSM_2.$name = "FSM_2";
TILE1.FSM_2.e0 = "BOUNDARY.in0";
TILE1.FSM_2.e1 = "BOUNDARY.in1";
TILE1.FSM_2.eqn_s0 = "(s0&(!e1))+(s0&e0)+(e0&(!e1))";
TILE1.COUNTER_0.$name = "COUNTER_0";
TILE1.COUNTER_0.mode0 = "FSM_2.S0";
TILE1.COUNTER_0.mode1 = "1";
TILE1.COUNTER_0.reset = "BOUNDARY.in1";
TILE1.COUNTER_0.match1_val = "100";
TILE1.COUNTER_1.$name = "COUNTER_1";
TILE1.COUNTER_2.$name = "COUNTER_2";
TILE1.OUTLUT_0.$name = "OUTLUT_0";
TILE1.OUTLUT_1.$name = "OUTLUT_1";
TILE1.OUTLUT_2.$name = "OUTLUT_2";
TILE1.OUTLUT_3.$name = "OUTLUT_3";
TILE1.OUTLUT_4.$name = "OUTLUT_4";
TILE1.OUTLUT_4.i0 = "COUNTER_0.count_match1";
TILE1.OUTLUT_4.eqn = "i0";
TILE1.OUTLUT_5.$name = "OUTLUT_5";
TILE1.OUTLUT_5.eqn = "!i0";
TILE1.OUTLUT_5.i0 = "FSM_2.S0";
TILE1.OUTLUT_6.$name = "OUTLUT_6";
TILE1.OUTLUT_7.$name = "OUTLUT_7";
TILE1.HLC.$name = "HLC_0";
TILE1.HLC.program0.$name = "HLCP_0";
TILE1.HLC.program1.$name = "HLCP_1";
TILE1.HLC.program2.$name = "HLCP_2";
TILE1.HLC.program3.$name = "HLCP_3";
@@ -0,0 +1,43 @@
<projectSpec>
<project
name="erad_debugger_ex1_profileinterrupts"
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 &quot;========= 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) =============&quot;
;if ${GENERATE_DIAGRAM} == 1 ${NODE_TOOL} &quot;${C2000WARE_ROOT}/utilities/clb_tool/clb_syscfg/dot_file_libraries/clbDotUtility.js&quot; &quot;${C2000WARE_ROOT}/utilities/clb_tool/clb_syscfg/&quot; &quot;${BuildDirectory}/syscfg&quot; &quot;${BuildDirectory}/syscfg/clb.dot&quot;
;if ${GENERATE_DIAGRAM} == 1 mkdir &quot;${BuildDirectory}/diagrams&quot;
;if ${GENERATE_DIAGRAM} == 1 ${NODE_TOOL} &quot;${C2000WARE_ROOT}/driverlib/.meta/generate_diagrams.js&quot; &quot;${C2000WARE_ROOT}&quot; &quot;${BuildDirectory}/diagrams&quot; &quot;${BuildDirectory}/syscfg&quot;
"
>
<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 --define=RAM --float_support=fpu64 --tmu_support=tmu0 --define=DEBUG --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 --float_support=fpu64 --tmu_support=tmu0 --define=DEBUG --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_lnk_cpu1.cmd" targetDirectory="" applicableConfigurations="CPU1_RAM" />
<file action="copy" path="../../../../../../../device_support/f2838x/common/cmd/2838x_FLASH_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="../erad_ex1_profileinterrupts.c" targetDirectory="" />
<file action="copy" path="../erad_ex1_profile_interrupts.js" targetDirectory="" />
<file action="copy" path="../erad.js" targetDirectory="" />
<file action="copy" path="../erad_util.js" targetDirectory="" />
<file action="copy" path="../../../empty_projects/c2000.syscfg" targetDirectory="" />
</project>
</projectSpec>
@@ -0,0 +1,43 @@
<projectSpec>
<project
name="erad_debugger_ex2_profilefunction"
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 &quot;========= 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) =============&quot;
;if ${GENERATE_DIAGRAM} == 1 ${NODE_TOOL} &quot;${C2000WARE_ROOT}/utilities/clb_tool/clb_syscfg/dot_file_libraries/clbDotUtility.js&quot; &quot;${C2000WARE_ROOT}/utilities/clb_tool/clb_syscfg/&quot; &quot;${BuildDirectory}/syscfg&quot; &quot;${BuildDirectory}/syscfg/clb.dot&quot;
;if ${GENERATE_DIAGRAM} == 1 mkdir &quot;${BuildDirectory}/diagrams&quot;
;if ${GENERATE_DIAGRAM} == 1 ${NODE_TOOL} &quot;${C2000WARE_ROOT}/driverlib/.meta/generate_diagrams.js&quot; &quot;${C2000WARE_ROOT}&quot; &quot;${BuildDirectory}/diagrams&quot; &quot;${BuildDirectory}/syscfg&quot;
"
>
<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 --define=RAM --float_support=fpu64 --tmu_support=tmu0 --define=DEBUG --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 --float_support=fpu64 --tmu_support=tmu0 --define=DEBUG --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_lnk_cpu1.cmd" targetDirectory="" applicableConfigurations="CPU1_RAM" />
<file action="copy" path="../../../../../../../device_support/f2838x/common/cmd/2838x_FLASH_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="../erad_ex2_profilefunction.c" targetDirectory="" />
<file action="copy" path="../erad_ex2_profile_function.js" targetDirectory="" />
<file action="copy" path="../erad.js" targetDirectory="" />
<file action="copy" path="../erad_util.js" targetDirectory="" />
<file action="copy" path="../../../empty_projects/c2000.syscfg" targetDirectory="" />
</project>
</projectSpec>
@@ -0,0 +1,42 @@
<projectSpec>
<project
name="erad_debugger_ex3_stackoverflow"
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 &quot;========= 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) =============&quot;
;if ${GENERATE_DIAGRAM} == 1 ${NODE_TOOL} &quot;${C2000WARE_ROOT}/utilities/clb_tool/clb_syscfg/dot_file_libraries/clbDotUtility.js&quot; &quot;${C2000WARE_ROOT}/utilities/clb_tool/clb_syscfg/&quot; &quot;${BuildDirectory}/syscfg&quot; &quot;${BuildDirectory}/syscfg/clb.dot&quot;
;if ${GENERATE_DIAGRAM} == 1 mkdir &quot;${BuildDirectory}/diagrams&quot;
;if ${GENERATE_DIAGRAM} == 1 ${NODE_TOOL} &quot;${C2000WARE_ROOT}/driverlib/.meta/generate_diagrams.js&quot; &quot;${C2000WARE_ROOT}&quot; &quot;${BuildDirectory}/diagrams&quot; &quot;${BuildDirectory}/syscfg&quot;
"
>
<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 --define=RAM --float_support=fpu64 --tmu_support=tmu0 --define=DEBUG --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 --float_support=fpu64 --tmu_support=tmu0 --define=DEBUG --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_lnk_cpu1.cmd" targetDirectory="" applicableConfigurations="CPU1_RAM" />
<file action="copy" path="../../../../../../../device_support/f2838x/common/cmd/2838x_FLASH_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="../erad_ex3_stackoverflow.c" targetDirectory="" />
<file action="copy" path="../erad_ex3_stack_overflow.js" targetDirectory="" />
<file action="copy" path="../erad.js" targetDirectory="" />
<file action="copy" path="../../../empty_projects/c2000.syscfg" targetDirectory="" />
</project>
</projectSpec>
@@ -0,0 +1,45 @@
<projectSpec>
<project
name="erad_debugger_ex4_profileinterrupts_cla"
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 &quot;========= 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) =============&quot;
;if ${GENERATE_DIAGRAM} == 1 ${NODE_TOOL} &quot;${C2000WARE_ROOT}/utilities/clb_tool/clb_syscfg/dot_file_libraries/clbDotUtility.js&quot; &quot;${C2000WARE_ROOT}/utilities/clb_tool/clb_syscfg/&quot; &quot;${BuildDirectory}/syscfg&quot; &quot;${BuildDirectory}/syscfg/clb.dot&quot;
;if ${GENERATE_DIAGRAM} == 1 mkdir &quot;${BuildDirectory}/diagrams&quot;
;if ${GENERATE_DIAGRAM} == 1 ${NODE_TOOL} &quot;${C2000WARE_ROOT}/driverlib/.meta/generate_diagrams.js&quot; &quot;${C2000WARE_ROOT}&quot; &quot;${BuildDirectory}/diagrams&quot; &quot;${BuildDirectory}/syscfg&quot;
"
>
<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="../erad_ex4_background_task_cla.cla" targetDirectory="" />
<file action="copy" path="../erad_ex4_background_task.h" targetDirectory="" />
<file action="copy" path="../erad_ex4_profileinterrupts_cla.c" targetDirectory="" />
<file action="copy" path="../erad_ex4_profile_interrupts_cla.js" targetDirectory="" />
<file action="copy" path="../erad.js" targetDirectory="" />
<file action="copy" path="../erad_util.js" targetDirectory="" />
<file action="copy" path="../../../empty_projects/c2000.syscfg" targetDirectory="" />
</project>
</projectSpec>
@@ -0,0 +1,77 @@
//#############################################################################
//
// erad.js
//
// This file contains addresses and offsets for all ERAD registers
//
//#############################################################################
print("Including erad.js \n");
//
// ERAD Global Registers Base Address
//
var EradGlobalRegs = 0x5E800;
//
// ERAD Global Register Offsets
//
var GLBL_EVENT_STAT = 0x0; // Global Event Status Register
var GLBL_HALT_STAT = 0x2; // Global Halt Status Register
var GLBL_ENABLE = 0x4; // Global Enable Register
var GLBL_CTM_RESET = 0x6; // Global Counter Reset
var GLBL_OWNER = 0xA; // Global Ownership
//
// ERAD Hardware Breakpoint Register Base Addresses
//
var EradHWBP1Regs = 0x5E900;
var EradHWBP2Regs = 0x5E908;
var EradHWBP3Regs = 0x5E910;
var EradHWBP4Regs = 0x5E918;
var EradHWBP5Regs = 0x5E920;
var EradHWBP6Regs = 0x5E928;
var EradHWBP7Regs = 0x5E930;
var EradHWBP8Regs = 0x5E938;
//
// ERAD Hardware Breakpoint Register Offsets
//
var HWBP_MASK = 0x0; // HWBP Mask Register
var HWBP_REF = 0x2; // HWBP Reference Register
var HWBP_CLEAR = 0x4; // HWBP Clear Register
var HWBP_CNTL = 0x6; // HWBP Control Register
var HWBP_STATUS = 0x7; // HWBP Status Register
//
// ERAD Counter Register Base Addresses
//
var EradCounter1Regs = 0x5E980;
var EradCounter2Regs = 0x5E990;
var EradCounter3Regs = 0x5E9A0;
var EradCounter4Regs = 0x5E9B0;
//
// ERAD Counter Register Offsets
//
var CTM_CNTL = 0x0; // Counter Control Register
var CTM_STATUS = 0x1; // Counter Status Register
var CTM_REF = 0x2; // Counter Reference Register
var CTM_COUNT = 0x4; // Counter Current Value Register
var CTM_MAX_COUNT = 0x6; // Counter Max Count Value
// Register
var CTM_INPUT_SEL = 0x8; // Counter Input Select Register
var CTM_CLEAR = 0x9; // Counter Clear Register
var CTM_INPUT_SEL_2 = 0xA; // Counter Input Select Extension
// Register
//
// ERAD Miscellaneous Constants
//
var OWNER_DEBUGGER = 0x2; // Value to set in Global
// Ownership register in order to
// set owner as debugger
//
// End of File
//
@@ -0,0 +1,546 @@
//#############################################################################
//
// erad_ex1_profile_interrupts.js
//
// This JavaScript file is used to configure ERAD registers for use with the CCS
// example "erad_ex1_profileinterrupts".
//
// To properly use this script, the following variables must be set in the
// scripting environment prior to launching the ERAD script:
//
// - var PROJ_NAME = "erad_debugger_ex1_profileinterrupts"
// - var PROJ_WKSPC_LOC = "<proj_workspace_path>"
// - var PROJ_CONFIG = "<name of active configuration [CPU1_FLASH|CPU1_RAM]>"
//
// To run this ERAD script, use the following command in the scripting console:
//
// - loadJSFile("<proj_workspace_path>\\erad_debugger_ex1_profileinterrupts\\erad_ex1_profile_interrupts.js", 0);
//
// This JavaScript file uses Debug Server Scripting (DSS) features. For
// information on using the DSS, please visit:
// http://software-dl.ti.com/ccs/esd/documents/users_guide/sdto_dss_handbook.html
//
//#############################################################################
//
// Import the DSS packages
//
importPackage(Packages.com.ti.debug.engine.scripting)
importPackage(Packages.com.ti.ccstudio.scripting.environment)
importPackage(Packages.java.lang)
//
// Load pre-defined macros for register addresses and useful functions
//
load(PROJ_WKSPC_LOC + "\\" + PROJ_NAME + "\\erad.js");
load(PROJ_WKSPC_LOC + "\\" + PROJ_NAME + "\\erad_util.js");
//
// Create our scripting environment object. This is the main entry point into
// any script and the factory for creating other scriptable servers and sessions
//
var script = ScriptingEnvironment.instance();
script.traceSetConsoleLevel(TraceLevel.ALL)
//
// Create a debug server
//
var ds = script.getServer( "DebugServer.1" );
//
// Open a debug session
//
debugSession = ds.openSession( "*", "C28xx_CPU1" );
//
// Variables for data read/write sizes
//
var DATA_SIZE_16 = 16;
var DATA_SIZE_32 = 32;
//*****************************************************************************
// Example: Profile Interrupts
//*****************************************************************************
//
// Set owner as debugger
//
debugSession.memory.writeData(Memory.Page.DATA,
EradGlobalRegs + GLBL_OWNER,
OWNER_DEBUGGER,
DATA_SIZE_16);
//
// Ensure that counters 1-4 are in idle mode (bits 15:12 are set to 0)
//
var counter1Status =
debugSession.memory.readData(Memory.Page.DATA,
EradCounter1Regs + CTM_STATUS,
DATA_SIZE_16);
var counter2Status =
debugSession.memory.readData(Memory.Page.DATA,
EradCounter2Regs + CTM_STATUS,
DATA_SIZE_16);
var counter3Status =
debugSession.memory.readData(Memory.Page.DATA,
EradCounter3Regs + CTM_STATUS,
DATA_SIZE_16);
var counter4Status =
debugSession.memory.readData(Memory.Page.DATA,
EradCounter4Regs + CTM_STATUS,
DATA_SIZE_16);
var CTM_STATUS_M = 0xF000;
if((0 == (counter1Status & CTM_STATUS_M)) &&
(0 == (counter2Status & CTM_STATUS_M)) &&
(0 == (counter3Status & CTM_STATUS_M)) &&
(0 == (counter4Status & CTM_STATUS_M)))
{
//
// Reset HWBP_1 and HWBP_2
//
debugSession.memory.writeData(Memory.Page.DATA,
EradHWBP1Regs + HWBP_CLEAR,
0x1,
DATA_SIZE_16);
debugSession.memory.writeData(Memory.Page.DATA,
EradHWBP2Regs + HWBP_CLEAR,
0x1,
DATA_SIZE_16);
//
// Get the start and end addresses of the Timer 2 ISR
//
var addrFunc = getFuncAddressXML("cpuTimer2ISR");
var startTimer2ISR = addrFunc[0];
var endTimer2ISR = addrFunc[1];
//
// Set two hardware breakpoints at the start and end of cpuTimer2ISR
//
debugSession.memory.writeData(Memory.Page.DATA,
EradHWBP1Regs + HWBP_REF,
startTimer2ISR,
DATA_SIZE_32);
debugSession.memory.writeData(Memory.Page.DATA,
EradHWBP2Regs + HWBP_REF,
endTimer2ISR,
DATA_SIZE_32);
//
// Set HWBP_1 and HWBP_2 to generate an event on PC match
// RESERVED = (0 << 0) | -> RESERVED
// BUS_SEL = (1 << 1) | -> VPC for program counter match
// STOP = (0 << 5) | -> Do not stop CPU on match
// RTOSINT = (0 << 6) | -> Do not generate RTOSINT
// COMP_MODE = (0 << 7) | -> Regular masked compare.
// (address | mask) == (reference | mask)
// RESERVED = (0 << 12) -> RESERVED
//
// HWBP_CNTL = 0x0002
//
debugSession.memory.writeData(Memory.Page.DATA,
EradHWBP1Regs + HWBP_CNTL,
0x0002,
DATA_SIZE_16);
debugSession.memory.writeData(Memory.Page.DATA,
EradHWBP2Regs + HWBP_CNTL,
0x0002,
DATA_SIZE_16);
//
// Reset Counters 1-4 globally
//
debugSession.memory.writeData(Memory.Page.DATA,
EradGlobalRegs + GLBL_CTM_RESET,
0xF,
DATA_SIZE_16);
//
// Clear CTM_COUNT
//
debugSession.memory.writeData(Memory.Page.DATA,
EradCounter1Regs + CTM_COUNT,
0x0,
DATA_SIZE_32);
//
// Clear CTM_MAX_COUNT
//
debugSession.memory.writeData(Memory.Page.DATA,
EradCounter1Regs + CTM_MAX_COUNT,
0x0,
DATA_SIZE_32);
//
// Clear EVENT_FIRED and OVERFLOW sticky bits
// EVENT_CLEAR = (1 << 0) | -> Clear EVENT_FIRED sticky bit in CTM_STATUS
// OVERFLOW_CLEAR = (1 << 1) | -> Clear OVERFLOW sticky bit in CTM_STATUS
// RESERVED = (0 << 2) -> RESERVED
//
debugSession.memory.writeData(Memory.Page.DATA,
EradCounter1Regs + CTM_CLEAR,
0x3,
DATA_SIZE_16);
//
// Clear CTM_REF
//
debugSession.memory.writeData(Memory.Page.DATA,
EradCounter1Regs + CTM_REF,
0x0,
DATA_SIZE_32);
//
// Configure CTM_1 to count cpuTimer2ISR execution cycles
// Configure CTM_1 to be in start-stop mode
//
// CTM_INPUT_SEL = 0x0000
// CTM_INP_SEL = (0 << 0) | -> Disabled by CTM_INP_SEL_EN
// STA_INP_SEL = (0 << 8) | -> Use HWBP_1 as start event for CTM_1
//
// CTM_INPUT_SEL_2 = 0x0001
// STO_INP_SEL = (1 << 0) -> Use HWBP_2 as stop event for CTM_1
// RST_INP_SEL = (0 << 8) -> Disabled by RST_EN
//
// CTM_CNTL = 0x0004
// RESERVED = (0 << 0) | -> RESERVED
// START_STOP_MODE = (1 << 2) | -> Enable start-stop mode
// EVENT_MODE = (0 << 3) | -> Count as long as input is active (high)
// RST_ON_MATCH = (0 << 4) | -> Stop counting once reference value is
// reached
// RESERVED = (0 << 5) | -> RESERVED
// STOP = (0 << 6) | -> Do not stop CPU when counter reaches
// reference value
// RTOSINT = (0 << 7) | -> Do not generate RTOSINT
// START_STOP_CUM = (0 << 8) | -> Counter gets cleared on stop event
// RESERVED = (0 << 9) | -> RESERVED
// RST_EN = (0 << 10) | -> Disable RST_INP_SEL
// CTM_INP_SEL_EN = (0 << 11) -> Disable CTM_IN_SEL register and count
// CPU cycles
//
debugSession.memory.writeData(Memory.Page.DATA,
EradCounter1Regs + CTM_INPUT_SEL,
(0x0),
DATA_SIZE_16);
debugSession.memory.writeData(Memory.Page.DATA,
EradCounter1Regs + CTM_INPUT_SEL_2,
(0x1),
DATA_SIZE_16);
debugSession.memory.writeData(Memory.Page.DATA,
EradCounter1Regs + CTM_CNTL,
0x004,
DATA_SIZE_16);
//
// Clear CTM_COUNT, CTM_MAX_COUNT, CTM_STATUS sticky bits
//
debugSession.memory.writeData(Memory.Page.DATA,
EradCounter2Regs + CTM_COUNT,
0x0,
DATA_SIZE_32);
debugSession.memory.writeData(Memory.Page.DATA,
EradCounter2Regs + CTM_MAX_COUNT,
0x0,
DATA_SIZE_32);
debugSession.memory.writeData(Memory.Page.DATA,
EradCounter2Regs + CTM_CLEAR,
0x3,
DATA_SIZE_16);
//
// Configure CTM_2 to count number of times system event TIMER2_TINT2 occurs
// Configure CTM_2 to be in rising-edge count mode
//
// CTM_INPUT_SEL = 34 ( Count system event TIMER2_TINT2 )
// CTM_INPUT_SEL_2 = 0
//
debugSession.memory.writeData(Memory.Page.DATA,
EradCounter2Regs + CTM_INPUT_SEL,
34,
DATA_SIZE_16);
debugSession.memory.writeData(Memory.Page.DATA,
EradCounter2Regs + CTM_INPUT_SEL_2,
0x0000,
DATA_SIZE_16);
//
// Configure CTM_2 to be in rising-edge count mode
//
// CTM_CNTL = 0x0808
// EVENT_MODE = (1 << 3) | -> Count only on rising-edge of count input
// CNT_INP_SEL_EN = (1 << 11) -> Enable CTM_INP_SEL
//
debugSession.memory.writeData(Memory.Page.DATA,
EradCounter2Regs + CTM_CNTL,
0x0808,
DATA_SIZE_16);
//
// Clear CTM_COUNT, CTM_MAX_COUNT, CTM_STATUS sticky bits
//
debugSession.memory.writeData(Memory.Page.DATA,
EradCounter3Regs + CTM_COUNT,
0x0,
DATA_SIZE_32);
debugSession.memory.writeData(Memory.Page.DATA,
EradCounter3Regs + CTM_MAX_COUNT,
0x0,
DATA_SIZE_32);
debugSession.memory.writeData(Memory.Page.DATA,
EradCounter3Regs + CTM_CLEAR,
0x3,
DATA_SIZE_16);
//
// Configure CTM_3 to count number of times cputTimer2ISR executes
// CNT_INP_SEL = 0 ( Use HWBP_1 as count event )
//
debugSession.memory.writeData(Memory.Page.DATA,
EradCounter3Regs + CTM_INPUT_SEL,
0x0000,
DATA_SIZE_16);
//
// Configure CTM_3 to be in rising-edge count mode
//
// CTM_CNTL = 0x0808
// EVENT_MODE = (1 << 3) | -> Count only on rising-edge of count input
// CNT_INP_SEL_EN = (1 << 11) -> Enable CTM_INP_SEL
//
debugSession.memory.writeData(Memory.Page.DATA,
EradCounter3Regs + CTM_CNTL,
0x0808,
DATA_SIZE_16);
//
// Clear CTM_COUNT, CTM_MAX_COUNT, CTM_STATUS sticky bits
//
debugSession.memory.writeData(Memory.Page.DATA,
EradCounter4Regs + CTM_COUNT,
0x0,
DATA_SIZE_32);
debugSession.memory.writeData(Memory.Page.DATA,
EradCounter4Regs + CTM_MAX_COUNT,
0x0,
DATA_SIZE_32);
debugSession.memory.writeData(Memory.Page.DATA,
EradCounter4Regs + CTM_CLEAR,
0x3,
DATA_SIZE_16);
//
// Configure CTM_4 to grab latency from TIMER2_TINT2 to cpuTimer2ISR
// execution
//
// CTM_INPUT_SEL = 0x2200
// STA_INP_SEL = (34 << 8) -> Use TIMER2_TINT2 as start event for CTM_4
//
// CTM_INPUT_SEL_2 = 0x0000
// STO_INP_SEL = (0 << 0) -> Use cpuTimer2ISR as stop event for CTM_4
//
debugSession.memory.writeData(Memory.Page.DATA,
EradCounter4Regs + CTM_INPUT_SEL,
0x2200,
DATA_SIZE_16);
debugSession.memory.writeData(Memory.Page.DATA,
EradCounter4Regs + CTM_INPUT_SEL_2,
0x0,
DATA_SIZE_16);
//
// Configure CTM_4 to be in start-stop mode
//
// CTM_CNTL = 0x0004
// START_STOP_MODE = (1 << 2) -> Enable start-stop mode
//
debugSession.memory.writeData(Memory.Page.DATA,
EradCounter4Regs + CTM_CNTL,
0x0004,
DATA_SIZE_16);
//
// Enable HWBP_1-2 and CTM_1-4
// HWBP_GLOBAL_ENABLE = (1 << 0) | (1 << 1)
// COUNTER_GLOBAL_ENABLE = (1 << 8) | (1 << 9) | (1 << 10) | (1 << 11)
//
var enableCounter =
debugSession.memory.readData(Memory.Page.DATA,
EradGlobalRegs + GLBL_ENABLE,
DATA_SIZE_16);
var enableBits = 0x0100 | 0x0200 | 0x0400 | 0x0800 | 0x0001 | 0x0002;
enableCounter = enableCounter | enableBits;
debugSession.memory.writeData(Memory.Page.DATA,
EradGlobalRegs + GLBL_ENABLE,
enableCounter,
DATA_SIZE_16);
print("\nCounter Started\n");
var coreRan = 0;
while(1)
{
var cycleCount =
debugSession.memory.readData(Memory.Page.DATA,
EradCounter1Regs + CTM_COUNT,
DATA_SIZE_32);
var cycleMax =
debugSession.memory.readData(Memory.Page.DATA,
EradCounter1Regs +
CTM_MAX_COUNT,
DATA_SIZE_32);
var intEventCount =
debugSession.memory.readData(Memory.Page.DATA,
EradCounter2Regs + CTM_COUNT,
DATA_SIZE_32);
var isrExecCount =
debugSession.memory.readData(Memory.Page.DATA,
EradCounter3Regs + CTM_COUNT,
DATA_SIZE_32);
var isrDelayCycleMax =
debugSession.memory.readData(Memory.Page.DATA,
EradCounter4Regs +
CTM_MAX_COUNT,
DATA_SIZE_32);
print("Current ISR Cycle Count = " + cycleCount.toString() +
"\t Max ISR Cycle Count = " + cycleMax.toString() +
"\t Int Occurence Count = " + intEventCount.toString() +
"\t ISR Execution Count = " + isrExecCount.toString() +
"\t ISR Delay Cycle Count = " + isrDelayCycleMax.toString());
//
// Halt script if CPU is halted
//
var halted = debugSession.target.isHalted();
if(!halted)
{
coreRan = 1;
}
if(coreRan && halted)
{
break;
}
}
//
// Disable HWBP_1-2 and CTM_1-4
//
enableCounter =
debugSession.memory.readData(Memory.Page.DATA,
EradGlobalRegs + GLBL_ENABLE,
DATA_SIZE_16);
enableCounter = enableCounter & (~enableBits);
debugSession.memory.writeData(Memory.Page.DATA,
EradGlobalRegs + GLBL_ENABLE,
enableCounter,
DATA_SIZE_16);
//
// Reset CTM_1-4 values
//
debugSession.memory.writeData(Memory.Page.DATA,
EradCounter1Regs + CTM_COUNT,
0x0,
DATA_SIZE_32);
debugSession.memory.writeData(Memory.Page.DATA,
EradCounter1Regs + CTM_MAX_COUNT,
0x0,
DATA_SIZE_32);
debugSession.memory.writeData(Memory.Page.DATA,
EradCounter1Regs + CTM_CLEAR,
0x3,
DATA_SIZE_32);
debugSession.memory.writeData(Memory.Page.DATA,
EradCounter2Regs + CTM_COUNT,
0x0,
DATA_SIZE_32);
debugSession.memory.writeData(Memory.Page.DATA,
EradCounter2Regs + CTM_MAX_COUNT,
0x0,
DATA_SIZE_32);
debugSession.memory.writeData(Memory.Page.DATA,
EradCounter2Regs + CTM_CLEAR,
0x3,
DATA_SIZE_32);
debugSession.memory.writeData(Memory.Page.DATA,
EradCounter3Regs + CTM_COUNT,
0x0,
DATA_SIZE_32);
debugSession.memory.writeData(Memory.Page.DATA,
EradCounter3Regs + CTM_MAX_COUNT,
0x0,
DATA_SIZE_32);
debugSession.memory.writeData(Memory.Page.DATA,
EradCounter3Regs + CTM_CLEAR,
0x3,
DATA_SIZE_32);
debugSession.memory.writeData(Memory.Page.DATA,
EradCounter4Regs + CTM_COUNT,
0x0,
DATA_SIZE_32);
debugSession.memory.writeData(Memory.Page.DATA,
EradCounter4Regs + CTM_MAX_COUNT,
0x0,
DATA_SIZE_32);
debugSession.memory.writeData(Memory.Page.DATA,
EradCounter4Regs + CTM_CLEAR,
0x3,
DATA_SIZE_32);
//
// Reset HWBP_1-2
//
debugSession.memory.writeData(Memory.Page.DATA,
EradHWBP1Regs + HWBP_CLEAR,
0x1,
DATA_SIZE_16);
debugSession.memory.writeData(Memory.Page.DATA,
EradHWBP2Regs + HWBP_CLEAR,
0x1,
DATA_SIZE_16);
print("\nCounter Stopped\n");
}
else
{
print("Failed\n");
}
//
// End of File
//
@@ -0,0 +1,405 @@
//#############################################################################
//
// FILE: erad_ex1_profileinterrupts.c
//
// TITLE: ERAD Profiling Interrupts Example
//
//! \addtogroup driver_example_list
//! <h1> ERAD Profiling Interrupts </h1>
//!
//! This example configures CPU Timer0, 1, and 2 to be profiled using the ERAD
//! module. Included is a JavaScript file, profile_interrupts.js, which is used
//! with the scripting console to program ERAD registers and view profiling
//! data.
//!
//! To properly use the provided ERAD script, the following variables must be
//! set in the scripting environment prior to launching the ERAD script:
//!
//! - var PROJ_NAME = "erad_debugger_ex1_profileinterrupts"
//! - var PROJ_WKSPC_LOC = "<proj_workspace_path>"
//! - var PROJ_CONFIG = "<name of active configuration [CPU1_FLASH|CPU1_RAM]>"
//!
//! To run the ERAD script, use the following command in the scripting console:
//!
//! - loadJSFile("<proj_workspace_path>\\erad_debugger_ex1_profileinterrupts\\erad_ex1_profile_interrupts.js", 0);
//!
//! The included JavaScript file, erad_ex1_profile_interrupts.js, uses Debug Server
//! Scripting (DSS) features. For information on using the DSS, please visit:
//! http://software-dl.ti.com/ccs/esd/documents/users_guide/sdto_dss_handbook.html
//!
//! Note that the script must be run after loading and running the .out on the
//! C28x core. Only CPU timer 2 ISR is profiled in this example.
//!
//! This example uses 2 HW breakpoints and 4 counters:
//! - HWBP_1 : PC = start address of cpuTimer2ISR
//! - HWBP_2 : PC = end address of cpuTimer2ISR
//! - CTM_1 : Used to count the cpuTimer2ISR execution cycles.
//! Configured in start-stop mode with start event as HWBP_1 and
//! stop event as HWBP_2
//! - CTM_2 : Used to count the number of times the system event TIMER2_TINT2
//! has occurred.
//! Configured in rising-edge count mode with counting input as
//! system event TIMER2_TINT2 (INP_SEL[25])
//! - CTM_3 : Used to count the number of times cputTimer2ISR executes.
//! Configured in rising-edge count mode with counting input as
//! HWBP_1 (INP_SEL[0])
//! - CTM_4 : Used to count the latency from the system event TIMER2_TINT2 to
//! cpuTimer2ISR entry.
//! Configured in start-stop mode with start event as TIMER2_TINT2
//! and stop event as HWBP_1
//!
//! \b External \b Connections \n
//! - None
//!
//! \b Watch \b Variables \n
//! - cpuTimer0IntCount
//! - cpuTimer1IntCount
//! - cpuTimer2IntCount
//!
//! \b Profiling \b Script \b Output
//! - Current ISR cycle count (CTM_1)
//! - Max ISR cycle count (maximum value of CTM_1)
//! - Interrupt occurrence count (CTM_2)
//! - ISR execution count (CTM_3)
//! - ISR entry delay cycle count (maximum value of CTM_4)
//!
//! Note that the large difference between Interrupt occurrence count (CTM_2)
//! and ISR execution count (CTM_3) is because the ISR takes more number of
//! cycles than the actual interrupt period. ISR entry delay cycle count will
//! also be higher due to the same reason.
//
//#############################################################################
//
//
//
// 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 <float.h>
#include <math.h>
#include "driverlib.h"
#include "device.h"
//
// Globals
//
uint64_t cpuTimer0IntCount;
uint64_t cpuTimer1IntCount;
uint64_t cpuTimer2IntCount;
//
// Pre-chosen Pseudo Random Generator constants
//
const uint16_t PseudoRand_multiplier = 31821;
const uint16_t PseudoRand_increment = 13849;
uint16_t PseudoRand_seed = 21845;
//
// Function Prototypes
//
interrupt void cpuTimer0ISR(void) __attribute__((ramfunc));
interrupt void cpuTimer1ISR(void) __attribute__((ramfunc));
interrupt void cpuTimer2ISR(void) __attribute__((ramfunc));
void initCPUTimers(void);
void configCPUTimer(uint32_t, float, float);
uint16_t generatePseudoRand16(uint16_t *);
//
// Main
//
void main(void)
{
//
// Initializes device clock and peripherals
//
Device_init();
//
// Configures the GPIO pin as a push-pull output
//
Device_initGPIO();
GPIO_setPinConfig(DEVICE_GPIO_PIN_LED1);
GPIO_setControllerCore(DEVICE_GPIO_PIN_LED1, GPIO_CORE_CPU1);
GPIO_setPadConfig(DEVICE_GPIO_PIN_LED1, GPIO_PIN_TYPE_STD);
GPIO_setDirectionMode(DEVICE_GPIO_PIN_LED1, GPIO_DIR_MODE_OUT);
//
// Initializes PIE and clears PIE registers. Disables CPU interrupts.
//
Interrupt_initModule();
//
// Initializes the PIE vector table with pointers to the shell Interrupt
// Service Routines (ISR).
//
Interrupt_initVectorTable();
//
// ISRs for each CPU Timer interrupt
//
Interrupt_register(INT_TIMER0, &cpuTimer0ISR);
Interrupt_register(INT_TIMER1, &cpuTimer1ISR);
Interrupt_register(INT_TIMER2, &cpuTimer2ISR);
//
// Initializes the Device Peripheral. For this example, only initialize the
// Cpu Timers.
//
initCPUTimers();
//
// Configure CPU-Timer 0, 1, and 2 to interrupt every 1066,
// 1776 and 2001 cycles
//
configCPUTimer(CPUTIMER0_BASE, DEVICE_SYSCLK_FREQ, 10.66);
configCPUTimer(CPUTIMER1_BASE, DEVICE_SYSCLK_FREQ, 17.76);
configCPUTimer(CPUTIMER2_BASE, DEVICE_SYSCLK_FREQ, 20.01);
//
// To ensure precise timing, use write-only instructions to write to the
// entire register. Therefore, if any of the configuration bits are changed
// in configCPUTimer and initCPUTimers, the below settings must also
// be updated.
//
CPUTimer_enableInterrupt(CPUTIMER0_BASE);
CPUTimer_enableInterrupt(CPUTIMER1_BASE);
CPUTimer_enableInterrupt(CPUTIMER2_BASE);
//
// Enables CPU int1, int13, and int14 which are connected to CPU-Timer 0,
// CPU-Timer 1, and CPU-Timer 2 respectively.
// Enable TINT0 in the PIE: Group 1 interrupt 7
//
Interrupt_enable(INT_TIMER0);
Interrupt_enable(INT_TIMER1);
Interrupt_enable(INT_TIMER2);
//
// Starts CPU-Timer 0, CPU-Timer 1, and CPU-Timer 2.
//
CPUTimer_startTimer(CPUTIMER0_BASE);
CPUTimer_startTimer(CPUTIMER1_BASE);
CPUTimer_startTimer(CPUTIMER2_BASE);
//
// Enable Global Interrupt (INTM) and realtime interrupt (DBGM)
//
EINT;
ERTM;
//
// IDLE loop. Just sit and loop forever (optional)
//
while(1)
{
}
}
//
// initCPUTimers - This function initializes all three CPU timers
// to a known state.
//
void
initCPUTimers(void)
{
//
// Make sure timer is stopped
//
CPUTimer_stopTimer(CPUTIMER0_BASE);
CPUTimer_stopTimer(CPUTIMER1_BASE);
CPUTimer_stopTimer(CPUTIMER2_BASE);
//
// Initialize timer period to maximum
//
CPUTimer_setPeriod(CPUTIMER0_BASE, 0xFFFFFFFF);
CPUTimer_setPeriod(CPUTIMER1_BASE, 0xFFFFFFFF);
CPUTimer_setPeriod(CPUTIMER2_BASE, 0xFFFFFFFF);
//
// Initialize pre-scale counter to divide by 1 (SYSCLKOUT)
//
CPUTimer_setPreScaler(CPUTIMER0_BASE, 0);
CPUTimer_setPreScaler(CPUTIMER1_BASE, 0);
CPUTimer_setPreScaler(CPUTIMER2_BASE, 0);
//
// Reload all counter register with period value
//
CPUTimer_reloadTimerCounter(CPUTIMER0_BASE);
CPUTimer_reloadTimerCounter(CPUTIMER1_BASE);
CPUTimer_reloadTimerCounter(CPUTIMER2_BASE);
//
// Reset interrupt counter
//
cpuTimer0IntCount = 0;
cpuTimer1IntCount = 0;
cpuTimer2IntCount = 0;
}
//
// configCPUTimer - This function initializes the selected timer to the
// period specified by the "Freq" and "Period" parameters. The "Freq" is
// entered as "Hz" and the period in "uSeconds". The timer is held in the
// stopped state after configuration.
//
void
configCPUTimer(uint32_t cpuTimer, float freq, float period)
{
uint32_t temp;
//
// Initialize timer period:
//
temp = (uint32_t) (freq / 1000000 * period);
CPUTimer_setPeriod(cpuTimer, temp - 1);
//
// Set pre-scale counter to divide by 1 (SYSCLKOUT):
//
CPUTimer_setPreScaler(cpuTimer, 0);
//
// Initializes timer control register. The timer is stopped, reloaded,
// free run disabled, and interrupt enabled.
// Additionally, the free and soft bits are set
//
CPUTimer_stopTimer(cpuTimer);
CPUTimer_reloadTimerCounter(cpuTimer);
CPUTimer_setEmulationMode(cpuTimer,
CPUTIMER_EMULATIONMODE_STOPAFTERNEXTDECREMENT);
CPUTimer_enableInterrupt(cpuTimer);
//
// Resets interrupt counters for the three cpuTimers
//
if (cpuTimer == CPUTIMER0_BASE)
{
cpuTimer0IntCount = 0;
}
else if(cpuTimer == CPUTIMER1_BASE)
{
cpuTimer1IntCount = 0;
}
else if(cpuTimer == CPUTIMER2_BASE)
{
cpuTimer2IntCount = 0;
}
}
//
// cpuTimer0ISR - Counter for CpuTimer0
//
interrupt void
cpuTimer0ISR(void)
{
cpuTimer0IntCount++;
//
// Acknowledge this interrupt to receive more interrupts from group 1
//
Interrupt_clearACKGroup(INTERRUPT_ACK_GROUP1);
}
//
// cpuTimer1ISR - Counter for CpuTimer1
//
interrupt void
cpuTimer1ISR(void)
{
//
// The CPU acknowledges the interrupt.
//
cpuTimer1IntCount++;
}
//
// cpuTimer2ISR - Counter for CpuTimer2
//
interrupt void
cpuTimer2ISR(void)
{
//
// Simulate storing data to a location. "volatile" keyword ensures this is
// not optimized out by the compiler.
//
volatile uint32_t output;
//
// Generate a random number.
//
uint16_t count = generatePseudoRand16(&PseudoRand_seed);
//
// Simulate a task that can take some time to complete. Loop a "random"
// number of times and store values to a location.
//
uint32_t i;
for(i = 0; i < count; i++)
{
output = i;
}
//
// The CPU acknowledges the interrupt.
//
cpuTimer2IntCount++;
}
//
// generatePseudoRand16 - Generate a pseudo random 16-bit number by passing a
// start value or "seed". This generator is a linear congruential pseudo random
// generator, which is very fast. The basic calculation is:
//
// randNum(n) = ((randNum(n-1) * multiplier) + increment) modulo M
//
uint16_t
generatePseudoRand16(uint16_t *seed)
{
//
// Perform calculation. Mask off bottom bits in lieu of modulus operation
//
*seed = ((uint32_t)*seed * PseudoRand_multiplier + PseudoRand_increment)
& 0xFFFF;
return(*seed);
}
//
// End of File
//
@@ -0,0 +1,460 @@
//#############################################################################
//
// erad_ex2_profile_function.js
//
// This JavaScript file is used to configure ERAD registers for use with the CCS
// example "erad_ex2_profilefunction".
//
// To properly use this script, the following variables must be set in the
// scripting environment prior to launching the ERAD script:
//
// - var PROJ_NAME = "erad_debugger_ex2_profilefunction"
// - var PROJ_WKSPC_LOC = "<proj_workspace_path>"
// - var PROJ_CONFIG = "<name of active configuration [CPU1_FLASH|CPU1_RAM]>"
//
// To run this ERAD script, use the following command in the scripting console:
//
// - loadJSFile("<proj_workspace_path>\\erad_debugger_ex2_profilefunction\\erad_ex2_profile_function.js", 0);
//
// This JavaScript file uses Debug Server Scripting (DSS) features. For
// information on using the DSS, please visit:
// http://software-dl.ti.com/ccs/esd/documents/users_guide/sdto_dss_handbook.html
//
//#############################################################################
//
// Import the DSS packages
//
importPackage(Packages.com.ti.debug.engine.scripting)
importPackage(Packages.com.ti.ccstudio.scripting.environment)
importPackage(Packages.java.lang)
//
// Load pre-defined macros for register addresses and useful functions
//
load(PROJ_WKSPC_LOC + "\\" + PROJ_NAME + "\\erad.js");
load(PROJ_WKSPC_LOC + "\\" + PROJ_NAME + "\\erad_util.js");
//
// Create our scripting environment object. This is the main entry point into
// any script and the factory for creating other scriptable servers and sessions
//
var script = ScriptingEnvironment.instance();
script.traceSetConsoleLevel(TraceLevel.ALL)
//
// Create a debug server
//
var ds = script.getServer( "DebugServer.1" );
//
// Open a debug session
//
debugSession = ds.openSession( "*", "C28xx_CPU1" );
//
// Variables for data read/write sizes
//
var DATA_SIZE_16 = 16;
var DATA_SIZE_32 = 32;
//*****************************************************************************
// Example: Profile Function
//*****************************************************************************
//
// Set owner as debugger
//
debugSession.memory.writeData(Memory.Page.DATA,
EradGlobalRegs + GLBL_OWNER,
OWNER_DEBUGGER,
DATA_SIZE_16);
//
// Ensure that counters 1-2 are in idle mode (bits 15:12 are set to 0)
//
var counter1Status =
debugSession.memory.readData(Memory.Page.DATA,
EradCounter1Regs + CTM_STATUS,
DATA_SIZE_16);
var counter2Status =
debugSession.memory.readData(Memory.Page.DATA,
EradCounter2Regs + CTM_STATUS,
DATA_SIZE_16);
var CTM_STATUS_M = 0x3000
if((0 == (counter1Status & CTM_STATUS_M)) &&
(0 == (counter2Status & CTM_STATUS_M)))
{
//
// Reset HWBP_1, HWBP_2, HWBP_3 and HWBP_4
//
debugSession.memory.writeData(Memory.Page.DATA,
EradHWBP1Regs + HWBP_CLEAR,
0x1,
DATA_SIZE_16);
debugSession.memory.writeData(Memory.Page.DATA,
EradHWBP2Regs + HWBP_CLEAR,
0x1,
DATA_SIZE_16);
debugSession.memory.writeData(Memory.Page.DATA,
EradHWBP3Regs + HWBP_CLEAR,
0x1,
DATA_SIZE_16);
debugSession.memory.writeData(Memory.Page.DATA,
EradHWBP4Regs + HWBP_CLEAR,
0x1,
DATA_SIZE_16);
//
// Get the start and end addresses of the FIR function "performFIR"
//
var addrFunc1 = getFuncAddressXML("performFIR");
var startFIRFunc = addrFunc1[0];
var endFIRFunc = addrFunc1[1];
//
// Get the start and end addresses of the sorting function "sortMax"
//
var addrFunc2 = getFuncAddressXML("sortMax");
var startSortFunc = addrFunc2[0];
var endSortFunc = addrFunc2[1];
//
// Set two hardware breakpoints at the start and end of performFIR
//
debugSession.memory.writeData(Memory.Page.DATA,
EradHWBP1Regs + HWBP_REF,
startFIRFunc,
DATA_SIZE_32);
debugSession.memory.writeData(Memory.Page.DATA,
EradHWBP2Regs + HWBP_REF,
endFIRFunc,
DATA_SIZE_32);
//
// Set two hardware breakpoints at the start and end of sortMax
//
debugSession.memory.writeData(Memory.Page.DATA,
EradHWBP3Regs + HWBP_REF,
startSortFunc,
DATA_SIZE_32);
debugSession.memory.writeData(Memory.Page.DATA,
EradHWBP4Regs + HWBP_REF,
endSortFunc,
DATA_SIZE_32);
//
// Set HWBP_1, HWBP_2, HWBP_3 and HWBP_4 to generate an event on PC match
// RESERVED = (0 << 0) | -> RESERVED
// BUS_SEL = (1 << 1) | -> VPC for program counter match
// STOP = (0 << 5) | -> Do not stop CPU on match
// RTOSINT = (0 << 6) | -> Do not generate RTOSINT
// COMP_MODE = (0 << 7) | -> Regular masked compare.
// (address | mask) == (reference | mask)
// RESERVED = (0 << 12) -> RESERVED
//
// HWBP_CNTL = 0x0002
//
debugSession.memory.writeData(Memory.Page.DATA,
EradHWBP1Regs + HWBP_CNTL,
0x0002,
DATA_SIZE_16);
debugSession.memory.writeData(Memory.Page.DATA,
EradHWBP2Regs + HWBP_CNTL,
0x0002,
DATA_SIZE_16);
debugSession.memory.writeData(Memory.Page.DATA,
EradHWBP3Regs + HWBP_CNTL,
0x0002,
DATA_SIZE_16);
debugSession.memory.writeData(Memory.Page.DATA,
EradHWBP4Regs + HWBP_CNTL,
0x0002,
DATA_SIZE_16);
//
// Reset Counters 1 and 2 globally
//
debugSession.memory.writeData(Memory.Page.DATA,
EradGlobalRegs + GLBL_CTM_RESET,
0x3,
DATA_SIZE_16);
//
// Clear CTM_COUNT
//
debugSession.memory.writeData(Memory.Page.DATA,
EradCounter1Regs + CTM_COUNT,
0x0,
DATA_SIZE_32);
//
// Clear CTM_MAX_COUNT
//
debugSession.memory.writeData(Memory.Page.DATA,
EradCounter1Regs + CTM_MAX_COUNT,
0x0,
DATA_SIZE_32);
//
// Clear EVENT_FIRED and OVERFLOW sticky bits
// EVENT_CLEAR = (1 << 0) | -> Clear EVENT_FIRED sticky bit in CTM_STATUS
// OVERFLOW_CLEAR = (1 << 1) | -> Clear OVERFLOW sticky bit in CTM_STATUS
// RESERVED = (0 << 2) -> RESERVED
//
debugSession.memory.writeData(Memory.Page.DATA,
EradCounter1Regs + CTM_CLEAR,
0x3,
DATA_SIZE_16);
//
// Clear CTM_REF
//
debugSession.memory.writeData(Memory.Page.DATA,
EradCounter1Regs + CTM_REF,
0x0,
DATA_SIZE_32);
//
// Configure CTM_1 to count cpuTimer2ISR execution cycles
// Configure CTM_1 to be in start-stop mode
//
// CTM_INPUT_SEL = 0x0000
// CTM_INP_SEL = (0 << 0) | -> Disabled by CTM_INP_SEL_EN
// STA_INP_SEL = (0 << 8) | -> Use HWBP_1 as start event for CTM_1
//
// CTM_INPUT_SEL_2 = 0x0001
// STO_INP_SEL = (1 << 0) -> Use HWBP_2 as stop event for CTM_1
// RST_INP_SEL = (0 << 8) -> Disabled by RST_EN
//
// CTM_CNTL = 0x0004
// RESERVED = (0 << 0) | -> RESERVED
// START_STOP_MODE = (1 << 2) | -> Enable start-stop mode
// EVENT_MODE = (0 << 3) | -> Count as long as input is active (high)
// RST_ON_MATCH = (0 << 4) | -> Stop counting once reference value is
// reached
// RESERVED = (0 << 5) | -> RESERVED
// STOP = (0 << 6) | -> Do not stop CPU when counter reaches
// reference value
// RTOSINT = (0 << 7) | -> Do not generate RTOSINT
// START_STOP_CUM = (0 << 8) | -> Counter gets cleared on stop event
// RESERVED = (0 << 9) | -> RESERVED
// RST_EN = (0 << 10) | -> Disable RST_INP_SEL
// CTM_INP_SEL_EN = (0 << 11) -> Disable CTM_IN_SEL register and count
// CPU cycles
//
debugSession.memory.writeData(Memory.Page.DATA,
EradCounter1Regs + CTM_INPUT_SEL,
(0x0),
DATA_SIZE_16);
debugSession.memory.writeData(Memory.Page.DATA,
EradCounter1Regs + CTM_INPUT_SEL_2,
(0x1),
DATA_SIZE_16);
debugSession.memory.writeData(Memory.Page.DATA,
EradCounter1Regs + CTM_CNTL,
0x004,
DATA_SIZE_16);
//
// Clear CTM_COUNT, CTM_MAX_COUNT, CTM_STATUS sticky bits
//
debugSession.memory.writeData(Memory.Page.DATA,
EradCounter2Regs + CTM_COUNT,
0x0,
DATA_SIZE_32);
debugSession.memory.writeData(Memory.Page.DATA,
EradCounter2Regs + CTM_MAX_COUNT,
0x0,
DATA_SIZE_32);
debugSession.memory.writeData(Memory.Page.DATA,
EradCounter2Regs + CTM_CLEAR,
0x3,
DATA_SIZE_16);
//
// Configure CTM_2 to count sortMax execution cycles
//
// CTM_INPUT_SEL = 0x0200
// STA_INP_SEL = (2 << 8) -> Use HWPB_3 as start event for CTM_2
//
// CTM_INPUT_SEL_2 = 0x0003
// STO_INP_SEL = (3 << 0) -> Use HWBP_4 as stop event for CTM_2
//
debugSession.memory.writeData(Memory.Page.DATA,
EradCounter2Regs + CTM_INPUT_SEL,
0x0200,
DATA_SIZE_16);
debugSession.memory.writeData(Memory.Page.DATA,
EradCounter2Regs + CTM_INPUT_SEL_2,
0x0003,
DATA_SIZE_16);
//
// Configure CTM_2 to be in start-stop mode
// CTM_CNTL = 0x0004
// START_STOP_MODE = (1 << 2) -> Enable start-stop mode
//
debugSession.memory.writeData(Memory.Page.DATA,
EradCounter2Regs + CTM_CNTL,
0x0004,
DATA_SIZE_16);
//
// Enable HWBP_1-4 and CTM_1-2
// HWBP_GLOBAL_ENABLE = (1 << 0) | (1 << 1) | (1 << 2) | (1 << 3)
// COUNTER_GLOBAL_ENABLE = (1 << 8) | (1 << 9)
//
var enableCounter =
debugSession.memory.readData(Memory.Page.DATA,
EradGlobalRegs + GLBL_ENABLE,
DATA_SIZE_16);
var enableBits = 0x0100 | 0x0200 | 0x0001 | 0x0002 | 0x0004 | 0x0008;
enableCounter = enableCounter | enableBits;
debugSession.memory.writeData(Memory.Page.DATA,
EradGlobalRegs + GLBL_ENABLE,
enableCounter,
DATA_SIZE_16);
print("\nCounter Started\n");
var coreRan = 0;
while(1)
{
var cycleCountFIR =
debugSession.memory.readData(Memory.Page.DATA,
EradCounter1Regs + CTM_COUNT,
DATA_SIZE_32);
var cycleMaxFIR =
debugSession.memory.readData(Memory.Page.DATA,
EradCounter1Regs +
CTM_MAX_COUNT,
DATA_SIZE_32);
var cycleCountSort =
debugSession.memory.readData(Memory.Page.DATA,
EradCounter2Regs + CTM_COUNT,
DATA_SIZE_32);
var cycleMaxSort =
debugSession.memory.readData(Memory.Page.DATA,
EradCounter2Regs +
CTM_MAX_COUNT,
DATA_SIZE_32);
print("Current FIR Cycle Count = " + cycleCountFIR.toString() +
"\t Max FIR Cycle Count = " + cycleMaxFIR.toString() +
"\t Current Sort Cycle Count = " + cycleCountSort.toString() +
"\t Max Sort Cycle Count = " + cycleMaxSort.toString());
//
// Halt script if CPU is halted
//
var halted = debugSession.target.isHalted();
if(!halted)
{
coreRan = 1;
}
if(coreRan && halted)
{
break;
}
}
//
// Disable HWBP_1-4 and CTM_1-2
//
enableCounter =
debugSession.memory.readData(Memory.Page.DATA,
EradGlobalRegs + GLBL_ENABLE,
DATA_SIZE_16);
enableCounter = enableCounter & (~enableBits);
debugSession.memory.writeData(Memory.Page.DATA,
EradGlobalRegs + GLBL_ENABLE,
enableCounter,
DATA_SIZE_16);
//
// Reset CTM_1-2 values
//
debugSession.memory.writeData(Memory.Page.DATA,
EradCounter1Regs + CTM_COUNT,
0x0,
DATA_SIZE_32);
debugSession.memory.writeData(Memory.Page.DATA,
EradCounter1Regs + CTM_MAX_COUNT,
0x0,
DATA_SIZE_32);
debugSession.memory.writeData(Memory.Page.DATA,
EradCounter1Regs + CTM_CLEAR,
0x3,
DATA_SIZE_32);
debugSession.memory.writeData(Memory.Page.DATA,
EradCounter2Regs + CTM_COUNT,
0x0,
DATA_SIZE_32);
debugSession.memory.writeData(Memory.Page.DATA,
EradCounter2Regs + CTM_MAX_COUNT,
0x0,
DATA_SIZE_32);
debugSession.memory.writeData(Memory.Page.DATA,
EradCounter2Regs + CTM_CLEAR,
0x3,
DATA_SIZE_32);
//
// Reset HWBP_1-4
//
debugSession.memory.writeData(Memory.Page.DATA,
EradHWBP1Regs + HWBP_CLEAR,
0x1,
DATA_SIZE_16);
debugSession.memory.writeData(Memory.Page.DATA,
EradHWBP2Regs + HWBP_CLEAR,
0x1,
DATA_SIZE_16);
debugSession.memory.writeData(Memory.Page.DATA,
EradHWBP3Regs + HWBP_CLEAR,
0x1,
DATA_SIZE_16);
debugSession.memory.writeData(Memory.Page.DATA,
EradHWBP4Regs + HWBP_CLEAR,
0x1,
DATA_SIZE_16);
print("\nCounter Stopped\n");
}
else
{
print("Failed\n");
}
//
// End of File
//
@@ -0,0 +1,301 @@
//#############################################################################
//
// FILE: erad_ex2_profilefunction.c
//
// TITLE: ERAD Function Profile Example
//
//! \addtogroup driver_example_list
//! <h1> ERAD Profile Function </h1>
//!
//! This example contains a basic FIR calculation and sorting algorithm to help
//! demonstrate the function profiling capability of the ERAD peripheral. A
//! number of FIR sums are calculated within a loop and are then sorted using
//! the insertion sort algorithm. Cycle counts of both the FIR calculations and
//! the sorting algorithm are output to the screen through the scripting console.
//! In this example, it can be seen that sorting the data takes up a majority
//! of the CPU cycles executed in this program.
//!
//! To properly use the provided ERAD script, the following variables must be
//! set in the scripting environment prior to launching the ERAD script:
//!
//! - var PROJ_NAME = "erad_debugger_ex2_profilefunction"
//! - var PROJ_WKSPC_LOC = "<proj_workspace_path>"
//! - var PROJ_CONFIG = "<name of active configuration [CPU1_FLASH|CPU1_RAM]>"
//!
//! To run the ERAD script, use the following command in the scripting console:
//!
//! - loadJSFile("<proj_workspace_path>\\erad_debugger_ex2_profilefunction\\erad_ex2_profile_function.js", 0);
//!
//! Note that the script must be run after loading and running the .out on the
//! C28x core.
//!
//! The included JavaScript file, erad_ex2_profile_function.js, uses Debug Server
//! Scripting (DSS) features. For information on using the DSS, please visit:
//! http://software-dl.ti.com/ccs/esd/documents/users_guide/sdto_dss_handbook.html
//!
//! This example uses 4 HW breakpoints and 2 counters:
//! - HWBP_1 : PC = start address of performFIR
//! - HWBP_2 : PC = end address of performFIR
//! - HWBP_3 : PC = start address of sortMax
//! - HWBP_4 : PC = end address of sortMax
//! - CTM_1 : Used to count the performFIR execution cycles.
//! Configured in start-stop mode with start event as HWBP_1 and
//! stop event as HWBP_2
//! - CTM_2 : Used to count the sortMax execution cycles.
//! Configured in start-stop mode with start event as HWBP_3 and
//! stop event as HWBP_4
//!
//! \b External \b Connections \n
//! - None.
//!
//! \b Watch \b Variables \n
//! - FIR_iterationCounter - A counter for the number of times FIR calculation
//! and sorting was performed
//!
//! \b Profiling \b Script \b Output
//! - Current FIR cycle count (CTM_1)
//! - Max FIR cycle count (maximum value of CTM_1)
//! - Current sorting function cycle count (CTM_2)
//! - Max sorting function cycle count (maximum value of CTM_2)
//!
//! Note that the the counters are reset after the stop event. The counter value
//! remains 0 till the next start event occurs. The javascript continuously
//! reads the counter value in a while(1) and hence the current counter may
//! return 0.
//
//#############################################################################
//
//
//
// 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"
//
// Defines
//
#define FIR_TAPS 64
#define FIR_NUM_ITERATIONS 250
//
// Global FIR variables
//
const uint16_t FIR_coeffVals[FIR_TAPS] =
{
2048, 2048, 2048, 2048,
2048, 2048, 2048, 2048,
2048, 2048, 2048, 2048,
2048, 2048, 2048, 2048,
2048, 2048, 2048, 2048,
2048, 2048, 2048, 2048,
2048, 2048, 2048, 2048,
2048, 2048, 2048, 2048,
2048, 2048, 2048, 2048,
2048, 2048, 2048, 2048,
2048, 2048, 2048, 2048,
2048, 2048, 2048, 2048,
2048, 2048, 2048, 2048,
2048, 2048, 2048, 2048,
2048, 2048, 2048, 2048,
2048, 2048, 2048, 2048,
};
uint16_t FIR_values[FIR_TAPS];
volatile uint32_t FIR_sums[FIR_NUM_ITERATIONS];
uint32_t FIR_iterationCounter;
uint32_t sortedArr[FIR_NUM_ITERATIONS];
//
// Pre-chosen Pseudo Random Generator constants
//
const uint16_t PseudoRand_multiplier = 31821;
const uint16_t PseudoRand_increment = 13849;
uint16_t PseudoRand_seed = 21845;
//
// Function Prototypes
//
uint32_t performFIR(uint16_t [], const uint16_t []);
uint16_t generatePseudoRand16(uint16_t *);
void sortMax(uint32_t [], uint32_t);
//
// Main
//
int main(void)
{
//
// Initialize device clock and peripherals
//
Device_init();
//
// Initialize FIR_values and iteration counter to 0
//
uint32_t i = 0;
for(i = 0; i < FIR_TAPS; i++)
{
FIR_values[i] = 0;
}
FIR_iterationCounter = 0;
//
// Loop forever, performing FIR calculations and sorting results
//
while(1)
{
//
// Perform FIR and record sum
//
for(i = 0; i < FIR_NUM_ITERATIONS; i++)
{
//
// Set 1st FIR element to a pseudo random number and perform FIR
//
FIR_values[0] = generatePseudoRand16(&PseudoRand_seed);
FIR_sums[i] = performFIR(FIR_values, FIR_coeffVals);
}
//
// Copy sums array into scratch array
//
for(i = 0; i < FIR_NUM_ITERATIONS; i++)
{
sortedArr[i] = FIR_sums[i];
}
//
// Sort results and grab maximum value, the last element of the sorted
// array
//
sortMax(sortedArr, FIR_NUM_ITERATIONS);
volatile uint32_t maxValue = sortedArr[FIR_NUM_ITERATIONS - 1];
//
// Record that FIR sums were calculated and sorting of the data was done
//
FIR_iterationCounter++;
}
}
//
// generatePseudoRand16 - Generate a pseudo random 16-bit number by passing a
// start value or "seed". This generator is a linear congruential pseudo random
// generator, which is very fast. The basic calculation is:
//
// randNum(n) = ((randNum(n-1) * multiplier) + increment) modulo M
//
uint16_t
generatePseudoRand16(uint16_t *seed)
{
//
// Perform calculation. Mask off bottom bits in lieu of modulus operation
//
*seed = ((uint32_t)*seed * PseudoRand_multiplier + PseudoRand_increment)
& 0xFFFF;
return(*seed);
}
//
// performFIR - Calculate Finite Impulse Response (FIR)
//
uint32_t
performFIR(uint16_t values[], const uint16_t coeff[])
{
uint32_t sum = 0;
//
// Loop over elements starting with Nth element and ending with 1st element
//
int32_t i = 0;
for(i = FIR_TAPS - 1; i >= 0; i--)
{
//
// Multiply current value by respective coefficient
//
sum += ((uint32_t)values[i] * (uint32_t)coeff[i]);
//
// Store value only after processing Nth (FIR_TAPS - 1) element
//
if(i < FIR_TAPS - 1)
{
values[i + 1] = values[i];
}
}
return(sum);
}
//
// sortMax - Perform insertion sort on an array of values, sorting from least to
// greatest
//
void
sortMax(uint32_t values[], uint32_t numElements)
{
//
// Loop over all elements starting with index 1. This allows for at least
// two elements to be compared
//
uint32_t i = 1;
for(i = 1; i < numElements; i++)
{
uint32_t j = i;
//
// Inner loop walks elements backwards from current index
//
for(j = i; j > 0; j--)
{
//
// If current value is less than the previous value, swap them
//
if(values[j] < values[j-1])
{
uint32_t temp = values[j-1];
values[j-1] = values[j];
values[j] = temp;
}
}
}
}
//
// End of File
//
@@ -0,0 +1,238 @@
//#############################################################################
//
// erad_ex3_stack_overflow.js
//
// This JavaScript file is used to configure ERAD registers for use with the CCS
// example "erad_ex3_stackoverflow".
//
// To properly use this script, the following variables must be set in the
// scripting environment prior to launching the ERAD script:
//
// - var PROJ_NAME = "erad_debugger_ex3_stackoverflow"
// - var PROJ_WKSPC_LOC = <proj_workspace_path>
//
// To run this ERAD script, use the following command in the scripting console:
//
// - loadJSFile("<proj_workspace_path>\\erad_debugger_ex3_stackoverflow\\erad_ex3_stack_overflow.js", 0);
//
// This JavaScript file uses Debug Server Scripting (DSS) features. For
// information on using the DSS, please visit:
// http://software-dl.ti.com/ccs/esd/documents/users_guide/sdto_dss_handbook.html
//
//#############################################################################
//
// Import the DSS packages
//
importPackage(Packages.com.ti.debug.engine.scripting)
importPackage(Packages.com.ti.ccstudio.scripting.environment)
importPackage(Packages.java.lang)
//
// Load pre-defined macros for register addresses
//
load(PROJ_WKSPC_LOC + "\\" + PROJ_NAME + "\\erad.js")
//
// Create our scripting environment object. This is the main entry point into
// any script and the factory for creating other scriptable servers and sessions
//
var script = ScriptingEnvironment.instance();
script.traceSetConsoleLevel(TraceLevel.ALL)
//
// Create a debug server
//
var ds = script.getServer( "DebugServer.1" );
//
// Open a debug session
//
debugSession = ds.openSession( "*", "C28xx_CPU1" );
//
// Variables for data read/write sizes
//
var DATA_SIZE_16 = 16;
var DATA_SIZE_32 = 32;
//*****************************************************************************
// Example: Stack Overflow
//*****************************************************************************
//
// Set owner as debugger
//
debugSession.memory.writeData(Memory.Page.DATA,
EradGlobalRegs + GLBL_OWNER,
OWNER_DEBUGGER,
DATA_SIZE_16);
//
// Ensure that HWBP_1 is in idle mode (bits 15:12 are set to 0)
//
var hwbp1Status =
debugSession.memory.readData(Memory.Page.DATA,
EradHWBP1Regs + HWBP_STATUS,
DATA_SIZE_16);
if(0 == (hwbp1Status & 0xF000))
{
print("\nProfile Setup\n");
//
// Reset HWBP_1
//
debugSession.memory.writeData(Memory.Page.DATA,
EradHWBP1Regs + HWBP_CLEAR,
0x1,
DATA_SIZE_16);
debugSession.memory.writeData(Memory.Page.DATA,
EradHWBP1Regs + HWBP_CNTL,
0x0,
DATA_SIZE_16);
debugSession.memory.writeData(Memory.Page.DATA,
EradHWBP1Regs + HWBP_REF,
0x0,
DATA_SIZE_32);
//
// Grab maximum value for stack
//
if (debugSession.symbol.exists("__STACK_END"))
{
var stackEnd = debugSession.expression.evaluate("__STACK_END");
}
else
{
var stackEnd = debugSession.expression.evaluate("__TI_STACK_END");
}
print("\nSP END: " + stackEnd.toString(16) + "\n");
//
// Set HWBP_REF to be stackEnd + 1 for HWBP_1
//
debugSession.memory.writeData(Memory.Page.DATA,
EradHWBP1Regs + HWBP_REF,
stackEnd + 1,
DATA_SIZE_32);
//
// Clear mask value
//
debugSession.memory.writeData(Memory.Page.DATA,
EradHWBP1Regs + HWBP_MASK,
0x0,
DATA_SIZE_32);
//
// Set CPU to halt when write to address greater than value in HWBP_REF
// occurs
// RESERVED = (0 << 0) | -> RESERVED
// BUS_SEL = (10 << 1) | -> DWAB for write data accesses
// STOP = (1 << 5) | -> Halt CPU on match
// ROTSINT = (0 << 6) | -> Do not generate RTOSINT
// COMP_MODE = (0 << 7) | -> Generate match when address matches HWBP_REF
// RESERVED = (0 << 10) -> RESERVED
//
// HWBP_CNTL = 0x24
//
debugSession.memory.writeData(Memory.Page.DATA,
EradHWBP1Regs + HWBP_CNTL,
0x24,
DATA_SIZE_16);
//
// Enable HWBP_1. Update GLBL_ENABLE register with value 0x1
//
var enableHWBP =
debugSession.memory.readData(Memory.Page.DATA,
EradGlobalRegs + GLBL_ENABLE,
DATA_SIZE_16);
var enableBits = 0x0001;
enableHWBP = enableHWBP | enableBits;
debugSession.memory.writeData(Memory.Page.DATA,
EradGlobalRegs + GLBL_ENABLE,
enableHWBP,
DATA_SIZE_16);
//
// Loop until Stack Overflow occurs
//
print("\nProfile Started. CPU will halt on stack overflow.\n");
var coreRan = 0;
while(1)
{
//
// Read status and check for event fired bit to be set active. This
// signals that a "match" has occured, as defined by the values set in
// HWBP_CNTL and HWBP_REF for HWBP_1. In this case, the event fired bit
// represents whether or not a write has occured to the address in
// HWBP_REF1, which is set to one past the _STACK_END value
//
var bp_status =
debugSession.memory.readData(Memory.Page.DATA,
EradHWBP1Regs + HWBP_STATUS,
DATA_SIZE_16);
if(bp_status & 0x1 == 1)
{
print("\nSTACK OVERFLOW detected. Halting CPU.\n");
break;
}
//
// Halt script if CPU is halted
//
var halted = debugSession.target.isHalted();
if(!halted)
{
coreRan = 1;
}
if(coreRan && halted)
{
break;
}
}
//
// Disable HWBP_1
//
enableHWBP = debugSession.memory.readData(Memory.Page.DATA,
EradGlobalRegs +
GLBL_ENABLE,
DATA_SIZE_16);
enableHWBP = enableHWBP & (~enableBits);
debugSession.memory.writeData(Memory.Page.DATA,
EradGlobalRegs + GLBL_ENABLE,
enableHWBP,
DATA_SIZE_16);
//
// Reset HWBP_1
//
debugSession.memory.writeData(Memory.Page.DATA,
EradHWBP1Regs + HWBP_CLEAR,
0x1,
DATA_SIZE_16);
print("\nProfile stopped\n");
}
else
{
print("\nFAILED. HWBP_1 is not in idle state\n");
}
//
// End of File
//
@@ -0,0 +1,295 @@
//#############################################################################
//
// FILE: erad_ex3_stackoverflow.c
//
// TITLE: ERAD Stack Overflow Example
//
//! \addtogroup driver_example_list
//! <h1> ERAD Stack Overflow </h1>
//!
//! This example shows the basic setup of CAN in order to transmit and receive
//! messages on the CAN bus. The CAN peripheral is configured to transmit
//! messages with a specific CAN ID. A message is then transmitted once per
//! second, using a simple delay loop for timing. The message that is sent is
//! a 2 byte message that contains an incrementing pattern.
//!
//! This example sets up the CAN controller in External Loopback test mode.
//! Data transmitted is visible on the CANTXA pin and is received internally
//! back to the CAN Core.
//!
//! A buffer is created to store message history up to 50 messages for the
//! duration of the program. A logic error is intentionally made to allow the
//! buffer to overflow, eventually causing a stack overflow. The included
//! JavaScript file, stack_overflow.js, programs ERAD registers in order to
//! detect the stack overflow and halt the CPU once the illegal write is made.
//! The illegal write is made after 507 messages are received.
//!
//! To properly use the provided ERAD script, the following variables must be
//! set in the scripting environment prior to launching the ERAD script:
//!
//! - var PROJ_NAME = "erad_debugger_ex3_stackoverflow"
//! - var PROJ_WKSPC_LOC = <proj_workspace_path>
//!
//! To run the ERAD script, use the following command in the scripting console:
//!
//! - loadJSFile("<proj_workspace_path>\\erad_debugger_ex3_stackoverflow\\erad_ex3_stack_overflow.js", 0);
//!
//! Note that the script must be run after loading and running the .out on the
//! C28x core.
//!
//! The included JavaScript file, erad_ex3_stack_overflow.js, uses Debug Server
//! Scripting (DSS) features. For information on using the DSS, please visit:
//! http://software-dl.ti.com/ccs/esd/documents/users_guide/sdto_dss_handbook.html
//!
//! This example uses 1 HW watchpoint :
//! - HWBP_1 : Data Write Address Bus = Stack end address + 1
//!
//! \b External \b Connections \n
//! - None.
//!
//! \b Watch \b Variables \n
//! - msgCount - A counter for the number of successful messages received
//! - txMsgData - An array with the data being sent
//! - rxMsgData - An array with the data that was received
//! - msgHistoryBuff - An array meant to store the last 50 messages received
//!
//! \b Profiling \b Script \b Output
//! - "STACK OVERFLOW detected. Halting CPU." will be printed in the scripting
//! console when a stack overflow occurs (that is, when the watchpoint is hit)
//
//#############################################################################
//
//
//
// 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"
//
// Defines
//
#define MSG_DATA_LENGTH 2
//
// Globals
//
volatile unsigned long msgCount = 0;
//
// Stack start and end addresses
//
extern uint16_t _stack;
extern uint16_t _STACK_END;
//
// Main
//
void main(void)
{
//
// Setup transfer and receive buffers
//
uint16_t txMsgData[2], rxMsgData[2];
//
// Create buffer to hold message history up to 50 messages
//
volatile uint32_t msgHistoryBuff[50];
//
// Initialize device clock and peripherals
//
Device_init();
//
// Initialize GPIO and configure GPIO pins for CANTX/CANRX
//
Device_initGPIO();
GPIO_setPinConfig(DEVICE_GPIO_CFG_CANRXA);
GPIO_setPinConfig(DEVICE_GPIO_CFG_CANTXA);
//
// Initialize the CAN controller
//
CAN_initModule(CANA_BASE);
//
// Set up the CAN bus bit rate to 500kHz
// Refer to the Driver Library User Guide for information on how to set
// tighter timing control. Additionally, consult the device data sheet
// for more information about the CAN module clocking.
//
CAN_setBitRate(CANA_BASE, DEVICE_SYSCLK_FREQ, 500000, 16);
//
// 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();
//
// Enable Global Interrupt (INTM) and realtime interrupt (DBGM)
//
EINT;
ERTM;
//
// Enable CAN test mode with external loopback
//
CAN_enableTestMode(CANA_BASE, CAN_TEST_EXL);
//
// Initialize the transmit message object used for sending CAN messages.
// Message Object Parameters:
// Message Object ID Number: 1
// Message Identifier: 0x1234
// Message Frame: Standard
// Message Type: Transmit
// Message ID Mask: 0x0
// Message Object Flags: None
// Message Data Length: 2 Bytes
//
CAN_setupMessageObject(CANA_BASE, 1, 0x1234, CAN_MSG_FRAME_STD,
CAN_MSG_OBJ_TYPE_TX, 0, CAN_MSG_OBJ_NO_FLAGS,
MSG_DATA_LENGTH);
//
// Initialize the receive message object used for receiving CAN messages.
// Message Object Parameters:
// Message Object ID Number: 2
// Message Identifier: 0x1234
// Message Frame: Standard
// Message Type: Receive
// Message ID Mask: 0x0
// Message Object Flags: None
// Message Data Length: 2 Bytes
//
CAN_setupMessageObject(CANA_BASE, 2, 0x1234, CAN_MSG_FRAME_STD,
CAN_MSG_OBJ_TYPE_RX, 0, CAN_MSG_OBJ_NO_FLAGS,
MSG_DATA_LENGTH);
//
// Start CAN module operations
//
CAN_startModule(CANA_BASE);
//
// Setup send and receive buffers
//
txMsgData[0] = 0x01;
txMsgData[1] = 0x02;
*(uint16_t *)rxMsgData = 0;
//
// Loop Forever - Send and Receive data continuously
//
for(;;)
{
//
// Send CAN message data from message object 1
//
CAN_sendMessage(CANA_BASE, 1, MSG_DATA_LENGTH, txMsgData);
//
// Delay before receiving the data
//
DEVICE_DELAY_US(50000);
//
// Read CAN message object 2 and check for new data
//
if (CAN_readMessage(CANA_BASE, 2, rxMsgData))
{
//
// Check that received data matches sent data.
// Device will halt here during debug if data doesn't match.
//
if((txMsgData[0] != rxMsgData[0]) ||
(txMsgData[1] != rxMsgData[1]))
{
asm(" ESTOP0");
}
else
{
//
// Store message in message history buffer and increment message
// received counter. Purposely leave out logic to reset counter
// when buffer is full, eventually causing a stack overflow
//
uint32_t message =
(uint32_t)rxMsgData[0] | ((uint32_t)rxMsgData[1] << 16);
msgHistoryBuff[msgCount++] = message;
}
}
else
{
//
// Device will halt here during debug if no new data was received.
//
asm(" ESTOP0");
}
//
// Increment the value in the transmitted message data.
//
txMsgData[0] += 0x01;
txMsgData[1] += 0x01;
//
// Reset data if exceeds a byte
//
if(txMsgData[0] > 0xFF)
{
txMsgData[0] = 0;
}
if(txMsgData[1] > 0xFF)
{
txMsgData[1] = 0;
}
}
}
//
// End of File
//
@@ -0,0 +1,115 @@
//#############################################################################
//
// FILE: erad_ex4_background_task.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 _ERAD_EX4_BACKGROUND_TASK_H_
#define _ERAD_EX4_BACKGROUND_TASK_H_
#ifdef __cplusplus
extern "C" {
#endif
//
// Included Files
//
//
// Defines
//
#define BUFFER_SIZE 1024 // NOTE: keep to a power of 2
#define FILTER_ORDER 28U
#define FILTER_LENGTH (FILTER_ORDER + 1U)
//
// Globals
//
//Task 1 (C) Variables
extern const float coeffs[FILTER_LENGTH];
extern float filter_out;
//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
extern volatile float buffer[BUFFER_SIZE];
//Common (C) Variables
extern float D[FILTER_LENGTH];
//
// Function Prototypes
//
//CLA C Tasks defined in erad_ex4_background_task_cla.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 //_ERAD_EX4_BACKGROUND_TASK_H_
//
// End of File
//
@@ -0,0 +1,253 @@
//#############################################################################
//
// FILE: erad_ex4_background_task_cla.cla
//
// TITLE: CLA ADC Sampling and Filtering with Buffering in a Background Task
//
// Task 1 implements a Finite Impulse Response Filter while the background
// task simply buffers the filtered output in a circular buffer
//
//#############################################################################
//
//
//
// 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 "erad_ex4_background_task.h"
#include "adc.h"
//
// Constants
//
// Generated using fdatool
// LPF FIR Equiripple (Minimum order)
// Fs = 1 KHz
// Fp = 100 Hz
// Fs = 150 Hz
// Ap = 1dB
// As = 40dB
const float coeffs[FILTER_LENGTH] = {
-0.00626161322, 0.004758020397, 0.01360770315, 0.02281877026,
0.02540917136, 0.01582550257,-0.005789283663, -0.03123718128,
-0.04604700953, -0.03544506058, 0.007868565619, 0.07814154029,
0.1567010134, 0.2183543742, 0.2416974753, 0.2183543742,
0.1567010134, 0.07814154029, 0.007868565619, -0.03544506058,
-0.04604700953, -0.03123718128,-0.005789283663, 0.01582550257,
0.02540917136, 0.02281877026, 0.01360770315, 0.004758020397,
-0.00626161322
};
//
// 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.
//
// Filter output
float filter_out;
// Filter delay line
float D[FILTER_LENGTH];
// Circular buffer index
uint16_t index;
// Flag to indicate filtered value is available
bool f_filteredValueReady;
//-----------------------------------------------------------------------------
//
// Task 1 - FIR Filter
//
// Description: A low pass Finite Impulse Response (FIR) filter.
//
//-----------------------------------------------------------------------------
__attribute__((interrupt)) void Cla1Task1 ( void )
{
//Local Variables
int16_t i, filter_in;
__mdebugstop();
filter_out = 0.0;
filter_in = ADC_readResult(ADCARESULT_BASE, ADC_SOC_NUMBER0);;
#if 1
filter_in = filter_in - (1 << 11); // Read ADC value minus bias
//Shift the delay line to the right by 1
#pragma UNROLL(FILTER_LENGTH-1)
for(i = FILTER_LENGTH-1; i > 0; i--){
D[i] = D[i-1];
//Multiply coefficients with the delay line and accumulate
filter_out += coeffs[i] * D[i];
}
__mdebugstop();
//Get adc input into start of the delay line
D[0] = (float)filter_in; //convert to single precision float
filter_out += coeffs[0] * D[0];
f_filteredValueReady = true;
#else
// Pass through unfiltered
filter_out = (float)filter_in;
f_filteredValueReady = true;
#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 - 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 )
{
// Locals
int16_t i;
__mdebugstop();
for(i = 0; i < FILTER_LENGTH; i++){
D[i] = 0.0;
}
index = 0U;
f_filteredValueReady = false;
}
//-----------------------------------------------------------------------------
//
// Background Task
//
// Description: This task will buffer the filtered output in a circular buffer
//
//-----------------------------------------------------------------------------
__attribute__((interrupt("background"))) void Cla1BackgroundTask ( void )
{
while(1)
{
if (f_filteredValueReady == true)
{
//
// Reset the flag
//
f_filteredValueReady = false;
//
// store the filtered output. Make this portion un-interruptible
//
__disable_interrupts();
buffer[index++] = filter_out;
__enable_interrupts();
//
// Since BUFFER_SIZE is a power of two, we can use unsigned modulo
// arithmetic to wrap the index around
//
index = index & (BUFFER_SIZE - 1U);
}
}
}
//
// End of File
//
@@ -0,0 +1,402 @@
//#############################################################################
//
// profile_interrupts_cla.js
//
// This JavaScript file is used to configure ERAD registers for use with the CCS
// example "erad_ex4_profileinterrupts_cla".
//
// To properly use this script, the following variables must be set in the
// scripting environment prior to launching the ERAD script:
//
// - var PROJ_NAME = "erad_ex4_profileinterrupts_cla"
// - var PROJ_WKSPC_LOC = <proj_workspace_path>
// - var PROJ_CONFIG = <name of active configuration [CPU1_FLASH|CPU1_RAM]>
//
// To run this ERAD script, use the following command in the scripting console:
//
// - loadJSFile("<proj_workspace_path>\\erad_ex4_profileinterrupts_cla\\profile_interrupts_cla.js", 0);
//
// This JavaScript file uses Debug Server Scripting (DSS) features. For
// information on using the DSS, please visit:
// http://software-dl.ti.com/ccs/esd/documents/users_guide/sdto_dss_handbook.html
//
//#############################################################################
//
// Import the DSS packages
//
importPackage(Packages.com.ti.debug.engine.scripting)
importPackage(Packages.com.ti.ccstudio.scripting.environment)
importPackage(Packages.java.lang)
//
// Load pre-defined macros for register addresses and useful functions
//
load(PROJ_WKSPC_LOC + "\\" + PROJ_NAME + "\\erad.js");
load(PROJ_WKSPC_LOC + "\\" + PROJ_NAME + "\\erad_util.js");
//
// Create our scripting environment object. This is the main entry point into
// any script and the factory for creating other scriptable servers and sessions
//
var script = ScriptingEnvironment.instance();
script.traceSetConsoleLevel(TraceLevel.ALL)
//
// Create a debug server
//
var ds = script.getServer( "DebugServer.1" );
//
// Open a debug session
//
debugSession = ds.openSession( "*", "C28xx_CPU1" );
//
// Variables for data read/write sizes
//
var DATA_SIZE_16 = 16;
var DATA_SIZE_32 = 32;
//*****************************************************************************
// Example: Profile Interrupts CLA
//*****************************************************************************
//
// Set owner as debugger
//
debugSession.memory.writeData(Memory.Page.DATA,
EradGlobalRegs + GLBL_OWNER,
OWNER_DEBUGGER,
DATA_SIZE_16);
//
// Ensure that counters 1-2 are in idle mode (bits 15:12 are set to 0)
//
var counter1Status =
debugSession.memory.readData(Memory.Page.DATA,
EradCounter1Regs + CTM_STATUS,
DATA_SIZE_16);
var counter2Status =
debugSession.memory.readData(Memory.Page.DATA,
EradCounter2Regs + CTM_STATUS,
DATA_SIZE_16);
var CTM_STATUS_M = 0x3000
if((0 == (counter1Status & CTM_STATUS_M)) &&
(0 == (counter2Status & CTM_STATUS_M)))
{
//
// Reset HWBP_1 and HWBP_2
//
debugSession.memory.writeData(Memory.Page.DATA,
EradHWBP1Regs + HWBP_CLEAR,
0x1,
DATA_SIZE_16);
debugSession.memory.writeData(Memory.Page.DATA,
EradHWBP2Regs + HWBP_CLEAR,
0x1,
DATA_SIZE_16);
//
// Get the start and end addresses of the ISR function "cla1Isr1"
//
var addrFunc = getFuncAddressXML("cla1Isr1");
var startISRFunc = addrFunc[0];
var endISRFunc = addrFunc[1];
//
// Set two hardware breakpoints at the start and end of cla1Isr1
//
debugSession.memory.writeData(Memory.Page.DATA,
EradHWBP1Regs + HWBP_REF,
startISRFunc,
DATA_SIZE_32);
debugSession.memory.writeData(Memory.Page.DATA,
EradHWBP2Regs + HWBP_REF,
endISRFunc,
DATA_SIZE_32);
//
// Set HWBP_1 and HWBP_2 to generate an event on PC match
// RESERVED = (0 << 0) | -> RESERVED
// BUS_SEL = (1 << 1) | -> VPC for program counter match
// STOP = (0 << 5) | -> Do not stop CPU on match
// RTOSINT = (0 << 6) | -> Do not generate RTOSINT
// COMP_MODE = (0 << 7) | -> Regular masked compare.
// (address | mask) == (reference | mask)
// RESERVED = (0 << 12) -> RESERVED
//
// HWBP_CNTL = 0x0002
//
debugSession.memory.writeData(Memory.Page.DATA,
EradHWBP1Regs + HWBP_CNTL,
0x0002,
DATA_SIZE_16);
debugSession.memory.writeData(Memory.Page.DATA,
EradHWBP2Regs + HWBP_CNTL,
0x0002,
DATA_SIZE_16);
//
// Reset Counters 1 and 2 globally
//
debugSession.memory.writeData(Memory.Page.DATA,
EradGlobalRegs + GLBL_CTM_RESET,
0x3,
DATA_SIZE_16);
//
// Clear CTM_COUNT
//
debugSession.memory.writeData(Memory.Page.DATA,
EradCounter1Regs + CTM_COUNT,
0x0,
DATA_SIZE_32);
//
// Clear CTM_MAX_COUNT
//
debugSession.memory.writeData(Memory.Page.DATA,
EradCounter1Regs + CTM_MAX_COUNT,
0x0,
DATA_SIZE_32);
//
// Clear EVENT_FIRED and OVERFLOW sticky bits
// EVENT_CLEAR = (1 << 0) | -> Clear EVENT_FIRED sticky bit in CTM_STATUS
// OVERFLOW_CLEAR = (1 << 1) | -> Clear OVERFLOW sticky bit in CTM_STATUS
// RESERVED = (0 << 2) -> RESERVED
//
debugSession.memory.writeData(Memory.Page.DATA,
EradCounter1Regs + CTM_CLEAR,
0x3,
DATA_SIZE_16);
//
// Clear CTM_REF
//
debugSession.memory.writeData(Memory.Page.DATA,
EradCounter1Regs + CTM_REF,
0x0,
DATA_SIZE_32);
//
// Configure CTM_1 to count cla1Isr1 execution cycles
// Configure CTM_1 to be in start-stop mode
//
// CTM_INPUT_SEL = 0x0000
// CTM_INP_SEL = (0 << 0) | -> Disabled by CTM_INP_SEL_EN
// STA_INP_SEL = (0 << 8) | -> Use HWBP_1 as start event for CTM_1
//
// CTM_INPUT_SEL_2 = 0x0001
// STO_INP_SEL = (1 << 0) -> Use HWBP_2 as stop event for CTM_1
// RST_INP_SEL = (0 << 8) -> Disabled by RST_EN
//
// CTM_CNTL = 0x0004
// RESERVED = (0 << 0) | -> RESERVED
// START_STOP_MODE = (1 << 2) | -> Enable start-stop mode
// EVENT_MODE = (0 << 3) | -> Count as long as input is active (high)
// RST_ON_MATCH = (0 << 4) | -> Stop counting once reference value is
// reached
// RESERVED = (0 << 5) | -> RESERVED
// STOP = (0 << 6) | -> Do not stop CPU when counter reaches
// reference value
// RTOSINT = (0 << 7) | -> Do not generate RTOSINT
// START_STOP_CUM = (0 << 8) | -> Counter gets cleared on stop event
// RESERVED = (0 << 9) | -> RESERVED
// RST_EN = (0 << 10) | -> Disable RST_INP_SEL
// CTM_INP_SEL_EN = (0 << 11) -> Disable CTM_IN_SEL register and count
// CPU cycles
//
debugSession.memory.writeData(Memory.Page.DATA,
EradCounter1Regs + CTM_INPUT_SEL,
(0x0),
DATA_SIZE_16);
debugSession.memory.writeData(Memory.Page.DATA,
EradCounter1Regs + CTM_INPUT_SEL_2,
(0x1),
DATA_SIZE_16);
debugSession.memory.writeData(Memory.Page.DATA,
EradCounter1Regs + CTM_CNTL,
0x004,
DATA_SIZE_16);
//
// Clear CTM_COUNT, CTM_MAX_COUNT, CTM_STATUS sticky bits
//
debugSession.memory.writeData(Memory.Page.DATA,
EradCounter2Regs + CTM_COUNT,
0x0,
DATA_SIZE_32);
debugSession.memory.writeData(Memory.Page.DATA,
EradCounter2Regs + CTM_MAX_COUNT,
0x0,
DATA_SIZE_32);
debugSession.memory.writeData(Memory.Page.DATA,
EradCounter2Regs + CTM_CLEAR,
0x3,
DATA_SIZE_16);
//
// Configure CTM_2 to count number of times CLA_INTERRUPT1 occurs
// CTM_INP_SEL = 35 ( Use CLA_INTERRUPT1 as count event )
// CTM_INPUT_SEL_2 = 0
//
debugSession.memory.writeData(Memory.Page.DATA,
EradCounter2Regs + CTM_INPUT_SEL,
35,
DATA_SIZE_16);
debugSession.memory.writeData(Memory.Page.DATA,
EradCounter2Regs + CTM_INPUT_SEL_2,
0x0000,
DATA_SIZE_16);
//
// Configure CTM_2 to be in rising-edge count mode
//
// CTM_CNTL = 0x0808
// EVENT_MODE = (1 << 3) | -> Count only on rising-edge of count input
// CNT_INP_SEL_EN = (1 << 11) -> Enable CTM_INP_SEL
//
debugSession.memory.writeData(Memory.Page.DATA,
EradCounter2Regs + CTM_CNTL,
0x0808,
DATA_SIZE_16);
//
// Enable HWBP_1-2 and CTM_1-2
// HWBP_GLOBAL_ENABLE = (1 << 0) | (1 << 1)
// COUNTER_GLOBAL_ENABLE = (1 << 8) | (1 << 9)
//
var enableCounter =
debugSession.memory.readData(Memory.Page.DATA,
EradGlobalRegs + GLBL_ENABLE,
DATA_SIZE_16);
var enableBits = 0x0100 | 0x0200 | 0x0001 | 0x0002;
enableCounter = enableCounter | enableBits;
debugSession.memory.writeData(Memory.Page.DATA,
EradGlobalRegs + GLBL_ENABLE,
enableCounter,
DATA_SIZE_16);
print("\nCounter Started\n");
var coreRan = 0;
while(1)
{
var cycleCountISR =
debugSession.memory.readData(Memory.Page.DATA,
EradCounter1Regs + CTM_COUNT,
DATA_SIZE_32);
var cycleMaxISR =
debugSession.memory.readData(Memory.Page.DATA,
EradCounter1Regs +
CTM_MAX_COUNT,
DATA_SIZE_32);
var interruptCount =
debugSession.memory.readData(Memory.Page.DATA,
EradCounter2Regs + CTM_COUNT,
DATA_SIZE_32);
print("Current ISR Cycle Count = " + cycleCountISR.toString() +
"\t Max ISR Cycle Count = " + cycleMaxISR.toString() +
"\t Interrupt Count = " + interruptCount.toString());
//
// Halt script if CPU is halted
//
var halted = debugSession.target.isHalted();
if(!halted)
{
coreRan = 1;
}
if(coreRan && halted)
{
break;
}
}
//
// Disable HWBP_1-2 and CTM_1-2
//
enableCounter =
debugSession.memory.readData(Memory.Page.DATA,
EradGlobalRegs + GLBL_ENABLE,
DATA_SIZE_16);
enableCounter = enableCounter & (~enableBits);
debugSession.memory.writeData(Memory.Page.DATA,
EradGlobalRegs + GLBL_ENABLE,
enableCounter,
DATA_SIZE_16);
//
// Reset CTM_1-2 values
//
debugSession.memory.writeData(Memory.Page.DATA,
EradCounter1Regs + CTM_COUNT,
0x0,
DATA_SIZE_32);
debugSession.memory.writeData(Memory.Page.DATA,
EradCounter1Regs + CTM_MAX_COUNT,
0x0,
DATA_SIZE_32);
debugSession.memory.writeData(Memory.Page.DATA,
EradCounter1Regs + CTM_CLEAR,
0x3,
DATA_SIZE_32);
debugSession.memory.writeData(Memory.Page.DATA,
EradCounter2Regs + CTM_COUNT,
0x0,
DATA_SIZE_32);
debugSession.memory.writeData(Memory.Page.DATA,
EradCounter2Regs + CTM_MAX_COUNT,
0x0,
DATA_SIZE_32);
debugSession.memory.writeData(Memory.Page.DATA,
EradCounter2Regs + CTM_CLEAR,
0x3,
DATA_SIZE_32);
//
// Reset HWBP_1-2
//
debugSession.memory.writeData(Memory.Page.DATA,
EradHWBP1Regs + HWBP_CLEAR,
0x1,
DATA_SIZE_16);
debugSession.memory.writeData(Memory.Page.DATA,
EradHWBP2Regs + HWBP_CLEAR,
0x1,
DATA_SIZE_16);
print("\nCounter Stopped\n");
}
else
{
print("Failed\n");
}
//
// End of File
//
@@ -0,0 +1,537 @@
//#############################################################################
//
// FILE: erad_ex4_profileinterrupts_cla.c
//
// TITLE: ERAD Profile Interrupts CLA Example
//
//! \addtogroup driver_example_list
//! <h1> ERAD Profile Interrupts CLA </h1>
//!
//! This example configures EPWM1A to run at 1 KHz (period = 1 ms) to
//! trigger a start-of-conversion on ADC channel A0. This channel will,
//! in turn, sample EPWM4A which is set to run at 100Hz.
//! At the end-of-conversion the ADC interrupt is fired. The interrupt signal
//! will be used to trigger a CLA task that runs an FIR filter. The filter
//! is designed to be low pass with a cutoff frequency of 100Hz; it will remove
//! the odd harmonics in the input signal smoothing the square wave to a
//! sinusoidal shape.
//! The CLA background task will continuously buffer the filtered output in a
//! circular buffer.
//!
//! This example also utilizes the ERAD peripheral to profile the Interrupt
//! Service Routine (ISR) cla1ISR1 (on the C28x core). The ISR contains a loop
//! that simulates storing a random amount of data to a location in order to
//! introduce variability into the cycle measurements. The ERAD peripheral is
//! also configured to count the number of times the system event CLA_INTERRUPT1
//! occurs.
//!
//! To properly use the provided ERAD script, the following variables must be
//! set in the scripting environment prior to launching the ERAD script:
//!
//! - var PROJ_NAME = "erad_debugger_ex4_profileinterrupts_cla"
//! - var PROJ_WKSPC_LOC = "<proj_workspace_path>"
//! - var PROJ_CONFIG = "<name of active configuration [CPU1_FLASH|CPU1_RAM]>"
//!
//! To run the ERAD script, use the following command in the scripting console:
//!
//! - loadJSFile("<proj_workspace_path>\\erad_debugger_ex4_profileinterrupts_cla\\erad_ex4_profile_interrupts_cla.js", 0);
//!
//! Note that the script must be run after loading and running the .out on the
//! C28x core.
//!
//! The included JavaScript file, erad_ex4_profile_interrupts_cla.js, uses Debug Server
//! Scripting (DSS) features. For information on using the DSS, please visit:
//! http://software-dl.ti.com/ccs/esd/documents/users_guide/sdto_dss_handbook.html
//!
//! This example uses 4 HW breakpoints and 2 counters:
//! - HWBP_1 : PC = start address of cla1Isr1
//! - HWBP_2 : PC = end address of cla1Isr1
//! - CTM_1 : Used to count the cla1Isr1 execution cycles.
//! Configured in start-stop mode with start event as HWBP_1 and
//! stop event as HWBP_2
//! - CTM_2 : Used to count the number of times the system event
//! CLA_INTERRUPT1 event has occurred.
//! Configured in rising-edge count mode with counting input as
//! system event CLA_INTERRUPT1 (INP_SEL[26])
//!
//! \b External \b Connections \n
//! - connect A0 to EPWM4A
//!
//! \b Watch \b Variables \n
//! - ISR_count - A counter that signifies how many times cla1ISR1 executes
//!
//! \b Profiling \b Script \b Output
//! - Current ISR cycle count (CTM_1)
//! - Max ISR cycle count (maximum value of CTM_1)
//! - Interrupt occurrence count (CTM_2)
//
//#############################################################################
//
//
//
// 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 "erad_ex4_background_task.h"
//
// Defines
//
#define EPWM_CLKDIV 64UL
#define EPWM1_FREQ 1000UL
#define EPWM4_FREQ 100UL
#define EPWM1_PERIOD (uint16_t)(DEVICE_SYSCLK_FREQ / \
(EPWM_CLKDIV * EPWM1_FREQ))
#define EPWM4_PERIOD (uint16_t)(DEVICE_SYSCLK_FREQ / \
(EPWM_CLKDIV * 2U * EPWM4_FREQ))
#define EPWM4_DUTY_CYCLE (EPWM4_PERIOD / 2)
//
// Globals
//
//
// Background Task (C) Variables
// Circular buffer to store filtered output
//
#pragma DATA_SECTION(buffer, "Cla1DataRam");
volatile float buffer[BUFFER_SIZE];
//
// Linker Defined variables
//
extern uint32_t Cla1funcsRunStart, Cla1funcsLoadStart, Cla1funcsLoadSize;
extern uint32_t Cla1ConstRunStart, Cla1ConstLoadStart, Cla1ConstLoadSize;
//
// Pre-chosen Pseudo Random Generator constants
//
const uint16_t PseudoRand_multiplier = 31821;
const uint16_t PseudoRand_increment = 13849;
uint16_t PseudoRand_seed = 21845;
//
// ISR Counter
//
uint32_t ISR_count = 0;
//
// Function Prototypes
//
void initADC(void);
void initADCSOC(void);
void initEPWM(void);
void initCLA(void);
__attribute__((interrupt)) void cla1Isr1(void);
uint16_t generatePseudoRand16(uint16_t *);
//
// 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);
//
// GPIO6 is set to EPWM4A
//
GPIO_setControllerCore(6, GPIO_CORE_CPU1);
GPIO_setPadConfig(6,GPIO_PIN_TYPE_STD);
GPIO_setPinConfig(GPIO_6_EPWM4A);
//
// 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();
//
// Map the ISR to the CLA end-of-task interrupt.
//
Interrupt_register(INT_CLA1_1, cla1Isr1);
//
// Setup the CLA and ADC
//
initCLA();
initADC();
initADCSOC();
//
// Disable sync(Freeze clock to PWM as well)
//
SysCtl_disablePeripheral(SYSCTL_PERIPH_CLK_TBCLKSYNC);
initEPWM();
//
// Enable the interrupts in the PIE: Group 11 interrupt 1.
//
Interrupt_enable(INT_CLA1_1);
Interrupt_clearACKGroup(INTERRUPT_ACK_GROUP11);
//
// 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 resolution and signal mode and load corresponding trims.
//
ADC_setMode(ADCA_BASE, ADC_RESOLUTION_12BIT, ADC_MODE_SINGLE_ENDED);
//
// Set pulse positions to late
//
ADC_setInterruptPulseMode(ADCA_BASE, ADC_PULSE_END_OF_CONV);
//
// 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 (the filter)
//
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 Hz and serves as the sampling
// clock for ADC channel A0 which will be sampling the slower running EPWM4A
// (at EPWM4_FREQ Hz). 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
// this event will trigger the ADC to start sampling on channel A0
// EPWM4A is setup for updown count mode with CMPA level at the half period
// point giving a 50% duty cycle square wave at EPWM4_FREQ Hz
// For a desired PWM frequency F_pwm (1/T_pwm), we have
// T_pwm = 2 x TBPRD / TBCLK
// TBPRD = TBCLK/(2*F_pwm)
// For e.g. F_pwm = 10KHz, TBCLK = 50e6
// TBPRD = 50e6/(2*10e3)
// = 2500
// For e.g. F_pwm = 1KHz, TBCLK = 50e6
// TBPRD = 50e6/(2*1e3)
// = 25000
// For e.g. F_pwm = 100Hz, TBCLK = 50e6
// TBPRD = 50e6/(2*1e2)
// = 250000
//
void initEPWM(void)
{
//
// Set up EPWM1 to
// - run on a base clock of SYSCLK/64
// - have a period of EPWM1_PERIOD
// - run in count up mode
//
EPWM_setClockPrescaler(EPWM1_BASE, EPWM_CLOCK_DIVIDER_8,
EPWM_HSCLOCK_DIVIDER_8);
EPWM_setTimeBasePeriod(EPWM1_BASE, EPWM1_PERIOD);
EPWM_setTimeBaseCounterMode(EPWM1_BASE, EPWM_COUNTER_MODE_UP);
EPWM_setTimeBaseCounter(EPWM1_BASE, 0U);
//
// 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);
//
// EPWM1 should toggle each time its counter hits zero
//
EPWM_setActionQualifierAction(EPWM1_BASE, EPWM_AQ_OUTPUT_A,
EPWM_AQ_OUTPUT_TOGGLE, EPWM_AQ_OUTPUT_ON_TIMEBASE_ZERO);
//
// Set up EPWM4 to
// - run on a base clock of SYSCLK/64
// - have a period of EPWM4_PERIOD
// - run in count up/down mode
// - have its CMPA value set for a 50% duty cycle
//
EPWM_setClockPrescaler(EPWM4_BASE, EPWM_CLOCK_DIVIDER_8,
EPWM_HSCLOCK_DIVIDER_8);
EPWM_setTimeBasePeriod(EPWM4_BASE, EPWM4_PERIOD);
EPWM_setTimeBaseCounterMode(EPWM4_BASE, EPWM_COUNTER_MODE_UP_DOWN);
EPWM_setTimeBaseCounter(EPWM4_BASE, 0U);
EPWM_setCounterCompareValue(EPWM4_BASE, EPWM_COUNTER_COMPARE_A,
EPWM4_DUTY_CYCLE);
//
// On compare A, when counting up, pull the EPWM A output high
// On compare A, when counting down, pull the EPWM A output low
//
EPWM_setActionQualifierAction(EPWM4_BASE, EPWM_AQ_OUTPUT_A,
EPWM_AQ_OUTPUT_HIGH, EPWM_AQ_OUTPUT_ON_TIMEBASE_UP_CMPA);
EPWM_setActionQualifierAction(EPWM4_BASE, EPWM_AQ_OUTPUT_A,
EPWM_AQ_OUTPUT_LOW, EPWM_AQ_OUTPUT_ON_TIMEBASE_DOWN_CMPA);
//
// 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);
}
//
// generatePseudoRand16 - Generate a pseudo random 16-bit number by passing a
// start value or "seed". This generator is a linear congruential pseudo random
// generator, which is very fast. The basic calculation is:
//
// randNum(n) = ((randNum(n-1) * multiplier) + increment) modulo M
//
uint16_t
generatePseudoRand16(uint16_t *seed)
{
//
// Perform calculation. Mask off bottom bits in lieu of modulus operation
//
*seed = ((uint32_t)*seed * PseudoRand_multiplier + PseudoRand_increment)
& 0xFFFF;
return(*seed);
}
//
// CLA Initialization
//
// Description: This function will
// - copy over code and const from flash to CLA program and data ram
// respectively
// - Initialize the task vectors (MVECTx)
// - setup each task's trigger
// - enable each individual task
// - map program and data spaces to the CLA
// - run any one-time initialization task
// Please note that the CLA can only run code and access data that is in RAM.
// the user must assign constants (tables) to FLASH, and copy them over to
// RAM at run-time. They must be copied to a RAM that lies in the address space
// of the CLA, and prior to giving the CLA control over that space
//
void initCLA(void)
{
//
// Copy the program and constants from FLASH to RAM before configuring
// the CLA
//
#if defined(_FLASH)
memcpy((uint32_t *)&Cla1funcsRunStart, (uint32_t *)&Cla1funcsLoadStart,
(uint32_t)&Cla1funcsLoadSize);
memcpy((uint32_t *)&Cla1ConstRunStart, (uint32_t *)&Cla1ConstLoadStart,
(uint32_t)&Cla1ConstLoadSize );
#endif //defined(_FLASH)
//
// CLA Program will reside in RAMLS5 and data in RAMLS0, RAMLS1
//
MemCfg_setLSRAMControllerSel(MEMCFG_SECT_LS5, MEMCFG_LSRAMCONTROLLER_CPU_CLA1);
MemCfg_setLSRAMControllerSel(MEMCFG_SECT_LS0, MEMCFG_LSRAMCONTROLLER_CPU_CLA1);
MemCfg_setLSRAMControllerSel(MEMCFG_SECT_LS1, MEMCFG_LSRAMCONTROLLER_CPU_CLA1);
MemCfg_setCLAMemType(MEMCFG_SECT_LS5, MEMCFG_CLA_MEM_PROGRAM);
MemCfg_setCLAMemType(MEMCFG_SECT_LS0, MEMCFG_CLA_MEM_DATA);
MemCfg_setCLAMemType(MEMCFG_SECT_LS1, MEMCFG_CLA_MEM_DATA);
//
// Suppressing #770-D conversion from pointer to smaller integer
// The CLA address range is 16 bits so the addresses passed to the MVECT
// registers will be in the lower 64KW address space. Turn the warning
// back on after the MVECTs are assigned addresses
//
#pragma diag_suppress=770
//
// Assign the task vectors and set the triggers for task 1 and 7
//
CLA_mapTaskVector(CLA1_BASE, CLA_MVECT_1, (uint16_t)&Cla1Task1);
CLA_mapTaskVector(CLA1_BASE, CLA_MVECT_7, (uint16_t)&Cla1Task7);
CLA_setTriggerSource(CLA_TASK_1, CLA_TRIGGER_ADCA1);
CLA_setTriggerSource(CLA_TASK_7, CLA_TRIGGER_SOFTWARE);
//
// Enable Tasks 1 and 7. Since task 7 is forced in software, we must
// enable software forcing (IACKE)
//
CLA_enableTasks(CLA1_BASE, (CLA_TASKFLAG_1 | CLA_TASKFLAG_7));
CLA_enableIACK(CLA1_BASE);
//
// The background task will be triggered by software; it shares
// the same trigger source as task 8. Disable the hardware triggering
// mechanism for the background task (if it is enabled) and then
// set the trigger source for task 8 to 0 indicating a software
// trigger.
//
// Enable the background task and start it. Enabling the background
// task disables task 8.
//
CLA_mapBackgroundTaskVector(CLA1_BASE, (uint16_t)&Cla1BackgroundTask);
#pragma diag_warning=770
CLA_disableHardwareTrigger(CLA1_BASE);
CLA_setTriggerSource(CLA_TASK_8, CLA_TRIGGER_SOFTWARE);
CLA_enableBackgroundTask(CLA1_BASE);
CLA_startBackgroundTask(CLA1_BASE);
//
// Force task 7, the one time initialization task
//
CLA_forceTasks(CLA1_BASE, CLA_TASKFLAG_7);
}
//
// CLA Task 1 End-of-Task Interrupt Service Routine
//
// Description: This ISR is run every time task 1 completes. It continuously
// takes the filtered values from the CLA and stores it to a circular buffer
//
__attribute__((interrupt)) void cla1Isr1 ()
{
//
// Clear the ADC interrupt flag so the next SOC can occur
//
ADC_clearInterruptStatus(ADCA_BASE, ADC_INT_NUMBER1);
//
// Acknowledge the end-of-task interrupt for task 1
//
Interrupt_clearACKGroup(INTERRUPT_ACK_GROUP11);
//
// Simulate storing data to a location. "volatile" keyword ensures this is
// not optimized out by the compiler.
//
volatile uint32_t output;
//
// Generate a random number.
//
uint16_t count = generatePseudoRand16(&PseudoRand_seed);
//
// Simulate a task that can take some time to complete. Loop a "random"
// number of times and store values to a location.
//
uint32_t i;
for(i = 0; i < count; i++)
{
output = i;
}
//
// Increment a counter signifying that ISR has executed
//
ISR_count++;
}
//
// End of File
//
@@ -0,0 +1,83 @@
importPackage(Packages.com.ti.debug.engine.scripting)
importPackage(Packages.com.ti.ccstudio.scripting.environment)
importPackage(Packages.org.w3c.dom)
importPackage(Packages.javax.xml.parsers)
importPackage(Packages.java.lang)
importPackage(Packages.java.util)
importPackage(Packages.java.io)
function getFuncAddressXML(funcName)
{
//
// Check for the existence of script environment variables. An error message
// is printed if the string has not been defined in the current scripting
// session. Note: These error messages will not trigger if the variables
// are defined, but are set to incorrect values. It is up to the user to
// make sure that each of these variables is set accordingly prior to
// running the example program
//
print("....Looking for the XML file....");
if (typeof PROJ_NAME == 'undefined')
{
print("\nERROR: Please set PROJ_NAME to the name of the" +
" CCS project\n");
}
if (typeof PROJ_WKSPC_LOC == 'undefined')
{
print("\nERROR: Please set PROJ_WKSPC_LOC to the correct" +
" CCS workspace path\n");
}
if (typeof PROJ_CONFIG == 'undefined')
{
print("\nERROR: Please set PROJ_CONFIG to the name of the" +
" active configuration\n");
}
var xmlFileName = PROJ_WKSPC_LOC + "\\" + PROJ_NAME + "\\" + PROJ_CONFIG +
"\\" + PROJ_NAME + "_linkinfo.xml";
print("....XML file: " + xmlFileName);
var xmlFile = new File(xmlFileName);
var dbFactory = DocumentBuilderFactory.newInstance();
var dBuilder = dbFactory.newDocumentBuilder();
var xmlDom = dBuilder.parse(xmlFile);
xmlDom.getDocumentElement().normalize();
/*
print("Root element :" + xmlDom.getDocumentElement().getNodeName());
*/
var nodeList = xmlDom.getElementsByTagName("object_component");
var length = nodeList.getLength();
print("Number of nodes: " + nodeList.getLength() + " with name: " + nodeList.item(0).getNodeName() );
var myFuncStart, myFuncLength, myFuncEnd;
for(var index = 0; index < length; index++)
{
var myName = nodeList.item(index).getElementsByTagName("name");
/*
print("Node " + index + ": " + myName.item(0).firstChild.nodeValue);
*/
if( (myName.item(0).firstChild.nodeValue == ".text:" + funcName) || (myName.item(0).firstChild.nodeValue == ".TI.ramfunc:" + funcName) )
{
print("....Found: " + nodeList.item(0).getNodeName() + " with " + myName.item(0).getNodeName() + " and child value: " + myName.item(0).firstChild.nodeValue);
myFuncStart = nodeList.item(index).getElementsByTagName("run_address").item(0).firstChild.nodeValue;
myFuncLength = nodeList.item(index).getElementsByTagName("size").item(0).firstChild.nodeValue;
myFuncEnd = parseInt(myFuncStart) + parseInt(myFuncLength) -1;
/*
print("....run_address: " + (myFuncStart) + " size: " + myFuncLength + " end: 0x" + myFuncEnd.toString(16));
*/
break;
}
/*
print("Node: " + myName.getLength() + "name: " + myName.item(0).getNodeName() + " child value: " + myName.item(0).firstChild.nodeValue);
*/
}
return [parseInt(myFuncStart), myFuncEnd];
}