Update repo
This commit is contained in:
1 parent
749dab5721
commit
ce65a0f59a
14950 files changed
+4408250
-1
No files matched your search
+40
@@ -0,0 +1,40 @@
|
||||
<projectSpec>
|
||||
<project
|
||||
name="adc_ex10_multiple_soc_epwm"
|
||||
device="TMS320F28388D"
|
||||
cgtVersion="22.6.1.LTS"
|
||||
products="sysconfig;C2000WARE"
|
||||
outputFormat="ELF"
|
||||
launchWizard="False"
|
||||
linkerCommandFile=""
|
||||
enableSysConfigTool="true"
|
||||
sysConfigBuildOptions="--product ${C2000WARE_ROOT}/.metadata/sdk.json --device F2838x --package 337bga --part F2838x_337bga"
|
||||
postBuildStep="
|
||||
echo "========= Build of the CLB simulation has moved to the CLB Tool. Click the '?' icon by the _Generate CLB Simulation File_ enable for more details (located in the Global Parameters of the Tile Design SysConfig module) ============="
|
||||
;if ${GENERATE_DIAGRAM} == 1 ${NODE_TOOL} "${C2000WARE_ROOT}/utilities/clb_tool/clb_syscfg/dot_file_libraries/clbDotUtility.js" "${C2000WARE_ROOT}/utilities/clb_tool/clb_syscfg/" "${BuildDirectory}/syscfg" "${BuildDirectory}/syscfg/clb.dot"
|
||||
;if ${GENERATE_DIAGRAM} == 1 mkdir "${BuildDirectory}/diagrams"
|
||||
;if ${GENERATE_DIAGRAM} == 1 ${NODE_TOOL} "${C2000WARE_ROOT}/driverlib/.meta/generate_diagrams.js" "${C2000WARE_ROOT}" "${BuildDirectory}/diagrams" "${BuildDirectory}/syscfg"
|
||||
"
|
||||
>
|
||||
<configuration name="CPU1_RAM" compilerBuildOptions= "--opt_level=off -I${C2000WARE_ROOT} -I${PROJECT_ROOT}/device -I${C2000WARE_DLIB_ROOT} -v28 -ml -mt --cla_support=cla2 --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="../adc_ex10_multiple_soc_epwm.c" targetDirectory="" />
|
||||
<file action="copy" path="../adc_ex10_multiple_soc_epwm.syscfg" targetDirectory=""/>
|
||||
</project>
|
||||
</projectSpec>
|
||||
@@ -0,0 +1,40 @@
|
||||
<projectSpec>
|
||||
<project
|
||||
name="adc_ex11_burst_mode_epwm"
|
||||
device="TMS320F28388D"
|
||||
cgtVersion="22.6.1.LTS"
|
||||
products="sysconfig;C2000WARE"
|
||||
outputFormat="ELF"
|
||||
launchWizard="False"
|
||||
linkerCommandFile=""
|
||||
enableSysConfigTool="true"
|
||||
sysConfigBuildOptions="--product ${C2000WARE_ROOT}/.metadata/sdk.json --device F2838x --package 337bga --part F2838x_337bga"
|
||||
postBuildStep="
|
||||
echo "========= Build of the CLB simulation has moved to the CLB Tool. Click the '?' icon by the _Generate CLB Simulation File_ enable for more details (located in the Global Parameters of the Tile Design SysConfig module) ============="
|
||||
;if ${GENERATE_DIAGRAM} == 1 ${NODE_TOOL} "${C2000WARE_ROOT}/utilities/clb_tool/clb_syscfg/dot_file_libraries/clbDotUtility.js" "${C2000WARE_ROOT}/utilities/clb_tool/clb_syscfg/" "${BuildDirectory}/syscfg" "${BuildDirectory}/syscfg/clb.dot"
|
||||
;if ${GENERATE_DIAGRAM} == 1 mkdir "${BuildDirectory}/diagrams"
|
||||
;if ${GENERATE_DIAGRAM} == 1 ${NODE_TOOL} "${C2000WARE_ROOT}/driverlib/.meta/generate_diagrams.js" "${C2000WARE_ROOT}" "${BuildDirectory}/diagrams" "${BuildDirectory}/syscfg"
|
||||
"
|
||||
>
|
||||
<configuration name="CPU1_RAM" compilerBuildOptions= "--opt_level=off -I${C2000WARE_ROOT} -I${PROJECT_ROOT}/device -I${C2000WARE_DLIB_ROOT} -v28 -ml -mt --cla_support=cla2 --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="../adc_ex11_burst_mode_epwm.c" targetDirectory="" />
|
||||
<file action="copy" path="../adc_ex11_burst_mode_epwm.syscfg" targetDirectory=""/>
|
||||
</project>
|
||||
</projectSpec>
|
||||
+40
@@ -0,0 +1,40 @@
|
||||
<projectSpec>
|
||||
<project
|
||||
name="adc_ex12_burst_mode_oversampling"
|
||||
device="TMS320F28388D"
|
||||
cgtVersion="22.6.1.LTS"
|
||||
products="sysconfig;C2000WARE"
|
||||
outputFormat="ELF"
|
||||
launchWizard="False"
|
||||
linkerCommandFile=""
|
||||
enableSysConfigTool="true"
|
||||
sysConfigBuildOptions="--product ${C2000WARE_ROOT}/.metadata/sdk.json --device F2838x --package 337bga --part F2838x_337bga"
|
||||
postBuildStep="
|
||||
echo "========= Build of the CLB simulation has moved to the CLB Tool. Click the '?' icon by the _Generate CLB Simulation File_ enable for more details (located in the Global Parameters of the Tile Design SysConfig module) ============="
|
||||
;if ${GENERATE_DIAGRAM} == 1 ${NODE_TOOL} "${C2000WARE_ROOT}/utilities/clb_tool/clb_syscfg/dot_file_libraries/clbDotUtility.js" "${C2000WARE_ROOT}/utilities/clb_tool/clb_syscfg/" "${BuildDirectory}/syscfg" "${BuildDirectory}/syscfg/clb.dot"
|
||||
;if ${GENERATE_DIAGRAM} == 1 mkdir "${BuildDirectory}/diagrams"
|
||||
;if ${GENERATE_DIAGRAM} == 1 ${NODE_TOOL} "${C2000WARE_ROOT}/driverlib/.meta/generate_diagrams.js" "${C2000WARE_ROOT}" "${BuildDirectory}/diagrams" "${BuildDirectory}/syscfg"
|
||||
"
|
||||
>
|
||||
<configuration name="CPU1_RAM" compilerBuildOptions= "--opt_level=off -I${C2000WARE_ROOT} -I${PROJECT_ROOT}/device -I${C2000WARE_DLIB_ROOT} -v28 -ml -mt --cla_support=cla2 --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="../adc_ex12_burst_mode_oversampling.c" targetDirectory="" />
|
||||
<file action="copy" path="../adc_ex12_burst_mode_oversampling.syscfg" targetDirectory=""/>
|
||||
</project>
|
||||
</projectSpec>
|
||||
+40
@@ -0,0 +1,40 @@
|
||||
<projectSpec>
|
||||
<project
|
||||
name="adc_ex13_soc_oversampling"
|
||||
device="TMS320F28388D"
|
||||
cgtVersion="22.6.1.LTS"
|
||||
products="sysconfig;C2000WARE"
|
||||
outputFormat="ELF"
|
||||
launchWizard="False"
|
||||
linkerCommandFile=""
|
||||
enableSysConfigTool="true"
|
||||
sysConfigBuildOptions="--product ${C2000WARE_ROOT}/.metadata/sdk.json --device F2838x --package 337bga --part F2838x_337bga"
|
||||
postBuildStep="
|
||||
echo "========= Build of the CLB simulation has moved to the CLB Tool. Click the '?' icon by the _Generate CLB Simulation File_ enable for more details (located in the Global Parameters of the Tile Design SysConfig module) ============="
|
||||
;if ${GENERATE_DIAGRAM} == 1 ${NODE_TOOL} "${C2000WARE_ROOT}/utilities/clb_tool/clb_syscfg/dot_file_libraries/clbDotUtility.js" "${C2000WARE_ROOT}/utilities/clb_tool/clb_syscfg/" "${BuildDirectory}/syscfg" "${BuildDirectory}/syscfg/clb.dot"
|
||||
;if ${GENERATE_DIAGRAM} == 1 mkdir "${BuildDirectory}/diagrams"
|
||||
;if ${GENERATE_DIAGRAM} == 1 ${NODE_TOOL} "${C2000WARE_ROOT}/driverlib/.meta/generate_diagrams.js" "${C2000WARE_ROOT}" "${BuildDirectory}/diagrams" "${BuildDirectory}/syscfg"
|
||||
"
|
||||
>
|
||||
<configuration name="CPU1_RAM" compilerBuildOptions= "--opt_level=off -I${C2000WARE_ROOT} -I${PROJECT_ROOT}/device -I${C2000WARE_DLIB_ROOT} -v28 -ml -mt --cla_support=cla2 --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="../adc_ex13_soc_oversampling.c" targetDirectory="" />
|
||||
<file action="copy" path="../adc_ex13_soc_oversampling.syscfg" targetDirectory=""/>
|
||||
</project>
|
||||
</projectSpec>
|
||||
@@ -0,0 +1,40 @@
|
||||
<projectSpec>
|
||||
<project
|
||||
name="adc_ex14_ppb_pwm_trip"
|
||||
device="TMS320F28388D"
|
||||
cgtVersion="22.6.1.LTS"
|
||||
products="sysconfig;C2000WARE"
|
||||
outputFormat="ELF"
|
||||
launchWizard="False"
|
||||
linkerCommandFile=""
|
||||
enableSysConfigTool="true"
|
||||
sysConfigBuildOptions="--product ${C2000WARE_ROOT}/.metadata/sdk.json --device F2838x --package 337bga --part F2838x_337bga"
|
||||
postBuildStep="
|
||||
echo "========= Build of the CLB simulation has moved to the CLB Tool. Click the '?' icon by the _Generate CLB Simulation File_ enable for more details (located in the Global Parameters of the Tile Design SysConfig module) ============="
|
||||
;if ${GENERATE_DIAGRAM} == 1 ${NODE_TOOL} "${C2000WARE_ROOT}/utilities/clb_tool/clb_syscfg/dot_file_libraries/clbDotUtility.js" "${C2000WARE_ROOT}/utilities/clb_tool/clb_syscfg/" "${BuildDirectory}/syscfg" "${BuildDirectory}/syscfg/clb.dot"
|
||||
;if ${GENERATE_DIAGRAM} == 1 mkdir "${BuildDirectory}/diagrams"
|
||||
;if ${GENERATE_DIAGRAM} == 1 ${NODE_TOOL} "${C2000WARE_ROOT}/driverlib/.meta/generate_diagrams.js" "${C2000WARE_ROOT}" "${BuildDirectory}/diagrams" "${BuildDirectory}/syscfg"
|
||||
"
|
||||
>
|
||||
<configuration name="CPU1_RAM" compilerBuildOptions= "--opt_level=off -I${C2000WARE_ROOT} -I${PROJECT_ROOT}/device -I${C2000WARE_DLIB_ROOT} -v28 -ml -mt --cla_support=cla2 --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="../adc_ex14_ppb_pwm_trip.c" targetDirectory="" />
|
||||
<file action="copy" path="../adc_ex14_ppb_pwm_trip.syscfg" targetDirectory=""/>
|
||||
</project>
|
||||
</projectSpec>
|
||||
+40
@@ -0,0 +1,40 @@
|
||||
<projectSpec>
|
||||
<project
|
||||
name="adc_ex15_high_priority_soc"
|
||||
device="TMS320F28388D"
|
||||
cgtVersion="22.6.1.LTS"
|
||||
products="sysconfig;C2000WARE"
|
||||
outputFormat="ELF"
|
||||
launchWizard="False"
|
||||
linkerCommandFile=""
|
||||
enableSysConfigTool="true"
|
||||
sysConfigBuildOptions="--product ${C2000WARE_ROOT}/.metadata/sdk.json --device F2838x --package 337bga --part F2838x_337bga"
|
||||
postBuildStep="
|
||||
echo "========= Build of the CLB simulation has moved to the CLB Tool. Click the '?' icon by the _Generate CLB Simulation File_ enable for more details (located in the Global Parameters of the Tile Design SysConfig module) ============="
|
||||
;if ${GENERATE_DIAGRAM} == 1 ${NODE_TOOL} "${C2000WARE_ROOT}/utilities/clb_tool/clb_syscfg/dot_file_libraries/clbDotUtility.js" "${C2000WARE_ROOT}/utilities/clb_tool/clb_syscfg/" "${BuildDirectory}/syscfg" "${BuildDirectory}/syscfg/clb.dot"
|
||||
;if ${GENERATE_DIAGRAM} == 1 mkdir "${BuildDirectory}/diagrams"
|
||||
;if ${GENERATE_DIAGRAM} == 1 ${NODE_TOOL} "${C2000WARE_ROOT}/driverlib/.meta/generate_diagrams.js" "${C2000WARE_ROOT}" "${BuildDirectory}/diagrams" "${BuildDirectory}/syscfg"
|
||||
"
|
||||
>
|
||||
<configuration name="CPU1_RAM" compilerBuildOptions= "--opt_level=off -I${C2000WARE_ROOT} -I${PROJECT_ROOT}/device -I${C2000WARE_DLIB_ROOT} -v28 -ml -mt --cla_support=cla2 --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="../adc_ex15_high_priority_soc.c" targetDirectory="" />
|
||||
<file action="copy" path="../../empty_projects/c2000.syscfg" targetDirectory="" />
|
||||
</project>
|
||||
</projectSpec>
|
||||
+40
@@ -0,0 +1,40 @@
|
||||
<projectSpec>
|
||||
<project
|
||||
name="adc_ex16_sw_interleaved_averaging"
|
||||
device="TMS320F28388D"
|
||||
cgtVersion="22.6.1.LTS"
|
||||
products="sysconfig;C2000WARE"
|
||||
outputFormat="ELF"
|
||||
launchWizard="False"
|
||||
linkerCommandFile=""
|
||||
enableSysConfigTool="true"
|
||||
sysConfigBuildOptions="--product ${C2000WARE_ROOT}/.metadata/sdk.json --device F2838x --package 337bga --part F2838x_337bga"
|
||||
postBuildStep="
|
||||
echo "========= Build of the CLB simulation has moved to the CLB Tool. Click the '?' icon by the _Generate CLB Simulation File_ enable for more details (located in the Global Parameters of the Tile Design SysConfig module) ============="
|
||||
;if ${GENERATE_DIAGRAM} == 1 ${NODE_TOOL} "${C2000WARE_ROOT}/utilities/clb_tool/clb_syscfg/dot_file_libraries/clbDotUtility.js" "${C2000WARE_ROOT}/utilities/clb_tool/clb_syscfg/" "${BuildDirectory}/syscfg" "${BuildDirectory}/syscfg/clb.dot"
|
||||
;if ${GENERATE_DIAGRAM} == 1 mkdir "${BuildDirectory}/diagrams"
|
||||
;if ${GENERATE_DIAGRAM} == 1 ${NODE_TOOL} "${C2000WARE_ROOT}/driverlib/.meta/generate_diagrams.js" "${C2000WARE_ROOT}" "${BuildDirectory}/diagrams" "${BuildDirectory}/syscfg"
|
||||
"
|
||||
>
|
||||
<configuration name="CPU1_RAM" compilerBuildOptions= "--opt_level=off -I${C2000WARE_ROOT} -I${PROJECT_ROOT}/device -I${C2000WARE_DLIB_ROOT} -v28 -ml -mt --cla_support=cla2 --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="../adc_ex16_sw_interleaved_averaging.c" targetDirectory="" />
|
||||
<file action="copy" path="../../empty_projects/c2000.syscfg" targetDirectory="" />
|
||||
</project>
|
||||
</projectSpec>
|
||||
+40
@@ -0,0 +1,40 @@
|
||||
<projectSpec>
|
||||
<project
|
||||
name="adc_ex17_open_shorts_detection"
|
||||
device="TMS320F28388D"
|
||||
cgtVersion="22.6.1.LTS"
|
||||
products="sysconfig;C2000WARE"
|
||||
outputFormat="ELF"
|
||||
launchWizard="False"
|
||||
linkerCommandFile=""
|
||||
enableSysConfigTool="true"
|
||||
sysConfigBuildOptions="--product ${C2000WARE_ROOT}/.metadata/sdk.json --device F2838x --package 337bga --part F2838x_337bga"
|
||||
postBuildStep="
|
||||
echo "========= Build of the CLB simulation has moved to the CLB Tool. Click the '?' icon by the _Generate CLB Simulation File_ enable for more details (located in the Global Parameters of the Tile Design SysConfig module) ============="
|
||||
;if ${GENERATE_DIAGRAM} == 1 ${NODE_TOOL} "${C2000WARE_ROOT}/utilities/clb_tool/clb_syscfg/dot_file_libraries/clbDotUtility.js" "${C2000WARE_ROOT}/utilities/clb_tool/clb_syscfg/" "${BuildDirectory}/syscfg" "${BuildDirectory}/syscfg/clb.dot"
|
||||
;if ${GENERATE_DIAGRAM} == 1 mkdir "${BuildDirectory}/diagrams"
|
||||
;if ${GENERATE_DIAGRAM} == 1 ${NODE_TOOL} "${C2000WARE_ROOT}/driverlib/.meta/generate_diagrams.js" "${C2000WARE_ROOT}" "${BuildDirectory}/diagrams" "${BuildDirectory}/syscfg"
|
||||
"
|
||||
>
|
||||
<configuration name="CPU1_RAM" compilerBuildOptions= "--opt_level=off -I${C2000WARE_ROOT} -I${PROJECT_ROOT}/device -I${C2000WARE_DLIB_ROOT} -v28 -ml -mt --cla_support=cla2 --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="../adc_ex17_open_shorts_detection.c" targetDirectory="" />
|
||||
<file action="copy" path="../../empty_projects/c2000.syscfg" targetDirectory="" />
|
||||
</project>
|
||||
</projectSpec>
|
||||
@@ -0,0 +1,40 @@
|
||||
<projectSpec>
|
||||
<project
|
||||
name="adc_ex1_soc_software"
|
||||
device="TMS320F28388D"
|
||||
cgtVersion="22.6.1.LTS"
|
||||
products="sysconfig;C2000WARE"
|
||||
outputFormat="ELF"
|
||||
launchWizard="False"
|
||||
linkerCommandFile=""
|
||||
enableSysConfigTool="true"
|
||||
sysConfigBuildOptions="--product ${C2000WARE_ROOT}/.metadata/sdk.json --device F2838x --package 337bga --part F2838x_337bga"
|
||||
postBuildStep="
|
||||
echo "========= Build of the CLB simulation has moved to the CLB Tool. Click the '?' icon by the _Generate CLB Simulation File_ enable for more details (located in the Global Parameters of the Tile Design SysConfig module) ============="
|
||||
;if ${GENERATE_DIAGRAM} == 1 ${NODE_TOOL} "${C2000WARE_ROOT}/utilities/clb_tool/clb_syscfg/dot_file_libraries/clbDotUtility.js" "${C2000WARE_ROOT}/utilities/clb_tool/clb_syscfg/" "${BuildDirectory}/syscfg" "${BuildDirectory}/syscfg/clb.dot"
|
||||
;if ${GENERATE_DIAGRAM} == 1 mkdir "${BuildDirectory}/diagrams"
|
||||
;if ${GENERATE_DIAGRAM} == 1 ${NODE_TOOL} "${C2000WARE_ROOT}/driverlib/.meta/generate_diagrams.js" "${C2000WARE_ROOT}" "${BuildDirectory}/diagrams" "${BuildDirectory}/syscfg"
|
||||
"
|
||||
>
|
||||
<configuration name="CPU1_RAM" compilerBuildOptions= "--opt_level=off -I${C2000WARE_ROOT} -I${PROJECT_ROOT}/device -I${C2000WARE_DLIB_ROOT} -v28 -ml -mt --cla_support=cla2 --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="../adc_ex1_soc_software.c" targetDirectory="" />
|
||||
<file action="copy" path="../adc_ex1_soc_software.syscfg" targetDirectory="" />
|
||||
</project>
|
||||
</projectSpec>
|
||||
@@ -0,0 +1,40 @@
|
||||
<projectSpec>
|
||||
<project
|
||||
name="adc_ex2_soc_epwm"
|
||||
device="TMS320F28388D"
|
||||
cgtVersion="22.6.1.LTS"
|
||||
products="sysconfig;C2000WARE"
|
||||
outputFormat="ELF"
|
||||
launchWizard="False"
|
||||
linkerCommandFile=""
|
||||
enableSysConfigTool="true"
|
||||
sysConfigBuildOptions="--product ${C2000WARE_ROOT}/.metadata/sdk.json --device F2838x --package 337bga --part F2838x_337bga"
|
||||
postBuildStep="
|
||||
echo "========= Build of the CLB simulation has moved to the CLB Tool. Click the '?' icon by the _Generate CLB Simulation File_ enable for more details (located in the Global Parameters of the Tile Design SysConfig module) ============="
|
||||
;if ${GENERATE_DIAGRAM} == 1 ${NODE_TOOL} "${C2000WARE_ROOT}/utilities/clb_tool/clb_syscfg/dot_file_libraries/clbDotUtility.js" "${C2000WARE_ROOT}/utilities/clb_tool/clb_syscfg/" "${BuildDirectory}/syscfg" "${BuildDirectory}/syscfg/clb.dot"
|
||||
;if ${GENERATE_DIAGRAM} == 1 mkdir "${BuildDirectory}/diagrams"
|
||||
;if ${GENERATE_DIAGRAM} == 1 ${NODE_TOOL} "${C2000WARE_ROOT}/driverlib/.meta/generate_diagrams.js" "${C2000WARE_ROOT}" "${BuildDirectory}/diagrams" "${BuildDirectory}/syscfg"
|
||||
"
|
||||
>
|
||||
<configuration name="CPU1_RAM" compilerBuildOptions= "--opt_level=off -I${C2000WARE_ROOT} -I${PROJECT_ROOT}/device -I${C2000WARE_DLIB_ROOT} -v28 -ml -mt --cla_support=cla2 --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="../adc_ex2_soc_epwm.c" targetDirectory="" />
|
||||
<file action="copy" path="../adc_ex2_soc_epwm.syscfg" targetDirectory="" />
|
||||
</project>
|
||||
</projectSpec>
|
||||
@@ -0,0 +1,40 @@
|
||||
<projectSpec>
|
||||
<project
|
||||
name="adc_ex3_temp_sensor"
|
||||
device="TMS320F28388D"
|
||||
cgtVersion="22.6.1.LTS"
|
||||
products="sysconfig;C2000WARE"
|
||||
outputFormat="ELF"
|
||||
launchWizard="False"
|
||||
linkerCommandFile=""
|
||||
enableSysConfigTool="true"
|
||||
sysConfigBuildOptions="--product ${C2000WARE_ROOT}/.metadata/sdk.json --device F2838x --package 337bga --part F2838x_337bga"
|
||||
postBuildStep="
|
||||
echo "========= Build of the CLB simulation has moved to the CLB Tool. Click the '?' icon by the _Generate CLB Simulation File_ enable for more details (located in the Global Parameters of the Tile Design SysConfig module) ============="
|
||||
;if ${GENERATE_DIAGRAM} == 1 ${NODE_TOOL} "${C2000WARE_ROOT}/utilities/clb_tool/clb_syscfg/dot_file_libraries/clbDotUtility.js" "${C2000WARE_ROOT}/utilities/clb_tool/clb_syscfg/" "${BuildDirectory}/syscfg" "${BuildDirectory}/syscfg/clb.dot"
|
||||
;if ${GENERATE_DIAGRAM} == 1 mkdir "${BuildDirectory}/diagrams"
|
||||
;if ${GENERATE_DIAGRAM} == 1 ${NODE_TOOL} "${C2000WARE_ROOT}/driverlib/.meta/generate_diagrams.js" "${C2000WARE_ROOT}" "${BuildDirectory}/diagrams" "${BuildDirectory}/syscfg"
|
||||
"
|
||||
>
|
||||
<configuration name="CPU1_RAM" compilerBuildOptions= "--opt_level=off -I${C2000WARE_ROOT} -I${PROJECT_ROOT}/device -I${C2000WARE_DLIB_ROOT} -v28 -ml -mt --cla_support=cla2 --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="../adc_ex3_temp_sensor.c" targetDirectory="" />
|
||||
<file action="copy" path="../adc_ex3_temp_sensor.syscfg" targetDirectory="" />
|
||||
</project>
|
||||
</projectSpec>
|
||||
+40
@@ -0,0 +1,40 @@
|
||||
<projectSpec>
|
||||
<project
|
||||
name="adc_ex4_soc_software_sync"
|
||||
device="TMS320F28388D"
|
||||
cgtVersion="22.6.1.LTS"
|
||||
products="sysconfig;C2000WARE"
|
||||
outputFormat="ELF"
|
||||
launchWizard="False"
|
||||
linkerCommandFile=""
|
||||
enableSysConfigTool="true"
|
||||
sysConfigBuildOptions="--product ${C2000WARE_ROOT}/.metadata/sdk.json --device F2838x --package 337bga --part F2838x_337bga"
|
||||
postBuildStep="
|
||||
echo "========= Build of the CLB simulation has moved to the CLB Tool. Click the '?' icon by the _Generate CLB Simulation File_ enable for more details (located in the Global Parameters of the Tile Design SysConfig module) ============="
|
||||
;if ${GENERATE_DIAGRAM} == 1 ${NODE_TOOL} "${C2000WARE_ROOT}/utilities/clb_tool/clb_syscfg/dot_file_libraries/clbDotUtility.js" "${C2000WARE_ROOT}/utilities/clb_tool/clb_syscfg/" "${BuildDirectory}/syscfg" "${BuildDirectory}/syscfg/clb.dot"
|
||||
;if ${GENERATE_DIAGRAM} == 1 mkdir "${BuildDirectory}/diagrams"
|
||||
;if ${GENERATE_DIAGRAM} == 1 ${NODE_TOOL} "${C2000WARE_ROOT}/driverlib/.meta/generate_diagrams.js" "${C2000WARE_ROOT}" "${BuildDirectory}/diagrams" "${BuildDirectory}/syscfg"
|
||||
"
|
||||
>
|
||||
<configuration name="CPU1_RAM" compilerBuildOptions= "--opt_level=off -I${C2000WARE_ROOT} -I${PROJECT_ROOT}/device -I${C2000WARE_DLIB_ROOT} -v28 -ml -mt --cla_support=cla2 --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="../adc_ex4_soc_software_sync.c" targetDirectory="" />
|
||||
<file action="copy" path="../adc_ex4_soc_software_sync.syscfg" targetDirectory="" />
|
||||
</project>
|
||||
</projectSpec>
|
||||
@@ -0,0 +1,40 @@
|
||||
<projectSpec>
|
||||
<project
|
||||
name="adc_ex5_soc_continuous"
|
||||
device="TMS320F28388D"
|
||||
cgtVersion="22.6.1.LTS"
|
||||
products="sysconfig;C2000WARE"
|
||||
outputFormat="ELF"
|
||||
launchWizard="False"
|
||||
linkerCommandFile=""
|
||||
enableSysConfigTool="true"
|
||||
sysConfigBuildOptions="--product ${C2000WARE_ROOT}/.metadata/sdk.json --device F2838x --package 337bga --part F2838x_337bga"
|
||||
postBuildStep="
|
||||
echo "========= Build of the CLB simulation has moved to the CLB Tool. Click the '?' icon by the _Generate CLB Simulation File_ enable for more details (located in the Global Parameters of the Tile Design SysConfig module) ============="
|
||||
;if ${GENERATE_DIAGRAM} == 1 ${NODE_TOOL} "${C2000WARE_ROOT}/utilities/clb_tool/clb_syscfg/dot_file_libraries/clbDotUtility.js" "${C2000WARE_ROOT}/utilities/clb_tool/clb_syscfg/" "${BuildDirectory}/syscfg" "${BuildDirectory}/syscfg/clb.dot"
|
||||
;if ${GENERATE_DIAGRAM} == 1 mkdir "${BuildDirectory}/diagrams"
|
||||
;if ${GENERATE_DIAGRAM} == 1 ${NODE_TOOL} "${C2000WARE_ROOT}/driverlib/.meta/generate_diagrams.js" "${C2000WARE_ROOT}" "${BuildDirectory}/diagrams" "${BuildDirectory}/syscfg"
|
||||
"
|
||||
>
|
||||
<configuration name="CPU1_RAM" compilerBuildOptions= "--opt_level=off -I${C2000WARE_ROOT} -I${PROJECT_ROOT}/device -I${C2000WARE_DLIB_ROOT} -v28 -ml -mt --cla_support=cla2 --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="../adc_ex5_soc_continuous.c" targetDirectory="" />
|
||||
<file action="copy" path="../adc_ex5_soc_continuous.syscfg" targetDirectory="" />
|
||||
</project>
|
||||
</projectSpec>
|
||||
+40
@@ -0,0 +1,40 @@
|
||||
<projectSpec>
|
||||
<project
|
||||
name="adc_ex6_soc_continuous_dma"
|
||||
device="TMS320F28388D"
|
||||
cgtVersion="22.6.1.LTS"
|
||||
products="sysconfig;C2000WARE"
|
||||
outputFormat="ELF"
|
||||
launchWizard="False"
|
||||
linkerCommandFile=""
|
||||
enableSysConfigTool="true"
|
||||
sysConfigBuildOptions="--product ${C2000WARE_ROOT}/.metadata/sdk.json --device F2838x --package 337bga --part F2838x_337bga"
|
||||
postBuildStep="
|
||||
echo "========= Build of the CLB simulation has moved to the CLB Tool. Click the '?' icon by the _Generate CLB Simulation File_ enable for more details (located in the Global Parameters of the Tile Design SysConfig module) ============="
|
||||
;if ${GENERATE_DIAGRAM} == 1 ${NODE_TOOL} "${C2000WARE_ROOT}/utilities/clb_tool/clb_syscfg/dot_file_libraries/clbDotUtility.js" "${C2000WARE_ROOT}/utilities/clb_tool/clb_syscfg/" "${BuildDirectory}/syscfg" "${BuildDirectory}/syscfg/clb.dot"
|
||||
;if ${GENERATE_DIAGRAM} == 1 mkdir "${BuildDirectory}/diagrams"
|
||||
;if ${GENERATE_DIAGRAM} == 1 ${NODE_TOOL} "${C2000WARE_ROOT}/driverlib/.meta/generate_diagrams.js" "${C2000WARE_ROOT}" "${BuildDirectory}/diagrams" "${BuildDirectory}/syscfg"
|
||||
"
|
||||
>
|
||||
<configuration name="CPU1_RAM" compilerBuildOptions= "--opt_level=off -I${C2000WARE_ROOT} -I${PROJECT_ROOT}/device -I${C2000WARE_DLIB_ROOT} -v28 -ml -mt --cla_support=cla2 --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="../adc_ex6_soc_continuous_dma.c" targetDirectory="" />
|
||||
<file action="copy" path="../adc_ex6_soc_continuous_dma.syscfg" targetDirectory="" />
|
||||
</project>
|
||||
</projectSpec>
|
||||
@@ -0,0 +1,41 @@
|
||||
<projectSpec>
|
||||
<project
|
||||
name="adc_ex7_ppb_offset"
|
||||
device="TMS320F28388D"
|
||||
cgtVersion="22.6.1.LTS"
|
||||
products="sysconfig;C2000WARE"
|
||||
outputFormat="ELF"
|
||||
launchWizard="False"
|
||||
linkerCommandFile=""
|
||||
enableSysConfigTool="true"
|
||||
sysConfigBuildOptions="--product ${C2000WARE_ROOT}/.metadata/sdk.json --device F2838x --package 337bga --part F2838x_337bga"
|
||||
postBuildStep="
|
||||
echo "========= Build of the CLB simulation has moved to the CLB Tool. Click the '?' icon by the _Generate CLB Simulation File_ enable for more details (located in the Global Parameters of the Tile Design SysConfig module) ============="
|
||||
;if ${GENERATE_DIAGRAM} == 1 ${NODE_TOOL} "${C2000WARE_ROOT}/utilities/clb_tool/clb_syscfg/dot_file_libraries/clbDotUtility.js" "${C2000WARE_ROOT}/utilities/clb_tool/clb_syscfg/" "${BuildDirectory}/syscfg" "${BuildDirectory}/syscfg/clb.dot"
|
||||
;if ${GENERATE_DIAGRAM} == 1 mkdir "${BuildDirectory}/diagrams"
|
||||
;if ${GENERATE_DIAGRAM} == 1 ${NODE_TOOL} "${C2000WARE_ROOT}/driverlib/.meta/generate_diagrams.js" "${C2000WARE_ROOT}" "${BuildDirectory}/diagrams" "${BuildDirectory}/syscfg"
|
||||
"
|
||||
>
|
||||
<configuration name="CPU1_RAM" compilerBuildOptions= "--opt_level=off -I${C2000WARE_ROOT} -I${PROJECT_ROOT}/device -I${C2000WARE_DLIB_ROOT} -v28 -ml -mt --cla_support=cla2 --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="../adc_ex7_ppb_offset.c" targetDirectory="" />
|
||||
<file action="copy" path="../adc_ex7_ppb_offset.syscfg" targetDirectory="" />
|
||||
</project>
|
||||
</projectSpec>
|
||||
|
||||
@@ -0,0 +1,40 @@
|
||||
<projectSpec>
|
||||
<project
|
||||
name="adc_ex8_ppb_limits"
|
||||
device="TMS320F28388D"
|
||||
cgtVersion="22.6.1.LTS"
|
||||
products="sysconfig;C2000WARE"
|
||||
outputFormat="ELF"
|
||||
launchWizard="False"
|
||||
linkerCommandFile=""
|
||||
enableSysConfigTool="true"
|
||||
sysConfigBuildOptions="--product ${C2000WARE_ROOT}/.metadata/sdk.json --device F2838x --package 337bga --part F2838x_337bga"
|
||||
postBuildStep="
|
||||
echo "========= Build of the CLB simulation has moved to the CLB Tool. Click the '?' icon by the _Generate CLB Simulation File_ enable for more details (located in the Global Parameters of the Tile Design SysConfig module) ============="
|
||||
;if ${GENERATE_DIAGRAM} == 1 ${NODE_TOOL} "${C2000WARE_ROOT}/utilities/clb_tool/clb_syscfg/dot_file_libraries/clbDotUtility.js" "${C2000WARE_ROOT}/utilities/clb_tool/clb_syscfg/" "${BuildDirectory}/syscfg" "${BuildDirectory}/syscfg/clb.dot"
|
||||
;if ${GENERATE_DIAGRAM} == 1 mkdir "${BuildDirectory}/diagrams"
|
||||
;if ${GENERATE_DIAGRAM} == 1 ${NODE_TOOL} "${C2000WARE_ROOT}/driverlib/.meta/generate_diagrams.js" "${C2000WARE_ROOT}" "${BuildDirectory}/diagrams" "${BuildDirectory}/syscfg"
|
||||
"
|
||||
>
|
||||
<configuration name="CPU1_RAM" compilerBuildOptions= "--opt_level=off -I${C2000WARE_ROOT} -I${PROJECT_ROOT}/device -I${C2000WARE_DLIB_ROOT} -v28 -ml -mt --cla_support=cla2 --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="../adc_ex8_ppb_limits.c" targetDirectory="" />
|
||||
<file action="copy" path="../adc_ex8_ppb_limits.syscfg" targetDirectory="" />
|
||||
</project>
|
||||
</projectSpec>
|
||||
@@ -0,0 +1,40 @@
|
||||
<projectSpec>
|
||||
<project
|
||||
name="adc_ex9_ppb_delay"
|
||||
device="TMS320F28388D"
|
||||
cgtVersion="22.6.1.LTS"
|
||||
products="sysconfig;C2000WARE"
|
||||
outputFormat="ELF"
|
||||
launchWizard="False"
|
||||
linkerCommandFile=""
|
||||
enableSysConfigTool="true"
|
||||
sysConfigBuildOptions="--product ${C2000WARE_ROOT}/.metadata/sdk.json --device F2838x --package 337bga --part F2838x_337bga"
|
||||
postBuildStep="
|
||||
echo "========= Build of the CLB simulation has moved to the CLB Tool. Click the '?' icon by the _Generate CLB Simulation File_ enable for more details (located in the Global Parameters of the Tile Design SysConfig module) ============="
|
||||
;if ${GENERATE_DIAGRAM} == 1 ${NODE_TOOL} "${C2000WARE_ROOT}/utilities/clb_tool/clb_syscfg/dot_file_libraries/clbDotUtility.js" "${C2000WARE_ROOT}/utilities/clb_tool/clb_syscfg/" "${BuildDirectory}/syscfg" "${BuildDirectory}/syscfg/clb.dot"
|
||||
;if ${GENERATE_DIAGRAM} == 1 mkdir "${BuildDirectory}/diagrams"
|
||||
;if ${GENERATE_DIAGRAM} == 1 ${NODE_TOOL} "${C2000WARE_ROOT}/driverlib/.meta/generate_diagrams.js" "${C2000WARE_ROOT}" "${BuildDirectory}/diagrams" "${BuildDirectory}/syscfg"
|
||||
"
|
||||
>
|
||||
<configuration name="CPU1_RAM" compilerBuildOptions= "--opt_level=off -I${C2000WARE_ROOT} -I${PROJECT_ROOT}/device -I${C2000WARE_DLIB_ROOT} -v28 -ml -mt --cla_support=cla2 --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="../adc_ex9_ppb_delay.c" targetDirectory="" />
|
||||
<file action="copy" path="../adc_ex9_ppb_delay.syscfg" targetDirectory=""/>
|
||||
</project>
|
||||
</projectSpec>
|
||||
@@ -0,0 +1,239 @@
|
||||
//#############################################################################
|
||||
//
|
||||
// FILE: adc_ex10_multiple_soc_epwm.c
|
||||
//
|
||||
// TITLE: ADC ePWM Triggering Multiple SOC
|
||||
//
|
||||
//! \addtogroup driver_example_list
|
||||
//! <h1>ADC ePWM Triggering Multiple SOC</h1>
|
||||
//!
|
||||
//! This example sets up ePWM1 to periodically trigger a set of conversions on
|
||||
//! ADCA and ADCC. This example demonstrates multiple ADCs working together
|
||||
//! to process of a batch of conversions using the available parallelism
|
||||
//! across multiple ADCs.
|
||||
//!
|
||||
//! ADCA Interrupt ISRs are used to read results of both ADCA and ADCC.
|
||||
//!
|
||||
//! \b External \b Connections \n
|
||||
//! - A0, A1, A2 and C2, C3, C4 pins should be connected to signals to be
|
||||
//! converted.
|
||||
//!
|
||||
//! \b Watch \b Variables \n
|
||||
//! - \b adcAResult0 - Digital representation of the voltage on pin A0
|
||||
//! - \b adcAResult1 - Digital representation of the voltage on pin A1
|
||||
//! - \b adcAResult2 - Digital representation of the voltage on pin A2
|
||||
//! - \b adcCResult0 - Digital representation of the voltage on pin C2
|
||||
//! - \b adcCResult1 - Digital representation of the voltage on pin C3
|
||||
//! - \b adcCResult2 - Digital representation of the voltage on pin C4
|
||||
//!
|
||||
//
|
||||
//#############################################################################
|
||||
//
|
||||
//
|
||||
//
|
||||
// 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 "board.h"
|
||||
|
||||
//
|
||||
// Globals
|
||||
//
|
||||
uint16_t adcAResult0;
|
||||
uint16_t adcAResult1;
|
||||
uint16_t adcAResult2;
|
||||
uint16_t adcCResult0;
|
||||
uint16_t adcCResult1;
|
||||
uint16_t adcCResult2;
|
||||
|
||||
//
|
||||
// Function Prototypes
|
||||
//
|
||||
void initEPWM();
|
||||
__interrupt void adcA1ISR(void);
|
||||
|
||||
//
|
||||
// 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();
|
||||
|
||||
//
|
||||
// Set up the ADCA and ADCC and initialize the ADC SOC.
|
||||
// ADC Resolution - 12-bit, signal mode - single ended
|
||||
// ADCA SOC0, SOC1, SOC2 are configured to convert A0,
|
||||
// A1 and A2 channels with EPWM1SOCA as SOC trigger.
|
||||
// ADCC SOC0, SOC1, SOC2 are configured to convert C2,
|
||||
// C3, C4 channels with EPWM1SOCA as trigger
|
||||
//
|
||||
Board_init();
|
||||
|
||||
//
|
||||
// Configure EPWM1 ADC SOCA trigger
|
||||
//
|
||||
initEPWM();
|
||||
|
||||
//
|
||||
// Enable ADC interrupt
|
||||
//
|
||||
Interrupt_enable(INT_ADCA1);
|
||||
|
||||
//
|
||||
// Enable Global Interrupt (INTM) and realtime interrupt (DBGM)
|
||||
//
|
||||
EINT;
|
||||
ERTM;
|
||||
|
||||
//
|
||||
// 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);
|
||||
|
||||
//
|
||||
// Take conversions indefinitely in loop
|
||||
//
|
||||
do
|
||||
{
|
||||
//
|
||||
// Wait while ePWM causes ADC conversions.
|
||||
// ADCA1 ISR processes each new set of conversions.
|
||||
//
|
||||
}
|
||||
while(1);
|
||||
}
|
||||
|
||||
//
|
||||
// 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 1000 and the period to 1999
|
||||
// Assuming ePWM clock is 100MHz, this would give 50kHz sampling
|
||||
// 50MHz ePWM clock would give 25kHz sampling, etc.
|
||||
// The sample rate can also be modulated by changing the ePWM period
|
||||
// directly (ensure that the compare A value is less than the period).
|
||||
//
|
||||
EPWM_setCounterCompareValue(EPWM1_BASE, EPWM_COUNTER_COMPARE_A, 1000);
|
||||
EPWM_setTimeBasePeriod(EPWM1_BASE, 1999);
|
||||
|
||||
//
|
||||
// Set the local ePWM module clock divider to /1
|
||||
//
|
||||
EPWM_setClockPrescaler(EPWM1_BASE,
|
||||
EPWM_CLOCK_DIVIDER_1,
|
||||
EPWM_HSCLOCK_DIVIDER_1);
|
||||
|
||||
//
|
||||
// Freeze the counter
|
||||
//
|
||||
EPWM_setTimeBaseCounterMode(EPWM1_BASE, EPWM_COUNTER_MODE_STOP_FREEZE);
|
||||
}
|
||||
|
||||
//
|
||||
// ADC A Interrupt 1 ISR
|
||||
//
|
||||
__interrupt void adcA1ISR(void)
|
||||
{
|
||||
//
|
||||
// Store results
|
||||
//
|
||||
adcAResult0 = ADC_readResult(ADCARESULT_BASE, ADC_SOC_NUMBER0);
|
||||
adcAResult1 = ADC_readResult(ADCARESULT_BASE, ADC_SOC_NUMBER1);
|
||||
adcAResult2 = ADC_readResult(ADCARESULT_BASE, ADC_SOC_NUMBER2);
|
||||
adcCResult0 = ADC_readResult(ADCCRESULT_BASE, ADC_SOC_NUMBER0);
|
||||
adcCResult1 = ADC_readResult(ADCCRESULT_BASE, ADC_SOC_NUMBER1);
|
||||
adcCResult2 = ADC_readResult(ADCCRESULT_BASE, ADC_SOC_NUMBER2);
|
||||
|
||||
//
|
||||
// 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);
|
||||
}
|
||||
|
||||
//
|
||||
// End of file
|
||||
//
|
||||
@@ -0,0 +1,63 @@
|
||||
|
||||
/**
|
||||
* Import the modules used in this configuration.
|
||||
*/
|
||||
const adc = scripting.addModule("/driverlib/adc.js", {}, false);
|
||||
const adc1 = adc.addInstance();
|
||||
const adc2 = adc.addInstance();
|
||||
|
||||
/**
|
||||
* Write custom configuration values to the imported modules.
|
||||
*/
|
||||
adc1.$name = "myADC0";
|
||||
adc1.adcBase = "ADCA_BASE";
|
||||
|
||||
adc1.adcClockPrescaler = "ADC_CLK_DIV_4_0";
|
||||
|
||||
adc1.adcSignalMode = "ADC_MODE_SINGLE_ENDED";
|
||||
adc1.adcResolutionMode = "ADC_RESOLUTION_12BIT";
|
||||
|
||||
adc1.interruptPulseMode = "ADC_PULSE_END_OF_CONV";
|
||||
adc1.enabledSOCs = ["ADC_SOC_NUMBER0","ADC_SOC_NUMBER1","ADC_SOC_NUMBER2"];
|
||||
|
||||
adc1.soc0Trigger = "ADC_TRIGGER_EPWM1_SOCA";
|
||||
adc1.soc1Trigger = "ADC_TRIGGER_EPWM1_SOCA";
|
||||
adc1.soc2Trigger = "ADC_TRIGGER_EPWM1_SOCA";
|
||||
|
||||
adc1.soc0Channel = "ADC_CH_ADCIN0";
|
||||
adc1.soc1Channel = "ADC_CH_ADCIN1";
|
||||
adc1.soc2Channel = "ADC_CH_ADCIN2";
|
||||
|
||||
adc1.soc0SampleWindow = 15;
|
||||
adc1.soc1SampleWindow = 15;
|
||||
adc1.soc2SampleWindow = 15;
|
||||
|
||||
adc1.enabledInts = ["ADC_INT_NUMBER1"];
|
||||
adc1.enableInterrupt1 = true;
|
||||
adc1.interrupt1SOCSource = "ADC_SOC_NUMBER2";
|
||||
adc1.registerInterrupts = ["1"];
|
||||
adc1.adcInt1.enableInterrupt = true;
|
||||
adc1.adcInt1.interruptHandler = "adcA1ISR";
|
||||
|
||||
adc2.$name = "myADC1";
|
||||
adc2.adcBase = "ADCC_BASE";
|
||||
adc2.adcClockPrescaler = "ADC_CLK_DIV_4_0";
|
||||
adc2.interruptPulseMode = "ADC_PULSE_END_OF_CONV";
|
||||
|
||||
adc2.adcSignalMode = "ADC_MODE_SINGLE_ENDED";
|
||||
adc2.adcResolutionMode = "ADC_RESOLUTION_12BIT";
|
||||
|
||||
adc2.enabledSOCs = ["ADC_SOC_NUMBER0","ADC_SOC_NUMBER1","ADC_SOC_NUMBER2"];
|
||||
|
||||
adc2.soc0Trigger = "ADC_TRIGGER_EPWM1_SOCA";
|
||||
adc2.soc1Trigger = "ADC_TRIGGER_EPWM1_SOCA";
|
||||
adc2.soc2Trigger = "ADC_TRIGGER_EPWM1_SOCA";
|
||||
|
||||
adc2.soc0Channel = "ADC_CH_ADCIN2";
|
||||
adc2.soc1Channel = "ADC_CH_ADCIN3";
|
||||
adc2.soc2Channel = "ADC_CH_ADCIN4";
|
||||
|
||||
adc2.soc0SampleWindow = 15;
|
||||
adc2.soc1SampleWindow = 15;
|
||||
adc2.soc2SampleWindow = 15;
|
||||
|
||||
@@ -0,0 +1,278 @@
|
||||
//#############################################################################
|
||||
//
|
||||
// FILE: adc_ex11_burst_mode_epwm.c
|
||||
//
|
||||
// TITLE: ADC burst mode example
|
||||
//
|
||||
//! \addtogroup driver_example_list
|
||||
//! <h1>ADC Burst Mode</h1>
|
||||
//!
|
||||
//! This example sets up ePWM1 to periodically trigger ADCA using burst mode.
|
||||
//! This allows for different channels to be sampled with each burst.
|
||||
//!
|
||||
//! Each burst triggers 3 conversions. A0 and A1 are part of every burst while
|
||||
//! the third conversion rotates between A2, A3, and A4. This allows high
|
||||
//! importance signals to be sampled at high speed while lower priority signals
|
||||
//! can be sampled at a lower rate.
|
||||
//!
|
||||
//! ADCA Interrupt ISRs are used to read results for ADCA.
|
||||
//!
|
||||
//! \b External \b Connections \n
|
||||
//! - A0, A1, A2, A3, A4
|
||||
//!
|
||||
//! \b Watch \b Variables \n
|
||||
//! - \b adcAResult0 - Digital representation of the voltage on pin A0
|
||||
//! - \b adcAResult1 - Digital representation of the voltage on pin A1
|
||||
//! - \b adcAResult2 - Digital representation of the voltage on pin A2
|
||||
//! - \b adcAResult3 - Digital representation of the voltage on pin A3
|
||||
//! - \b adcAResult4 - Digital representation of the voltage on pin A4
|
||||
//!
|
||||
//
|
||||
//#############################################################################
|
||||
//
|
||||
//
|
||||
//
|
||||
// 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 "board.h"
|
||||
|
||||
//
|
||||
// Globals
|
||||
//
|
||||
uint16_t adcAResult0;
|
||||
uint16_t adcAResult1;
|
||||
uint16_t adcAResult2;
|
||||
uint16_t adcAResult3;
|
||||
uint16_t adcAResult4;
|
||||
|
||||
|
||||
//
|
||||
// Function Prototypes
|
||||
//
|
||||
void initEPWM();
|
||||
__interrupt void adcABurstISR(void);
|
||||
|
||||
//
|
||||
// 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();
|
||||
|
||||
//
|
||||
// Set up ADCs:
|
||||
// Signal Mode : single-ended
|
||||
// Conversion Resolution : 12-bit;
|
||||
//
|
||||
// Enable burst mode for SOC7-15 with burst size of 3 with
|
||||
// burst mode trigger as EPWM1 SOCA. Select the channels to be
|
||||
// converted and configure the S+H duration
|
||||
// Burst1: SOC7 (A0) + SOC8 (A1) + SOC9 (A2)
|
||||
// Burst2: SOC10 (A0) + SOC11 (A1) + SOC12 (A3)
|
||||
// Burst3: SOC13 (A0) + SOC14 (A1) + SOC15 (A4)
|
||||
//
|
||||
// Register and enable the interrupts:
|
||||
// Interrupts that are used in this example are re-mapped to ISR functions
|
||||
// found within this file. Each of the 3 interrupts will occur at the end
|
||||
// of the 3 different bursts, but all 3 will map to the same ADC result
|
||||
// handling ISR
|
||||
//
|
||||
Board_init();
|
||||
|
||||
//
|
||||
// Initialize PWM
|
||||
//
|
||||
initEPWM();
|
||||
|
||||
//
|
||||
// Enable Global Interrupt (INTM) and realtime interrupt (DBGM)
|
||||
//
|
||||
EINT;
|
||||
ERTM;
|
||||
|
||||
//
|
||||
// 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);
|
||||
|
||||
//
|
||||
// Take conversions indefinitely in loop
|
||||
//
|
||||
do
|
||||
{
|
||||
//
|
||||
// Wait while ePWM causes ADC conversions.
|
||||
// ADCA Burst ISR processes each new set of conversions.
|
||||
//
|
||||
}
|
||||
while(1);
|
||||
}
|
||||
|
||||
//
|
||||
// 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 1000 and the period to 1999
|
||||
// Assuming ePWM clock is 100MHz, this would give 50kHz sampling
|
||||
// 50MHz ePWM clock would give 25kHz sampling, etc.
|
||||
// The sample rate can also be modulated by changing the ePWM period
|
||||
// directly (ensure that the compare A value is less than the period).
|
||||
//
|
||||
EPWM_setCounterCompareValue(EPWM1_BASE, EPWM_COUNTER_COMPARE_A, 1000);
|
||||
EPWM_setTimeBasePeriod(EPWM1_BASE, 1999);
|
||||
|
||||
//
|
||||
// Set the local ePWM module clock divider to /1
|
||||
//
|
||||
EPWM_setClockPrescaler(EPWM1_BASE,
|
||||
EPWM_CLOCK_DIVIDER_1,
|
||||
EPWM_HSCLOCK_DIVIDER_1);
|
||||
|
||||
//
|
||||
// Freeze the counter
|
||||
//
|
||||
EPWM_setTimeBaseCounterMode(EPWM1_BASE, EPWM_COUNTER_MODE_STOP_FREEZE);
|
||||
}
|
||||
|
||||
//
|
||||
// ADC A Interrupt Burst Mode ISR
|
||||
//
|
||||
__interrupt void adcABurstISR(void)
|
||||
{
|
||||
uint16_t rrPointer;
|
||||
ADC_IntNumber burstIntSource;
|
||||
|
||||
//
|
||||
//Read the round-robin pointer to determine which burst just completed
|
||||
//
|
||||
rrPointer = (HWREGH(ADCA_BASE + ADC_O_SOCPRICTL) & 0x03E0) >> 5;
|
||||
switch(rrPointer){
|
||||
//
|
||||
// Burst 1
|
||||
//
|
||||
case 9:
|
||||
adcAResult0 = ADC_readResult(ADCARESULT_BASE, ADC_SOC_NUMBER7);
|
||||
adcAResult1 = ADC_readResult(ADCARESULT_BASE, ADC_SOC_NUMBER8);
|
||||
adcAResult2 = ADC_readResult(ADCARESULT_BASE, ADC_SOC_NUMBER9);
|
||||
burstIntSource = ADC_INT_NUMBER1;
|
||||
break;
|
||||
|
||||
//
|
||||
// Burst 2
|
||||
//
|
||||
case 12:
|
||||
adcAResult0 = ADC_readResult(ADCARESULT_BASE, ADC_SOC_NUMBER10);
|
||||
adcAResult1 = ADC_readResult(ADCARESULT_BASE, ADC_SOC_NUMBER11);
|
||||
adcAResult3 = ADC_readResult(ADCARESULT_BASE, ADC_SOC_NUMBER12);
|
||||
burstIntSource = ADC_INT_NUMBER2;
|
||||
break;
|
||||
|
||||
//
|
||||
// Burst 3
|
||||
//
|
||||
case 15:
|
||||
adcAResult0 = ADC_readResult(ADCARESULT_BASE, ADC_SOC_NUMBER13);
|
||||
adcAResult1 = ADC_readResult(ADCARESULT_BASE, ADC_SOC_NUMBER14);
|
||||
adcAResult4 = ADC_readResult(ADCARESULT_BASE, ADC_SOC_NUMBER15);
|
||||
burstIntSource = ADC_INT_NUMBER3;
|
||||
break;
|
||||
|
||||
default:
|
||||
ESTOP0; //handle error for unexpected RR pointer value
|
||||
}
|
||||
|
||||
//
|
||||
// Clear the interrupt flag
|
||||
//
|
||||
ADC_clearInterruptStatus(ADCA_BASE, burstIntSource);
|
||||
|
||||
//
|
||||
// Check if overflow has occurred
|
||||
//
|
||||
if(true == ADC_getInterruptOverflowStatus(ADCA_BASE, burstIntSource))
|
||||
{
|
||||
ADC_clearInterruptOverflowStatus(ADCA_BASE, burstIntSource);
|
||||
ADC_clearInterruptStatus(ADCA_BASE, burstIntSource);
|
||||
}
|
||||
|
||||
//
|
||||
// Acknowledge the interrupt
|
||||
//
|
||||
Interrupt_clearACKGroup(INTERRUPT_ACK_GROUP1);
|
||||
Interrupt_clearACKGroup(INTERRUPT_ACK_GROUP10);
|
||||
}
|
||||
|
||||
//
|
||||
// End of file
|
||||
//
|
||||
@@ -0,0 +1,75 @@
|
||||
|
||||
/**
|
||||
* Import the modules used in this configuration.
|
||||
*/
|
||||
const adc = scripting.addModule("/driverlib/adc.js", {}, false);
|
||||
const adc1 = adc.addInstance();
|
||||
|
||||
/**
|
||||
* Write custom configuration values to the imported modules.
|
||||
*/
|
||||
adc1.$name = "myADC0";
|
||||
adc1.adcBase = "ADCA_BASE";
|
||||
|
||||
adc1.adcClockPrescaler = "ADC_CLK_DIV_4_0";
|
||||
adc1.interruptPulseMode = "ADC_PULSE_END_OF_CONV";
|
||||
|
||||
adc1.adcSignalMode = "ADC_MODE_SINGLE_ENDED";
|
||||
adc1.adcResolutionMode = "ADC_RESOLUTION_12BIT";
|
||||
|
||||
adc1.enableBurstMode = true;
|
||||
adc1.burstTrigger = "ADC_TRIGGER_EPWM1_SOCA";
|
||||
adc1.burstSize = 2;
|
||||
adc1.socHighPriorityMode = "ADC_PRI_THRU_SOC6_HIPRI";
|
||||
|
||||
adc1.enabledSOCs = ["ADC_SOC_NUMBER10","ADC_SOC_NUMBER11","ADC_SOC_NUMBER12","ADC_SOC_NUMBER13","ADC_SOC_NUMBER14","ADC_SOC_NUMBER15","ADC_SOC_NUMBER7","ADC_SOC_NUMBER8","ADC_SOC_NUMBER9"];
|
||||
|
||||
adc1.soc7Channel = "ADC_CH_ADCIN0";
|
||||
adc1.soc8Channel = "ADC_CH_ADCIN1";
|
||||
adc1.soc9Channel = "ADC_CH_ADCIN2";
|
||||
adc1.soc10Channel = "ADC_CH_ADCIN0";
|
||||
adc1.soc11Channel = "ADC_CH_ADCIN1";
|
||||
adc1.soc12Channel = "ADC_CH_ADCIN3";
|
||||
adc1.soc13Channel = "ADC_CH_ADCIN0";
|
||||
adc1.soc14Channel = "ADC_CH_ADCIN1";
|
||||
adc1.soc15Channel = "ADC_CH_ADCIN4";
|
||||
|
||||
adc1.soc7SampleWindow = 15;
|
||||
adc1.soc8SampleWindow = 15;
|
||||
adc1.soc9SampleWindow = 15;
|
||||
adc1.soc10SampleWindow = 15;
|
||||
adc1.soc11SampleWindow = 15;
|
||||
adc1.soc12SampleWindow = 15;
|
||||
adc1.soc13SampleWindow = 15;
|
||||
adc1.soc14SampleWindow = 15;
|
||||
adc1.soc15SampleWindow = 15;
|
||||
|
||||
adc1.enabledInts = ["ADC_INT_NUMBER1","ADC_INT_NUMBER2","ADC_INT_NUMBER3"];
|
||||
|
||||
adc1.enableInterrupt1 = true;
|
||||
adc1.enableInterrupt2 = true;
|
||||
adc1.enableInterrupt3 = true;
|
||||
|
||||
adc1.interrupt1SOCSource = "ADC_SOC_NUMBER9";
|
||||
adc1.interrupt2SOCSource = "ADC_SOC_NUMBER12";
|
||||
adc1.interrupt3SOCSource = "ADC_SOC_NUMBER15";
|
||||
|
||||
adc1.registerInterrupts = ["1","2","3"];
|
||||
|
||||
adc1.adcInt1.enableInterrupt = true;
|
||||
adc1.adcInt1.interruptHandler = "adcABurstISR";
|
||||
adc1.adcInt2.enableInterrupt = true;
|
||||
adc1.adcInt2.interruptHandler = "adcABurstISR";
|
||||
adc1.adcInt3.enableInterrupt = true;
|
||||
adc1.adcInt3.interruptHandler = "adcABurstISR";
|
||||
|
||||
|
||||
scripting.suppress("SOC7 is configured for Round Robin\. With burst mode enabled, the burst mode trigger will override the selected trigger for this SOC",adc1,"soc7Trigger");
|
||||
scripting.suppress("SOC8 is configured for Round Robin\. With burst mode enabled, the burst mode trigger will override the selected trigger for this SOC",adc1,"soc8Trigger");
|
||||
scripting.suppress("SOC9 is configured for Round Robin\. With burst mode enabled, the burst mode trigger will override the selected trigger for this SOC",adc1,"soc9Trigger");
|
||||
scripting.suppress("SOC10 is configured for Round Robin\. With burst mode enabled, the burst mode trigger will override the selected trigger for this SOC",adc1,"soc10Trigger");
|
||||
scripting.suppress("SOC11 is configured for Round Robin\. With burst mode enabled, the burst mode trigger will override the selected trigger for this SOC",adc1,"soc11Trigger");
|
||||
scripting.suppress("SOC12 is configured for Round Robin\. With burst mode enabled, the burst mode trigger will override the selected trigger for this SOC",adc1,"soc12Trigger");
|
||||
scripting.suppress("SOC13 is configured for Round Robin\. With burst mode enabled, the burst mode trigger will override the selected trigger for this SOC",adc1,"soc13Trigger");
|
||||
scripting.suppress("SOC14 is configured for Round Robin\. With burst mode enabled, the burst mode trigger will override the selected trigger for this SOC",adc1,"soc14Trigger");
|
||||
scripting.suppress("SOC15 is configured for Round Robin\. With burst mode enabled, the burst mode trigger will override the selected trigger for this SOC",adc1,"soc15Trigger");
|
||||
@@ -0,0 +1,265 @@
|
||||
//#############################################################################
|
||||
//
|
||||
// FILE: adc_ex13_burst_mode_oversampling.c
|
||||
//
|
||||
// TITLE: ADC burst mode oversampling example
|
||||
//
|
||||
//! \addtogroup driver_example_list
|
||||
//! <h1>ADC Burst Mode Oversampling</h1>
|
||||
//!
|
||||
//! This example is an ADC oversampling example implemented with software. The
|
||||
//! ADC SOCs are configured in burst mode, triggered by the ePWM SOC A event
|
||||
//! trigger.
|
||||
//!
|
||||
//! \b External \b Connection \n
|
||||
//! - A2
|
||||
//!
|
||||
//! \b Watch \b Variables \n
|
||||
//! - \b lv_results - Array of digital values measured on pin A2 (oversampling
|
||||
//! is configured by Oversampling_Amount)
|
||||
//!
|
||||
//
|
||||
//#############################################################################
|
||||
//
|
||||
//
|
||||
//
|
||||
// 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 "board.h"
|
||||
|
||||
//
|
||||
// Macros and Enumerations
|
||||
//
|
||||
#define DO_TOGGLE 0
|
||||
typedef enum
|
||||
{
|
||||
Baseline = 0, //!< No oversampling
|
||||
X2_Oversampling = 1, //!< 2X oversampling
|
||||
X4_Oversampling = 2, //!< 4X oversampling
|
||||
X8_Oversampling = 3, //!< 8X oversampling
|
||||
X16_Oversampling = 4, //!< 16X oversampling
|
||||
} Oversampling_Amount;
|
||||
|
||||
//
|
||||
// Global Variables
|
||||
//
|
||||
uint16_t acc;
|
||||
uint16_t numBins = 8192;
|
||||
volatile uint16_t nloops = 0;
|
||||
volatile uint16_t *lv_results;
|
||||
Oversampling_Amount ovrsmplAmt = Baseline;
|
||||
|
||||
//
|
||||
// Functions
|
||||
//
|
||||
__interrupt void INT_myADC0_1_ISR(void);
|
||||
|
||||
//
|
||||
// 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();
|
||||
|
||||
//
|
||||
// Set up ADCs:
|
||||
// Signal Mode : single-ended
|
||||
// Conversion Resolution : 12-bit;
|
||||
//
|
||||
// Burst mode configuration:
|
||||
// 1 burst of 16 conversions (SOC0 - SOC15) with equal priority
|
||||
//
|
||||
// Burst mode trigger is EPWM1 SOCA. Select the channels to be
|
||||
// converted and configure the S+H duration
|
||||
//
|
||||
Board_init();
|
||||
|
||||
//
|
||||
// Initialize memory address for results table
|
||||
//
|
||||
lv_results = (uint16_t*)0xC000;
|
||||
|
||||
//
|
||||
// Debug Timing of ePWM and SOC conversions
|
||||
//
|
||||
#if(DO_TOGGLE == 1)
|
||||
SysCtl_enableExtADCSOCSource(SYSCTL_ADCSOC_SRC_PWM1SOCA); //Routes ePWM SOCA trigger to external pin
|
||||
GPIO_setPinConfig(GPIO_8_ADCSOCAO);
|
||||
GPIO_setPadConfig(7, GPIO_PIN_TYPE_STD/*GPIO_PIN_TYPE_PULLUP*/);
|
||||
GPIO_setPinConfig(GPIO_7_GPIO7);
|
||||
GPIO_setDirectionMode(7, GPIO_DIR_MODE_OUT);
|
||||
GPIO_writePin(0,0);
|
||||
#endif
|
||||
|
||||
//
|
||||
// Enable Global Interrupt (INTM) and real time interrupt (DBGM)
|
||||
//
|
||||
EINT;
|
||||
ERTM;
|
||||
|
||||
while(1);
|
||||
}
|
||||
|
||||
//
|
||||
// INT_myADC0_1_ISR - ADC A Interrupt Burst Mode ISR
|
||||
// Interrupt performs oversampling calculation based on oversampling factor
|
||||
//
|
||||
__interrupt void INT_myADC0_1_ISR(void)
|
||||
{
|
||||
//
|
||||
// Clear the interrupt flag
|
||||
//
|
||||
ADC_clearInterruptStatus(myADC0_BASE, ADC_INT_NUMBER1);
|
||||
|
||||
//
|
||||
// Debug Timing of ePWM and SOC conversions
|
||||
//
|
||||
#if(DO_TOGGLE == 1)
|
||||
GPIO_togglePin(myGPIO0);
|
||||
#endif
|
||||
|
||||
//
|
||||
// Accumulate SOC results (store only 1 value per burst)
|
||||
//
|
||||
if(ovrsmplAmt == Baseline)
|
||||
{
|
||||
//
|
||||
// 1X Oversampling
|
||||
//
|
||||
lv_results[nloops++] = ADC_readResult(myADC0_RESULT_BASE, ADC_SOC_NUMBER0);
|
||||
}
|
||||
else if(ovrsmplAmt == X2_Oversampling)
|
||||
{
|
||||
//
|
||||
// 2X Oversampling
|
||||
//
|
||||
lv_results[nloops++] = (ADC_readResult(myADC0_RESULT_BASE, ADC_SOC_NUMBER0) + ADC_readResult(myADC0_RESULT_BASE, ADC_SOC_NUMBER1));
|
||||
}
|
||||
else if(ovrsmplAmt == X4_Oversampling)
|
||||
{
|
||||
//
|
||||
// 4X Oversampling
|
||||
//
|
||||
lv_results[nloops++] = (ADC_readResult(myADC0_RESULT_BASE, ADC_SOC_NUMBER0) + ADC_readResult(myADC0_RESULT_BASE, ADC_SOC_NUMBER1) +
|
||||
ADC_readResult(myADC0_RESULT_BASE, ADC_SOC_NUMBER2) + ADC_readResult(myADC0_RESULT_BASE, ADC_SOC_NUMBER3));
|
||||
}
|
||||
else if(ovrsmplAmt == X8_Oversampling)
|
||||
{
|
||||
//
|
||||
// 8X Oversampling
|
||||
//
|
||||
lv_results[nloops++] = (ADC_readResult(myADC0_RESULT_BASE, ADC_SOC_NUMBER0) + ADC_readResult(myADC0_RESULT_BASE, ADC_SOC_NUMBER1) +
|
||||
ADC_readResult(myADC0_RESULT_BASE, ADC_SOC_NUMBER2) + ADC_readResult(myADC0_RESULT_BASE, ADC_SOC_NUMBER3) +
|
||||
ADC_readResult(myADC0_RESULT_BASE, ADC_SOC_NUMBER4) + ADC_readResult(myADC0_RESULT_BASE, ADC_SOC_NUMBER5) +
|
||||
ADC_readResult(myADC0_RESULT_BASE, ADC_SOC_NUMBER6) + ADC_readResult(myADC0_RESULT_BASE, ADC_SOC_NUMBER7));
|
||||
}
|
||||
else if(ovrsmplAmt == X16_Oversampling)
|
||||
{
|
||||
//
|
||||
// 16X Oversampling
|
||||
//
|
||||
acc = (ADC_readResult(myADC0_RESULT_BASE, ADC_SOC_NUMBER0) + ADC_readResult(myADC0_RESULT_BASE, ADC_SOC_NUMBER1) +
|
||||
ADC_readResult(myADC0_RESULT_BASE, ADC_SOC_NUMBER2) + ADC_readResult(myADC0_RESULT_BASE, ADC_SOC_NUMBER3) +
|
||||
ADC_readResult(myADC0_RESULT_BASE, ADC_SOC_NUMBER4) + ADC_readResult(myADC0_RESULT_BASE, ADC_SOC_NUMBER5) +
|
||||
ADC_readResult(myADC0_RESULT_BASE, ADC_SOC_NUMBER6) + ADC_readResult(myADC0_RESULT_BASE, ADC_SOC_NUMBER7) +
|
||||
ADC_readResult(myADC0_RESULT_BASE, ADC_SOC_NUMBER8) + ADC_readResult(myADC0_RESULT_BASE, ADC_SOC_NUMBER9) +
|
||||
ADC_readResult(myADC0_RESULT_BASE, ADC_SOC_NUMBER10) + ADC_readResult(myADC0_RESULT_BASE, ADC_SOC_NUMBER11) +
|
||||
ADC_readResult(myADC0_RESULT_BASE, ADC_SOC_NUMBER12) + ADC_readResult(myADC0_RESULT_BASE, ADC_SOC_NUMBER13) +
|
||||
ADC_readResult(myADC0_RESULT_BASE, ADC_SOC_NUMBER14) + ADC_readResult(myADC0_RESULT_BASE, ADC_SOC_NUMBER15));
|
||||
lv_results[nloops] = acc;
|
||||
nloops++;
|
||||
}
|
||||
|
||||
//
|
||||
// Check if overflow has occurred
|
||||
//
|
||||
if(true == ADC_getInterruptOverflowStatus(myADC0_BASE, ADC_INT_NUMBER1))
|
||||
{
|
||||
ADC_clearInterruptOverflowStatus(myADC0_BASE, ADC_INT_NUMBER1);
|
||||
ADC_clearInterruptStatus(myADC0_BASE, ADC_INT_NUMBER1);
|
||||
}
|
||||
|
||||
//
|
||||
// Check if all results are stored
|
||||
//
|
||||
if(nloops >= numBins)
|
||||
{
|
||||
//
|
||||
// Disable ADC interrupt
|
||||
//
|
||||
ADC_disableInterrupt(myADC0_BASE, ADC_INT_NUMBER1);
|
||||
ESTOP0;
|
||||
}
|
||||
|
||||
//
|
||||
// Debug Timing of ePWM and SOC conversions
|
||||
//
|
||||
#if(DO_TOGGLE == 1)
|
||||
GPIO_togglePin(myGPIO0);
|
||||
#endif
|
||||
|
||||
//
|
||||
// Acknowledge the interrupt
|
||||
//
|
||||
Interrupt_clearACKGroup(INTERRUPT_ACK_GROUP1);
|
||||
}
|
||||
|
||||
//
|
||||
// End of file
|
||||
//
|
||||
@@ -0,0 +1,101 @@
|
||||
|
||||
/**
|
||||
* Import the modules used in this configuration.
|
||||
*/
|
||||
const adc = scripting.addModule("/driverlib/adc.js", {}, false);
|
||||
const adc1 = adc.addInstance();
|
||||
const epwm = scripting.addModule("/driverlib/epwm.js");
|
||||
const epwm1 = epwm.addInstance();
|
||||
const gpio = scripting.addModule("/driverlib/gpio.js", {}, false);
|
||||
const gpio1 = gpio.addInstance();
|
||||
const sync = scripting.addModule("/driverlib/sync.js");
|
||||
|
||||
/**
|
||||
* Write custom configuration values to the imported modules.
|
||||
*/
|
||||
adc1.$name = "myADC0";
|
||||
adc1.adcBase = "ADCA_BASE";
|
||||
|
||||
adc1.adcSignalMode = "ADC_MODE_SINGLE_ENDED";
|
||||
adc1.adcResolutionMode = "ADC_RESOLUTION_12BIT";
|
||||
|
||||
adc1.adcClockPrescaler = "ADC_CLK_DIV_4_0";
|
||||
|
||||
adc1.interruptPulseMode = "ADC_PULSE_END_OF_CONV";
|
||||
adc1.enabledSOCs = ["ADC_SOC_NUMBER0","ADC_SOC_NUMBER1","ADC_SOC_NUMBER2","ADC_SOC_NUMBER3","ADC_SOC_NUMBER4","ADC_SOC_NUMBER5","ADC_SOC_NUMBER6","ADC_SOC_NUMBER7","ADC_SOC_NUMBER8","ADC_SOC_NUMBER9","ADC_SOC_NUMBER10","ADC_SOC_NUMBER11","ADC_SOC_NUMBER12","ADC_SOC_NUMBER13","ADC_SOC_NUMBER14","ADC_SOC_NUMBER15"];
|
||||
|
||||
adc1.soc0Channel = "ADC_CH_ADCIN2";
|
||||
adc1.soc1Channel = "ADC_CH_ADCIN2";
|
||||
adc1.soc2Channel = "ADC_CH_ADCIN2";
|
||||
adc1.soc3Channel = "ADC_CH_ADCIN2";
|
||||
adc1.soc4Channel = "ADC_CH_ADCIN2";
|
||||
adc1.soc5Channel = "ADC_CH_ADCIN2";
|
||||
adc1.soc6Channel = "ADC_CH_ADCIN2";
|
||||
adc1.soc7Channel = "ADC_CH_ADCIN2";
|
||||
adc1.soc8Channel = "ADC_CH_ADCIN2";
|
||||
adc1.soc9Channel = "ADC_CH_ADCIN2";
|
||||
adc1.soc10Channel = "ADC_CH_ADCIN2";
|
||||
adc1.soc11Channel = "ADC_CH_ADCIN2";
|
||||
adc1.soc12Channel = "ADC_CH_ADCIN2";
|
||||
adc1.soc13Channel = "ADC_CH_ADCIN2";
|
||||
adc1.soc14Channel = "ADC_CH_ADCIN2";
|
||||
adc1.soc15Channel = "ADC_CH_ADCIN2";
|
||||
|
||||
adc1.soc0SampleWindow = 15;
|
||||
adc1.soc1SampleWindow = 15;
|
||||
adc1.soc2SampleWindow = 15;
|
||||
adc1.soc3SampleWindow = 15;
|
||||
adc1.soc4SampleWindow = 15;
|
||||
adc1.soc5SampleWindow = 15;
|
||||
adc1.soc6SampleWindow = 15;
|
||||
adc1.soc7SampleWindow = 15;
|
||||
adc1.soc8SampleWindow = 15;
|
||||
adc1.soc9SampleWindow = 15;
|
||||
adc1.soc10SampleWindow = 15;
|
||||
adc1.soc11SampleWindow = 15;
|
||||
adc1.soc12SampleWindow = 15;
|
||||
adc1.soc13SampleWindow = 15;
|
||||
adc1.soc14SampleWindow = 15;
|
||||
adc1.soc15SampleWindow = 15;
|
||||
|
||||
adc1.enabledInts = ["ADC_INT_NUMBER1"];
|
||||
adc1.enableInterrupt1 = true;
|
||||
adc1.interrupt1SOCSource = "ADC_SOC_NUMBER15";
|
||||
adc1.registerInterrupts = ["1"];
|
||||
adc1.enableBurstMode = true;
|
||||
adc1.burstTrigger = "ADC_TRIGGER_EPWM1_SOCA";
|
||||
adc1.adcInt1.enableInterrupt = true;
|
||||
|
||||
|
||||
scripting.suppress("SOC0 is configured for Round Robin\\. With burst mode enabled, the burst mode trigger will override the selected trigger for this SOC", adc1, "soc0Trigger");
|
||||
scripting.suppress("SOC1 is configured for Round Robin\\. With burst mode enabled, the burst mode trigger will override the selected trigger for this SOC", adc1, "soc1Trigger");
|
||||
scripting.suppress("SOC2 is configured for Round Robin\\. With burst mode enabled, the burst mode trigger will override the selected trigger for this SOC", adc1, "soc2Trigger");
|
||||
scripting.suppress("SOC3 is configured for Round Robin\\. With burst mode enabled, the burst mode trigger will override the selected trigger for this SOC", adc1, "soc3Trigger");
|
||||
scripting.suppress("SOC4 is configured for Round Robin\\. With burst mode enabled, the burst mode trigger will override the selected trigger for this SOC", adc1, "soc4Trigger");
|
||||
scripting.suppress("SOC5 is configured for Round Robin\\. With burst mode enabled, the burst mode trigger will override the selected trigger for this SOC", adc1, "soc5Trigger");
|
||||
scripting.suppress("SOC6 is configured for Round Robin\\. With burst mode enabled, the burst mode trigger will override the selected trigger for this SOC", adc1, "soc6Trigger");
|
||||
scripting.suppress("SOC7 is configured for Round Robin\\. With burst mode enabled, the burst mode trigger will override the selected trigger for this SOC", adc1, "soc7Trigger");
|
||||
scripting.suppress("SOC8 is configured for Round Robin\\. With burst mode enabled, the burst mode trigger will override the selected trigger for this SOC", adc1, "soc8Trigger");
|
||||
scripting.suppress("SOC9 is configured for Round Robin\\. With burst mode enabled, the burst mode trigger will override the selected trigger for this SOC", adc1, "soc9Trigger");
|
||||
scripting.suppress("SOC10 is configured for Round Robin\\. With burst mode enabled, the burst mode trigger will override the selected trigger for this SOC", adc1, "soc10Trigger");
|
||||
scripting.suppress("SOC11 is configured for Round Robin\\. With burst mode enabled, the burst mode trigger will override the selected trigger for this SOC", adc1, "soc11Trigger");
|
||||
scripting.suppress("SOC12 is configured for Round Robin\\. With burst mode enabled, the burst mode trigger will override the selected trigger for this SOC", adc1, "soc12Trigger");
|
||||
scripting.suppress("SOC13 is configured for Round Robin\\. With burst mode enabled, the burst mode trigger will override the selected trigger for this SOC", adc1, "soc13Trigger");
|
||||
scripting.suppress("SOC14 is configured for Round Robin\\. With burst mode enabled, the burst mode trigger will override the selected trigger for this SOC", adc1, "soc14Trigger");
|
||||
scripting.suppress("SOC15 is configured for Round Robin\\. With burst mode enabled, the burst mode trigger will override the selected trigger for this SOC", adc1, "soc15Trigger");
|
||||
|
||||
epwm.commentOutDefaultCode = true;
|
||||
epwm1.$name = "myEPWM0";
|
||||
epwm1.epwmEventTrigger_EPWM_SOC_A_triggerEnable = true;
|
||||
epwm1.epwmTimebase_hsClockDiv = "EPWM_HSCLOCK_DIVIDER_1";
|
||||
epwm1.epwmEventTrigger_EPWM_SOC_A_triggerEventPrescalar = "1";
|
||||
epwm1.epwmActionQualifier_EPWM_AQ_OUTPUT_A_ON_TIMEBASE_ZERO = "EPWM_AQ_OUTPUT_HIGH";
|
||||
epwm1.epwmActionQualifier_EPWM_AQ_OUTPUT_A_ON_TIMEBASE_UP_CMPA = "EPWM_AQ_OUTPUT_LOW";
|
||||
epwm1.epwmEventTrigger_EPWM_SOC_A_triggerSource = "EPWM_SOC_TBCTR_U_CMPA";
|
||||
epwm1.epwmTimebase_counterMode = "EPWM_COUNTER_MODE_UP";
|
||||
epwm1.epwmTimebase_period = 910;
|
||||
epwm1.epwmCounterCompare_cmpA = 909;
|
||||
|
||||
gpio1.$name = "myGPIO0";
|
||||
gpio1.direction = "GPIO_DIR_MODE_OUT";
|
||||
gpio1.gpioPin.$assign = "GPIO0";
|
||||
@@ -0,0 +1,237 @@
|
||||
//#############################################################################
|
||||
//
|
||||
// FILE: adc_ex13_soc_oversampling.c
|
||||
//
|
||||
// TITLE: ADC Oversampling Using Multiple SOCs
|
||||
//
|
||||
//! \addtogroup driver_example_list
|
||||
//! <h1>ADC SOC Oversampling </h1>
|
||||
//!
|
||||
//! This example sets up ePWM1 to periodically trigger a set of conversions on
|
||||
//! ADCA including multiple SOCs that all convert A2 to achieve oversampling on
|
||||
//! A2.
|
||||
//!
|
||||
//! ADCA Interrupt ISRs are used to read results of ADCA.
|
||||
//!
|
||||
//! \b External \b Connections \n
|
||||
//! - A0, A1, A2 should be connected to signals to be converted.
|
||||
//!
|
||||
//! \b Watch \b Variables \n
|
||||
//! - \b adcAResult0 - Digital representation of the voltage on pin A0
|
||||
//! - \b adcAResult1 - Digital representation of the voltage on pin A1
|
||||
//! - \b adcAResult2 - Digital representation of the voltage on pin A2
|
||||
//!
|
||||
//
|
||||
//#############################################################################
|
||||
//
|
||||
//
|
||||
//
|
||||
// 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 "board.h"
|
||||
|
||||
//
|
||||
// Globals
|
||||
//
|
||||
uint16_t adcAResult0;
|
||||
uint16_t adcAResult1;
|
||||
uint16_t adcAResult2;
|
||||
|
||||
//
|
||||
// Function Prototypes
|
||||
//
|
||||
void initEPWM();
|
||||
__interrupt void adcA1ISR(void);
|
||||
|
||||
//
|
||||
// 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();
|
||||
|
||||
//
|
||||
// Set up ADCs:
|
||||
// Signal Mode : single-ended
|
||||
// Conversion Resolution : 12-bit;
|
||||
//
|
||||
// Configure SOC0-1 in round robin mode to sample A0 and A1 channel
|
||||
// respectively and SOC2-SOC5 oversamples channel A2 on EPWM1SOCA
|
||||
// trigger.
|
||||
//
|
||||
// Register and enable the interrupts:
|
||||
// SOC0 and SOC1 results are read after each PWM trigger for
|
||||
// channel 0 and 1 outputs while SOC2-SOC5 results will be
|
||||
// averaged together for oversampled channel A2 result
|
||||
//
|
||||
Board_init();
|
||||
|
||||
//
|
||||
// Initialize PWM
|
||||
//
|
||||
initEPWM();
|
||||
|
||||
//
|
||||
// Enable Global Interrupt (INTM) and realtime interrupt (DBGM)
|
||||
//
|
||||
EINT;
|
||||
ERTM;
|
||||
|
||||
//
|
||||
// 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);
|
||||
|
||||
//
|
||||
// Take conversions indefinitely in loop
|
||||
//
|
||||
do
|
||||
{
|
||||
//
|
||||
// Wait while ePWM causes ADC conversions.
|
||||
// ADCA1 ISR processes each new set of conversions.
|
||||
//
|
||||
}
|
||||
while(1);
|
||||
}
|
||||
|
||||
//
|
||||
// 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 1000 and the period to 1999
|
||||
// Assuming ePWM clock is 100MHz, this would give 50kHz sampling
|
||||
// 50MHz ePWM clock would give 25kHz sampling, etc.
|
||||
// The sample rate can also be modulated by changing the ePWM period
|
||||
// directly (ensure that the compare A value is less than the period).
|
||||
//
|
||||
EPWM_setCounterCompareValue(EPWM1_BASE, EPWM_COUNTER_COMPARE_A, 1000);
|
||||
EPWM_setTimeBasePeriod(EPWM1_BASE, 1999);
|
||||
|
||||
//
|
||||
// Set the local ePWM module clock divider to /1
|
||||
//
|
||||
EPWM_setClockPrescaler(EPWM1_BASE,
|
||||
EPWM_CLOCK_DIVIDER_1,
|
||||
EPWM_HSCLOCK_DIVIDER_1);
|
||||
|
||||
//
|
||||
// Freeze the counter
|
||||
//
|
||||
EPWM_setTimeBaseCounterMode(EPWM1_BASE, EPWM_COUNTER_MODE_STOP_FREEZE);
|
||||
}
|
||||
|
||||
//
|
||||
// adcA1ISR - ADC A Interrupt 1 ISR
|
||||
//
|
||||
__interrupt void adcA1ISR(void)
|
||||
{
|
||||
//
|
||||
// Store results for A0 and A1
|
||||
//
|
||||
adcAResult0 = ADC_readResult(ADCARESULT_BASE, ADC_SOC_NUMBER0);
|
||||
adcAResult1 = ADC_readResult(ADCARESULT_BASE, ADC_SOC_NUMBER1);
|
||||
|
||||
//
|
||||
// Average the 4 oversampled A2 results together
|
||||
//
|
||||
adcAResult2 =
|
||||
(ADC_readResult(ADCARESULT_BASE, ADC_SOC_NUMBER2) +
|
||||
ADC_readResult(ADCARESULT_BASE, ADC_SOC_NUMBER3) +
|
||||
ADC_readResult(ADCARESULT_BASE, ADC_SOC_NUMBER4) +
|
||||
ADC_readResult(ADCARESULT_BASE, ADC_SOC_NUMBER5)) >> 2;
|
||||
|
||||
//
|
||||
// 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);
|
||||
}
|
||||
|
||||
//
|
||||
// End of file
|
||||
//
|
||||
@@ -0,0 +1,49 @@
|
||||
|
||||
/**
|
||||
* Import the modules used in this configuration.
|
||||
*/
|
||||
const adc = scripting.addModule("/driverlib/adc.js", {}, false);
|
||||
const adc1 = adc.addInstance();
|
||||
|
||||
/**
|
||||
* Write custom configuration values to the imported modules.
|
||||
*/
|
||||
adc1.$name = "myADC0";
|
||||
adc1.adcBase = "ADCA_BASE";
|
||||
|
||||
adc1.adcClockPrescaler = "ADC_CLK_DIV_4_0";
|
||||
adc1.interruptPulseMode = "ADC_PULSE_END_OF_CONV";
|
||||
|
||||
adc1.adcSignalMode = "ADC_MODE_SINGLE_ENDED";
|
||||
adc1.adcResolutionMode = "ADC_RESOLUTION_12BIT";
|
||||
|
||||
adc1.enabledSOCs = ["ADC_SOC_NUMBER0","ADC_SOC_NUMBER1","ADC_SOC_NUMBER2","ADC_SOC_NUMBER3","ADC_SOC_NUMBER4","ADC_SOC_NUMBER5"];
|
||||
|
||||
adc1.soc0Trigger = "ADC_TRIGGER_EPWM1_SOCA";
|
||||
adc1.soc1Trigger = "ADC_TRIGGER_EPWM1_SOCA";
|
||||
adc1.soc2Trigger = "ADC_TRIGGER_EPWM1_SOCA";
|
||||
adc1.soc3Trigger = "ADC_TRIGGER_EPWM1_SOCA";
|
||||
adc1.soc4Trigger = "ADC_TRIGGER_EPWM1_SOCA";
|
||||
adc1.soc5Trigger = "ADC_TRIGGER_EPWM1_SOCA";
|
||||
|
||||
adc1.soc0Channel = "ADC_CH_ADCIN0";
|
||||
adc1.soc1Channel = "ADC_CH_ADCIN1";
|
||||
adc1.soc2Channel = "ADC_CH_ADCIN2";
|
||||
adc1.soc3Channel = "ADC_CH_ADCIN2";
|
||||
adc1.soc4Channel = "ADC_CH_ADCIN2";
|
||||
adc1.soc5Channel = "ADC_CH_ADCIN2";
|
||||
|
||||
adc1.soc0SampleWindow = 15;
|
||||
adc1.soc1SampleWindow = 15;
|
||||
adc1.soc2SampleWindow = 15;
|
||||
adc1.soc3SampleWindow = 15;
|
||||
adc1.soc4SampleWindow = 15;
|
||||
adc1.soc5SampleWindow = 15;
|
||||
|
||||
adc1.enabledInts = ["ADC_INT_NUMBER1"];
|
||||
adc1.enableInterrupt1 = true;
|
||||
adc1.interrupt1SOCSource = "ADC_SOC_NUMBER5";
|
||||
adc1.registerInterrupts = ["1"];
|
||||
adc1.adcInt1.enableInterrupt = true;
|
||||
adc1.adcInt1.interruptHandler = "adcA1ISR";
|
||||
|
||||
@@ -0,0 +1,692 @@
|
||||
//###########################################################################
|
||||
//
|
||||
// FILE: adc_ex14_ppb_pwm_trip.c
|
||||
//
|
||||
// TITLE: ADC limits check and PWM trip in case of out of bound input.
|
||||
//
|
||||
//! \addtogroup driver_example_list
|
||||
//! <h1> ADC PPB PWM trip (adc_ppb_pwm_trip)</h1>
|
||||
//!
|
||||
//! This example demonstrates EPWM tripping through ADC limit detection PPB
|
||||
//! block. ADCAINT1 is configured to periodically trigger the ADCA channel 2
|
||||
//! post initial software forced trigger. The limit detection post-processing
|
||||
//! block(PPB) is configured and if the ADC results are outside of the
|
||||
//! defined range, the post-processing block will generate an ADCxEVTy event.
|
||||
//! This event is configured as EPWM trip source through configuring EPWM
|
||||
//! XBAR and corresponding EPWM's trip zone and digital compare sub-modules.
|
||||
//! The example showcases
|
||||
//! - one-shot
|
||||
//! - cycle-by-cycle
|
||||
//! - and direct tripping of PWMs
|
||||
//! through ADCAEVT1 source via Digital compare submodule.
|
||||
//!
|
||||
//! The default limits are 0LSBs and 3600LSBs. With VREFHI set to 3.3V, the
|
||||
//! PPB will generate a trip event if the input voltage goes above about
|
||||
//! 2.9V.
|
||||
//!
|
||||
//! \b External \b Connections \n
|
||||
//! - A2 should be connected to a signal to convert
|
||||
//! - Observe the following signals on an oscilloscope
|
||||
//! - ePWM1(GPIO0 - GPIO1)
|
||||
//! - ePWM2(GPIO2 - GPIO3)
|
||||
//! - ePWM3(GPIO4 - GPIO5)
|
||||
//! -
|
||||
//!
|
||||
//! \b Watch \b Variables \n
|
||||
//! - adcA2Results - digital representation of the voltage on pin A2
|
||||
//!
|
||||
//
|
||||
//#############################################################################
|
||||
//
|
||||
//
|
||||
//
|
||||
// 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
|
||||
//
|
||||
|
||||
// Uncomment to enable profiling
|
||||
//#define ENABLE_PROFILING
|
||||
#define RESULTS_BUFFER_SIZE 512U
|
||||
#define EX_ADC_RESOLUTION 12
|
||||
// 12 for 12-bit conversion resolution, which supports single-ended signaling
|
||||
// Or 16 for 16-bit conversion resolution, which supports single-ended or
|
||||
// differential signaling
|
||||
#define EX_ADC_SIGNALMODE "SINGLE-ENDED"
|
||||
//"SINGLE-ENDED" for ADC_MODE_SINGLE_ENDED:
|
||||
// Sample on single pin (VREFLO is the low reference)
|
||||
// Or "Differential" for ADC_MODE_DIFFERENTIAL:
|
||||
// Sample on pair of pins (difference between pins is converted, subject to
|
||||
// common mode voltage requirements; see the device data manual)
|
||||
|
||||
|
||||
//
|
||||
// Globals
|
||||
//
|
||||
volatile uint16_t indexA = 0; // Index into result buffer
|
||||
volatile uint16_t bufferFull; // Flag to indicate buffer is full
|
||||
uint16_t adcA2Results[RESULTS_BUFFER_SIZE]; // ADC result buffer
|
||||
|
||||
//
|
||||
// Characteristics of PWMs to be tripped
|
||||
// EPWM1 - frequency -> 10kHz, dutyA -> 50%, dutyB -> 50%, ePWM1B - inverted
|
||||
// EPWM2 - frequency -> 2.5kHz, dutyA -> 20%, dutyB -> 50%, ePWM2B - inverted
|
||||
// EPWM3 - frequency -> 5kHz, dutyA -> 70%, dutyB -> 50%, ePWM3B - inverted
|
||||
//
|
||||
EPWM_SignalParams pwmSignal1 =
|
||||
{10000, 0.5f, 0.5f, true, DEVICE_SYSCLK_FREQ, SYSCTL_EPWMCLK_DIV_2,
|
||||
EPWM_COUNTER_MODE_UP_DOWN, EPWM_CLOCK_DIVIDER_1,
|
||||
EPWM_HSCLOCK_DIVIDER_1};
|
||||
|
||||
EPWM_SignalParams pwmSignal2 =
|
||||
{25000, 0.2f, 0.5f, true, DEVICE_SYSCLK_FREQ, SYSCTL_EPWMCLK_DIV_2,
|
||||
EPWM_COUNTER_MODE_UP_DOWN, EPWM_CLOCK_DIVIDER_1,
|
||||
EPWM_HSCLOCK_DIVIDER_1};
|
||||
|
||||
EPWM_SignalParams pwmSignal3 =
|
||||
{5000, 0.7f, 0.5f, true, DEVICE_SYSCLK_FREQ, SYSCTL_EPWMCLK_DIV_2,
|
||||
EPWM_COUNTER_MODE_UP_DOWN, EPWM_CLOCK_DIVIDER_1,
|
||||
EPWM_HSCLOCK_DIVIDER_1};
|
||||
|
||||
//
|
||||
// Functional Prototypes
|
||||
//
|
||||
|
||||
//
|
||||
// ADC configuration related APIs
|
||||
//
|
||||
void configureADC(uint32_t adcBase);
|
||||
void configureADCSOC(uint32_t adcBase, uint16_t channel);
|
||||
void configureLimitDetectionPPB(uint16_t soc, uint16_t limitHigh,
|
||||
uint16_t limitLow);
|
||||
|
||||
//
|
||||
// EPWM configuration related APIs
|
||||
//
|
||||
void initEPWMGPIO(void);
|
||||
void configureOSHTripSignal(uint32_t epwmBase);
|
||||
void configureCBCTripSignal(uint32_t epwmBase);
|
||||
void configureDirectTripSignal(uint32_t epwmBase);
|
||||
|
||||
#ifdef ENABLE_PROFILING
|
||||
void setupProfileGpio(void);
|
||||
#endif
|
||||
|
||||
//
|
||||
// ISRs
|
||||
//
|
||||
__interrupt void adcA1ISR(void);
|
||||
|
||||
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);
|
||||
|
||||
#ifdef ENABLE_PROFILING
|
||||
//
|
||||
// Setup profiling GPIO
|
||||
//
|
||||
setupProfileGpio();
|
||||
#endif
|
||||
|
||||
//
|
||||
// For this case just init GPIO pins for ePWM1, ePWM2, ePWM3
|
||||
//
|
||||
initEPWMGPIO();
|
||||
|
||||
|
||||
//
|
||||
// Configure the ADC and power it up
|
||||
//
|
||||
configureADC(ADCA_BASE);
|
||||
|
||||
//
|
||||
// Disable sync(Freeze clock to PWM as well)
|
||||
//
|
||||
SysCtl_disablePeripheral(SYSCTL_PERIPH_CLK_TBCLKSYNC);
|
||||
|
||||
//
|
||||
// Configuring ePWM modules for desired frequency and duty
|
||||
//
|
||||
EPWM_configureSignal(EPWM1_BASE, &pwmSignal1);
|
||||
EPWM_configureSignal(EPWM2_BASE, &pwmSignal2);
|
||||
EPWM_configureSignal(EPWM3_BASE, &pwmSignal3);
|
||||
|
||||
//
|
||||
// Configure ADCEVTx as one-shot trip signal for ePWM1
|
||||
//
|
||||
configureOSHTripSignal(EPWM1_BASE);
|
||||
|
||||
//
|
||||
// Configure ADCEVTx as cycle-by-cycle trip signal for ePWM2
|
||||
//
|
||||
configureCBCTripSignal(EPWM2_BASE);
|
||||
|
||||
//
|
||||
// Configure ADCEVTx as direct trip signal for ePWM3
|
||||
//
|
||||
configureDirectTripSignal(EPWM3_BASE);
|
||||
//
|
||||
// Setup the ADC for ADCAINT1 triggered conversions on channel 2
|
||||
//
|
||||
configureADCSOC(ADCA_BASE, 2U);
|
||||
|
||||
//
|
||||
// Configure ADC post-processing limits
|
||||
// SOC0 will generate an interrupt if conversion is above or below limits
|
||||
//
|
||||
configureLimitDetectionPPB(0U, 3600U, 0U);
|
||||
|
||||
//
|
||||
// Enable ADC interrupt
|
||||
//
|
||||
Interrupt_enable(INT_ADCA1);
|
||||
|
||||
//
|
||||
// Enable global Interrupts and higher priority real-time debug events:
|
||||
//
|
||||
EINT; // Enable Global interrupt INTM
|
||||
ERTM; // Enable Global realtime interrupt DBGM
|
||||
|
||||
//
|
||||
// Start ePWM:
|
||||
// Enable sync and clock to PWM
|
||||
//
|
||||
SysCtl_enablePeripheral(SYSCTL_PERIPH_CLK_TBCLKSYNC);
|
||||
|
||||
//
|
||||
// Trigger ADC once through software
|
||||
//
|
||||
ADC_forceSOC(ADCA_BASE, ADC_SOC_NUMBER0);
|
||||
|
||||
//
|
||||
// IDLE loop. Just sit and loop forever (optional):
|
||||
//
|
||||
do
|
||||
{
|
||||
}
|
||||
while(1);
|
||||
}
|
||||
|
||||
//
|
||||
// configureOSHTripSignal - Configure ADCAEVT1 as one-shot trip signal for
|
||||
// desired PWM instance
|
||||
//
|
||||
void configureOSHTripSignal(uint32_t epwmBase)
|
||||
{
|
||||
//
|
||||
// Configure trip 7 input to be triggered by ADCAEVT1
|
||||
//
|
||||
XBAR_setEPWMMuxConfig(XBAR_TRIP7, XBAR_EPWM_MUX00_ADCAEVT1);
|
||||
|
||||
//
|
||||
// Enable mux 0
|
||||
//
|
||||
XBAR_enableEPWMMux(XBAR_TRIP7, XBAR_MUX00);
|
||||
|
||||
//
|
||||
// Select Trip 7 input as input to DC module
|
||||
//
|
||||
EPWM_selectDigitalCompareTripInput(epwmBase, EPWM_DC_TRIP_TRIPIN7,
|
||||
EPWM_DC_TYPE_DCAH);
|
||||
|
||||
//
|
||||
// DCAEVT1 is generated when DCAH is high.
|
||||
//
|
||||
EPWM_setTripZoneDigitalCompareEventCondition(epwmBase,EPWM_TZ_DC_OUTPUT_A1,
|
||||
EPWM_TZ_EVENT_DCXH_HIGH);
|
||||
|
||||
//
|
||||
// DCAEVT1 uses the unfiltered version of DCAEVT1
|
||||
//
|
||||
EPWM_setDigitalCompareEventSource(epwmBase, EPWM_DC_MODULE_A,
|
||||
EPWM_DC_EVENT_1, EPWM_DC_EVENT_SOURCE_ORIG_SIGNAL);
|
||||
|
||||
//
|
||||
// DCAEVT1 is asynchronous
|
||||
//
|
||||
EPWM_setDigitalCompareEventSyncMode( epwmBase, EPWM_DC_MODULE_A,
|
||||
EPWM_DC_EVENT_1,EPWM_DC_EVENT_INPUT_NOT_SYNCED);
|
||||
|
||||
//
|
||||
// Enable Trip zone signals
|
||||
//
|
||||
EPWM_enableTripZoneSignals(epwmBase, EPWM_TZ_SIGNAL_DCAEVT1);
|
||||
|
||||
//
|
||||
// Action on DCAEVT1
|
||||
// Force the EPWMxA LOW and EPWMxB HIGH
|
||||
//
|
||||
EPWM_setTripZoneAction(epwmBase,
|
||||
EPWM_TZ_ACTION_EVENT_TZA,
|
||||
EPWM_TZ_ACTION_LOW);
|
||||
|
||||
EPWM_setTripZoneAction(epwmBase,
|
||||
EPWM_TZ_ACTION_EVENT_TZB,
|
||||
EPWM_TZ_ACTION_HIGH);
|
||||
|
||||
//
|
||||
// Clear any spurious trip zone flags before enabling the interrupt
|
||||
//
|
||||
EPWM_clearTripZoneFlag(epwmBase, EPWM_TZ_FLAG_DCAEVT1);
|
||||
|
||||
EPWM_clearOneShotTripZoneFlag(epwmBase, EPWM_TZ_OST_FLAG_DCAEVT1);
|
||||
|
||||
//
|
||||
// Enable TZ interrupt
|
||||
//
|
||||
EPWM_enableTripZoneInterrupt(epwmBase, EPWM_TZ_INTERRUPT_OST);
|
||||
}
|
||||
|
||||
//
|
||||
// configureCBCTripSignal - Configure ADCAEVT1 as cycle-by-cycle trip signal
|
||||
// for desired PWM instance
|
||||
//
|
||||
void configureCBCTripSignal(uint32_t epwmBase)
|
||||
{
|
||||
//
|
||||
// Configure trip 8 input to be triggered by ADCAEVT1
|
||||
//
|
||||
XBAR_setEPWMMuxConfig(XBAR_TRIP8, XBAR_EPWM_MUX00_ADCAEVT1);
|
||||
|
||||
//
|
||||
// Enable mux 0
|
||||
//
|
||||
XBAR_enableEPWMMux(XBAR_TRIP8, XBAR_MUX00);
|
||||
|
||||
//
|
||||
// Select Trip 8 input as input to DC module
|
||||
//
|
||||
EPWM_selectDigitalCompareTripInput(epwmBase, EPWM_DC_TRIP_TRIPIN8,
|
||||
EPWM_DC_TYPE_DCAH);
|
||||
|
||||
//
|
||||
// DCAEVT2 is generated when DCAH is high.
|
||||
//
|
||||
EPWM_setTripZoneDigitalCompareEventCondition(epwmBase, EPWM_TZ_DC_OUTPUT_A2,
|
||||
EPWM_TZ_EVENT_DCXH_HIGH);
|
||||
|
||||
//
|
||||
// DCAEVT2 uses the unfiltered version of DCAEVT2
|
||||
//
|
||||
EPWM_setDigitalCompareEventSource(epwmBase, EPWM_DC_MODULE_A,
|
||||
EPWM_DC_EVENT_2, EPWM_DC_EVENT_SOURCE_ORIG_SIGNAL);
|
||||
|
||||
//
|
||||
// DCAEVT2 is asynchronous
|
||||
//
|
||||
EPWM_setDigitalCompareEventSyncMode(epwmBase, EPWM_DC_MODULE_A,
|
||||
EPWM_DC_EVENT_2, EPWM_DC_EVENT_INPUT_NOT_SYNCED);
|
||||
|
||||
//
|
||||
// Enable Trip zone signals
|
||||
//
|
||||
EPWM_enableTripZoneSignals(epwmBase, EPWM_TZ_SIGNAL_DCAEVT2);
|
||||
|
||||
//
|
||||
// Configure CBC clear event
|
||||
//
|
||||
EPWM_selectCycleByCycleTripZoneClearEvent(epwmBase,
|
||||
EPWM_TZ_CBC_PULSE_CLR_CNTR_ZERO_PERIOD);
|
||||
|
||||
//
|
||||
// Action on DCAEVT2
|
||||
// Force the EPWMxA/EPWMxB LOW
|
||||
//
|
||||
EPWM_setTripZoneAction(epwmBase, EPWM_TZ_ACTION_EVENT_TZA,
|
||||
EPWM_TZ_ACTION_LOW);
|
||||
|
||||
EPWM_setTripZoneAction(epwmBase, EPWM_TZ_ACTION_EVENT_TZB,
|
||||
EPWM_TZ_ACTION_HIGH);
|
||||
|
||||
//
|
||||
// Clear any spurious trip zone flags before enabling the interrupt
|
||||
//
|
||||
EPWM_clearTripZoneFlag(epwmBase, EPWM_TZ_FLAG_DCAEVT2);
|
||||
|
||||
EPWM_clearCycleByCycleTripZoneFlag(epwmBase, EPWM_TZ_CBC_FLAG_DCAEVT2);
|
||||
|
||||
//
|
||||
// Enable TZ interrupt
|
||||
//
|
||||
EPWM_enableTripZoneInterrupt(epwmBase, EPWM_TZ_INTERRUPT_CBC);
|
||||
}
|
||||
|
||||
//
|
||||
// configureDirectTripSignal - Configure ADCAEVT1 as direct trip signal for
|
||||
// desired PWM instance
|
||||
//
|
||||
void configureDirectTripSignal(uint32_t epwmBase)
|
||||
{
|
||||
//
|
||||
// Configure trip 9 input to be triggered by ADCAEVT1
|
||||
//
|
||||
XBAR_setEPWMMuxConfig(XBAR_TRIP9, XBAR_EPWM_MUX00_ADCAEVT1);
|
||||
|
||||
//
|
||||
// Enable mux 0
|
||||
//
|
||||
XBAR_enableEPWMMux(XBAR_TRIP9, XBAR_MUX00);
|
||||
|
||||
//
|
||||
// Select Trip 9 input as input to DC module
|
||||
//
|
||||
EPWM_selectDigitalCompareTripInput(epwmBase, EPWM_DC_TRIP_TRIPIN9,
|
||||
EPWM_DC_TYPE_DCAH);
|
||||
EPWM_selectDigitalCompareTripInput(epwmBase, EPWM_DC_TRIP_TRIPIN9,
|
||||
EPWM_DC_TYPE_DCBH);
|
||||
|
||||
//
|
||||
// DCAEVT1 is generated when DCAH is high. DCBEVT2 is generated when DCBH
|
||||
// is high
|
||||
//
|
||||
EPWM_setTripZoneDigitalCompareEventCondition(epwmBase, EPWM_TZ_DC_OUTPUT_A1,
|
||||
EPWM_TZ_EVENT_DCXH_HIGH);
|
||||
EPWM_setTripZoneDigitalCompareEventCondition(epwmBase, EPWM_TZ_DC_OUTPUT_B2,
|
||||
EPWM_TZ_EVENT_DCXH_HIGH);
|
||||
|
||||
//
|
||||
// DCAEVT1/DCBEVT2 uses the unfiltered version of DCAEVT1/DCBEVT2
|
||||
//
|
||||
EPWM_setDigitalCompareEventSource(epwmBase, EPWM_DC_MODULE_A,
|
||||
EPWM_DC_EVENT_1, EPWM_DC_EVENT_SOURCE_ORIG_SIGNAL);
|
||||
EPWM_setDigitalCompareEventSource(epwmBase, EPWM_DC_MODULE_B,
|
||||
EPWM_DC_EVENT_2, EPWM_DC_EVENT_SOURCE_ORIG_SIGNAL);
|
||||
|
||||
//
|
||||
// DCAEVT1/ DCBEVT2 is asynchronous
|
||||
//
|
||||
EPWM_setDigitalCompareEventSyncMode(epwmBase, EPWM_DC_MODULE_A,
|
||||
EPWM_DC_EVENT_1, EPWM_DC_EVENT_INPUT_NOT_SYNCED);
|
||||
EPWM_setDigitalCompareEventSyncMode(epwmBase, EPWM_DC_MODULE_B,
|
||||
EPWM_DC_EVENT_2, EPWM_DC_EVENT_INPUT_NOT_SYNCED);
|
||||
|
||||
//
|
||||
// Action on TZA/TZB
|
||||
// Force the EPWMxA LOW and EPWMxB HIGH
|
||||
//
|
||||
EPWM_setTripZoneAction(epwmBase,
|
||||
EPWM_TZ_ACTION_EVENT_DCAEVT1,
|
||||
EPWM_TZ_ACTION_LOW);
|
||||
|
||||
EPWM_setTripZoneAction(epwmBase,
|
||||
EPWM_TZ_ACTION_EVENT_DCBEVT2,
|
||||
EPWM_TZ_ACTION_HIGH);
|
||||
|
||||
//
|
||||
// Clear any spurious trip zone flags before enabling the interrupt
|
||||
//
|
||||
EPWM_clearTripZoneFlag(epwmBase, (EPWM_TZ_INTERRUPT_DCAEVT1 |
|
||||
EPWM_TZ_INTERRUPT_DCBEVT2));
|
||||
|
||||
//
|
||||
// Enable TZ interrupt
|
||||
//
|
||||
EPWM_enableTripZoneInterrupt(epwmBase, (EPWM_TZ_INTERRUPT_DCAEVT1 |
|
||||
EPWM_TZ_INTERRUPT_DCBEVT2));
|
||||
}
|
||||
|
||||
//
|
||||
// configureADC - Write ADC configurations and power up the ADC for both
|
||||
// ADC A and ADC B
|
||||
//
|
||||
void configureADC(uint32_t adcBase)
|
||||
{
|
||||
//
|
||||
// Set ADCCLK divider to /4
|
||||
//
|
||||
ADC_setPrescaler(adcBase, ADC_CLK_DIV_4_0);
|
||||
|
||||
//
|
||||
// Set resolution and signal mode (see #defines above) and load
|
||||
// corresponding trims.
|
||||
//
|
||||
#if(EX_ADC_RESOLUTION == 12)
|
||||
ADC_setMode(adcBase, ADC_RESOLUTION_12BIT, ADC_MODE_SINGLE_ENDED);
|
||||
#elif(EX_ADC_RESOLUTION == 16)
|
||||
#if(EX_ADC_SIGNALMODE == "SINGLE-ENDED")
|
||||
ADC_setMode(adcBase, ADC_RESOLUTION_16BIT, ADC_MODE_SINGLE_ENDED);
|
||||
#elif(EX_ADC_SIGNALMODE == "DIFFERENTIAL")
|
||||
ADC_setMode(adcBase, ADC_RESOLUTION_16BIT, ADC_MODE_DIFFERENTIAL);
|
||||
#endif
|
||||
#endif
|
||||
|
||||
//
|
||||
// Set pulse positions to late
|
||||
//
|
||||
ADC_setInterruptPulseMode(adcBase, ADC_PULSE_END_OF_CONV);
|
||||
|
||||
//
|
||||
// Power up the ADCs and then delay for 1 ms
|
||||
//
|
||||
ADC_enableConverter(adcBase);
|
||||
|
||||
//
|
||||
// Delay for 1ms to allow ADC time to power up
|
||||
//
|
||||
DEVICE_DELAY_US(1000);
|
||||
}
|
||||
|
||||
//
|
||||
// configureLimitDetectionPPB - Configure high and low limits for ADCPPB
|
||||
//
|
||||
void configureLimitDetectionPPB(uint16_t soc, uint16_t limitHigh,
|
||||
uint16_t limitLow)
|
||||
{
|
||||
//
|
||||
// Associate PPB1 with soc
|
||||
//
|
||||
ADC_setupPPB(ADCA_BASE, ADC_PPB_NUMBER1, (ADC_SOCNumber)soc);
|
||||
|
||||
//
|
||||
// Set high and low limits
|
||||
//
|
||||
ADC_setPPBTripLimits(ADCA_BASE, ADC_PPB_NUMBER1, limitHigh, limitLow);
|
||||
|
||||
//
|
||||
// Enable high and low limit PPB events
|
||||
//
|
||||
ADC_enablePPBEvent(ADCA_BASE, ADC_PPB_NUMBER1, (ADC_EVT_TRIPHI |
|
||||
ADC_EVT_TRIPLO));
|
||||
|
||||
//
|
||||
// Configure CBCEN
|
||||
//
|
||||
EALLOW;
|
||||
HWREGH(ADCA_BASE + ADC_O_PPB1CONFIG) |= ADC_PPB2CONFIG_CBCEN;
|
||||
EDIS;
|
||||
}
|
||||
|
||||
//
|
||||
// configureADCSOC - Setup ADC EPWM channel and trigger settings
|
||||
//
|
||||
void configureADCSOC(uint32_t adcBase, uint16_t channel)
|
||||
{
|
||||
uint16_t acqps;
|
||||
|
||||
//
|
||||
// Determine minimum acquisition window (in SYSCLKS) based on resolution
|
||||
//
|
||||
if(EX_ADC_RESOLUTION == 12)
|
||||
{
|
||||
acqps = 14; // 75ns
|
||||
}
|
||||
else //resolution is 16-bit
|
||||
{
|
||||
acqps = 63; // 320ns
|
||||
}
|
||||
//
|
||||
// - NOTE: A longer sampling window will be required if the ADC driving
|
||||
// source is less than ideal (an ideal source would be a high bandwidth
|
||||
// op-amp with a small series resistance). See TI application report
|
||||
// SPRACT6 for guidance on ADC driver design.
|
||||
//
|
||||
|
||||
//
|
||||
// Select the channels to convert and end of conversion flag
|
||||
// ADCA
|
||||
//
|
||||
ADC_setupSOC(adcBase, ADC_SOC_NUMBER0, ADC_TRIGGER_SW_ONLY,
|
||||
(ADC_Channel)channel, acqps);
|
||||
|
||||
//
|
||||
// Configure ADCINT1 as SOC0 trigger
|
||||
//
|
||||
ADC_setInterruptSOCTrigger(adcBase, ADC_SOC_NUMBER0,
|
||||
ADC_INT_SOC_TRIGGER_ADCINT1);
|
||||
|
||||
//
|
||||
// Enable continuous mode
|
||||
//
|
||||
ADC_enableContinuousMode(ADCA_BASE, ADC_INT_NUMBER1);
|
||||
|
||||
//
|
||||
// Configure source as EOC1, clear & enable the interrupt
|
||||
//
|
||||
ADC_setInterruptSource(adcBase, ADC_INT_NUMBER1, ADC_SOC_NUMBER0);
|
||||
ADC_clearInterruptStatus(adcBase, ADC_INT_NUMBER1);
|
||||
ADC_enableInterrupt(adcBase, ADC_INT_NUMBER1);
|
||||
}
|
||||
|
||||
//
|
||||
// ADC A Interrupt 1 ISR
|
||||
//
|
||||
__interrupt void adcA1ISR(void)
|
||||
{
|
||||
#ifdef ENABLE_PROFILING
|
||||
//
|
||||
// Setting Profiling GPIO12 : Takes 3 cycles
|
||||
//
|
||||
HWREG(GPIODATA_BASE + GPIO_O_GPASET) = 0x1000;
|
||||
#endif
|
||||
|
||||
//
|
||||
// Add the latest result to the buffer
|
||||
//
|
||||
adcA2Results[indexA++] = ADC_readResult(ADCARESULT_BASE, ADC_SOC_NUMBER0);
|
||||
|
||||
//
|
||||
// Set the bufferFull flag if the buffer is full
|
||||
//
|
||||
if(RESULTS_BUFFER_SIZE <= indexA)
|
||||
{
|
||||
indexA = 0;
|
||||
}
|
||||
|
||||
//
|
||||
// Acknowledge the interrupt
|
||||
//
|
||||
Interrupt_clearACKGroup(INTERRUPT_ACK_GROUP1);
|
||||
|
||||
#ifdef ENABLE_PROFILING
|
||||
//
|
||||
// Resetting Profiling GPIO12
|
||||
//
|
||||
HWREG(GPIODATA_BASE + GPIO_O_GPACLEAR) = 0x1000;
|
||||
#endif
|
||||
}
|
||||
|
||||
//
|
||||
// initEPWMGPIO - Configure ePWM1-ePWM3 GPIO
|
||||
//
|
||||
void initEPWMGPIO(void)
|
||||
{
|
||||
//
|
||||
// Disable pull up on GPIO0-5 and configure them as PWMs
|
||||
//
|
||||
GPIO_setPadConfig(0, GPIO_PIN_TYPE_STD);
|
||||
GPIO_setPinConfig(GPIO_0_EPWM1A);
|
||||
|
||||
GPIO_setPadConfig(1, GPIO_PIN_TYPE_STD);
|
||||
GPIO_setPinConfig(GPIO_1_EPWM1B);
|
||||
|
||||
GPIO_setPadConfig(2, GPIO_PIN_TYPE_STD);
|
||||
GPIO_setPinConfig(GPIO_2_EPWM2A);
|
||||
|
||||
GPIO_setPadConfig(3, GPIO_PIN_TYPE_STD);
|
||||
GPIO_setPinConfig(GPIO_3_EPWM2B);
|
||||
|
||||
GPIO_setPadConfig(4, GPIO_PIN_TYPE_STD);
|
||||
GPIO_setPinConfig(GPIO_4_EPWM3A);
|
||||
|
||||
GPIO_setPadConfig(5, GPIO_PIN_TYPE_STD);
|
||||
GPIO_setPinConfig(GPIO_5_EPWM3B);
|
||||
}
|
||||
|
||||
#ifdef ENABLE_PROFILING
|
||||
void setupProfileGpio(void)
|
||||
{
|
||||
GPIO_setDirectionMode(12,GPIO_DIR_MODE_OUT);
|
||||
GPIO_setQualificationMode(12,GPIO_QUAL_SYNC);
|
||||
GPIO_setPinConfig(GPIO_12_GPIO12);
|
||||
GPIO_writePin(12,0);
|
||||
}
|
||||
|
||||
#endif
|
||||
//
|
||||
// End of file
|
||||
//
|
||||
@@ -0,0 +1,3 @@
|
||||
/**
|
||||
* Blank
|
||||
*/
|
||||
@@ -0,0 +1,752 @@
|
||||
//###########################################################################
|
||||
//
|
||||
// FILE: adc_ex15_high_priority_soc.c
|
||||
//
|
||||
// TITLE: ADC High Priority SOC Example.
|
||||
//
|
||||
//! \addtogroup driver_example_list
|
||||
//! <h1> ADC High Priority SOC (adc_high_priority_soc)</h1>
|
||||
//!
|
||||
//! This example demonstrates configuration of ADC high priority SOCs in
|
||||
//! order to sample fastest control loop signals with high priority while
|
||||
//! low priority signals are sampled with default round robin priority.
|
||||
//!
|
||||
//! ADC PPB block is configured to capture delay between SOC trigger
|
||||
//! and actual start of the SOC sampling in order to quantify the jitters
|
||||
//! in sampling high priority signals due to low priority signals. The
|
||||
//! delay in processing an SOC is captured in ADCPPBxSTAMP.DLYSTAMP
|
||||
//! register field and the total delay in sampling an SOC is equal to
|
||||
//! (DLYSTAMP - 2) cycles. In an optimal design the high priority SOC
|
||||
//! is expected to have less delay between SOC trigger and actual start
|
||||
//! of the sample.
|
||||
//!
|
||||
//! In this example ADCA, ADCB and ADCD are configured to sample both
|
||||
//! high and low priority signals. SOC0-3 are configured as high priority
|
||||
//! SOCs while rest are configured with default round-robin priority. ADCA
|
||||
//! SOC0-3 are configured as high priority SOCs sampling channels A0-A3,
|
||||
//! ADCB SOC0-1 are configured as high priority SOCs sampling channels
|
||||
//! B0-B1 and ADCD SOC0-1 are configured as high priority SOCs sampling
|
||||
//! channels D0-D1. For sampling low priority signals SOC4-SOC5 are
|
||||
//! configured sampling channel 4 and channel 13 respectively for ADCA
|
||||
//! and channel 4 and 5 for ADCB and ADCD. For ADCA, channel 13 is
|
||||
//! connected to internal temperature sensor output and hence no signal
|
||||
//! needs to be connected to channel A13. High priority SOC results are
|
||||
//! read in ADCINT1 ISR while low priority SOC results are read in idle
|
||||
//! loop.
|
||||
//!
|
||||
//! This example has two modes of operation as follows. Desired mode
|
||||
//! can be selected by configuring the EX_ADC_LP_SOC_TRIGGER macro
|
||||
//! accordingly.
|
||||
//! Mode 0: ADCINT as round robin SOC trigger
|
||||
//! Mode 1: EPWM2 as round robin SOC trigger
|
||||
//!
|
||||
//! In mode 0, EPWM1 is configured as trigger for high priority SOCs while
|
||||
//! ADCINT1 is configured as low priority SOC trigger. ADCINT1 is configured
|
||||
//! to be triggered on completion of SOC1 conversion which in turn trigger
|
||||
//! low priority SOCs 4 and 5 and ADCINT2 is configured to be triggered on
|
||||
//! completion of SOC5. ADC result for high priority SOCs are read in ADCINT
|
||||
//! ISR while low priority SOC results are read in idle loop. ADCINT3 is
|
||||
//! configured to be triggered on completion of SOC3 and hence SOC2-SOC3
|
||||
//! results for ADCA are read post checking if the conversion is complete
|
||||
//! in ADCINT1 ISR.
|
||||
//!
|
||||
//! In mode 0, SOC0-SOC1 for all ADCs will experience minimal delay(0 and 1
|
||||
//! conversions) in processing due to the high priority configuration. For
|
||||
//! ADCA, SOC4-SOC5 are triggered when SOC2-SOC3 conversion is ongoing, hence
|
||||
//! SOC4-SOC5 will see some delay(2 and 3 conversions) in processing as
|
||||
//! expected. For ADCB and ADCD, SOC4-SOC5 will see minimal delay (0 and 1
|
||||
//! conversions) in processing as expected.
|
||||
//!
|
||||
//! In mode 1, EPWM1 is configured as trigger for high priority SOCs while
|
||||
//! EPWM2 is configured as low priority SOC trigger. ADCINT1 is configured
|
||||
//! to be triggered on completion of SOC3 conversion and ADC result for high
|
||||
//! priority SOCs are read in the ADCINT ISR. Low priority SOCs 4 and 5 are
|
||||
//! triggered through EPWM2 and ADCINT2 is configured to be triggered on
|
||||
//! completion of SOC5. The result for low priority SOCs are read in background
|
||||
//! loop. Since, SOC4-5 are triggered post SOC2-3 conversion(due to configured
|
||||
//! EPWM1 and EPWM2 trigger frequency and duty), SOC4-SOC5 will have minimal
|
||||
//! delay(0 and 1 conversions respectively) in SOC processing as expected.
|
||||
//!
|
||||
//! Optimization Level: Example is expected to run with opt level = O2.
|
||||
//!
|
||||
//! To view ADC results, put breakpoint at the statement where indexB is
|
||||
//! reset to zero in idle loop.
|
||||
//!
|
||||
//! \b External \b Connections \n
|
||||
//! - A0-A4, B0-B1, B4-B5, D0-D1 and D4-D5 pins should be connected to signals
|
||||
//! to be converted.
|
||||
//!
|
||||
//! - Observe ePWM1, ePWM2 signals on oscilloscope
|
||||
//!
|
||||
//! \b Watch \b Variables \n
|
||||
//! ADC Results:
|
||||
//! - adcA0Results - adcA4Results - ADC result of channels A0-A4
|
||||
//! - adcA13Results - ADC result of channels A13(Temp Sensor output)
|
||||
//! - adcB0Results - adcB1Results - ADC result of channels B0-B1
|
||||
//! - adcB4Results - ADC result of channel B4
|
||||
//! - adcB5Results - ADC result of channel B5
|
||||
//! - adcD0Results - adcD1Results - ADC result of channels D0-D1
|
||||
//! - adcD4Results - ADC result of channel D4
|
||||
//! - adcD5Results - ADC result of channel D5
|
||||
//!
|
||||
//! SOC conversion delays:
|
||||
//! - delaySocA0 - Delay in sampling ADCA SOC0
|
||||
//! - delaySocA3 - Delay in sampling ADCA SOC3
|
||||
//! - delaySocA4-delaySocA5 - Delay in sampling ADCA SOC4-SOC5
|
||||
//! - delaySocB0-delaySocB1 - Delay in sampling ADCB SOC0-SOC1
|
||||
//! - delaySocB4-delaySocB5 - Delay in sampling ADCB SOC4-SOC5
|
||||
//! - delaySocD0-delaySocD1 - Delay in sampling ADCD SOC0-SOC1
|
||||
//! - delaySocD4-delaySocD5 - Delay in sampling ADCD SOC4-SOC5
|
||||
//!
|
||||
//
|
||||
//###########################################################################
|
||||
//
|
||||
//
|
||||
//
|
||||
// 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
|
||||
//
|
||||
|
||||
// Uncomment to enable profiling
|
||||
//#define ENABLE_PROFILING
|
||||
|
||||
//
|
||||
// Macro for defining ADC resolution
|
||||
//
|
||||
#define EX_ADC_RESOLUTION 12U
|
||||
|
||||
//
|
||||
// Macro to define acquisition window duration based on resolution.
|
||||
// This can vary as per application hardware. In this example, a
|
||||
// sampling window of 15 (75 ns at a 200MHz SYSCLK rate) will be used
|
||||
// for 12-bit resolution while a sampling window of 64 (320 ns at a
|
||||
// 200MHz SYSCLK rate) will be used for 16-bit resolution.
|
||||
//
|
||||
#define EX_ACQ_WIN_12_BIT 15U
|
||||
#define EX_ACQ_WIN_16_BIT 65U
|
||||
|
||||
//
|
||||
// Macro to define ADC result buffer size
|
||||
//
|
||||
#define RESULTS_BUFFER_SIZE 50U
|
||||
|
||||
//
|
||||
// Macro to define ADC Low Priority SOC trigger
|
||||
// if EX_ADC_LP_SOC_TRIGGER == 0U, low priority SOC trigger = ADCINT1
|
||||
// if EX_ADC_LP_SOC_TRIGGER == 1U, low priority SOC trigger = EPWM2
|
||||
//
|
||||
#define EX_ADC_LP_SOC_TRIGGER 0U
|
||||
|
||||
//
|
||||
// Globals
|
||||
//
|
||||
volatile uint16_t indexA = 0, indexB = 0; // Index into result buffer
|
||||
volatile uint16_t bufferFull; // Flag to indicate buffer is full
|
||||
|
||||
//
|
||||
// Globals for capturing SOC delay
|
||||
//
|
||||
volatile uint16_t delaySocA0 = 0, delaySocA3 = 0, delaySocA4 = 0, delaySocA5 = 0;
|
||||
volatile uint16_t delaySocB0 = 0, delaySocB1 = 0, delaySocB4 = 0, delaySocB5 = 0;
|
||||
volatile uint16_t delaySocD0 = 0, delaySocD1 = 0, delaySocD4 = 0, delaySocD5 = 0;
|
||||
|
||||
//
|
||||
// Globals for capturing ADC results
|
||||
//
|
||||
uint16_t adcA0Results[RESULTS_BUFFER_SIZE] = {0}; // ADC result buffer for Ch A0
|
||||
uint16_t adcB0Results[RESULTS_BUFFER_SIZE] = {0}; // ADC result buffer for Ch B0
|
||||
uint16_t adcD0Results[RESULTS_BUFFER_SIZE] = {0}; // ADC result buffer for Ch D0
|
||||
uint16_t adcA1Results[RESULTS_BUFFER_SIZE] = {0}; // ADC result buffer for Ch A1
|
||||
uint16_t adcB1Results[RESULTS_BUFFER_SIZE] = {0}; // ADC result buffer for Ch B1
|
||||
uint16_t adcD1Results[RESULTS_BUFFER_SIZE] = {0}; // ADC result buffer for Ch D1
|
||||
uint16_t adcA2Results[RESULTS_BUFFER_SIZE] = {0}; // ADC result buffer for Ch A2
|
||||
uint16_t adcA3Results[RESULTS_BUFFER_SIZE] = {0}; // ADC result buffer for Ch A3
|
||||
uint16_t adcA4Results[RESULTS_BUFFER_SIZE] = {0}; // ADC result buffer for Ch A4
|
||||
uint16_t adcB4Results[RESULTS_BUFFER_SIZE] = {0}; // ADC result buffer for Ch B4
|
||||
uint16_t adcD4Results[RESULTS_BUFFER_SIZE] = {0}; // ADC result buffer for Ch D4
|
||||
uint16_t adcA13Results[RESULTS_BUFFER_SIZE] = {0}; // ADC result buffer for Ch A13
|
||||
uint16_t adcB5Results[RESULTS_BUFFER_SIZE] = {0}; // ADC result buffer for Ch B5
|
||||
uint16_t adcD5Results[RESULTS_BUFFER_SIZE] = {0}; // ADC result buffer for Ch D5
|
||||
|
||||
//
|
||||
// Characteristics of PWM triggers
|
||||
// EPWM1 - frequency -> 400kHz, dutyA -> 50%, dutyB -> 50%, ePWM1B - inverted
|
||||
//
|
||||
EPWM_SignalParams pwmSignal1 =
|
||||
{400000, 0.5f, 0.5f, true, DEVICE_SYSCLK_FREQ, SYSCTL_EPWMCLK_DIV_2,
|
||||
EPWM_COUNTER_MODE_UP, EPWM_CLOCK_DIVIDER_1,
|
||||
EPWM_HSCLOCK_DIVIDER_1};
|
||||
|
||||
#if(EX_ADC_LP_SOC_TRIGGER == 1)
|
||||
//
|
||||
// EPWM2 - frequency -> 100kHz, dutyA -> 50%, dutyB -> 50%, ePWM2B - inverted
|
||||
//
|
||||
EPWM_SignalParams pwmSignal2 =
|
||||
{100000, 0.5f, 0.5f, true, DEVICE_SYSCLK_FREQ, SYSCTL_EPWMCLK_DIV_2,
|
||||
EPWM_COUNTER_MODE_UP, EPWM_CLOCK_DIVIDER_1,
|
||||
EPWM_HSCLOCK_DIVIDER_1};
|
||||
#endif
|
||||
|
||||
//
|
||||
// Functional Prototypes
|
||||
//
|
||||
|
||||
//
|
||||
// ADC configuration related APIs
|
||||
//
|
||||
void configureADC(uint32_t adcBase);
|
||||
void initADCSOC(uint32_t adcBase);
|
||||
void initADCPPB(void);
|
||||
|
||||
//
|
||||
// EPWM configuration related APIs
|
||||
//
|
||||
void initEPWMGPIO(void);
|
||||
|
||||
#ifdef ENABLE_PROFILING
|
||||
void setupProfileGpio(void);
|
||||
#endif
|
||||
|
||||
//
|
||||
// ADC ISR defined as high priority interrupt
|
||||
//
|
||||
__interrupt void adcA1ISR(void);
|
||||
#pragma CODE_SECTION(adcA1ISR, ".TI.ramfunc")
|
||||
#pragma INTERRUPT (adcA1ISR, HPI)
|
||||
|
||||
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);
|
||||
|
||||
#ifdef ENABLE_PROFILING
|
||||
//
|
||||
// Setup profiling GPIO
|
||||
//
|
||||
setupProfileGpio();
|
||||
#endif
|
||||
|
||||
//
|
||||
// For this case just init GPIO pins for ePWM1, ePWM2, ePWM3
|
||||
//
|
||||
initEPWMGPIO();
|
||||
|
||||
//
|
||||
// Configure the ADC and power it up
|
||||
//
|
||||
configureADC(ADCA_BASE);
|
||||
configureADC(ADCB_BASE);
|
||||
configureADC(ADCD_BASE);
|
||||
|
||||
//
|
||||
// Disable sync(Freeze clock to PWM as well)
|
||||
//
|
||||
SysCtl_disablePeripheral(SYSCTL_PERIPH_CLK_TBCLKSYNC);
|
||||
|
||||
//
|
||||
// Configuring ePWM modules for desired frequency and duty
|
||||
//
|
||||
EPWM_configureSignal(EPWM1_BASE, &pwmSignal1);
|
||||
EPWM_setTimeBaseCounterMode(EPWM1_BASE, EPWM_COUNTER_MODE_STOP_FREEZE);
|
||||
EPWM_disableADCTrigger(EPWM1_BASE, EPWM_SOC_A);
|
||||
|
||||
#if(EX_ADC_LP_SOC_TRIGGER == 1)
|
||||
EPWM_configureSignal(EPWM2_BASE, &pwmSignal2);
|
||||
EPWM_setTimeBaseCounterMode(EPWM2_BASE, EPWM_COUNTER_MODE_STOP_FREEZE);
|
||||
EPWM_disableADCTrigger(EPWM2_BASE, EPWM_SOC_A);
|
||||
#endif
|
||||
|
||||
//
|
||||
// Setup the ADC SOCs
|
||||
//
|
||||
initADCSOC(ADCA_BASE);
|
||||
initADCSOC(ADCB_BASE);
|
||||
initADCSOC(ADCD_BASE);
|
||||
|
||||
//
|
||||
// Configure ADC PPB for delay capture
|
||||
//
|
||||
initADCPPB();
|
||||
|
||||
//
|
||||
// Enable the temperature sensor and give it 500 us to power up
|
||||
//
|
||||
ASysCtl_enableTemperatureSensor();
|
||||
DEVICE_DELAY_US(500);
|
||||
|
||||
//
|
||||
// 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);
|
||||
EPWM_enableADCTrigger(EPWM1_BASE, EPWM_SOC_A);
|
||||
EPWM_setTimeBaseCounterMode(EPWM1_BASE, EPWM_COUNTER_MODE_UP);
|
||||
|
||||
#if(EX_ADC_LP_SOC_TRIGGER == 1)
|
||||
//
|
||||
// Configure the SOC to occur on the first up-count event
|
||||
//
|
||||
EPWM_setADCTriggerSource(EPWM2_BASE, EPWM_SOC_A, EPWM_SOC_TBCTR_U_CMPA);
|
||||
EPWM_setADCTriggerEventPrescale(EPWM2_BASE, EPWM_SOC_A, 1);
|
||||
EPWM_enableADCTrigger(EPWM2_BASE, EPWM_SOC_A);
|
||||
EPWM_setTimeBaseCounterMode(EPWM2_BASE, EPWM_COUNTER_MODE_UP);
|
||||
#endif
|
||||
|
||||
//
|
||||
// Enable ADC interrupt
|
||||
//
|
||||
Interrupt_enable(INT_ADCA1);
|
||||
|
||||
//
|
||||
// Enable global Interrupts and higher priority real-time debug events:
|
||||
//
|
||||
EINT; // Enable Global interrupt INTM
|
||||
ERTM; // Enable Global realtime interrupt DBGM
|
||||
|
||||
//
|
||||
// Start ePWM:
|
||||
// Enable sync and clock to PWM
|
||||
//
|
||||
SysCtl_enablePeripheral(SYSCTL_PERIPH_CLK_TBCLKSYNC);
|
||||
|
||||
//
|
||||
// Loop indefinitely:
|
||||
//
|
||||
while(1)
|
||||
{
|
||||
//
|
||||
// Wait for ADCA to complete conversion of low priority SOCs,
|
||||
// then acknowledge flag
|
||||
//
|
||||
while(ADC_getInterruptStatus(ADCA_BASE, ADC_INT_NUMBER2) == false)
|
||||
{
|
||||
}
|
||||
|
||||
ADC_clearInterruptStatus(ADCA_BASE, ADC_INT_NUMBER2);
|
||||
ADC_clearInterruptStatus(ADCB_BASE, ADC_INT_NUMBER2);
|
||||
ADC_clearInterruptStatus(ADCD_BASE, ADC_INT_NUMBER2);
|
||||
|
||||
//
|
||||
// Capture delays for low priority SOCs
|
||||
//
|
||||
delaySocA4 = ADC_getPPBDelayTimeStamp(ADCA_BASE, ADC_PPB_NUMBER3);
|
||||
delaySocA5 = ADC_getPPBDelayTimeStamp(ADCA_BASE, ADC_PPB_NUMBER4);
|
||||
|
||||
delaySocB4 = ADC_getPPBDelayTimeStamp(ADCB_BASE, ADC_PPB_NUMBER3);
|
||||
delaySocB5 = ADC_getPPBDelayTimeStamp(ADCB_BASE, ADC_PPB_NUMBER4);
|
||||
|
||||
delaySocD4 = ADC_getPPBDelayTimeStamp(ADCD_BASE, ADC_PPB_NUMBER3);
|
||||
delaySocD5 = ADC_getPPBDelayTimeStamp(ADCD_BASE, ADC_PPB_NUMBER4);
|
||||
|
||||
//
|
||||
// Read low priority ADC signals in background loop
|
||||
//
|
||||
adcA4Results[indexB] = ADC_readResult(ADCARESULT_BASE, ADC_SOC_NUMBER4);
|
||||
adcB4Results[indexB] = ADC_readResult(ADCBRESULT_BASE, ADC_SOC_NUMBER4);
|
||||
adcD4Results[indexB] = ADC_readResult(ADCDRESULT_BASE, ADC_SOC_NUMBER4);
|
||||
|
||||
adcA13Results[indexB] = ADC_readResult(ADCARESULT_BASE, ADC_SOC_NUMBER5);
|
||||
adcB5Results[indexB] = ADC_readResult(ADCBRESULT_BASE, ADC_SOC_NUMBER5);
|
||||
adcD5Results[indexB++] = ADC_readResult(ADCDRESULT_BASE, ADC_SOC_NUMBER5);
|
||||
|
||||
if(indexB == RESULTS_BUFFER_SIZE)
|
||||
{
|
||||
//
|
||||
// Reset the index on buffer full condition. Put breakpoint on below
|
||||
// statement to view ADC results on graph window.
|
||||
//
|
||||
indexB = 0U;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
//
|
||||
// configureADC - Write ADC configurations and power up the desired ADC instance
|
||||
//
|
||||
void configureADC(uint32_t adcBase)
|
||||
{
|
||||
//
|
||||
// Set ADCCLK divider to /4
|
||||
//
|
||||
ADC_setPrescaler(adcBase, ADC_CLK_DIV_4_0);
|
||||
|
||||
//
|
||||
// Set resolution and signal mode (see #defines above) and load
|
||||
// corresponding trims.
|
||||
//
|
||||
#if(EX_ADC_RESOLUTION == 12)
|
||||
ADC_setMode(adcBase, ADC_RESOLUTION_12BIT, ADC_MODE_SINGLE_ENDED);
|
||||
#elif(EX_ADC_RESOLUTION == 16)
|
||||
ADC_setMode(adcBase, ADC_RESOLUTION_16BIT, ADC_MODE_DIFFERENTIAL);
|
||||
#endif
|
||||
|
||||
//
|
||||
// Set pulse positions to late
|
||||
//
|
||||
ADC_setInterruptPulseMode(adcBase, ADC_PULSE_END_OF_CONV);
|
||||
|
||||
//
|
||||
// Power up the ADCs and then delay for 1 ms
|
||||
//
|
||||
ADC_enableConverter(adcBase);
|
||||
|
||||
//
|
||||
// Delay for 1ms to allow ADC time to power up
|
||||
//
|
||||
DEVICE_DELAY_US(1000);
|
||||
}
|
||||
|
||||
//
|
||||
// initADCSOC - Function to configure ADC SOCs as per application requirement
|
||||
//
|
||||
void initADCSOC(uint32_t adcBase)
|
||||
{
|
||||
uint16_t i;
|
||||
|
||||
//
|
||||
// Set SOC priority- SOC0-SOC3 are high priority SOCs and SOC4-SOC15
|
||||
// would have round-robin priority
|
||||
//
|
||||
ADC_setSOCPriority(adcBase, ADC_PRI_THRU_SOC3_HIPRI);
|
||||
|
||||
//
|
||||
// Configure EPWM1 as SOC0-SOC1 trigger
|
||||
//
|
||||
for(i = 0; i < 2; i++)
|
||||
{
|
||||
ADC_setupSOC(adcBase, (ADC_SOCNumber)i,
|
||||
ADC_TRIGGER_EPWM1_SOCA,
|
||||
(ADC_Channel)i,
|
||||
((EX_ADC_RESOLUTION == ADC_RESOLUTION_16BIT) ?
|
||||
EX_ACQ_WIN_16_BIT : EX_ACQ_WIN_12_BIT));
|
||||
}
|
||||
|
||||
if(adcBase == ADCA_BASE)
|
||||
{
|
||||
//
|
||||
// Configure EPWM1 as SOC2-SOC3 trigger
|
||||
//
|
||||
for(i = 2; i < 4; i++)
|
||||
{
|
||||
ADC_setupSOC(adcBase, (ADC_SOCNumber)i,
|
||||
ADC_TRIGGER_EPWM1_SOCA,
|
||||
(ADC_Channel)i,
|
||||
((EX_ADC_RESOLUTION == ADC_RESOLUTION_16BIT) ?
|
||||
EX_ACQ_WIN_16_BIT : EX_ACQ_WIN_12_BIT));
|
||||
}
|
||||
}
|
||||
|
||||
#if(EX_ADC_LP_SOC_TRIGGER == 1)
|
||||
//
|
||||
// Configuration for EPWM trigger for low priority SOCs
|
||||
//
|
||||
|
||||
//
|
||||
// Configure EPWM2 as SOC4-SOC5 trigger. Configure SOC5 to sample
|
||||
// channel 13. For ADCA it is temperature sensor output
|
||||
//
|
||||
ADC_setupSOC(adcBase, ADC_SOC_NUMBER4, ADC_TRIGGER_EPWM2_SOCA,
|
||||
ADC_CH_ADCIN4, ((EX_ADC_RESOLUTION == ADC_RESOLUTION_16BIT) ?
|
||||
EX_ACQ_WIN_16_BIT : EX_ACQ_WIN_12_BIT));
|
||||
|
||||
if(adcBase == ADCA_BASE)
|
||||
{
|
||||
ADC_setupSOC(adcBase, ADC_SOC_NUMBER5, ADC_TRIGGER_EPWM2_SOCA,
|
||||
ADC_CH_ADCIN13, 140);
|
||||
}
|
||||
else
|
||||
{
|
||||
ADC_setupSOC(adcBase, ADC_SOC_NUMBER5, ADC_TRIGGER_EPWM2_SOCA,
|
||||
ADC_CH_ADCIN5, 140);
|
||||
|
||||
}
|
||||
|
||||
//
|
||||
// Set ADCA SOC3 to set the interrupt 1 flag.
|
||||
//
|
||||
ADC_setInterruptSource(adcBase, ADC_INT_NUMBER1, ADC_SOC_NUMBER3);
|
||||
|
||||
#elif(EX_ADC_LP_SOC_TRIGGER == 0)
|
||||
//
|
||||
// Configuration for ADCINT1 Trigger for low priority SOCs
|
||||
//
|
||||
|
||||
//
|
||||
// Configure SOC4-SOC5. Configure SOC5 to sample channel 13. For ADCA it
|
||||
// is temperature sensor output
|
||||
//
|
||||
ADC_setupSOC(adcBase, ADC_SOC_NUMBER4, ADC_TRIGGER_SW_ONLY,
|
||||
ADC_CH_ADCIN4, ((EX_ADC_RESOLUTION == ADC_RESOLUTION_16BIT) ?
|
||||
EX_ACQ_WIN_16_BIT : EX_ACQ_WIN_12_BIT));
|
||||
|
||||
if(adcBase == ADCA_BASE)
|
||||
{
|
||||
ADC_setupSOC(adcBase, ADC_SOC_NUMBER5, ADC_TRIGGER_SW_ONLY,
|
||||
ADC_CH_ADCIN13, 140);
|
||||
}
|
||||
else
|
||||
{
|
||||
ADC_setupSOC(adcBase, ADC_SOC_NUMBER5, ADC_TRIGGER_SW_ONLY,
|
||||
ADC_CH_ADCIN5, 140);
|
||||
}
|
||||
|
||||
//
|
||||
// Configure ADCINT1 as SOC4-SOC5 trigger
|
||||
//
|
||||
for(i = 4; i < 6; i++)
|
||||
{
|
||||
//
|
||||
// Set interrupt SOC trigger
|
||||
//
|
||||
ADC_setInterruptSOCTrigger(adcBase, (ADC_SOCNumber)i,
|
||||
ADC_INT_SOC_TRIGGER_ADCINT1);
|
||||
}
|
||||
|
||||
|
||||
if(adcBase == ADCA_BASE)
|
||||
{
|
||||
//
|
||||
// Set ADCA SOC3 to set the interrupt 3 flag. Enable the interrupt,
|
||||
// and make sure its flag is cleared.
|
||||
//
|
||||
ADC_setInterruptSource(adcBase, ADC_INT_NUMBER3, ADC_SOC_NUMBER3);
|
||||
ADC_enableInterrupt(adcBase, ADC_INT_NUMBER3);
|
||||
ADC_clearInterruptStatus(adcBase, ADC_INT_NUMBER3);
|
||||
}
|
||||
|
||||
//
|
||||
// Set ADCA SOC1 to set the interrupt 1 flag. Enable the interrupt,
|
||||
// continuous interrupt mode and make sure its flag is cleared.
|
||||
//
|
||||
ADC_setInterruptSource(adcBase, ADC_INT_NUMBER1, ADC_SOC_NUMBER1);
|
||||
|
||||
#endif
|
||||
|
||||
//
|
||||
// Enable the ADCINT1 interrupt, continuous interrupt mode
|
||||
// and make sure its flag is cleared.
|
||||
//
|
||||
ADC_enableContinuousMode(adcBase, ADC_INT_NUMBER1);
|
||||
ADC_enableInterrupt(adcBase, ADC_INT_NUMBER1);
|
||||
ADC_clearInterruptStatus(adcBase, ADC_INT_NUMBER1);
|
||||
|
||||
//
|
||||
// Set ADC SOC5 to set the interrupt 2 flag. Enable the interrupt
|
||||
// and make sure its flag is cleared.
|
||||
//
|
||||
ADC_setInterruptSource(adcBase, ADC_INT_NUMBER2, ADC_SOC_NUMBER5);
|
||||
ADC_enableInterrupt(adcBase, ADC_INT_NUMBER2);
|
||||
ADC_clearInterruptStatus(adcBase, ADC_INT_NUMBER2);
|
||||
}
|
||||
|
||||
//
|
||||
// initADCPPB - Function to configure ADC PPBs as per application requirement
|
||||
//
|
||||
void initADCPPB(void)
|
||||
{
|
||||
//
|
||||
// PPB configuration for ADCA
|
||||
//
|
||||
ADC_setupPPB(ADCA_BASE, ADC_PPB_NUMBER1, ADC_SOC_NUMBER0);
|
||||
ADC_setupPPB(ADCA_BASE, ADC_PPB_NUMBER2, ADC_SOC_NUMBER3);
|
||||
ADC_setupPPB(ADCA_BASE, ADC_PPB_NUMBER3, ADC_SOC_NUMBER4);
|
||||
ADC_setupPPB(ADCA_BASE, ADC_PPB_NUMBER4, ADC_SOC_NUMBER5);
|
||||
|
||||
//
|
||||
// PPB configuration for ADCB
|
||||
//
|
||||
ADC_setupPPB(ADCB_BASE, ADC_PPB_NUMBER1, ADC_SOC_NUMBER0);
|
||||
ADC_setupPPB(ADCB_BASE, ADC_PPB_NUMBER2, ADC_SOC_NUMBER1);
|
||||
ADC_setupPPB(ADCB_BASE, ADC_PPB_NUMBER3, ADC_SOC_NUMBER4);
|
||||
ADC_setupPPB(ADCB_BASE, ADC_PPB_NUMBER4, ADC_SOC_NUMBER5);
|
||||
|
||||
//
|
||||
// PPB configuration for ADCD
|
||||
//
|
||||
ADC_setupPPB(ADCD_BASE, ADC_PPB_NUMBER1, ADC_SOC_NUMBER0);
|
||||
ADC_setupPPB(ADCD_BASE, ADC_PPB_NUMBER2, ADC_SOC_NUMBER1);
|
||||
ADC_setupPPB(ADCD_BASE, ADC_PPB_NUMBER3, ADC_SOC_NUMBER4);
|
||||
ADC_setupPPB(ADCD_BASE, ADC_PPB_NUMBER4, ADC_SOC_NUMBER5);
|
||||
}
|
||||
|
||||
//
|
||||
// adcA1ISR - ADC A Interrupt 1 ISR
|
||||
//
|
||||
__interrupt void adcA1ISR(void)
|
||||
{
|
||||
#ifdef ENABLE_PROFILING
|
||||
//
|
||||
// Setting Profiling GPIO12 : Takes 3 cycles
|
||||
//
|
||||
HWREG(GPIODATA_BASE + GPIO_O_GPASET) = 0x1000;
|
||||
#endif
|
||||
|
||||
//
|
||||
// Read SOC delays
|
||||
//
|
||||
delaySocA0 = ADC_getPPBDelayTimeStamp(ADCA_BASE, ADC_PPB_NUMBER1);
|
||||
delaySocB0 = ADC_getPPBDelayTimeStamp(ADCB_BASE, ADC_PPB_NUMBER1);
|
||||
delaySocB1 = ADC_getPPBDelayTimeStamp(ADCB_BASE, ADC_PPB_NUMBER2);
|
||||
delaySocD0 = ADC_getPPBDelayTimeStamp(ADCD_BASE, ADC_PPB_NUMBER1);
|
||||
delaySocD1 = ADC_getPPBDelayTimeStamp(ADCD_BASE, ADC_PPB_NUMBER2);
|
||||
|
||||
//
|
||||
// Add the latest ADC result of high priority signals to the buffer
|
||||
//
|
||||
adcA0Results[indexA] = ADC_readResult(ADCARESULT_BASE, ADC_SOC_NUMBER0);
|
||||
adcB0Results[indexA] = ADC_readResult(ADCBRESULT_BASE, ADC_SOC_NUMBER0);
|
||||
adcD0Results[indexA] = ADC_readResult(ADCDRESULT_BASE, ADC_SOC_NUMBER0);
|
||||
adcA1Results[indexA] = ADC_readResult(ADCARESULT_BASE, ADC_SOC_NUMBER1);
|
||||
adcB1Results[indexA] = ADC_readResult(ADCBRESULT_BASE, ADC_SOC_NUMBER1);
|
||||
adcD1Results[indexA] = ADC_readResult(ADCDRESULT_BASE, ADC_SOC_NUMBER1);
|
||||
|
||||
#if(EX_ADC_LP_SOC_TRIGGER == 0)
|
||||
//
|
||||
// Wait for ADCA to complete conversion of SOC2-SOC3, then acknowledge
|
||||
// flag
|
||||
//
|
||||
while(ADC_getInterruptStatus(ADCA_BASE, ADC_INT_NUMBER3) == false)
|
||||
{
|
||||
}
|
||||
|
||||
ADC_clearInterruptStatus(ADCA_BASE, ADC_INT_NUMBER3);
|
||||
#endif
|
||||
|
||||
//
|
||||
// Read ADCA SOC2-SOC3 results post checking the ADCINT3 flag
|
||||
//
|
||||
adcA2Results[indexA] = ADC_readResult(ADCARESULT_BASE, ADC_SOC_NUMBER2);
|
||||
adcA3Results[indexA++] = ADC_readResult(ADCARESULT_BASE, ADC_SOC_NUMBER3);
|
||||
|
||||
//
|
||||
// Read delay for ADCA SOC3
|
||||
//
|
||||
delaySocA3 = ADC_getPPBDelayTimeStamp(ADCA_BASE, ADC_PPB_NUMBER2);
|
||||
|
||||
if(RESULTS_BUFFER_SIZE <= indexA)
|
||||
{
|
||||
//
|
||||
// Reset the index when buffer is full.
|
||||
//
|
||||
indexA = 0;
|
||||
}
|
||||
|
||||
//
|
||||
// Acknowledge the interrupt
|
||||
//
|
||||
Interrupt_clearACKGroup(INTERRUPT_ACK_GROUP1);
|
||||
|
||||
#ifdef ENABLE_PROFILING
|
||||
//
|
||||
// Resetting Profiling GPIO12
|
||||
//
|
||||
HWREG(GPIODATA_BASE + GPIO_O_GPACLEAR) = 0x1000;
|
||||
#endif
|
||||
}
|
||||
|
||||
//
|
||||
// initEPWMGPIO - Configure ePWM1-ePWM2 GPIO
|
||||
//
|
||||
void initEPWMGPIO(void)
|
||||
{
|
||||
//
|
||||
// Disable pull up on GPIO0-1 and configure them as PWMs
|
||||
//
|
||||
GPIO_setPadConfig(0, GPIO_PIN_TYPE_STD);
|
||||
GPIO_setPinConfig(GPIO_0_EPWM1A);
|
||||
|
||||
GPIO_setPadConfig(1, GPIO_PIN_TYPE_STD);
|
||||
GPIO_setPinConfig(GPIO_1_EPWM1B);
|
||||
|
||||
#if(EX_ADC_LP_SOC_TRIGGER == 1)
|
||||
//
|
||||
// Disable pull up on GPIO2-3 and configure them as PWMs
|
||||
//
|
||||
GPIO_setPadConfig(2, GPIO_PIN_TYPE_STD);
|
||||
GPIO_setPinConfig(GPIO_2_EPWM2A);
|
||||
|
||||
GPIO_setPadConfig(3, GPIO_PIN_TYPE_STD);
|
||||
GPIO_setPinConfig(GPIO_3_EPWM2B);
|
||||
#endif
|
||||
}
|
||||
|
||||
#ifdef ENABLE_PROFILING
|
||||
//
|
||||
// setupProfileGpio - Configure profiling GPIO
|
||||
//
|
||||
void setupProfileGpio(void)
|
||||
{
|
||||
GPIO_setDirectionMode(12,GPIO_DIR_MODE_OUT);
|
||||
GPIO_setQualificationMode(12,GPIO_QUAL_SYNC);
|
||||
GPIO_setPinConfig(GPIO_12_GPIO12);
|
||||
GPIO_writePin(12,0);
|
||||
}
|
||||
#endif
|
||||
|
||||
//
|
||||
// End of file
|
||||
//
|
||||
@@ -0,0 +1,3 @@
|
||||
/**
|
||||
* Blank
|
||||
*/
|
||||
@@ -0,0 +1,460 @@
|
||||
//#############################################################################
|
||||
//
|
||||
// FILE: adc_ex16_sw_interleaved_averaging.c
|
||||
//
|
||||
// TITLE: ADC Interleaved Averaging in Software
|
||||
//
|
||||
//! \addtogroup driver_example_list
|
||||
//! <h1>ADC Interleaved Averaging in Software</h1>
|
||||
//!
|
||||
//! This example demonstrates software interleaved averaging of ADC input
|
||||
//! channels. ADCA/B channel 0 and 1 are sampled one after another in order
|
||||
//! to achieve interleaved averaging. SOC0-15 of ADCA and ADCB are configured
|
||||
//! to sample channel 0 and 1 alternatively with channel 0 being sampled by
|
||||
//! even SOCs namely SOC0, 2, 4, 6, 8, 10, 12 & 14 and channel 1 being sampled
|
||||
//! by odd SOCs namely SOC1, 3, 5, 7, 9, 11, 13 & 15.
|
||||
//!
|
||||
//! Sampling is initially triggered through external GPIO signal through
|
||||
//! enabling ADCEXTSOC signal via input XBAR and thereafter through ADCINT1.
|
||||
//! GPIO33 is configured to trigger ADCA and B SOCs for the first time in order
|
||||
//! to ensure synchronous operation. GPIO33 needs to be connected to GPIO32
|
||||
//! which in turn is driven by software to trigger the respective ADC SOCs.
|
||||
//!
|
||||
//! ADCA Interrupt ISRs are used to read results of both ADCA and ADCB to
|
||||
//! demonstrate parallel operation of multiple ADCs. ADCINT2 is configured
|
||||
//! to be triggered after completion of SOC7 while ADCINT1 is configured to be
|
||||
//! triggered after completion of SOC15 conversion and respective SOC results
|
||||
//! of ADCA and ADCB are read in ADCAINT2 and ADCAINT1 ISRs. Read SOC0-SOC15
|
||||
//! ADC results are then averaged in ADCINT1 ISR to get the filtered ADC output.
|
||||
//!
|
||||
//! Early interrupt mode is configured to trigger the ADC interrupt just at the
|
||||
//! end of acquisition window in order to save cycles(~42 cycles) since ADCA
|
||||
//! result of SOC7 in ADCINT2 and SOC15 in ADCINT1 are read post around 60 and
|
||||
//! 65 cycles respectively. Also, Fast ISRs are configured in the example to
|
||||
//! save some cycles during compiler specific context save and restore.
|
||||
//!
|
||||
//! Optimization level: This example is expected to be run with opt level = 2
|
||||
//!
|
||||
//! Sampling rate related calculations:
|
||||
//! - ADC acquisition cycles programmed( S + H) = 15 SYSCLKS
|
||||
//! - Conversion time for 12-bit data = 10.5 ADCCLKS = N = 42 SYSCLKs
|
||||
//! - Time from 1st SOC trigger to interrupt trigger: 15 * 57 + 15 = 870 SYSCLKs
|
||||
//! - Next ADC trigger will come after 870 SYSCLKs
|
||||
//! - Approximate ISR trigger frequency = 1/(870 * 5ns) = 1/4350ns = 229 KSPS
|
||||
//! - Time taken in ADCINT1 ISR : 132 SYSCLKs (Fast ISR)(O2)
|
||||
//! - Time taken in ADCINT2 ISR : 76 SYSCLKs (Fast ISR)(O2)
|
||||
//!
|
||||
//! To view results in graph window, add breakpoint inside while(1) loop in
|
||||
//! main() where bufferFull flag is cleared and plot the watch variables.
|
||||
//!
|
||||
//! \b External \b Connections \n
|
||||
//! - A0, A1, B0 and B1 pins should be connected to signals to be converted
|
||||
//! - Connect GPIO32 to GPIO33 to trigger ADC channels for the first time
|
||||
//!
|
||||
//! \b Watch \b Variables \n
|
||||
//! - \b adcA0Results - A sequence of analog-to-digital conversion samples from
|
||||
//! pin A0.
|
||||
//! - \b adcA1Results - A sequence of analog-to-digital conversion samples from
|
||||
//! pin A1.
|
||||
//! - \b adcB0Results - A sequence of analog-to-digital conversion samples from
|
||||
//! pin B0.
|
||||
//! - \b adcB1Results - A sequence of analog-to-digital conversion samples from
|
||||
//! pin B1.
|
||||
//!
|
||||
//
|
||||
//#############################################################################
|
||||
//
|
||||
//
|
||||
//
|
||||
// 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 RESULTS_BUFFER_SIZE 256U
|
||||
|
||||
//
|
||||
// Macros to define ADC resolution and input signal mode. Valid values of
|
||||
// resolution are 12 for 12-bit conversion resolution, which support input
|
||||
// modes ADC_MODE_SINGLE_ENDED & 16 for 16-bit conversion resolution, which
|
||||
// support ADC_MODE_SINGLE_ENDED & ADC_MODE_DIFFERENTIAL input signal modes.
|
||||
//
|
||||
#define EX_ADC_RESOLUTION (ADC_RESOLUTION_12BIT)
|
||||
#define EX_ADC_INPUT_MODE (ADC_MODE_SINGLE_ENDED)
|
||||
|
||||
//
|
||||
// Globals
|
||||
//
|
||||
uint16_t adcA0Results[RESULTS_BUFFER_SIZE]; // Buffer for ADCA channel 0
|
||||
uint16_t adcA1Results[RESULTS_BUFFER_SIZE]; // Buffer for ADCA channel 1
|
||||
uint16_t adcB0Results[RESULTS_BUFFER_SIZE]; // Buffer for ADCB channel 0
|
||||
uint16_t adcB1Results[RESULTS_BUFFER_SIZE]; // Buffer for ADCB channel 1
|
||||
volatile uint32_t sumACh0 = 0, sumACh1 = 0, averageACh0 = 0, averageACh1 = 0;
|
||||
volatile uint32_t sumBCh0 = 0, sumBCh1 = 0, averageBCh0 = 0, averageBCh1 = 0;
|
||||
volatile uint16_t indexA = 0, indexB = 0; // Index into result buffer
|
||||
volatile uint16_t bufferFull = 0; // Flag to indicate buffer is full
|
||||
volatile uint32_t countIdle = 0; // Idle counter
|
||||
|
||||
//
|
||||
// Function Prototypes
|
||||
//
|
||||
void configureADC(uint32_t adcBase);
|
||||
void initEPWM(uint32_t pwmBase);
|
||||
void initADCSOC(uint32_t adcBase);
|
||||
void initADCGPIOTrigger(void);
|
||||
|
||||
//
|
||||
// ISRs
|
||||
//
|
||||
__interrupt void adcA1ISR(void);
|
||||
#pragma CODE_SECTION(adcA1ISR, ".TI.ramfunc")
|
||||
#pragma INTERRUPT (adcA1ISR, HPI)
|
||||
__interrupt void adcA2ISR(void);
|
||||
#pragma CODE_SECTION(adcA2ISR, ".TI.ramfunc")
|
||||
#pragma INTERRUPT (adcA2ISR, HPI)
|
||||
|
||||
//
|
||||
// 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_ADCA2, &adcA2ISR);
|
||||
|
||||
//
|
||||
// Set up the ADC and the ePWM and initialize the SOC
|
||||
//
|
||||
configureADC(ADCA_BASE);
|
||||
configureADC(ADCB_BASE);
|
||||
initADCSOC(ADCA_BASE);
|
||||
initADCSOC(ADCB_BASE);
|
||||
|
||||
//
|
||||
// Configure GPIO trigger for ADC
|
||||
//
|
||||
initADCGPIOTrigger();
|
||||
|
||||
//
|
||||
// Initialize results buffer
|
||||
//
|
||||
for(indexA = 0; indexA < RESULTS_BUFFER_SIZE; indexA++)
|
||||
{
|
||||
adcA0Results[indexA] = 0;
|
||||
adcA1Results[indexA] = 0;
|
||||
adcB0Results[indexA] = 0;
|
||||
adcB1Results[indexA] = 0;
|
||||
}
|
||||
|
||||
indexA = 0;
|
||||
indexB = 0;
|
||||
bufferFull = 0;
|
||||
|
||||
//
|
||||
// Enable ADC interrupt
|
||||
//
|
||||
Interrupt_enable(INT_ADCA1);
|
||||
Interrupt_enable(INT_ADCA2);
|
||||
|
||||
//
|
||||
// Enable Global Interrupt (INTM) and realtime interrupt (DBGM)
|
||||
//
|
||||
EINT;
|
||||
ERTM;
|
||||
|
||||
//
|
||||
// Trigger ADC once through setting GPIO32 connected to ADCEXTSOC
|
||||
// pin(GPIO33)
|
||||
//
|
||||
GPIO_setPortPins(GPIO_PORT_B, GPIO_GPBDIR_GPIO32);
|
||||
|
||||
//
|
||||
// Loop indefinitely
|
||||
//
|
||||
while(1)
|
||||
{
|
||||
countIdle = 0;
|
||||
indexA = 0;
|
||||
indexB = 0;
|
||||
|
||||
//
|
||||
// Wait while ADCINT1 causes ADC conversions which then cause interrupts.
|
||||
// When the results buffer is filled, the bufferFull flag will be set.
|
||||
//
|
||||
while(bufferFull == 0)
|
||||
{
|
||||
//
|
||||
// Incrementing idle counter to get the CPU bandwidth
|
||||
//
|
||||
countIdle++;
|
||||
}
|
||||
|
||||
//
|
||||
// Clear the buffer full flag. Add breakpoint at this statement to
|
||||
// view ADC results in graph view.
|
||||
//
|
||||
bufferFull = 0;
|
||||
|
||||
// //
|
||||
// // Software breakpoint to view results.
|
||||
// // Hit run again to get updated conversions.
|
||||
// // Uncomment to halt the execution once buffer is full.
|
||||
// //
|
||||
// ESTOP0;
|
||||
}
|
||||
}
|
||||
|
||||
//
|
||||
// initADCGPIOTrigger - Configure ADCEXTSOC as ADC GPIO trigger
|
||||
//
|
||||
void initADCGPIOTrigger(void)
|
||||
{
|
||||
//
|
||||
// Load the output latch
|
||||
//
|
||||
GPIO_clearPortPins(GPIO_PORT_B, GPIO_GPBDIR_GPIO32);
|
||||
GPIO_setDirectionMode(32, GPIO_DIR_MODE_OUT); // output
|
||||
|
||||
GPIO_setDirectionMode(33, GPIO_DIR_MODE_IN); // input
|
||||
XBAR_setInputPin(INPUTXBAR_BASE, XBAR_INPUT5, 33);
|
||||
}
|
||||
|
||||
//
|
||||
// configureADC - Write ADC configurations and power up the selected ADC
|
||||
// instance
|
||||
//
|
||||
void configureADC(uint32_t adcBase)
|
||||
{
|
||||
//
|
||||
// Set ADCCLK divider to /4
|
||||
//
|
||||
ADC_setPrescaler(adcBase, ADC_CLK_DIV_4_0);
|
||||
|
||||
//
|
||||
// Set resolution and signal mode (see #defines above) and load
|
||||
// corresponding trims.
|
||||
//
|
||||
ADC_setMode(adcBase, EX_ADC_RESOLUTION, EX_ADC_INPUT_MODE);
|
||||
|
||||
//
|
||||
// Set pulse positions at the end of the acquisition window.
|
||||
//
|
||||
ADC_setInterruptPulseMode(adcBase, ADC_PULSE_END_OF_ACQ_WIN);
|
||||
|
||||
//
|
||||
// Power up the ADCs and then delay for 1 ms
|
||||
//
|
||||
ADC_enableConverter(adcBase);
|
||||
|
||||
//
|
||||
// Delay for 1ms to allow ADC time to power up
|
||||
//
|
||||
DEVICE_DELAY_US(1000);
|
||||
}
|
||||
|
||||
//
|
||||
// Function to configure selected ADC's SOC0 to be triggered by ePWM1.
|
||||
//
|
||||
void initADCSOC(uint32_t adcBase)
|
||||
{
|
||||
uint16_t i;
|
||||
|
||||
//
|
||||
// Configure SOCs of selected ADC
|
||||
// - For 12-bit resolution, a sampling window of 15 (75 ns at a 200MHz
|
||||
// SYSCLK rate) will be used. For 16-bit resolution, a sampling window
|
||||
// of 64 (320 ns at a 200MHz SYSCLK rate) will be used.
|
||||
//
|
||||
|
||||
//
|
||||
// ADC channel for SOC0, SOC2, ...,SOC14 = ADCIN0
|
||||
// ADC channel for SOC1, SOC3, ...,SOC15 = ADCIN1
|
||||
// SOC Trigger = GPIO (for first time triggering)
|
||||
// ACQPS = 64 for 16-bit resolution & 15 for 12-bit resolution
|
||||
//
|
||||
for(i = 0; i < 16; i++)
|
||||
{
|
||||
ADC_setupSOC(adcBase, (ADC_SOCNumber)i,
|
||||
ADC_TRIGGER_GPIO,
|
||||
((i % 2 == 0) ? ADC_CH_ADCIN0 : ADC_CH_ADCIN1),
|
||||
((EX_ADC_RESOLUTION == ADC_RESOLUTION_16BIT) ? 64U : 15U));
|
||||
|
||||
//
|
||||
// Set SOC trigger
|
||||
//
|
||||
ADC_setInterruptSOCTrigger(adcBase, (ADC_SOCNumber)i,
|
||||
ADC_INT_SOC_TRIGGER_ADCINT1);
|
||||
}
|
||||
|
||||
//
|
||||
// Set ADCA SOC7 to set the interrupt 2 flag and SOC15 to set interrupt 1
|
||||
// flag. Enable the interrupt and make sure its flag is cleared.
|
||||
//
|
||||
if(adcBase == ADCA_BASE)
|
||||
{
|
||||
ADC_setInterruptSource(adcBase, ADC_INT_NUMBER2, ADC_SOC_NUMBER7);
|
||||
ADC_enableContinuousMode(adcBase, ADC_INT_NUMBER2);
|
||||
ADC_enableInterrupt(adcBase, ADC_INT_NUMBER2);
|
||||
ADC_clearInterruptStatus(adcBase, ADC_INT_NUMBER2);
|
||||
}
|
||||
|
||||
ADC_setInterruptSource(adcBase, ADC_INT_NUMBER1, ADC_SOC_NUMBER15);
|
||||
ADC_enableContinuousMode(adcBase, ADC_INT_NUMBER1);
|
||||
ADC_enableInterrupt(adcBase, ADC_INT_NUMBER1);
|
||||
ADC_clearInterruptStatus(adcBase, ADC_INT_NUMBER1);
|
||||
}
|
||||
|
||||
//
|
||||
// ADC A Interrupt 2 ISR
|
||||
//
|
||||
__interrupt void adcA2ISR(void)
|
||||
{
|
||||
//
|
||||
// Take sum of different channels
|
||||
//
|
||||
sumACh0 = ADC_readResult(ADCARESULT_BASE, ADC_SOC_NUMBER0) +
|
||||
ADC_readResult(ADCARESULT_BASE, ADC_SOC_NUMBER2) +
|
||||
ADC_readResult(ADCARESULT_BASE, ADC_SOC_NUMBER4) +
|
||||
ADC_readResult(ADCARESULT_BASE, ADC_SOC_NUMBER6);
|
||||
|
||||
sumBCh0 = ADC_readResult(ADCBRESULT_BASE, ADC_SOC_NUMBER0) +
|
||||
ADC_readResult(ADCBRESULT_BASE, ADC_SOC_NUMBER2) +
|
||||
ADC_readResult(ADCBRESULT_BASE, ADC_SOC_NUMBER4) +
|
||||
ADC_readResult(ADCBRESULT_BASE, ADC_SOC_NUMBER6);
|
||||
|
||||
sumACh1 = ADC_readResult(ADCARESULT_BASE, ADC_SOC_NUMBER1) +
|
||||
ADC_readResult(ADCARESULT_BASE, ADC_SOC_NUMBER3) +
|
||||
ADC_readResult(ADCARESULT_BASE, ADC_SOC_NUMBER5) +
|
||||
ADC_readResult(ADCARESULT_BASE, ADC_SOC_NUMBER7);
|
||||
|
||||
sumBCh1 = ADC_readResult(ADCBRESULT_BASE, ADC_SOC_NUMBER1) +
|
||||
ADC_readResult(ADCBRESULT_BASE, ADC_SOC_NUMBER3) +
|
||||
ADC_readResult(ADCBRESULT_BASE, ADC_SOC_NUMBER5) +
|
||||
ADC_readResult(ADCBRESULT_BASE, ADC_SOC_NUMBER7);
|
||||
|
||||
//
|
||||
// Acknowledge the interrupt
|
||||
//
|
||||
Interrupt_clearACKGroup(INTERRUPT_ACK_GROUP10);
|
||||
}
|
||||
|
||||
//
|
||||
// ADC A Interrupt 1 ISR
|
||||
//
|
||||
__interrupt void adcA1ISR(void)
|
||||
{
|
||||
//
|
||||
// Add the latest result to the buffer
|
||||
//
|
||||
sumACh0 += ADC_readResult(ADCARESULT_BASE, ADC_SOC_NUMBER8) +
|
||||
ADC_readResult(ADCARESULT_BASE, ADC_SOC_NUMBER10) +
|
||||
ADC_readResult(ADCARESULT_BASE, ADC_SOC_NUMBER12) +
|
||||
ADC_readResult(ADCARESULT_BASE, ADC_SOC_NUMBER14);
|
||||
|
||||
sumBCh0 += ADC_readResult(ADCBRESULT_BASE, ADC_SOC_NUMBER8) +
|
||||
ADC_readResult(ADCBRESULT_BASE, ADC_SOC_NUMBER10) +
|
||||
ADC_readResult(ADCBRESULT_BASE, ADC_SOC_NUMBER12) +
|
||||
ADC_readResult(ADCBRESULT_BASE, ADC_SOC_NUMBER14);
|
||||
|
||||
sumACh1 += ADC_readResult(ADCARESULT_BASE, ADC_SOC_NUMBER9) +
|
||||
ADC_readResult(ADCARESULT_BASE, ADC_SOC_NUMBER11) +
|
||||
ADC_readResult(ADCARESULT_BASE, ADC_SOC_NUMBER13) +
|
||||
ADC_readResult(ADCARESULT_BASE, ADC_SOC_NUMBER15);
|
||||
|
||||
sumBCh1 += ADC_readResult(ADCBRESULT_BASE, ADC_SOC_NUMBER9) +
|
||||
ADC_readResult(ADCBRESULT_BASE, ADC_SOC_NUMBER11) +
|
||||
ADC_readResult(ADCBRESULT_BASE, ADC_SOC_NUMBER13) +
|
||||
ADC_readResult(ADCBRESULT_BASE, ADC_SOC_NUMBER15);
|
||||
|
||||
//
|
||||
// Taking average of 8 channels
|
||||
//
|
||||
averageACh0 = sumACh0 >> 3;
|
||||
averageACh1 = sumACh1 >> 3;
|
||||
averageBCh0 = sumBCh0 >> 3;
|
||||
averageBCh1 = sumBCh1 >> 3;
|
||||
|
||||
adcA0Results[indexA] = averageACh0;
|
||||
adcA1Results[indexA++] = averageACh1;
|
||||
adcB0Results[indexB] = averageBCh0;
|
||||
adcB1Results[indexB++] = averageBCh1;
|
||||
|
||||
//
|
||||
// Set the bufferFull flag if the buffer is full
|
||||
//
|
||||
if(RESULTS_BUFFER_SIZE <= indexA)
|
||||
{
|
||||
bufferFull = 1;
|
||||
}
|
||||
|
||||
//
|
||||
// Acknowledge the interrupt
|
||||
//
|
||||
Interrupt_clearACKGroup(INTERRUPT_ACK_GROUP1);
|
||||
}
|
||||
|
||||
//
|
||||
// End of file
|
||||
//
|
||||
@@ -0,0 +1,3 @@
|
||||
/**
|
||||
* Blank
|
||||
*/
|
||||
@@ -0,0 +1,573 @@
|
||||
//###########################################################################
|
||||
//
|
||||
// FILE: adc_ex17_open_shorts_detection.c
|
||||
//
|
||||
// TITLE: ADC input pin fault check through Open/Shorts Detection Circuit
|
||||
//
|
||||
//! \addtogroup driver_example_list
|
||||
//! <h1> ADC Open Shorts Detection (adc_open_shorts_detection)</h1>
|
||||
//!
|
||||
//! This example demonstrates the ADC open/shorts detection(ADCOSDETECT) circuit
|
||||
//! configuration for detecting pin faults in the system. The example enables
|
||||
//! the open/shorts detection circuit along with mandatory ADC configurations
|
||||
//! and diagnoses ADCA A0 input pin state before starting normal ADC
|
||||
//! conversions.
|
||||
//!
|
||||
//! To enable the ADC OSDetect circuit:
|
||||
//! 1. Configure the ADC for conversion (E.g. channel, SOC, ACQPS, prescalar,
|
||||
//! trigger etc). The OSDetect functionality is available in 12-bit only,
|
||||
//! hence ADCA is configured in 12-bit mode in the example.
|
||||
//! 2. Set up the ADCOSDETECT register for the desired voltage divider
|
||||
//! connection. Refer device TRM for details on available OSDetect
|
||||
//! configurations.
|
||||
//! 3. Initiate a conversion and inspect the conversion result.
|
||||
//! \note Note: The results must be interpreted based on what is driving on
|
||||
//! the input side and what are the values of Rs and Cp. If the Vs signal can
|
||||
//! be disconnected from the input pin, the circuit can be used to detect
|
||||
//! open and shorted input pins.
|
||||
//!
|
||||
//! In the example, after configuring ADCA A0 channel in 12-bit mode along with
|
||||
//! other required ADC configurations, following algorithm is used to check the
|
||||
//! A0 pin status:
|
||||
//! Step 1: Configure full scale OSDETECT mode & capture ADC results(resultHi)
|
||||
//! Step 2: Configure zero scale OSDETECT mode & capture ADC results(resultLo)
|
||||
//! Step 3: Disable OSDETECT mode and capture ADC results(resultNormal)
|
||||
//! Step 4: Determine the state of the ADC pin
|
||||
//! a. If the pin is open, resultLo would be equal to Vreflo and resultHi
|
||||
//! would be equal to Vrefhi
|
||||
//! b. If the pin is shorted to Vrefhi, resultLo should be approximately
|
||||
//! equal to Vrefhi and resultHi should be equal to Vrefhi
|
||||
//! c. If the pin is shorted to Vreflo, resultLo should be equal to
|
||||
//! Vreflo and resultHi should be approximately equal to Vreflo
|
||||
//! d. If the pin is connected to a valid signal, resultLo should be
|
||||
//! greater than osdLoLimit but less than resultNormal while resultHi
|
||||
//! should be less than osdHiLimit but greater than resultNormal
|
||||
//!-----------------------------------------------------------------------------
|
||||
//! Input | Full-Scale output | Zero-scale Output | Pin Status
|
||||
//!-----------------------------------------------------------------------------
|
||||
//! Unknown| VREFHI | VREFLO | Open
|
||||
//! VREFHI | VREFHI | approx. VREFHI | Shorted to VREFHI
|
||||
//! VREFLO | approx. VREFLO | VREFLO | Shorted to VREFLO
|
||||
//! Vn | Vn < resultHi < VREFHI | VREFLO < resultLo < Vn | Good
|
||||
//!-----------------------------------------------------------------------------
|
||||
//! Step 5: osDetectStatusVal of value greater than 4 would mean that there is
|
||||
//! no pin fault.
|
||||
//! a. If osDetectStatusVal == 1, means pin A0 is OPEN
|
||||
//! b. If osDetectStatusVal == 2, means pin A0 is shorted to VREFLO
|
||||
//! c. If osDetectStatusVal == 4, means pin A0 is shorted to VREFHI
|
||||
//! d. If osDetectStatusVal == 8, means pin A0 is in GOOD/VALID state
|
||||
//! e. Any value of osDetectStatusVal > 4, means pin A0 is in VALID state
|
||||
//!
|
||||
//! Following points should be noted while configuring the ADC in OSDETECT mode.
|
||||
//! 1. The divider resistance tolerances can vary widely, hence this
|
||||
//! feature should not be used to check for conversion accuracy.
|
||||
//! 2. Consult the device data manual for implementation and availability of
|
||||
//! analog input channels.
|
||||
//! 3. Due to high drive impedance, a S+H duration much longer than
|
||||
//! the ADC minimum will be needed.
|
||||
//!
|
||||
//! \b External \b Connections \n
|
||||
//! - A0 pin should be connected to signals to convert
|
||||
//!
|
||||
//! \b Watch \b Variables \n
|
||||
//! - \b osDetectStatusVal \b: OS detection status of voltage on pin A0\n
|
||||
//! - \b adcAResult0 \b: a digital representation of the voltage on pin A0\n
|
||||
//!
|
||||
//
|
||||
//###########################################################################
|
||||
// $TI Release: $
|
||||
//
|
||||
//
|
||||
// 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 EX_ENABLE_OS_DETECTION
|
||||
#define EX_ADC_RESOLUTION 12
|
||||
|
||||
//
|
||||
// Globals
|
||||
//
|
||||
uint16_t i = 0U;
|
||||
volatile uint16_t adcAResult0;
|
||||
volatile uint16_t resultHi;
|
||||
volatile uint16_t resultLo;
|
||||
volatile uint16_t resultNormal;
|
||||
|
||||
#ifdef EX_ENABLE_OS_DETECTION
|
||||
//
|
||||
// Application specific limits from Vreflo to Vrefhi.
|
||||
// This can change due to various factors like source
|
||||
// voltage offset etc.
|
||||
//
|
||||
uint16_t osdHiLimit = 3900; // upper limit
|
||||
uint16_t osdLoLimit = 15; // lower limit
|
||||
|
||||
//
|
||||
// Macros for open/shorts detection circuit status. If the osDetect status is
|
||||
// other than open, shorted to Vreflo and shorted to Vrefhi values (i.e > 4),
|
||||
// it can be considered as a valid signal
|
||||
//
|
||||
#define ADC_OSDETECT_STATUS_OPEN 1
|
||||
#define ADC_OSDETECT_STATUS_SHORTED_TO_VREFLO 2
|
||||
#define ADC_OSDETECT_STATUS_SHORTED_TO_VREFHI 4
|
||||
#define ADC_OSDETECT_STATUS_GOOD 8
|
||||
#define ADC_OSDETECT_STATUS_UNDETERMINED 16
|
||||
|
||||
uint16_t osDetectStatusVal = 0;
|
||||
#endif
|
||||
|
||||
//
|
||||
// Function Prototypes
|
||||
//
|
||||
void configureADC(uint32_t adcBase);
|
||||
void configureADCSOC(uint32_t adcBase, uint16_t channel);
|
||||
#ifdef EX_ENABLE_OS_DETECTION
|
||||
void configureADCTestMode(uint32_t adcBase, ADC_Channel channel);
|
||||
uint16_t performOSDetection(uint32_t adcBase, uint32_t adcResultBase,
|
||||
uint16_t channel);
|
||||
#endif
|
||||
|
||||
//
|
||||
// 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();
|
||||
|
||||
#ifdef EX_ENABLE_OS_DETECTION
|
||||
//
|
||||
// Configure ADC in test mode for checking pin status
|
||||
//
|
||||
configureADCTestMode(ADCA_BASE, ADC_CH_ADCIN0);
|
||||
|
||||
//
|
||||
// Perform open/shorts detection
|
||||
//
|
||||
for(i = 0U; i < 7U; i++)
|
||||
{
|
||||
osDetectStatusVal = osDetectStatusVal |
|
||||
performOSDetection(ADCA_BASE, ADCARESULT_BASE, 0U);
|
||||
|
||||
}
|
||||
|
||||
if(osDetectStatusVal > ADC_OSDETECT_STATUS_SHORTED_TO_VREFHI)
|
||||
{
|
||||
#endif
|
||||
//
|
||||
// Set up ADCs, initializing the SOCs to be triggered by software
|
||||
//
|
||||
configureADC(ADCA_BASE);
|
||||
configureADCSOC(ADCA_BASE, ADC_CH_ADCIN0);
|
||||
|
||||
//
|
||||
// Enable Global Interrupt (INTM) and realtime interrupt (DBGM)
|
||||
//
|
||||
EINT;
|
||||
ERTM;
|
||||
|
||||
//
|
||||
// Loop indefinitely
|
||||
//
|
||||
while(1)
|
||||
{
|
||||
|
||||
//
|
||||
// Convert, wait for completion, and store results
|
||||
//
|
||||
ADC_forceSOC(ADCA_BASE, ADC_SOC_NUMBER0);
|
||||
|
||||
//
|
||||
// Wait for ADCA to complete, then acknowledge flag
|
||||
//
|
||||
while(ADC_getInterruptStatus(ADCA_BASE, ADC_INT_NUMBER1) == false)
|
||||
{
|
||||
}
|
||||
ADC_clearInterruptStatus(ADCA_BASE, ADC_INT_NUMBER1);
|
||||
|
||||
//
|
||||
// Store results
|
||||
//
|
||||
adcAResult0 = ADC_readResult(ADCARESULT_BASE, ADC_SOC_NUMBER0);
|
||||
|
||||
//
|
||||
// Software breakpoint. At this point, conversion results are stored
|
||||
// in adcAResult0, adcAResult1, adcBResult0, and adcBResult1.
|
||||
//
|
||||
// Hit run again to get updated conversions.
|
||||
//
|
||||
ESTOP0;
|
||||
}
|
||||
#ifdef EX_ENABLE_OS_DETECTION
|
||||
}
|
||||
else
|
||||
{
|
||||
//
|
||||
// Selected ADC pin is either open or shorted to Vrefhi or Vreflo.
|
||||
// Loop indefinitely.
|
||||
//
|
||||
while(1)
|
||||
{
|
||||
}
|
||||
}
|
||||
#endif
|
||||
}
|
||||
|
||||
#ifdef EX_ENABLE_OS_DETECTION
|
||||
//
|
||||
// performOSDetection - Function to perform open/shorts detection
|
||||
// for selected ADC channel
|
||||
//
|
||||
uint16_t performOSDetection(uint32_t adcBase, uint32_t adcResultBase,
|
||||
uint16_t channel)
|
||||
{
|
||||
uint16_t i;
|
||||
uint16_t status = ADC_OSDETECT_STATUS_UNDETERMINED;
|
||||
resultHi = 0, resultLo = 0, resultNormal = 0;
|
||||
|
||||
//
|
||||
// Step 1: Configure full scale OSDETECT mode and capture
|
||||
// ADC results
|
||||
//
|
||||
|
||||
//
|
||||
// Enable pull-up mode
|
||||
//
|
||||
ADC_configOSDetectMode(adcBase, ADC_OSDETECT_MODE_VDDA);
|
||||
|
||||
//
|
||||
// Force SOC0-SOC15
|
||||
//
|
||||
ADC_forceMultipleSOC(adcBase, 0xFFFF);
|
||||
|
||||
//
|
||||
// Wait for ADC to complete, then acknowledge flag
|
||||
//
|
||||
while(ADC_getInterruptStatus(adcBase, ADC_INT_NUMBER1) == false)
|
||||
{
|
||||
}
|
||||
ADC_clearInterruptStatus(adcBase, ADC_INT_NUMBER1);
|
||||
|
||||
//
|
||||
// Read ADC results
|
||||
//
|
||||
for(i = 0U; i < 16U; i++)
|
||||
{
|
||||
resultHi = resultHi + ADC_readResult(adcResultBase,
|
||||
(ADC_SOCNumber)i);
|
||||
}
|
||||
|
||||
resultHi = resultHi >> 4U;
|
||||
|
||||
//
|
||||
// Step 2: Configure zero scale OSDETECT mode and capture
|
||||
// ADC results
|
||||
//
|
||||
|
||||
//
|
||||
// Enable pull-down mode
|
||||
//
|
||||
ADC_configOSDetectMode(adcBase, ADC_OSDETECT_MODE_VSSA);
|
||||
|
||||
//
|
||||
// Force SOC0-SOC15
|
||||
//
|
||||
ADC_forceMultipleSOC(adcBase, 0xFFFFU);
|
||||
|
||||
//
|
||||
// Wait for ADC to complete, then acknowledge flag
|
||||
//
|
||||
while(ADC_getInterruptStatus(adcBase, ADC_INT_NUMBER1) == false)
|
||||
{
|
||||
}
|
||||
ADC_clearInterruptStatus(adcBase, ADC_INT_NUMBER1);
|
||||
|
||||
//
|
||||
// Read ADC results
|
||||
//
|
||||
for(i = 0U; i < 16U; i++)
|
||||
{
|
||||
resultLo = resultLo + ADC_readResult(adcResultBase, (ADC_SOCNumber)i);
|
||||
}
|
||||
|
||||
resultLo = resultLo >> 4U;
|
||||
|
||||
//
|
||||
// Step 3: Disable OSDETECT mode and capture
|
||||
// ADC results
|
||||
//
|
||||
|
||||
//
|
||||
// Disable OSDETECT mode
|
||||
//
|
||||
ADC_configOSDetectMode(adcBase, ADC_OSDETECT_MODE_DISABLED);
|
||||
|
||||
//
|
||||
// Force SOC0-SOC15
|
||||
//
|
||||
ADC_forceMultipleSOC(adcBase, 0xFFFFU);
|
||||
|
||||
//
|
||||
// Wait for ADC to complete, then acknowledge flag
|
||||
//
|
||||
while(ADC_getInterruptStatus(adcBase, ADC_INT_NUMBER1) == false)
|
||||
{
|
||||
}
|
||||
ADC_clearInterruptStatus(adcBase, ADC_INT_NUMBER1);
|
||||
|
||||
//
|
||||
// Read ADC results
|
||||
//
|
||||
for(i = 0U; i < 16U; i++)
|
||||
{
|
||||
resultNormal = resultNormal + ADC_readResult(adcResultBase,
|
||||
(ADC_SOCNumber)i);
|
||||
}
|
||||
|
||||
resultNormal = resultNormal >> 4U;
|
||||
|
||||
//
|
||||
// Step 4: Determine the state of the ADC pin
|
||||
//
|
||||
|
||||
//
|
||||
// If the pin is open, resultLo would be equal to Vreflo and
|
||||
// resultHi would be equal to Vrefhi
|
||||
//
|
||||
if((resultLo <= osdLoLimit) && (resultHi >= osdHiLimit))
|
||||
{
|
||||
status = ADC_OSDETECT_STATUS_OPEN;
|
||||
}
|
||||
|
||||
//
|
||||
// If the pin is shorted to Vrefhi, resultLo should be approximately
|
||||
// equal to Vrefhi and resultHi should be equal to Vrefhi
|
||||
//
|
||||
else if((resultLo > osdLoLimit) && (resultHi >= osdHiLimit) &&
|
||||
(resultNormal >= osdHiLimit))
|
||||
{
|
||||
status = ADC_OSDETECT_STATUS_SHORTED_TO_VREFHI;
|
||||
}
|
||||
|
||||
//
|
||||
// If the pin is shorted to Vreflo, resultLo should be equal to Vreflo
|
||||
// and resultHi should be approximately equal to Vreflo
|
||||
//
|
||||
else if((resultLo <= osdLoLimit) && (resultHi < osdHiLimit ) &&
|
||||
(resultNormal <= osdLoLimit ))
|
||||
{
|
||||
status = ADC_OSDETECT_STATUS_SHORTED_TO_VREFLO;
|
||||
}
|
||||
|
||||
//
|
||||
// If the pin is connected to a valid signal, resultLo should be greater
|
||||
// than osdLoLimit but less than resultNormal while resultHi should be
|
||||
// less than osdHiLimit but greater than resultNormal
|
||||
//
|
||||
else if((osdLoLimit < resultLo < resultNormal) &&
|
||||
(osdHiLimit < resultHi < resultNormal ))
|
||||
{
|
||||
status = ADC_OSDETECT_STATUS_GOOD;
|
||||
}
|
||||
|
||||
return(status);
|
||||
}
|
||||
|
||||
|
||||
//
|
||||
// configureADCTestMode - Function to configure selected ADC to enable testing
|
||||
// of Open/Shorts Detection
|
||||
//
|
||||
void configureADCTestMode(uint32_t adcBase, ADC_Channel channel)
|
||||
{
|
||||
uint16_t i;
|
||||
|
||||
//
|
||||
// Set ADCCLK divider to /4
|
||||
//
|
||||
ADC_setPrescaler(adcBase, ADC_CLK_DIV_4_0);
|
||||
|
||||
//
|
||||
// Set resolution to 12-bit and signal mode as single-ended
|
||||
//
|
||||
ADC_setMode(adcBase, ADC_RESOLUTION_12BIT, ADC_MODE_SINGLE_ENDED);
|
||||
|
||||
//
|
||||
// Set pulse positions to late
|
||||
//
|
||||
ADC_setInterruptPulseMode(adcBase, ADC_PULSE_END_OF_CONV);
|
||||
|
||||
//
|
||||
// Power up the ADCs and then delay for 1 ms
|
||||
//
|
||||
ADC_enableConverter(adcBase);
|
||||
|
||||
DEVICE_DELAY_US(1000);
|
||||
|
||||
//
|
||||
// Configure ADC SOCs to sample selected channel in test mode
|
||||
//
|
||||
for(i = 0; i < 16; i++)
|
||||
{
|
||||
ADC_setupSOC(adcBase, (ADC_SOCNumber)i, ADC_TRIGGER_SW_ONLY,
|
||||
channel, 64U);
|
||||
}
|
||||
|
||||
//
|
||||
// Set SOC15 to set the interrupt 1 flag. Enable the interrupt and make
|
||||
// sure its flag is cleared.
|
||||
//
|
||||
ADC_setInterruptSource(adcBase, ADC_INT_NUMBER1, ADC_SOC_NUMBER15);
|
||||
ADC_enableInterrupt(adcBase, ADC_INT_NUMBER1);
|
||||
ADC_clearInterruptStatus(adcBase, ADC_INT_NUMBER1);
|
||||
}
|
||||
|
||||
#endif
|
||||
|
||||
//
|
||||
// configureADC - Write ADC configurations and power up the desired ADC instance
|
||||
//
|
||||
void configureADC(uint32_t adcBase)
|
||||
{
|
||||
//
|
||||
// Set ADCCLK divider to /4
|
||||
//
|
||||
ADC_setPrescaler(adcBase, ADC_CLK_DIV_4_0);
|
||||
|
||||
//
|
||||
// Set resolution and signal mode (see #defines above) and load
|
||||
// corresponding trims.
|
||||
//
|
||||
#if(EX_ADC_RESOLUTION == 12)
|
||||
ADC_setMode(adcBase, ADC_RESOLUTION_12BIT, ADC_MODE_SINGLE_ENDED);
|
||||
#elif(EX_ADC_RESOLUTION == 16)
|
||||
ADC_setMode(adcBase, ADC_RESOLUTION_16BIT, ADC_MODE_SINGLE_ENDED);
|
||||
#endif
|
||||
|
||||
//
|
||||
// Set pulse positions to late
|
||||
//
|
||||
ADC_setInterruptPulseMode(adcBase, ADC_PULSE_END_OF_CONV);
|
||||
|
||||
//
|
||||
// Power up the ADCs and then delay for 1 ms
|
||||
//
|
||||
ADC_enableConverter(adcBase);
|
||||
|
||||
//
|
||||
// Delay for 1ms to allow ADC time to power up
|
||||
//
|
||||
DEVICE_DELAY_US(1000);
|
||||
}
|
||||
|
||||
//
|
||||
// configureADCSOC - Setup ADC EPWM channel and trigger settings
|
||||
//
|
||||
void configureADCSOC(uint32_t adcBase, uint16_t channel)
|
||||
{
|
||||
uint16_t acqps;
|
||||
|
||||
//
|
||||
// Determine minimum acquisition window (in SYSCLKS) based on resolution
|
||||
// - NOTE: A longer sampling window will be required if the ADC driving
|
||||
// source is less than ideal (an ideal source would be a high bandwidth
|
||||
// op-amp with a small series resistance). See TI application report
|
||||
// SPRACT6 for guidance on ADC driver design.
|
||||
//
|
||||
if(EX_ADC_RESOLUTION == 12)
|
||||
{
|
||||
acqps = 32;
|
||||
}
|
||||
else //resolution is 16-bit
|
||||
{
|
||||
acqps = 63;
|
||||
}
|
||||
|
||||
//
|
||||
// Select the channels to convert and end of conversion flag
|
||||
// ADCA
|
||||
//
|
||||
ADC_setupSOC(adcBase, ADC_SOC_NUMBER0, ADC_TRIGGER_SW_ONLY,
|
||||
(ADC_Channel)channel, acqps);
|
||||
|
||||
//
|
||||
// Configure ADCINT1 as SOC0 trigger
|
||||
//
|
||||
ADC_setInterruptSOCTrigger(adcBase, ADC_SOC_NUMBER0,
|
||||
ADC_INT_SOC_TRIGGER_ADCINT1);
|
||||
|
||||
//
|
||||
// Enable continuous mode
|
||||
//
|
||||
ADC_enableContinuousMode(ADCA_BASE, ADC_INT_NUMBER1);
|
||||
|
||||
//
|
||||
// Configure source as EOC1, clear & enable the interrupt
|
||||
//
|
||||
ADC_setInterruptSource(adcBase, ADC_INT_NUMBER1, ADC_SOC_NUMBER0);
|
||||
ADC_clearInterruptStatus(adcBase, ADC_INT_NUMBER1);
|
||||
ADC_enableInterrupt(adcBase, ADC_INT_NUMBER1);
|
||||
}
|
||||
|
||||
//
|
||||
// End of File
|
||||
//
|
||||
|
||||
@@ -0,0 +1,164 @@
|
||||
//#############################################################################
|
||||
//
|
||||
// FILE: adc_ex1_soc_software.c
|
||||
//
|
||||
// TITLE: ADC Software Triggering
|
||||
//
|
||||
//! \addtogroup driver_example_list
|
||||
//! <h1>ADC Software Triggering</h1>
|
||||
//!
|
||||
//! This example converts some voltages on ADCA and ADCC based on a software
|
||||
//! trigger.
|
||||
//!
|
||||
//! The ADCC will not convert until ADCA is complete, so the ADCs will not run
|
||||
//! asynchronously. However, this is much less efficient than allowing the ADCs
|
||||
//! to convert synchronously in parallel (for example, by using an ePWM
|
||||
//! trigger).
|
||||
//!
|
||||
//! \b External \b Connections \n
|
||||
//! - A0, A1, C2, and C3 should be connected to signals to convert
|
||||
//!
|
||||
//! \b Watch \b Variables \n
|
||||
//! - \b myADC0Result0 - Digital representation of the voltage on pin A0
|
||||
//! - \b myADC0Result1 - Digital representation of the voltage on pin A1
|
||||
//! - \b myADC1Result0 - Digital representation of the voltage on pin C2
|
||||
//! - \b myADC1Result1 - Digital representation of the voltage on pin C3
|
||||
//!
|
||||
//
|
||||
//#############################################################################
|
||||
//
|
||||
//
|
||||
//
|
||||
// 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 "board.h"
|
||||
|
||||
//
|
||||
// Globals
|
||||
//
|
||||
uint16_t myADC0Result0;
|
||||
uint16_t myADC0Result1;
|
||||
uint16_t myADC1Result0;
|
||||
uint16_t myADC1Result1;
|
||||
|
||||
//
|
||||
// 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();
|
||||
|
||||
//
|
||||
// Set up ADCs, initializing the SOCs to be triggered by software
|
||||
// Signal Mode : single-ended
|
||||
// Conversion Resolution : 12-bit;
|
||||
//
|
||||
Board_init();
|
||||
|
||||
//
|
||||
// Enable Global Interrupt (INTM) and realtime interrupt (DBGM)
|
||||
//
|
||||
EINT;
|
||||
ERTM;
|
||||
|
||||
//
|
||||
// Loop indefinitely
|
||||
//
|
||||
while(1)
|
||||
{
|
||||
//
|
||||
// Convert, wait for completion, and store results
|
||||
//
|
||||
ADC_forceMultipleSOC(myADC0_BASE, (ADC_FORCE_SOC0 | ADC_FORCE_SOC1));
|
||||
|
||||
//
|
||||
// Wait for ADCA to complete, then acknowledge flag
|
||||
//
|
||||
while(ADC_getInterruptStatus(myADC0_BASE, ADC_INT_NUMBER1) == false)
|
||||
{
|
||||
}
|
||||
ADC_clearInterruptStatus(myADC0_BASE, ADC_INT_NUMBER1);
|
||||
|
||||
ADC_forceMultipleSOC(myADC1_BASE, (ADC_FORCE_SOC0 | ADC_FORCE_SOC1));
|
||||
//
|
||||
// Wait for ADCC to complete, then acknowledge flag
|
||||
//
|
||||
while(ADC_getInterruptStatus(myADC1_BASE, ADC_INT_NUMBER1) == false)
|
||||
{
|
||||
}
|
||||
ADC_clearInterruptStatus(myADC1_BASE, ADC_INT_NUMBER1);
|
||||
|
||||
//
|
||||
// Store results
|
||||
//
|
||||
myADC0Result0 = ADC_readResult(ADCARESULT_BASE, ADC_SOC_NUMBER0);
|
||||
myADC0Result1 = ADC_readResult(ADCARESULT_BASE, ADC_SOC_NUMBER1);
|
||||
myADC1Result0 = ADC_readResult(ADCCRESULT_BASE, ADC_SOC_NUMBER0);
|
||||
myADC1Result1 = ADC_readResult(ADCCRESULT_BASE, ADC_SOC_NUMBER1);
|
||||
|
||||
//
|
||||
// Software breakpoint. At this point, conversion results are stored in
|
||||
// myADC0Result0, myADC0Result1, myADC1Result0, and myADC1Result1.
|
||||
//
|
||||
// Hit run again to get updated conversions.
|
||||
//
|
||||
ESTOP0;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,39 @@
|
||||
|
||||
/**
|
||||
* Import the modules used in this configuration.
|
||||
*/
|
||||
const adc = scripting.addModule("/driverlib/adc.js", {}, false);
|
||||
const adc1 = adc.addInstance();
|
||||
const adc2 = adc.addInstance();
|
||||
|
||||
/**
|
||||
* Write custom configuration values to the imported modules.
|
||||
*/
|
||||
adc1.$name = "myADC0";
|
||||
adc1.adcClockPrescaler = "ADC_CLK_DIV_4_0";
|
||||
adc1.enabledSOCs = ["ADC_SOC_NUMBER0","ADC_SOC_NUMBER1"];
|
||||
adc1.soc1Channel = "ADC_CH_ADCIN1";
|
||||
adc1.soc0SampleWindow = 15;
|
||||
adc1.soc1SampleWindow = 15;
|
||||
adc1.enabledInts = ["ADC_INT_NUMBER1"];
|
||||
adc1.interruptPulseMode = "ADC_PULSE_END_OF_CONV";
|
||||
adc1.enableInterrupt1 = true;
|
||||
adc1.interrupt1SOCSource = "ADC_SOC_NUMBER1";
|
||||
adc1.adcSignalMode = "ADC_MODE_SINGLE_ENDED";
|
||||
adc1.adcResolutionMode = "ADC_RESOLUTION_12BIT";
|
||||
|
||||
adc2.$name = "myADC1";
|
||||
adc2.adcBase = "ADCC_BASE";
|
||||
adc2.adcClockPrescaler = "ADC_CLK_DIV_4_0";
|
||||
adc2.enabledSOCs = ["ADC_SOC_NUMBER0","ADC_SOC_NUMBER1"];
|
||||
adc2.soc0SampleWindow = 15;
|
||||
adc2.soc1SampleWindow = 15;
|
||||
adc2.soc1Channel = "ADC_CH_ADCIN3";
|
||||
adc2.soc0Channel = "ADC_CH_ADCIN2";
|
||||
adc2.enabledInts = ["ADC_INT_NUMBER1"];
|
||||
adc2.interruptPulseMode = "ADC_PULSE_END_OF_CONV";
|
||||
adc2.enableInterrupt1 = true;
|
||||
adc2.interrupt1SOCSource = "ADC_SOC_NUMBER1";
|
||||
adc2.adcSignalMode = "ADC_MODE_SINGLE_ENDED";
|
||||
adc2.adcResolutionMode = "ADC_RESOLUTION_12BIT";
|
||||
|
||||
@@ -0,0 +1,251 @@
|
||||
//#############################################################################
|
||||
//
|
||||
// FILE: adc_ex2_soc_epwm.c
|
||||
//
|
||||
// TITLE: ADC ePWM Triggering
|
||||
//
|
||||
//! \addtogroup driver_example_list
|
||||
//! <h1>ADC ePWM Triggering</h1>
|
||||
//!
|
||||
//! This example sets up ePWM1 to periodically trigger a conversion on ADCA.
|
||||
//!
|
||||
//! \b External \b Connections \n
|
||||
//! - A0 should be connected to a signal to convert
|
||||
//!
|
||||
//! \b Watch \b Variables \n
|
||||
//! - \b myADC0Results - A sequence of analog-to-digital conversion samples from
|
||||
//! pin A0. The time between samples is determined based on the period
|
||||
//! of the ePWM timer.
|
||||
//!
|
||||
//
|
||||
//#############################################################################
|
||||
//
|
||||
//
|
||||
//
|
||||
// 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 "board.h"
|
||||
|
||||
//
|
||||
// Defines
|
||||
//
|
||||
#define RESULTS_BUFFER_SIZE 256
|
||||
|
||||
//
|
||||
// Globals
|
||||
//
|
||||
uint16_t myADC0Results[RESULTS_BUFFER_SIZE]; // Buffer for results
|
||||
uint16_t index; // Index into result buffer
|
||||
volatile uint16_t bufferFull; // Flag to indicate buffer is full
|
||||
|
||||
//
|
||||
// Function Prototypes
|
||||
//
|
||||
void initEPWM(void);
|
||||
|
||||
//
|
||||
// Main
|
||||
//
|
||||
void main(void)
|
||||
{
|
||||
//
|
||||
// Initialize device clock and peripherals
|
||||
//
|
||||
Device_init();
|
||||
|
||||
//
|
||||
// Disable pin locks and enable internal pullups.
|
||||
//
|
||||
Device_initGPIO();
|
||||
|
||||
//
|
||||
// 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();
|
||||
|
||||
//
|
||||
// Board Initialization
|
||||
// - Set up the ADC and initialize the SOC
|
||||
// - Enable ADC interrupt
|
||||
// - Signal Mode : single-ended
|
||||
// - Conversion Resolution : 12-bit;
|
||||
//
|
||||
Board_init();
|
||||
|
||||
// Set up the ePWM
|
||||
initEPWM();
|
||||
|
||||
//
|
||||
// Initialize results buffer
|
||||
//
|
||||
for(index = 0; index < RESULTS_BUFFER_SIZE; index++)
|
||||
{
|
||||
myADC0Results[index] = 0;
|
||||
}
|
||||
|
||||
index = 0;
|
||||
bufferFull = 0;
|
||||
|
||||
//
|
||||
// Enable Global Interrupt (INTM) and realtime interrupt (DBGM)
|
||||
//
|
||||
EINT;
|
||||
ERTM;
|
||||
|
||||
//
|
||||
// Loop indefinitely
|
||||
//
|
||||
while(1)
|
||||
{
|
||||
//
|
||||
// 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
|
||||
// myADC0Results.
|
||||
//
|
||||
// Hit run again to get updated conversions.
|
||||
//
|
||||
ESTOP0;
|
||||
}
|
||||
}
|
||||
|
||||
//
|
||||
// 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 1000 and the period to 1999
|
||||
// Assuming ePWM clock is 100MHz, this would give 50kHz sampling
|
||||
// 50MHz ePWM clock would give 25kHz sampling, etc.
|
||||
// The sample rate can also be modulated by changing the ePWM period
|
||||
// directly (ensure that the compare A value is less than the period).
|
||||
//
|
||||
EPWM_setCounterCompareValue(EPWM1_BASE, EPWM_COUNTER_COMPARE_A, 1000);
|
||||
EPWM_setTimeBasePeriod(EPWM1_BASE, 1999);
|
||||
|
||||
//
|
||||
// Set the local ePWM module clock divider to /1
|
||||
//
|
||||
EPWM_setClockPrescaler(EPWM1_BASE,
|
||||
EPWM_CLOCK_DIVIDER_1,
|
||||
EPWM_HSCLOCK_DIVIDER_1);
|
||||
|
||||
//
|
||||
// Freeze the counter
|
||||
//
|
||||
EPWM_setTimeBaseCounterMode(EPWM1_BASE, EPWM_COUNTER_MODE_STOP_FREEZE);
|
||||
}
|
||||
|
||||
//
|
||||
// adcA1ISR - ADC A Interrupt 1 ISR
|
||||
//
|
||||
__interrupt void adcA1ISR(void)
|
||||
{
|
||||
//
|
||||
// Add the latest result to the buffer
|
||||
//
|
||||
myADC0Results[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(myADC0_BASE, ADC_INT_NUMBER1);
|
||||
|
||||
//
|
||||
// Check if overflow has occurred
|
||||
//
|
||||
if(true == ADC_getInterruptOverflowStatus(myADC0_BASE, ADC_INT_NUMBER1))
|
||||
{
|
||||
ADC_clearInterruptOverflowStatus(myADC0_BASE, ADC_INT_NUMBER1);
|
||||
ADC_clearInterruptStatus(myADC0_BASE, ADC_INT_NUMBER1);
|
||||
}
|
||||
|
||||
//
|
||||
// Acknowledge the interrupt
|
||||
//
|
||||
Interrupt_clearACKGroup(INT_myADC0_1_INTERRUPT_ACK_GROUP);
|
||||
}
|
||||
@@ -0,0 +1,24 @@
|
||||
|
||||
/**
|
||||
* Import the modules used in this configuration.
|
||||
*/
|
||||
const adc = scripting.addModule("/driverlib/adc.js", {}, false);
|
||||
const adc1 = adc.addInstance();
|
||||
|
||||
/**
|
||||
* Write custom configuration values to the imported modules.
|
||||
*/
|
||||
adc1.$name = "myADC0";
|
||||
adc1.adcClockPrescaler = "ADC_CLK_DIV_4_0";
|
||||
adc1.interruptPulseMode = "ADC_PULSE_END_OF_CONV";
|
||||
adc1.enabledSOCs = ["ADC_SOC_NUMBER0"];
|
||||
adc1.soc0Trigger = "ADC_TRIGGER_EPWM1_SOCA";
|
||||
adc1.soc0SampleWindow = 15;
|
||||
adc1.enabledInts = ["ADC_INT_NUMBER1"];
|
||||
adc1.enableInterrupt1 = true;
|
||||
adc1.registerInterrupts = ["1"];
|
||||
adc1.adcInt1.enableInterrupt = true;
|
||||
adc1.adcInt1.interruptHandler = "adcA1ISR";
|
||||
adc1.adcSignalMode = "ADC_MODE_SINGLE_ENDED";
|
||||
adc1.adcResolutionMode = "ADC_RESOLUTION_12BIT";
|
||||
|
||||
@@ -0,0 +1,213 @@
|
||||
//#############################################################################
|
||||
//
|
||||
// FILE: adc_ex3_temp_sensor.c
|
||||
//
|
||||
// TITLE: Sample temperature sensor and convert to temperature
|
||||
//
|
||||
//! \addtogroup driver_example_list
|
||||
//! <h1>ADC Temperature Sensor Conversion</h1>
|
||||
//!
|
||||
//! This example sets up the ePWM to periodically trigger the ADC. The
|
||||
//! ADC converts the internal connection to the temperature sensor,
|
||||
//! which is then interpreted as a temperature by calling the
|
||||
//! ADC_getTemperatureC() function.
|
||||
//!
|
||||
//! \b Watch \b Variables \n
|
||||
//! - \b sensorSample - The raw reading from the temperature sensor
|
||||
//! - \b sensorTemp - The interpretation of the sensor sample as a temperature
|
||||
//! in degrees Celsius.
|
||||
//
|
||||
//#############################################################################
|
||||
//
|
||||
//
|
||||
//
|
||||
// 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 "board.h"
|
||||
|
||||
//
|
||||
// Globals
|
||||
//
|
||||
uint16_t sensorSample;
|
||||
int16_t sensorTemp;
|
||||
|
||||
//
|
||||
// Function Prototypes
|
||||
//
|
||||
void initEPWM(void);
|
||||
|
||||
//
|
||||
// Main
|
||||
//
|
||||
void main(void)
|
||||
{
|
||||
//
|
||||
// Initialize device clock and peripherals
|
||||
//
|
||||
Device_init();
|
||||
|
||||
//
|
||||
// Disable pin locks and enable internal pullups.
|
||||
//
|
||||
Device_initGPIO();
|
||||
|
||||
//
|
||||
// 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();
|
||||
|
||||
//
|
||||
// Board Initialization
|
||||
// - Configure and power up ADCA.
|
||||
// - Configure ADC's SOC0 to be triggered by ePWM1.
|
||||
// - Enable the temperature sensor and give it 500 us to power up
|
||||
// - Enable ADC interrupt
|
||||
// - Signal Mode : single-ended
|
||||
// - Conversion Resolution : 12-bit;
|
||||
//
|
||||
Board_init();
|
||||
|
||||
//
|
||||
// Set up the ePWM
|
||||
//
|
||||
initEPWM();
|
||||
|
||||
//
|
||||
// Enable Global Interrupt (INTM) and realtime interrupt (DBGM)
|
||||
//
|
||||
EINT;
|
||||
ERTM;
|
||||
|
||||
//
|
||||
// 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);
|
||||
|
||||
//
|
||||
// Loop indefinitely
|
||||
//
|
||||
while(1)
|
||||
{
|
||||
;
|
||||
}
|
||||
}
|
||||
|
||||
//
|
||||
// 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 1000 and the period to 1999
|
||||
// Assuming ePWM clock is 100MHz, this would give 50kHz sampling
|
||||
// 50MHz ePWM clock would give 25kHz sampling, etc.
|
||||
// The sample rate can also be modulated by changing the ePWM period
|
||||
// directly (ensure that the compare A value is less than the period).
|
||||
//
|
||||
EPWM_setCounterCompareValue(EPWM1_BASE, EPWM_COUNTER_COMPARE_A, 1000);
|
||||
EPWM_setTimeBasePeriod(EPWM1_BASE, 1999);
|
||||
|
||||
//
|
||||
// Set the local ePWM module clock divider to /1
|
||||
//
|
||||
EPWM_setClockPrescaler(EPWM1_BASE,
|
||||
EPWM_CLOCK_DIVIDER_1,
|
||||
EPWM_HSCLOCK_DIVIDER_1);
|
||||
|
||||
//
|
||||
// Freeze the counter
|
||||
//
|
||||
EPWM_setTimeBaseCounterMode(EPWM1_BASE, EPWM_COUNTER_MODE_STOP_FREEZE);
|
||||
}
|
||||
|
||||
//
|
||||
// adcA1ISR - ADC A Interrupt 1 ISR
|
||||
//
|
||||
__interrupt void adcA1ISR(void)
|
||||
{
|
||||
//
|
||||
// Read the raw result
|
||||
//
|
||||
sensorSample = ADC_readResult(ADCARESULT_BASE, ADC_SOC_NUMBER0);
|
||||
|
||||
//
|
||||
// Convert the result to a temperature in degrees C
|
||||
//
|
||||
sensorTemp = ADC_getTemperatureC(sensorSample, 3.0f);
|
||||
|
||||
//
|
||||
// Clear the interrupt flag
|
||||
//
|
||||
ADC_clearInterruptStatus(myADC0_BASE, ADC_INT_NUMBER1);
|
||||
|
||||
//
|
||||
// Check if overflow has occurred
|
||||
//
|
||||
if(true == ADC_getInterruptOverflowStatus(myADC0_BASE, ADC_INT_NUMBER1))
|
||||
{
|
||||
ADC_clearInterruptOverflowStatus(myADC0_BASE, ADC_INT_NUMBER1);
|
||||
ADC_clearInterruptStatus(myADC0_BASE, ADC_INT_NUMBER1);
|
||||
}
|
||||
|
||||
//
|
||||
// Acknowledge the interrupt
|
||||
//
|
||||
Interrupt_clearACKGroup(INT_myADC0_1_INTERRUPT_ACK_GROUP);
|
||||
}
|
||||
|
||||
@@ -0,0 +1,28 @@
|
||||
|
||||
/**
|
||||
* Import the modules used in this configuration.
|
||||
*/
|
||||
const adc = scripting.addModule("/driverlib/adc.js", {}, false);
|
||||
const adc1 = adc.addInstance();
|
||||
const asysctl = scripting.addModule("/driverlib/asysctl.js");
|
||||
|
||||
/**
|
||||
* Write custom configuration values to the imported modules.
|
||||
*/
|
||||
adc1.$name = "myADC0";
|
||||
adc1.enabledSOCs = ["ADC_SOC_NUMBER0"];
|
||||
adc1.soc0Channel = "ADC_CH_ADCIN13";
|
||||
adc1.adcBase = "ADCA_BASE";
|
||||
adc1.adcClockPrescaler = "ADC_CLK_DIV_4_0";
|
||||
adc1.soc0Trigger = "ADC_TRIGGER_EPWM1_SOCA";
|
||||
adc1.interruptPulseMode = "ADC_PULSE_END_OF_CONV";
|
||||
adc1.enabledInts = ["ADC_INT_NUMBER1"];
|
||||
adc1.soc0SampleWindow = 140;
|
||||
adc1.enableInterrupt1 = true;
|
||||
adc1.registerInterrupts = ["1"];
|
||||
adc1.adcInt1.enableInterrupt = true;
|
||||
adc1.adcInt1.interruptHandler = "adcA1ISR";
|
||||
adc1.adcSignalMode = "ADC_MODE_SINGLE_ENDED";
|
||||
adc1.adcResolutionMode = "ADC_RESOLUTION_12BIT";
|
||||
|
||||
asysctl.enableTemperatureSensor = true;
|
||||
@@ -0,0 +1,169 @@
|
||||
//###########################################################################
|
||||
//
|
||||
// FILE: adc_ex4_soc_software_sync.c
|
||||
//
|
||||
// TITLE: ADC synchronous software triggering
|
||||
//
|
||||
//! \addtogroup driver_example_list
|
||||
//! <h1> ADC Synchronous SOC Software Force (adc_soc_software_sync)</h1>
|
||||
//!
|
||||
//! This example converts some voltages on ADCA and ADCC using input 5 of the
|
||||
//! input X-BAR as a software force. Input 5 is triggered by toggling GPIO0,
|
||||
//! but any spare GPIO could be used. This method will ensure that both ADCs
|
||||
//! start converting at exactly the same time.
|
||||
//!
|
||||
//! \b External \b Connections \n
|
||||
//! - A2, A3, C2, C3 pins should be connected to signals to convert
|
||||
//!
|
||||
//! \b Watch \b Variables \n
|
||||
//! - \b myADC0Result0 \b: a digital representation of the voltage on pin A2\n
|
||||
//! - \b myADC0Result1 \b: a digital representation of the voltage on pin A3\n
|
||||
//! - \b myADC1Result0 \b: a digital representation of the voltage on pin C2\n
|
||||
//! - \b myADC1Result1 \b: a digital representation of the voltage on pin C3\n
|
||||
//!
|
||||
//
|
||||
//#############################################################################
|
||||
//
|
||||
//
|
||||
//
|
||||
// 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 "board.h"
|
||||
|
||||
//
|
||||
// Globals
|
||||
//
|
||||
uint16_t myADC0Result0;
|
||||
uint16_t myADC0Result1;
|
||||
uint16_t myADC1Result0;
|
||||
uint16_t myADC1Result1;
|
||||
|
||||
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();
|
||||
|
||||
//
|
||||
// Board Initialization
|
||||
// - Write ADC configurations and power up the ADC for both ADC A and ADC C
|
||||
// - Setup GPIO 0 to trigger input XBAR line 5. GPIO0 is used
|
||||
// as an example, but any spare GPIO could be used. The
|
||||
// physical GPIO pin should be allowed to float, since the
|
||||
// code configures it as an output and changes the value.
|
||||
// - Setup ADC acquisition window and compare values
|
||||
// - Signal Mode : single-ended
|
||||
// - Conversion Resolution : 12-bit;
|
||||
//
|
||||
Board_init();
|
||||
|
||||
//
|
||||
// Enable global Interrupts and higher priority real-time debug events:
|
||||
//
|
||||
EINT; // Enable Global interrupt INTM
|
||||
ERTM; // Enable Global realtime interrupt DBGM
|
||||
|
||||
//
|
||||
// Take conversions indefinitely in loop
|
||||
//
|
||||
do
|
||||
{
|
||||
//
|
||||
// Convert, wait for completion, and store results
|
||||
//
|
||||
|
||||
//
|
||||
// Toggle GPIO0 in software. This will cause a trigger to
|
||||
// both ADCs via input XBAR, line 5.
|
||||
//
|
||||
GPIO_writePin(0U, 1U); // Set pin
|
||||
GPIO_writePin(0U, 0U); // Clear pin
|
||||
|
||||
//
|
||||
// Wait for ADCA to complete, then acknowledge the flag.
|
||||
// Since both ADCs are running synchronously, it isn't necessary
|
||||
// to wait for completion notification from both ADCs
|
||||
//
|
||||
while(ADC_getInterruptStatus(myADC0_BASE, ADC_INT_NUMBER1) == 0U);
|
||||
ADC_clearInterruptStatus(myADC0_BASE, ADC_INT_NUMBER1);
|
||||
|
||||
//
|
||||
// Store results
|
||||
//
|
||||
myADC0Result0 = ADC_readResult(ADCARESULT_BASE, ADC_SOC_NUMBER0);
|
||||
myADC0Result1 = ADC_readResult(ADCARESULT_BASE, ADC_SOC_NUMBER1);
|
||||
myADC1Result0 = ADC_readResult(ADCCRESULT_BASE, ADC_SOC_NUMBER0);
|
||||
myADC1Result1 = ADC_readResult(ADCCRESULT_BASE, ADC_SOC_NUMBER1);
|
||||
|
||||
//
|
||||
// At this point, conversion results are stored in
|
||||
// myADC0Result0, myADC0Result1, myADC1Result0, and myADC1Result1
|
||||
//
|
||||
|
||||
//
|
||||
// Software breakpoint, hit run again to get updated conversions
|
||||
//
|
||||
asm(" ESTOP0");
|
||||
|
||||
}
|
||||
while(1);
|
||||
}
|
||||
|
||||
//
|
||||
// End of file
|
||||
//
|
||||
@@ -0,0 +1,54 @@
|
||||
|
||||
/**
|
||||
* Import the modules used in this configuration.
|
||||
*/
|
||||
const adc = scripting.addModule("/driverlib/adc.js", {}, false);
|
||||
const adc1 = adc.addInstance();
|
||||
const adc2 = adc.addInstance();
|
||||
const gpio = scripting.addModule("/driverlib/gpio.js", {}, false);
|
||||
const gpio1 = gpio.addInstance();
|
||||
const inputxbar = scripting.addModule("/driverlib/inputxbar.js", {}, false);
|
||||
const inputxbar1 = inputxbar.addInstance();
|
||||
|
||||
/**
|
||||
* Write custom configuration values to the imported modules.
|
||||
*/
|
||||
adc1.$name = "myADC0";
|
||||
adc1.adcClockPrescaler = "ADC_CLK_DIV_4_0";
|
||||
adc1.interruptPulseMode = "ADC_PULSE_END_OF_CONV";
|
||||
adc1.enabledSOCs = ["ADC_SOC_NUMBER0","ADC_SOC_NUMBER1"];
|
||||
adc1.soc0Trigger = "ADC_TRIGGER_GPIO";
|
||||
adc1.soc1Trigger = "ADC_TRIGGER_GPIO";
|
||||
adc1.soc0Channel = "ADC_CH_ADCIN2";
|
||||
adc1.soc1Channel = "ADC_CH_ADCIN3";
|
||||
adc1.soc0SampleWindow = 15;
|
||||
adc1.soc1SampleWindow = 15;
|
||||
adc1.enabledInts = ["ADC_INT_NUMBER1"];
|
||||
adc1.enableInterrupt1 = true;
|
||||
adc1.interrupt1SOCSource = "ADC_SOC_NUMBER1";
|
||||
adc1.adcSignalMode = "ADC_MODE_SINGLE_ENDED";
|
||||
adc1.adcResolutionMode = "ADC_RESOLUTION_12BIT";
|
||||
|
||||
adc2.$name = "myADC1";
|
||||
adc2.adcBase = "ADCC_BASE";
|
||||
adc2.adcClockPrescaler = "ADC_CLK_DIV_4_0";
|
||||
adc2.interruptPulseMode = "ADC_PULSE_END_OF_CONV";
|
||||
adc2.enabledSOCs = ["ADC_SOC_NUMBER0","ADC_SOC_NUMBER1"];
|
||||
adc2.soc0Channel = "ADC_CH_ADCIN2";
|
||||
adc2.soc0Trigger = "ADC_TRIGGER_GPIO";
|
||||
adc2.soc1Channel = "ADC_CH_ADCIN3";
|
||||
adc2.soc1Trigger = "ADC_TRIGGER_GPIO";
|
||||
adc2.soc0SampleWindow = 15;
|
||||
adc2.soc1SampleWindow = 15;
|
||||
adc2.adcSignalMode = "ADC_MODE_SINGLE_ENDED";
|
||||
adc2.adcResolutionMode = "ADC_RESOLUTION_12BIT";
|
||||
|
||||
|
||||
gpio1.$name = "myGPIO0";
|
||||
gpio1.direction = "GPIO_DIR_MODE_OUT";
|
||||
gpio1.writeInitialValue = true;
|
||||
gpio1.gpioPin.$assign = "GPIO0";
|
||||
|
||||
inputxbar1.$name = "myINPUTXBAR0";
|
||||
inputxbar1.inputsUsed = ["inputxbar5Gpio"];
|
||||
inputxbar1.inputxbar5Gpio = "GPIO0";
|
||||
@@ -0,0 +1,251 @@
|
||||
//###########################################################################
|
||||
//
|
||||
// FILE: adc_ex5_soc_continuous.c
|
||||
//
|
||||
// TITLE: ADC continuous self-triggering.
|
||||
//
|
||||
//! \addtogroup driver_example_list
|
||||
//! <h1> ADC Continuous Triggering (adc_soc_continuous)</h1>
|
||||
//!
|
||||
//! This example sets up the ADC to convert continuously, achieving maximum
|
||||
//! sampling rate.\n
|
||||
//!
|
||||
//! \b External \b Connections \n
|
||||
//! - A0 pin should be connected to signal to convert
|
||||
//!
|
||||
//! \b Watch \b Variables \n
|
||||
//! - \b adcAResults - A sequence of analog-to-digital conversion samples
|
||||
//! from pin A0. The time between samples is the minimum possible based on the
|
||||
//! ADC speed.
|
||||
//
|
||||
//#############################################################################
|
||||
//
|
||||
//
|
||||
//
|
||||
// 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 "board.h"
|
||||
|
||||
//
|
||||
// Defines
|
||||
//
|
||||
#define RESULTS_BUFFER_SIZE 256 //buffer for storing conversion results
|
||||
//(size must be multiple of 16)
|
||||
|
||||
//
|
||||
// Globals
|
||||
//
|
||||
uint16_t adcAResults[RESULTS_BUFFER_SIZE];
|
||||
uint16_t resultsIndex;
|
||||
|
||||
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();
|
||||
|
||||
//
|
||||
// Board Initialization
|
||||
// - Configure the ADC and power it up
|
||||
// - Setup the ADC for continuous conversions on channel 0
|
||||
// - Signal Mode : single-ended
|
||||
// - Conversion Resolution : 12-bit;
|
||||
//
|
||||
Board_init();
|
||||
|
||||
//
|
||||
// Initialize results buffer
|
||||
//
|
||||
for(resultsIndex = 0; resultsIndex < RESULTS_BUFFER_SIZE; resultsIndex++)
|
||||
{
|
||||
adcAResults[resultsIndex] = 0;
|
||||
}
|
||||
resultsIndex = 0;
|
||||
|
||||
//
|
||||
// Enable global Interrupts and higher priority real-time debug events:
|
||||
//
|
||||
EINT; // Enable Global interrupt INTM
|
||||
ERTM; // Enable Global realtime interrupt DBGM
|
||||
|
||||
//
|
||||
// Take conversions indefinitely in loop
|
||||
//
|
||||
do
|
||||
{
|
||||
//
|
||||
// Enable ADC interrupts
|
||||
//
|
||||
ADC_enableInterrupt(myADC0_BASE, ADC_INT_NUMBER1);
|
||||
ADC_enableInterrupt(myADC0_BASE, ADC_INT_NUMBER2);
|
||||
ADC_enableInterrupt(myADC0_BASE, ADC_INT_NUMBER3);
|
||||
ADC_enableInterrupt(myADC0_BASE, ADC_INT_NUMBER4);
|
||||
|
||||
//
|
||||
// Clear all interrupts flags(INT1-4)
|
||||
//
|
||||
HWREGH(myADC0_BASE + ADC_O_INTFLGCLR) = 0x000F;
|
||||
|
||||
//
|
||||
// Initialize results index
|
||||
//
|
||||
resultsIndex = 0;
|
||||
|
||||
//
|
||||
// Software force start SOC0 to SOC7
|
||||
//
|
||||
HWREGH(myADC0_BASE + ADC_O_SOCFRC1) = 0x00FF;
|
||||
|
||||
//
|
||||
// Keep taking samples until the results buffer is full
|
||||
//
|
||||
while(resultsIndex < RESULTS_BUFFER_SIZE)
|
||||
{
|
||||
//
|
||||
// Wait for first set of 8 conversions to complete
|
||||
//
|
||||
while(false == ADC_getInterruptStatus(myADC0_BASE, ADC_INT_NUMBER3));
|
||||
|
||||
//
|
||||
// Clear the interrupt flag
|
||||
//
|
||||
ADC_clearInterruptStatus(myADC0_BASE, ADC_INT_NUMBER3);
|
||||
|
||||
//
|
||||
// Save results for first 8 conversions
|
||||
//
|
||||
// Note that during this time, the second 8 conversions have
|
||||
// already been triggered by EOC6->ADCIN1 and will be actively
|
||||
// converting while first 8 results are being saved
|
||||
//
|
||||
adcAResults[resultsIndex++] = ADC_readResult(ADCARESULT_BASE,
|
||||
ADC_SOC_NUMBER0);
|
||||
adcAResults[resultsIndex++] = ADC_readResult(ADCARESULT_BASE,
|
||||
ADC_SOC_NUMBER1);
|
||||
adcAResults[resultsIndex++] = ADC_readResult(ADCARESULT_BASE,
|
||||
ADC_SOC_NUMBER2);
|
||||
adcAResults[resultsIndex++] = ADC_readResult(ADCARESULT_BASE,
|
||||
ADC_SOC_NUMBER3);
|
||||
adcAResults[resultsIndex++] = ADC_readResult(ADCARESULT_BASE,
|
||||
ADC_SOC_NUMBER4);
|
||||
adcAResults[resultsIndex++] = ADC_readResult(ADCARESULT_BASE,
|
||||
ADC_SOC_NUMBER5);
|
||||
adcAResults[resultsIndex++] = ADC_readResult(ADCARESULT_BASE,
|
||||
ADC_SOC_NUMBER6);
|
||||
adcAResults[resultsIndex++] = ADC_readResult(ADCARESULT_BASE,
|
||||
ADC_SOC_NUMBER7);
|
||||
|
||||
//
|
||||
// Wait for the second set of 8 conversions to complete
|
||||
//
|
||||
while(false == ADC_getInterruptStatus(myADC0_BASE, ADC_INT_NUMBER4));
|
||||
|
||||
//
|
||||
// Clear the interrupt flag
|
||||
//
|
||||
ADC_clearInterruptStatus(myADC0_BASE, ADC_INT_NUMBER4);
|
||||
|
||||
//
|
||||
// Save results for second 8 conversions
|
||||
//
|
||||
// Note that during this time, the first 8 conversions have
|
||||
// already been triggered by EOC14->ADCIN2 and will be actively
|
||||
// converting while second 8 results are being saved
|
||||
//
|
||||
adcAResults[resultsIndex++] = ADC_readResult(ADCARESULT_BASE,
|
||||
ADC_SOC_NUMBER8);
|
||||
adcAResults[resultsIndex++] = ADC_readResult(ADCARESULT_BASE,
|
||||
ADC_SOC_NUMBER9);
|
||||
adcAResults[resultsIndex++] = ADC_readResult(ADCARESULT_BASE,
|
||||
ADC_SOC_NUMBER10);
|
||||
adcAResults[resultsIndex++] = ADC_readResult(ADCARESULT_BASE,
|
||||
ADC_SOC_NUMBER11);
|
||||
adcAResults[resultsIndex++] = ADC_readResult(ADCARESULT_BASE,
|
||||
ADC_SOC_NUMBER12);
|
||||
adcAResults[resultsIndex++] = ADC_readResult(ADCARESULT_BASE,
|
||||
ADC_SOC_NUMBER13);
|
||||
adcAResults[resultsIndex++] = ADC_readResult(ADCARESULT_BASE,
|
||||
ADC_SOC_NUMBER14);
|
||||
adcAResults[resultsIndex++] = ADC_readResult(ADCARESULT_BASE,
|
||||
ADC_SOC_NUMBER15);
|
||||
}
|
||||
|
||||
//
|
||||
// Disable all ADCINT flags to stop sampling
|
||||
//
|
||||
ADC_disableInterrupt(myADC0_BASE, ADC_INT_NUMBER1);
|
||||
ADC_disableInterrupt(myADC0_BASE, ADC_INT_NUMBER2);
|
||||
ADC_disableInterrupt(myADC0_BASE, ADC_INT_NUMBER3);
|
||||
ADC_disableInterrupt(myADC0_BASE, ADC_INT_NUMBER4);
|
||||
|
||||
//
|
||||
// At this point, adcAResults[] contains a sequence of conversions
|
||||
// from the selected channel
|
||||
//
|
||||
|
||||
//
|
||||
// Software breakpoint, hit run again to get updated conversions
|
||||
//
|
||||
asm(" ESTOP0");
|
||||
}
|
||||
while(1); // Loop forever
|
||||
}
|
||||
|
||||
//
|
||||
// End of file
|
||||
//
|
||||
@@ -0,0 +1,58 @@
|
||||
|
||||
/**
|
||||
* Import the modules used in this configuration.
|
||||
*/
|
||||
const adc = scripting.addModule("/driverlib/adc.js", {}, false);
|
||||
const adc1 = adc.addInstance();
|
||||
|
||||
/**
|
||||
* Write custom configuration values to the imported modules.
|
||||
*/
|
||||
adc1.$name = "myADC0";
|
||||
adc1.adcClockPrescaler = "ADC_CLK_DIV_4_0";
|
||||
adc1.interruptPulseMode = "ADC_PULSE_END_OF_CONV";
|
||||
adc1.soc0SampleWindow = 15;
|
||||
adc1.soc1SampleWindow = 15;
|
||||
adc1.soc2SampleWindow = 15;
|
||||
adc1.soc3SampleWindow = 15;
|
||||
adc1.soc4SampleWindow = 15;
|
||||
adc1.soc5SampleWindow = 15;
|
||||
adc1.soc6SampleWindow = 15;
|
||||
adc1.soc7SampleWindow = 15;
|
||||
adc1.soc8SampleWindow = 15;
|
||||
adc1.soc9SampleWindow = 15;
|
||||
adc1.soc10SampleWindow = 15;
|
||||
adc1.soc11SampleWindow = 15;
|
||||
adc1.soc12SampleWindow = 15;
|
||||
adc1.soc13SampleWindow = 15;
|
||||
adc1.soc14SampleWindow = 15;
|
||||
adc1.soc15SampleWindow = 15;
|
||||
adc1.enabledSOCs = ["ADC_SOC_NUMBER0","ADC_SOC_NUMBER1","ADC_SOC_NUMBER10","ADC_SOC_NUMBER11","ADC_SOC_NUMBER12","ADC_SOC_NUMBER13","ADC_SOC_NUMBER14","ADC_SOC_NUMBER15","ADC_SOC_NUMBER2","ADC_SOC_NUMBER3","ADC_SOC_NUMBER4","ADC_SOC_NUMBER5","ADC_SOC_NUMBER6","ADC_SOC_NUMBER7","ADC_SOC_NUMBER8","ADC_SOC_NUMBER9"];
|
||||
adc1.soc0InterruptTrigger = "ADC_INT_SOC_TRIGGER_ADCINT2";
|
||||
adc1.soc1InterruptTrigger = "ADC_INT_SOC_TRIGGER_ADCINT2";
|
||||
adc1.soc2InterruptTrigger = "ADC_INT_SOC_TRIGGER_ADCINT2";
|
||||
adc1.soc3InterruptTrigger = "ADC_INT_SOC_TRIGGER_ADCINT2";
|
||||
adc1.soc4InterruptTrigger = "ADC_INT_SOC_TRIGGER_ADCINT2";
|
||||
adc1.soc5InterruptTrigger = "ADC_INT_SOC_TRIGGER_ADCINT2";
|
||||
adc1.soc6InterruptTrigger = "ADC_INT_SOC_TRIGGER_ADCINT2";
|
||||
adc1.soc7InterruptTrigger = "ADC_INT_SOC_TRIGGER_ADCINT2";
|
||||
adc1.soc8InterruptTrigger = "ADC_INT_SOC_TRIGGER_ADCINT1";
|
||||
adc1.soc9InterruptTrigger = "ADC_INT_SOC_TRIGGER_ADCINT1";
|
||||
adc1.soc10InterruptTrigger = "ADC_INT_SOC_TRIGGER_ADCINT1";
|
||||
adc1.soc11InterruptTrigger = "ADC_INT_SOC_TRIGGER_ADCINT1";
|
||||
adc1.soc12InterruptTrigger = "ADC_INT_SOC_TRIGGER_ADCINT1";
|
||||
adc1.soc13InterruptTrigger = "ADC_INT_SOC_TRIGGER_ADCINT1";
|
||||
adc1.soc14InterruptTrigger = "ADC_INT_SOC_TRIGGER_ADCINT1";
|
||||
adc1.soc15InterruptTrigger = "ADC_INT_SOC_TRIGGER_ADCINT1";
|
||||
adc1.enabledInts = ["ADC_INT_NUMBER1","ADC_INT_NUMBER2","ADC_INT_NUMBER3","ADC_INT_NUMBER4"];
|
||||
adc1.enableInterrupt1ContinuousMode = true;
|
||||
adc1.enableInterrupt2ContinuousMode = true;
|
||||
adc1.enableInterrupt3ContinuousMode = true;
|
||||
adc1.enableInterrupt4ContinuousMode = true;
|
||||
adc1.interrupt1SOCSource = "ADC_SOC_NUMBER6";
|
||||
adc1.interrupt2SOCSource = "ADC_SOC_NUMBER14";
|
||||
adc1.interrupt3SOCSource = "ADC_SOC_NUMBER7";
|
||||
adc1.interrupt4SOCSource = "ADC_SOC_NUMBER15";
|
||||
adc1.adcSignalMode = "ADC_MODE_SINGLE_ENDED";
|
||||
adc1.adcResolutionMode = "ADC_RESOLUTION_12BIT";
|
||||
|
||||
@@ -0,0 +1,372 @@
|
||||
//###########################################################################
|
||||
//
|
||||
// FILE: adc_ex6_soc_continuous_dma.c
|
||||
//
|
||||
// TITLE: ADC continuous conversions read by DMA.
|
||||
//
|
||||
//! \addtogroup driver_example_list
|
||||
//! <h1> ADC Continuous Conversions Read by DMA (adc_soc_continuous_dma)</h1>
|
||||
//!
|
||||
//! This example sets up two ADC channels to convert simultaneously. The
|
||||
//! results will be transferred by the DMA into a buffer in RAM.
|
||||
//!
|
||||
//! \b External \b Connections \n
|
||||
//! - A3 & C3 pins should be connected to signals to convert
|
||||
//!
|
||||
//! \b Watch \b Variables \n
|
||||
//! - \b myADC0DataBuffer \b: a digital representation of the voltage on pin A3\n
|
||||
//! - \b myADC1DataBuffer \b: a digital representation of the voltage on pin C3\n
|
||||
//!
|
||||
//
|
||||
//#############################################################################
|
||||
//
|
||||
//
|
||||
//
|
||||
// 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 "board.h"
|
||||
|
||||
//
|
||||
// Function Prototypes
|
||||
//
|
||||
__interrupt void dmach1ISR(void);
|
||||
|
||||
void configureEPWM(uint32_t epwmBase);
|
||||
void initializeDMA(void);
|
||||
void configureDMAChannels(void);
|
||||
|
||||
//
|
||||
// Defines
|
||||
//
|
||||
#define RESULTS_BUFFER_SIZE 1024 //buffer for storing conversion results
|
||||
//(size must be multiple of 16)
|
||||
|
||||
//
|
||||
// Globals
|
||||
//
|
||||
#pragma DATA_SECTION(myADC0DataBuffer, "ramgs0");
|
||||
#pragma DATA_SECTION(myADC1DataBuffer, "ramgs0");
|
||||
uint16_t myADC0DataBuffer[RESULTS_BUFFER_SIZE];
|
||||
uint16_t myADC1DataBuffer[RESULTS_BUFFER_SIZE];
|
||||
volatile uint16_t done;
|
||||
|
||||
void main(void)
|
||||
{
|
||||
uint16_t resultsIndex;
|
||||
|
||||
//
|
||||
// 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();
|
||||
|
||||
//
|
||||
// Board Initializatrion
|
||||
// - Configure the ADCA & ADCC and power it up
|
||||
// - Setup the ADC for continuous conversions on channels A3 and C3
|
||||
// - Set up ISR for ADCA INT1 - occurs after first conversion
|
||||
// - Enable specific PIE & CPU interrupts: ADCA INT1 - Group 1, interrupt 1
|
||||
// - Signal Mode : single-ended
|
||||
// - Conversion Resolution : 12-bit;
|
||||
//
|
||||
Board_init();
|
||||
|
||||
//
|
||||
// Set up ISRs used by this example
|
||||
// ISR for DMA ch1 - occurs when DMA transfer is complete
|
||||
//
|
||||
Interrupt_register(INT_DMA_CH1, &dmach1ISR);
|
||||
|
||||
//
|
||||
// Enable specific PIE & CPU interrupts:
|
||||
// DMA interrupt - Group 7, interrupt 1
|
||||
//
|
||||
Interrupt_enable(INT_DMA_CH1);
|
||||
|
||||
//
|
||||
// Stop the ePWM clock
|
||||
//
|
||||
SysCtl_disablePeripheral(SYSCTL_PERIPH_CLK_TBCLKSYNC);
|
||||
|
||||
//
|
||||
// Call the set up function for ePWM 2
|
||||
//
|
||||
configureEPWM(EPWM2_BASE);
|
||||
|
||||
//
|
||||
// Start the ePWM clock
|
||||
//
|
||||
SysCtl_enablePeripheral(SYSCTL_PERIPH_CLK_TBCLKSYNC);
|
||||
|
||||
//
|
||||
// Initialize the DMA & configure DMA channels 1 & 2
|
||||
//
|
||||
initializeDMA();
|
||||
configureDMAChannels();
|
||||
|
||||
//
|
||||
// Initialize results buffer
|
||||
//
|
||||
for(resultsIndex = 0; resultsIndex < RESULTS_BUFFER_SIZE; resultsIndex++)
|
||||
{
|
||||
myADC0DataBuffer[resultsIndex] = 0;
|
||||
myADC1DataBuffer[resultsIndex] = 0;
|
||||
}
|
||||
|
||||
//
|
||||
// Clearing all pending interrupt flags
|
||||
//
|
||||
DMA_clearTriggerFlag(DMA_CH1_BASE); // DMA channel 1
|
||||
DMA_clearTriggerFlag(DMA_CH2_BASE); // DMA channel 2
|
||||
HWREGH(myADC0_BASE + ADC_O_INTFLGCLR) = 0x3U; // ADCA
|
||||
HWREGH(myADC1_BASE + ADC_O_INTFLGCLR) = 0x3U; // ADCC
|
||||
EPWM_forceADCTriggerEventCountInit(EPWM2_BASE, EPWM_SOC_A); // EPWM2 SOCA
|
||||
EPWM_clearADCTriggerFlag(EPWM2_BASE, EPWM_SOC_A); // EPWM2 SOCA
|
||||
|
||||
//
|
||||
// Enable continuous operation by setting the last SOC to re-trigger
|
||||
// the first
|
||||
//
|
||||
ADC_setInterruptSOCTrigger(myADC0_BASE, ADC_SOC_NUMBER0, // ADCA
|
||||
ADC_INT_SOC_TRIGGER_ADCINT2);
|
||||
ADC_setInterruptSOCTrigger(myADC1_BASE, ADC_SOC_NUMBER0, // ADCC
|
||||
ADC_INT_SOC_TRIGGER_ADCINT2);
|
||||
|
||||
//
|
||||
// Enable global Interrupts and higher priority real-time debug events:
|
||||
//
|
||||
EINT; // Enable Global interrupt INTM
|
||||
ERTM; // Enable Global realtime interrupt DBGM
|
||||
|
||||
//
|
||||
// Start DMA
|
||||
//
|
||||
done = 0;
|
||||
DMA_startChannel(DMA_CH1_BASE);
|
||||
DMA_startChannel(DMA_CH2_BASE);
|
||||
|
||||
//
|
||||
// Finally, enable the SOCA trigger from ePWM. This will kick off
|
||||
// conversions at the next ePWM event.
|
||||
//
|
||||
EPWM_enableADCTrigger(EPWM2_BASE, EPWM_SOC_A);
|
||||
|
||||
//
|
||||
// Loop until the ISR signals the transfer is complete
|
||||
//
|
||||
while(done == 0)
|
||||
{
|
||||
__asm(" NOP");
|
||||
}
|
||||
ESTOP0;
|
||||
}
|
||||
|
||||
//
|
||||
// adcA1ISR - This is called after the very first conversion and will disable
|
||||
// the ePWM SOC to avoid re-triggering problems.
|
||||
//
|
||||
#pragma CODE_SECTION(adcA1ISR, ".TI.ramfunc");
|
||||
__interrupt void adcA1ISR(void)
|
||||
{
|
||||
//
|
||||
// Remove ePWM trigger
|
||||
//
|
||||
EPWM_disableADCTrigger(EPWM2_BASE, EPWM_SOC_A);
|
||||
|
||||
//
|
||||
// Disable this interrupt from happening again
|
||||
//
|
||||
Interrupt_disable(INT_ADCA1);
|
||||
|
||||
//
|
||||
// Acknowledge interrupt
|
||||
//
|
||||
Interrupt_clearACKGroup(INT_myADC0_1_INTERRUPT_ACK_GROUP);
|
||||
}
|
||||
|
||||
//
|
||||
// dmach1ISR - This is called at the end of the DMA transfer, the conversions
|
||||
// are stopped by removing the trigger of the first SOC from
|
||||
// the last.
|
||||
//
|
||||
#pragma CODE_SECTION(dmach1ISR, ".TI.ramfunc");
|
||||
__interrupt void dmach1ISR(void)
|
||||
{
|
||||
//
|
||||
// Stop the ADC by removing the trigger for SOC0
|
||||
//
|
||||
ADC_setInterruptSOCTrigger(myADC0_BASE, ADC_SOC_NUMBER0,
|
||||
ADC_INT_SOC_TRIGGER_NONE);
|
||||
ADC_setInterruptSOCTrigger(myADC1_BASE, ADC_SOC_NUMBER0,
|
||||
ADC_INT_SOC_TRIGGER_NONE);
|
||||
done = 1;
|
||||
|
||||
//
|
||||
// Acknowledge interrupt
|
||||
//
|
||||
Interrupt_clearACKGroup(INTERRUPT_ACK_GROUP7);
|
||||
}
|
||||
|
||||
//
|
||||
// configureEPWM - Set up the ePWM2 module so that the A output has a period
|
||||
// of 40us with a 50% duty. The SOCA signal is coincident with
|
||||
// the rising edge of this.
|
||||
//
|
||||
void configureEPWM(uint32_t epwmBase)
|
||||
{
|
||||
//
|
||||
// Make the timer count up with a period of 40us
|
||||
//
|
||||
HWREGH(epwmBase + EPWM_O_TBCTL) = 0x0000U;
|
||||
EPWM_setTimeBasePeriod(epwmBase, 4000U);
|
||||
|
||||
//
|
||||
// Set the A output on zero and reset on CMPA
|
||||
//
|
||||
EPWM_setActionQualifierAction(epwmBase, EPWM_AQ_OUTPUT_A,
|
||||
EPWM_AQ_OUTPUT_HIGH,
|
||||
EPWM_AQ_OUTPUT_ON_TIMEBASE_ZERO);
|
||||
EPWM_setActionQualifierAction(epwmBase, EPWM_AQ_OUTPUT_A,
|
||||
EPWM_AQ_OUTPUT_LOW,
|
||||
EPWM_AQ_OUTPUT_ON_TIMEBASE_UP_CMPA);
|
||||
|
||||
//
|
||||
// Set CMPA to 20us to get a 50% duty
|
||||
//
|
||||
EPWM_setCounterCompareValue(epwmBase, EPWM_COUNTER_COMPARE_A, 2000U);
|
||||
|
||||
//
|
||||
// Start ADC when timer equals zero (note: don't enable yet)
|
||||
//
|
||||
EPWM_setADCTriggerSource(epwmBase, EPWM_SOC_A, EPWM_SOC_TBCTR_ZERO);
|
||||
EPWM_setADCTriggerEventPrescale(epwmBase, EPWM_SOC_A, 1U);
|
||||
|
||||
//
|
||||
// Enable initialization of the SOCA event counter. Since we are
|
||||
// disabling the ETSEL.SOCAEN bit, we need a way to reset the SOCACNT.
|
||||
// Hence, enable the counter initialize control.
|
||||
//
|
||||
EPWM_enableADCTriggerEventCountInit(epwmBase, EPWM_SOC_A);
|
||||
}
|
||||
|
||||
//
|
||||
// initializeDMA - Initialize DMA through hard reset
|
||||
//
|
||||
void initializeDMA(void)
|
||||
{
|
||||
//
|
||||
// Perform a hard reset on DMA
|
||||
//
|
||||
DMA_initController();
|
||||
|
||||
//
|
||||
// Allow DMA to run free on emulation suspend
|
||||
//
|
||||
DMA_setEmulationMode(DMA_EMULATION_FREE_RUN);
|
||||
}
|
||||
|
||||
//
|
||||
// configureDMAChannels - Initialize DMA ch 1 to transfer ADCA results
|
||||
// and DMA ch 2 to transfer ADCB results
|
||||
//
|
||||
void configureDMAChannels(void)
|
||||
{
|
||||
//
|
||||
// DMA channel 1 set up for ADCA
|
||||
//
|
||||
DMA_configAddresses(DMA_CH1_BASE, (uint16_t *)&myADC0DataBuffer,
|
||||
(uint16_t *)ADCARESULT_BASE);
|
||||
|
||||
//
|
||||
// Perform enough 16-word bursts to fill the results buffer. Data will be
|
||||
// transferred 32 bits at a time hence the address steps below.
|
||||
//
|
||||
DMA_configBurst(DMA_CH1_BASE, 16, 2, 2);
|
||||
DMA_configTransfer(DMA_CH1_BASE, (RESULTS_BUFFER_SIZE >> 4), -14, 2);
|
||||
DMA_configMode(DMA_CH1_BASE, DMA_TRIGGER_ADCA2,
|
||||
(DMA_CFG_ONESHOT_DISABLE | DMA_CFG_CONTINUOUS_DISABLE |
|
||||
DMA_CFG_SIZE_32BIT));
|
||||
|
||||
DMA_enableTrigger(DMA_CH1_BASE);
|
||||
DMA_disableOverrunInterrupt(DMA_CH1_BASE);
|
||||
DMA_setInterruptMode(DMA_CH1_BASE, DMA_INT_AT_END);
|
||||
DMA_enableInterrupt(DMA_CH1_BASE);
|
||||
|
||||
//
|
||||
// DMA channel 2 set up for ADCC
|
||||
//
|
||||
DMA_configAddresses(DMA_CH2_BASE, (uint16_t *)&myADC1DataBuffer,
|
||||
(uint16_t *)ADCCRESULT_BASE);
|
||||
|
||||
//
|
||||
// Perform enough 16-word bursts to fill the results buffer. Data will be
|
||||
// transferred 32 bits at a time hence the address steps below.
|
||||
//
|
||||
DMA_configBurst(DMA_CH2_BASE, 16, 2, 2);
|
||||
DMA_configTransfer(DMA_CH2_BASE, (RESULTS_BUFFER_SIZE >> 4), -14, 2);
|
||||
DMA_configMode(DMA_CH2_BASE, DMA_TRIGGER_ADCA2,
|
||||
(DMA_CFG_ONESHOT_DISABLE | DMA_CFG_CONTINUOUS_DISABLE |
|
||||
DMA_CFG_SIZE_32BIT));
|
||||
|
||||
DMA_enableTrigger(DMA_CH2_BASE);
|
||||
DMA_disableOverrunInterrupt(DMA_CH2_BASE);
|
||||
DMA_setInterruptMode(DMA_CH2_BASE, DMA_INT_AT_END);
|
||||
DMA_enableInterrupt(DMA_CH2_BASE);
|
||||
}
|
||||
|
||||
//
|
||||
// End of file
|
||||
//
|
||||
@@ -0,0 +1,141 @@
|
||||
|
||||
/**
|
||||
* Import the modules used in this configuration.
|
||||
*/
|
||||
const adc = scripting.addModule("/driverlib/adc.js", {}, false);
|
||||
const adc1 = adc.addInstance();
|
||||
const adc2 = adc.addInstance();
|
||||
/**
|
||||
* Write custom configuration values to the imported modules.
|
||||
*/
|
||||
adc1.$name = "myADC0";
|
||||
adc1.registerInterrupts = ["1"];
|
||||
adc1.adcClockPrescaler = "ADC_CLK_DIV_4_0";
|
||||
adc1.interruptPulseMode = "ADC_PULSE_END_OF_CONV";
|
||||
adc1.enabledSOCs = ["ADC_SOC_NUMBER0","ADC_SOC_NUMBER1","ADC_SOC_NUMBER10","ADC_SOC_NUMBER11","ADC_SOC_NUMBER12","ADC_SOC_NUMBER13","ADC_SOC_NUMBER14","ADC_SOC_NUMBER15","ADC_SOC_NUMBER2","ADC_SOC_NUMBER3","ADC_SOC_NUMBER4","ADC_SOC_NUMBER5","ADC_SOC_NUMBER6","ADC_SOC_NUMBER7","ADC_SOC_NUMBER8","ADC_SOC_NUMBER9"];
|
||||
adc1.soc0SampleWindow = 15;
|
||||
adc1.soc1SampleWindow = 15;
|
||||
adc1.soc2SampleWindow = 15;
|
||||
adc1.soc3SampleWindow = 15;
|
||||
adc1.soc4SampleWindow = 15;
|
||||
adc1.soc5SampleWindow = 15;
|
||||
adc1.soc6SampleWindow = 15;
|
||||
adc1.soc7SampleWindow = 15;
|
||||
adc1.soc8SampleWindow = 15;
|
||||
adc1.soc9SampleWindow = 15;
|
||||
adc1.soc10SampleWindow = 15;
|
||||
adc1.soc11SampleWindow = 15;
|
||||
adc1.soc12SampleWindow = 15;
|
||||
adc1.soc13SampleWindow = 15;
|
||||
adc1.soc14SampleWindow = 15;
|
||||
adc1.soc15SampleWindow = 15;
|
||||
adc1.soc0Channel = "ADC_CH_ADCIN3";
|
||||
adc1.soc1Channel = "ADC_CH_ADCIN3";
|
||||
adc1.soc2Channel = "ADC_CH_ADCIN3";
|
||||
adc1.soc3Channel = "ADC_CH_ADCIN3";
|
||||
adc1.soc4Channel = "ADC_CH_ADCIN3";
|
||||
adc1.soc5Channel = "ADC_CH_ADCIN3";
|
||||
adc1.soc6Channel = "ADC_CH_ADCIN3";
|
||||
adc1.soc7Channel = "ADC_CH_ADCIN3";
|
||||
adc1.soc8Channel = "ADC_CH_ADCIN3";
|
||||
adc1.soc9Channel = "ADC_CH_ADCIN3";
|
||||
adc1.soc10Channel = "ADC_CH_ADCIN3";
|
||||
adc1.soc11Channel = "ADC_CH_ADCIN3";
|
||||
adc1.soc12Channel = "ADC_CH_ADCIN3";
|
||||
adc1.soc13Channel = "ADC_CH_ADCIN3";
|
||||
adc1.soc14Channel = "ADC_CH_ADCIN3";
|
||||
adc1.soc15Channel = "ADC_CH_ADCIN3";
|
||||
adc1.soc0Trigger = "ADC_TRIGGER_EPWM2_SOCA";
|
||||
adc1.soc0InterruptTrigger = "ADC_INT_SOC_TRIGGER_ADCINT1";
|
||||
adc1.soc1InterruptTrigger = "ADC_INT_SOC_TRIGGER_ADCINT1";
|
||||
adc1.soc2InterruptTrigger = "ADC_INT_SOC_TRIGGER_ADCINT1";
|
||||
adc1.soc3InterruptTrigger = "ADC_INT_SOC_TRIGGER_ADCINT1";
|
||||
adc1.soc4InterruptTrigger = "ADC_INT_SOC_TRIGGER_ADCINT1";
|
||||
adc1.soc5InterruptTrigger = "ADC_INT_SOC_TRIGGER_ADCINT1";
|
||||
adc1.soc6InterruptTrigger = "ADC_INT_SOC_TRIGGER_ADCINT1";
|
||||
adc1.soc7InterruptTrigger = "ADC_INT_SOC_TRIGGER_ADCINT1";
|
||||
adc1.soc8InterruptTrigger = "ADC_INT_SOC_TRIGGER_ADCINT1";
|
||||
adc1.soc9InterruptTrigger = "ADC_INT_SOC_TRIGGER_ADCINT1";
|
||||
adc1.soc10InterruptTrigger = "ADC_INT_SOC_TRIGGER_ADCINT1";
|
||||
adc1.soc11InterruptTrigger = "ADC_INT_SOC_TRIGGER_ADCINT1";
|
||||
adc1.soc12InterruptTrigger = "ADC_INT_SOC_TRIGGER_ADCINT1";
|
||||
adc1.soc13InterruptTrigger = "ADC_INT_SOC_TRIGGER_ADCINT1";
|
||||
adc1.soc14InterruptTrigger = "ADC_INT_SOC_TRIGGER_ADCINT1";
|
||||
adc1.soc15InterruptTrigger = "ADC_INT_SOC_TRIGGER_ADCINT1";
|
||||
adc1.enabledInts = ["ADC_INT_NUMBER1","ADC_INT_NUMBER2","ADC_INT_NUMBER3","ADC_INT_NUMBER4"];
|
||||
adc1.enableInterrupt1 = true;
|
||||
adc1.enableInterrupt2 = true;
|
||||
adc1.enableInterrupt1ContinuousMode = true;
|
||||
adc1.enableInterrupt2ContinuousMode = true;
|
||||
adc1.interrupt1SOCSource = "ADC_SOC_NUMBER0";
|
||||
adc1.interrupt2SOCSource = "ADC_SOC_NUMBER15";
|
||||
|
||||
adc1.adcInt1.enableInterrupt = true;
|
||||
adc1.adcInt1.interruptHandler = "adcA1ISR";
|
||||
adc1.adcSignalMode = "ADC_MODE_SINGLE_ENDED";
|
||||
adc1.adcResolutionMode = "ADC_RESOLUTION_12BIT";
|
||||
|
||||
adc2.$name = "myADC1";
|
||||
adc2.adcBase = "ADCC_BASE";
|
||||
adc2.adcClockPrescaler = "ADC_CLK_DIV_4_0";
|
||||
adc2.interruptPulseMode = "ADC_PULSE_END_OF_CONV";
|
||||
adc2.enabledSOCs = ["ADC_SOC_NUMBER0","ADC_SOC_NUMBER1","ADC_SOC_NUMBER10","ADC_SOC_NUMBER11","ADC_SOC_NUMBER12","ADC_SOC_NUMBER13","ADC_SOC_NUMBER14","ADC_SOC_NUMBER15","ADC_SOC_NUMBER2","ADC_SOC_NUMBER3","ADC_SOC_NUMBER4","ADC_SOC_NUMBER5","ADC_SOC_NUMBER6","ADC_SOC_NUMBER7","ADC_SOC_NUMBER8","ADC_SOC_NUMBER9"];
|
||||
adc2.soc0SampleWindow = 15;
|
||||
adc2.soc1SampleWindow = 15;
|
||||
adc2.soc2SampleWindow = 15;
|
||||
adc2.soc3SampleWindow = 15;
|
||||
adc2.soc4SampleWindow = 15;
|
||||
adc2.soc5SampleWindow = 15;
|
||||
adc2.soc6SampleWindow = 15;
|
||||
adc2.soc7SampleWindow = 15;
|
||||
adc2.soc8SampleWindow = 15;
|
||||
adc2.soc9SampleWindow = 15;
|
||||
adc2.soc10SampleWindow = 15;
|
||||
adc2.soc11SampleWindow = 15;
|
||||
adc2.soc12SampleWindow = 15;
|
||||
adc2.soc13SampleWindow = 15;
|
||||
adc2.soc14SampleWindow = 15;
|
||||
adc2.soc15SampleWindow = 15;
|
||||
adc2.soc0Channel = "ADC_CH_ADCIN3";
|
||||
adc2.soc1Channel = "ADC_CH_ADCIN3";
|
||||
adc2.soc2Channel = "ADC_CH_ADCIN3";
|
||||
adc2.soc3Channel = "ADC_CH_ADCIN3";
|
||||
adc2.soc4Channel = "ADC_CH_ADCIN3";
|
||||
adc2.soc5Channel = "ADC_CH_ADCIN3";
|
||||
adc2.soc6Channel = "ADC_CH_ADCIN3";
|
||||
adc2.soc7Channel = "ADC_CH_ADCIN3";
|
||||
adc2.soc8Channel = "ADC_CH_ADCIN3";
|
||||
adc2.soc9Channel = "ADC_CH_ADCIN3";
|
||||
adc2.soc10Channel = "ADC_CH_ADCIN3";
|
||||
adc2.soc11Channel = "ADC_CH_ADCIN3";
|
||||
adc2.soc12Channel = "ADC_CH_ADCIN3";
|
||||
adc2.soc13Channel = "ADC_CH_ADCIN3";
|
||||
adc2.soc14Channel = "ADC_CH_ADCIN3";
|
||||
adc2.soc15Channel = "ADC_CH_ADCIN3";
|
||||
adc2.soc0Trigger = "ADC_TRIGGER_EPWM2_SOCA";
|
||||
adc2.soc0InterruptTrigger = "ADC_INT_SOC_TRIGGER_ADCINT1";
|
||||
adc2.soc1InterruptTrigger = "ADC_INT_SOC_TRIGGER_ADCINT1";
|
||||
adc2.soc2InterruptTrigger = "ADC_INT_SOC_TRIGGER_ADCINT1";
|
||||
adc2.soc3InterruptTrigger = "ADC_INT_SOC_TRIGGER_ADCINT1";
|
||||
adc2.soc4InterruptTrigger = "ADC_INT_SOC_TRIGGER_ADCINT1";
|
||||
adc2.soc5InterruptTrigger = "ADC_INT_SOC_TRIGGER_ADCINT1";
|
||||
adc2.soc6InterruptTrigger = "ADC_INT_SOC_TRIGGER_ADCINT1";
|
||||
adc2.soc7InterruptTrigger = "ADC_INT_SOC_TRIGGER_ADCINT1";
|
||||
adc2.soc8InterruptTrigger = "ADC_INT_SOC_TRIGGER_ADCINT1";
|
||||
adc2.soc9InterruptTrigger = "ADC_INT_SOC_TRIGGER_ADCINT1";
|
||||
adc2.soc10InterruptTrigger = "ADC_INT_SOC_TRIGGER_ADCINT1";
|
||||
adc2.soc11InterruptTrigger = "ADC_INT_SOC_TRIGGER_ADCINT1";
|
||||
adc2.soc12InterruptTrigger = "ADC_INT_SOC_TRIGGER_ADCINT1";
|
||||
adc2.soc13InterruptTrigger = "ADC_INT_SOC_TRIGGER_ADCINT1";
|
||||
adc2.soc14InterruptTrigger = "ADC_INT_SOC_TRIGGER_ADCINT1";
|
||||
adc2.soc15InterruptTrigger = "ADC_INT_SOC_TRIGGER_ADCINT1";
|
||||
adc2.enabledInts = ["ADC_INT_NUMBER1","ADC_INT_NUMBER2","ADC_INT_NUMBER3","ADC_INT_NUMBER4"];
|
||||
adc2.enableInterrupt1 = true;
|
||||
adc2.enableInterrupt2 = true;
|
||||
adc2.interrupt1SOCSource = "ADC_SOC_NUMBER0";
|
||||
adc2.interrupt2SOCSource = "ADC_SOC_NUMBER15";
|
||||
adc2.enableInterrupt1ContinuousMode = true;
|
||||
adc2.enableInterrupt2ContinuousMode = true;
|
||||
adc2.adcSignalMode = "ADC_MODE_SINGLE_ENDED";
|
||||
adc2.adcResolutionMode = "ADC_RESOLUTION_12BIT";
|
||||
|
||||
@@ -0,0 +1,168 @@
|
||||
//###########################################################################
|
||||
//
|
||||
// FILE: adc_ex7_ppb_offset.c
|
||||
//
|
||||
// TITLE: ADC offset adjust using post-processing block
|
||||
//
|
||||
//! \addtogroup driver_example_list
|
||||
//! <h1> ADC PPB Offset (adc_ppb_offset)</h1>
|
||||
//!
|
||||
//! This example software triggers the ADC. Some SOCs have automatic offset
|
||||
//! adjustment applied by the post-processing block. After the program runs,
|
||||
//! the memory will contain ADC & post-processing block(PPB) results.
|
||||
//!
|
||||
//! \b External \b Connections \n
|
||||
//! - A2, C2 pins should be connected to signals to convert
|
||||
//!
|
||||
//! \b Watch \b Variables \n
|
||||
//! - \b myADC0Result \b: a digital representation of the voltage on pin A2
|
||||
//! - \b myADC0PPBResult \b : a digital representation of the voltage
|
||||
//! on pin A2, minus 100 LSBs of automatically added offset
|
||||
//! - \b myADC1Result \b: a digital representation of the voltage on pin C2
|
||||
//! - \b myADC1PPBResult \b : a digital representation of the voltage
|
||||
//! on pin C2 plus 100 LSBs of automatically added offset
|
||||
//
|
||||
//#############################################################################
|
||||
//
|
||||
//
|
||||
//
|
||||
// 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 "board.h"
|
||||
|
||||
//
|
||||
// Globals
|
||||
//
|
||||
uint16_t myADC0Result;
|
||||
uint16_t myADC0PPBResult;
|
||||
uint16_t myADC1Result;
|
||||
uint16_t myADC1PPBResult;
|
||||
|
||||
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();
|
||||
|
||||
//
|
||||
// Board Initialization
|
||||
// - Configure the ADCs and power them up
|
||||
// - Setup the ADCs for software conversions
|
||||
// - Setup PPB offset correction.
|
||||
// conversion on channel A will subtract 100.
|
||||
// conversion on channel C will add 100.
|
||||
// - Signal Mode : single-ended
|
||||
// - Conversion Resolution : 12-bit;
|
||||
//
|
||||
Board_init();
|
||||
|
||||
//
|
||||
// Enable global Interrupts and higher priority real-time debug events:
|
||||
//
|
||||
EINT; // Enable Global interrupt INTM
|
||||
ERTM; // Enable Global realtime interrupt DBGM
|
||||
|
||||
//
|
||||
// Take conversions indefinitely in loop
|
||||
//
|
||||
do
|
||||
{
|
||||
//
|
||||
// Convert, wait for completion, and store results.
|
||||
// Start conversions immediately via software, ADCA
|
||||
//
|
||||
ADC_forceSOC(myADC0_BASE, ADC_SOC_NUMBER0);
|
||||
ADC_forceSOC(myADC0_BASE, ADC_SOC_NUMBER1);
|
||||
|
||||
//
|
||||
// Wait for ADCA to complete, then acknowledge flag
|
||||
//
|
||||
while(ADC_getInterruptStatus(myADC0_BASE, ADC_INT_NUMBER1) == false);
|
||||
ADC_clearInterruptStatus(myADC0_BASE, ADC_INT_NUMBER1);
|
||||
|
||||
//
|
||||
// Start conversions immediately via software, ADCC
|
||||
//
|
||||
ADC_forceSOC(myADC1_BASE, ADC_SOC_NUMBER0);
|
||||
ADC_forceSOC(myADC1_BASE, ADC_SOC_NUMBER1);
|
||||
|
||||
//
|
||||
// Wait for ADCC to complete, then acknowledge flag
|
||||
//
|
||||
while(ADC_getInterruptStatus(myADC1_BASE, ADC_INT_NUMBER1) == false);
|
||||
ADC_clearInterruptStatus(myADC1_BASE, ADC_INT_NUMBER1);
|
||||
|
||||
//
|
||||
// Store results
|
||||
//
|
||||
myADC0Result = ADC_readResult(ADCARESULT_BASE, ADC_SOC_NUMBER0);
|
||||
myADC0PPBResult = ADC_readPPBResult(ADCARESULT_BASE, ADC_PPB_NUMBER1);
|
||||
myADC1Result = ADC_readResult(ADCCRESULT_BASE, ADC_SOC_NUMBER0);
|
||||
myADC1PPBResult = ADC_readPPBResult(ADCCRESULT_BASE, ADC_PPB_NUMBER1);
|
||||
|
||||
//
|
||||
// Software breakpoint, hit run again to get updated conversions
|
||||
//
|
||||
asm(" ESTOP0");
|
||||
}
|
||||
while(1);
|
||||
}
|
||||
|
||||
//
|
||||
// End of file
|
||||
//
|
||||
@@ -0,0 +1,46 @@
|
||||
|
||||
/**
|
||||
* Import the modules used in this configuration.
|
||||
*/
|
||||
const adc = scripting.addModule("/driverlib/adc.js", {}, false);
|
||||
const adc1 = adc.addInstance();
|
||||
const adc2 = adc.addInstance();
|
||||
|
||||
/**
|
||||
* Write custom configuration values to the imported modules.
|
||||
*/
|
||||
adc1.$name = "myADC0";
|
||||
adc1.adcClockPrescaler = "ADC_CLK_DIV_4_0";
|
||||
adc1.interruptPulseMode = "ADC_PULSE_END_OF_CONV";
|
||||
adc1.enabledSOCs = ["ADC_SOC_NUMBER0","ADC_SOC_NUMBER1"];
|
||||
adc1.soc0SampleWindow = 15;
|
||||
adc1.soc1SampleWindow = 15;
|
||||
adc1.soc0Channel = "ADC_CH_ADCIN2";
|
||||
adc1.soc1Channel = "ADC_CH_ADCIN2";
|
||||
adc1.enabledInts = ["ADC_INT_NUMBER1"];
|
||||
adc1.enableInterrupt1 = true;
|
||||
adc1.interrupt1SOCSource = "ADC_SOC_NUMBER1";
|
||||
adc1.enabledPPBs = ["ADC_PPB_NUMBER1"];
|
||||
adc1.ppb1SOCNumber = "ADC_SOC_NUMBER1";
|
||||
adc1.ppb1CalibrationOffset = 100;
|
||||
adc1.adcSignalMode = "ADC_MODE_SINGLE_ENDED";
|
||||
adc1.adcResolutionMode = "ADC_RESOLUTION_12BIT";
|
||||
|
||||
adc2.$name = "myADC1";
|
||||
adc2.adcBase = "ADCC_BASE";
|
||||
adc2.adcClockPrescaler = "ADC_CLK_DIV_4_0";
|
||||
adc2.interruptPulseMode = "ADC_PULSE_END_OF_CONV";
|
||||
adc2.enabledSOCs = ["ADC_SOC_NUMBER0","ADC_SOC_NUMBER1"];
|
||||
adc2.soc0SampleWindow = 15;
|
||||
adc2.soc1SampleWindow = 15;
|
||||
adc2.soc0Channel = "ADC_CH_ADCIN2";
|
||||
adc2.soc1Channel = "ADC_CH_ADCIN2";
|
||||
adc2.enabledInts = ["ADC_INT_NUMBER1"];
|
||||
adc2.enableInterrupt1 = true;
|
||||
adc2.interrupt1SOCSource = "ADC_SOC_NUMBER1";
|
||||
adc2.enabledPPBs = ["ADC_PPB_NUMBER1"];
|
||||
adc2.ppb1SOCNumber = "ADC_SOC_NUMBER1";
|
||||
adc2.ppb1CalibrationOffset = -100;
|
||||
adc2.adcSignalMode = "ADC_MODE_SINGLE_ENDED";
|
||||
adc2.adcResolutionMode = "ADC_RESOLUTION_12BIT";
|
||||
|
||||
@@ -0,0 +1,230 @@
|
||||
//###########################################################################
|
||||
//
|
||||
// FILE: adc_ex8_ppb_limits.c
|
||||
//
|
||||
// TITLE: ADC limits check using post-processing block.
|
||||
//
|
||||
//! \addtogroup driver_example_list
|
||||
//! <h1> ADC PPB Limits (adc_ppb_limits)</h1>
|
||||
//!
|
||||
//! This example sets up the ePWM to periodically trigger the ADC. If the
|
||||
//! results are outside of the defined range, the post-processing block
|
||||
//! will generate an interrupt.
|
||||
//!
|
||||
//! The default limits are 1000LSBs and 3000LSBs. With VREFHI set to 3.3V, the
|
||||
//! PPB will generate an interrupt if the input voltage goes above about
|
||||
//! 2.4V or below about 0.8V.
|
||||
//!
|
||||
//! \b External \b Connections \n
|
||||
//! - A0 should be connected to a signal to convert
|
||||
//!
|
||||
//! \b Watch \b Variables \n
|
||||
//! - None
|
||||
//!
|
||||
//
|
||||
//#############################################################################
|
||||
//
|
||||
//
|
||||
//
|
||||
// C2000Ware v5.04.00.00
|
||||
//
|
||||
// Copyright (C) 2024 Texas Instruments Incorporated - http://www.ti.com
|
||||
//
|
||||
// Redistribution and use in source and binary forms, with or without
|
||||
// modification, are permitted provided that the following conditions
|
||||
// are met:
|
||||
//
|
||||
// Redistributions of source code must retain the above copyright
|
||||
// notice, this list of conditions and the following disclaimer.
|
||||
//
|
||||
// Redistributions in binary form must reproduce the above copyright
|
||||
// notice, this list of conditions and the following disclaimer in the
|
||||
// documentation and/or other materials provided with the
|
||||
// distribution.
|
||||
//
|
||||
// Neither the name of Texas Instruments Incorporated nor the names of
|
||||
// its contributors may be used to endorse or promote products derived
|
||||
// from this software without specific prior written permission.
|
||||
//
|
||||
// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
|
||||
// "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
|
||||
// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
|
||||
// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
|
||||
// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
|
||||
// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
|
||||
// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
|
||||
// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
|
||||
// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
||||
// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
|
||||
// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
// $
|
||||
//#############################################################################
|
||||
//
|
||||
|
||||
//
|
||||
// Included Files
|
||||
//
|
||||
#include "driverlib.h"
|
||||
#include "device.h"
|
||||
#include "board.h"
|
||||
|
||||
//
|
||||
// Globals
|
||||
//
|
||||
uint32_t intStatus;
|
||||
//
|
||||
// Functional Prototypes
|
||||
//
|
||||
void configureEPWM(uint32_t epwmBase);
|
||||
|
||||
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();
|
||||
|
||||
//
|
||||
// Board Initialization
|
||||
// - Configure the ADC and power it up
|
||||
// - Setup the ADC for ePWM triggered conversions on channel 0
|
||||
// - Configure ADC post-processing limits
|
||||
// SOC0 will generate an interrupt if conversion is above or below limits
|
||||
// - Signal Mode : single-ended
|
||||
// - Conversion Resolution : 12-bit;
|
||||
//
|
||||
Board_init();
|
||||
|
||||
//
|
||||
// Configure the ePWM
|
||||
//
|
||||
configureEPWM(EPWM1_BASE);
|
||||
|
||||
//
|
||||
// Enable global Interrupts and higher priority real-time debug events:
|
||||
//
|
||||
EINT; // Enable Global interrupt INTM
|
||||
ERTM; // Enable Global realtime interrupt DBGM
|
||||
|
||||
//
|
||||
// Start ePWM:
|
||||
// Enable sync and clock to PWM
|
||||
//
|
||||
SysCtl_enablePeripheral(SYSCTL_PERIPH_CLK_TBCLKSYNC);
|
||||
|
||||
//
|
||||
// Enable SOCA trigger
|
||||
//
|
||||
EPWM_enableADCTrigger(EPWM1_BASE, EPWM_SOC_A);
|
||||
|
||||
//
|
||||
// Unfreeze epwm counter to count-up
|
||||
//
|
||||
EPWM_setTimeBaseCounterMode(EPWM1_BASE, EPWM_COUNTER_MODE_UP);
|
||||
|
||||
//
|
||||
// Take conversions indefinitely in loop
|
||||
//
|
||||
do
|
||||
{
|
||||
//
|
||||
// Wait while ePWM causes ADC conversions.
|
||||
// If the ADC conversions exceed the PPB limits, then an interrupt
|
||||
// will be generated. User can read ADC results either in idle loop
|
||||
// or ADCINT ISR as per application requirement.
|
||||
//
|
||||
}
|
||||
while(1);
|
||||
}
|
||||
|
||||
//
|
||||
// configureEPWM - Setup SOC and compare values for EPWM
|
||||
//
|
||||
void configureEPWM(uint32_t epwmBase)
|
||||
{
|
||||
//
|
||||
// Disable SOCA trigger
|
||||
//
|
||||
EPWM_disableADCTrigger(epwmBase, EPWM_SOC_A);
|
||||
|
||||
//
|
||||
// Trigger SOCA on CMPA up-count
|
||||
//
|
||||
EPWM_setADCTriggerSource(epwmBase, EPWM_SOC_A, EPWM_SOC_TBCTR_U_CMPA);
|
||||
|
||||
//
|
||||
// Generate pulse on 1st event
|
||||
//
|
||||
EPWM_setADCTriggerEventPrescale(epwmBase, EPWM_SOC_A, 1U);
|
||||
|
||||
//
|
||||
// Set compare A value to 2048 counts
|
||||
//
|
||||
EPWM_setCounterCompareValue(epwmBase, EPWM_COUNTER_COMPARE_A, 2048U);
|
||||
|
||||
//
|
||||
// Set period to 4096 counts
|
||||
//
|
||||
EPWM_setTimeBasePeriod(epwmBase, 4096U);
|
||||
|
||||
//
|
||||
// Freeze counter
|
||||
//
|
||||
EPWM_setTimeBaseCounterMode(epwmBase, EPWM_COUNTER_MODE_STOP_FREEZE);
|
||||
}
|
||||
|
||||
//
|
||||
// adcAEvtISR - ISR for ADCA PPB
|
||||
//
|
||||
interrupt void adcAEvtISR(void)
|
||||
{
|
||||
//
|
||||
// Warning, you are outside of PPB limits
|
||||
//
|
||||
intStatus = ADC_getPPBEventStatus(myADC0_BASE, ADC_PPB_NUMBER1);
|
||||
if((intStatus & ADC_EVT_TRIPHI) != 0U)
|
||||
{
|
||||
//
|
||||
// Voltage exceeded high limit
|
||||
//
|
||||
asm(" ESTOP0");
|
||||
|
||||
//
|
||||
// Clear the trip flag and continue
|
||||
//
|
||||
ADC_clearPPBEventStatus(myADC0_BASE, ADC_PPB_NUMBER1, ADC_EVT_TRIPHI);
|
||||
}
|
||||
if((intStatus & ADC_EVT_TRIPLO) != 0U)
|
||||
{
|
||||
//
|
||||
// Voltage exceeded low limit
|
||||
//
|
||||
asm(" ESTOP0");
|
||||
|
||||
//
|
||||
// Clear the trip flag and continue
|
||||
//
|
||||
ADC_clearPPBEventStatus(myADC0_BASE, ADC_PPB_NUMBER1, ADC_EVT_TRIPLO);
|
||||
}
|
||||
Interrupt_clearACKGroup(INT_myADC0_EVT_INTERRUPT_ACK_GROUP);
|
||||
}
|
||||
|
||||
//
|
||||
// End of file
|
||||
//
|
||||
@@ -0,0 +1,28 @@
|
||||
|
||||
/**
|
||||
* Import the modules used in this configuration.
|
||||
*/
|
||||
const adc = scripting.addModule("/driverlib/adc.js", {}, false);
|
||||
const adc1 = adc.addInstance();
|
||||
|
||||
/**
|
||||
* Write custom configuration values to the imported modules.
|
||||
*/
|
||||
adc1.$name = "myADC0";
|
||||
adc1.adcClockPrescaler = "ADC_CLK_DIV_4_0";
|
||||
adc1.interruptPulseMode = "ADC_PULSE_END_OF_CONV";
|
||||
adc1.enabledSOCs = ["ADC_SOC_NUMBER0"];
|
||||
adc1.soc0Trigger = "ADC_TRIGGER_EPWM1_SOCA";
|
||||
adc1.soc0SampleWindow = 15;
|
||||
adc1.enabledInts = ["ADC_INT_NUMBER1"];
|
||||
adc1.enableInterrupt1 = true;
|
||||
adc1.enabledPPBs = ["ADC_PPB_NUMBER1"];
|
||||
adc1.ppb1HighTripLimit = 3000;
|
||||
adc1.ppb1LowTripLimit = 1000;
|
||||
adc1.ppb1EventInterruptEnable = ["ADC_EVT_TRIPHI","ADC_EVT_TRIPLO"];
|
||||
adc1.registerInterrupts = ["5"];
|
||||
adc1.adcIntEvent.enableInterrupt = true;
|
||||
adc1.adcIntEvent.interruptHandler = "adcAEvtISR";
|
||||
adc1.adcSignalMode = "ADC_MODE_SINGLE_ENDED";
|
||||
adc1.adcResolutionMode = "ADC_RESOLUTION_12BIT";
|
||||
|
||||
@@ -0,0 +1,326 @@
|
||||
//###########################################################################
|
||||
//
|
||||
// FILE: adc_ex9_ppb_delay.c
|
||||
//
|
||||
// TITLE: ADC delay capture using Post-Processing block.
|
||||
//
|
||||
//! \addtogroup driver_example_list
|
||||
//! <h1> ADC PPB Delay Capture (adc_ppb_delay)</h1>
|
||||
//!
|
||||
//! This example demonstrates delay capture using the post-processing block.
|
||||
//!
|
||||
//! Two asynchronous ADC triggers are setup:\n
|
||||
//! - ePWM1, with period 2048, triggering SOC0 to convert on pin A0\n
|
||||
//! - ePWM2, with period 9999, triggering SOC1 to convert on pin A2\n
|
||||
//!
|
||||
//! Each conversion generates an ISR at the end of the conversion. In the
|
||||
//! ISR for SOC0, a conversion counter is incremented and the PPB is checked
|
||||
//! to determine if the sample was delayed.\n
|
||||
//!
|
||||
//! After the program runs, the memory will contain:\n
|
||||
//! - \b conversion \b: the sequence of conversions using SOC0 that were delayed
|
||||
//! - \b delay \b: the corresponding delay of each of the delayed conversions
|
||||
//!
|
||||
//
|
||||
//#############################################################################
|
||||
//
|
||||
//
|
||||
//
|
||||
// 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 "board.h"
|
||||
|
||||
//
|
||||
// Defines
|
||||
//
|
||||
#define DELAY_BUFFER_SIZE 30
|
||||
|
||||
//
|
||||
// Globals
|
||||
//
|
||||
uint32_t conversion_count;
|
||||
uint32_t conversion[DELAY_BUFFER_SIZE];
|
||||
uint16_t delay[DELAY_BUFFER_SIZE];
|
||||
volatile uint16_t delay_index;
|
||||
|
||||
//
|
||||
// Functional Prototypes
|
||||
//
|
||||
void configureEPWM(uint32_t epwmBase, uint16_t period);
|
||||
__interrupt void adcA1ISR(void);
|
||||
__interrupt void adcA2ISR(void);
|
||||
|
||||
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();
|
||||
|
||||
//
|
||||
// initialize program variables
|
||||
//
|
||||
conversion_count = 0;
|
||||
for(delay_index = 0; delay_index < DELAY_BUFFER_SIZE; delay_index++)
|
||||
{
|
||||
delay[delay_index] = 0;
|
||||
conversion[delay_index] = 0;
|
||||
}
|
||||
|
||||
//
|
||||
// Set up ADCs:
|
||||
// Signal Mode : single-ended
|
||||
// Conversion Resolution : 12-bit;
|
||||
// Configure ADC SOCs and PPB for delay capture
|
||||
// Register and enable the interrupts
|
||||
//
|
||||
Board_init();
|
||||
|
||||
//
|
||||
// Configure the ePWMs to have async. periods
|
||||
//
|
||||
configureEPWM(EPWM1_BASE, 2048);
|
||||
configureEPWM(EPWM2_BASE, 9999);
|
||||
|
||||
//
|
||||
// Enable global Interrupts and higher priority real-time debug events:
|
||||
//
|
||||
EINT; // Enable Global interrupt INTM
|
||||
ERTM; // Enable Global realtime interrupt DBGM
|
||||
|
||||
//
|
||||
// Start ePWM:
|
||||
// Enable sync and clock to PWM
|
||||
//
|
||||
SysCtl_enablePeripheral(SYSCTL_PERIPH_CLK_TBCLKSYNC);
|
||||
|
||||
//
|
||||
// Take conversions indefinitely in loop
|
||||
//
|
||||
do
|
||||
{
|
||||
delay_index = 0;
|
||||
|
||||
//
|
||||
// Enable SOCA triggers
|
||||
//
|
||||
EPWM_enableADCTrigger(EPWM1_BASE, EPWM_SOC_A);
|
||||
EPWM_enableADCTrigger(EPWM2_BASE, EPWM_SOC_A);
|
||||
|
||||
//
|
||||
// Unfreeze epwm counters to count-up
|
||||
//
|
||||
EPWM_setTimeBaseCounterMode(EPWM1_BASE, EPWM_COUNTER_MODE_UP);
|
||||
EPWM_setTimeBaseCounterMode(EPWM2_BASE, EPWM_COUNTER_MODE_UP);
|
||||
|
||||
//
|
||||
//wait for list of delayed conversions to fill via interrupts
|
||||
//
|
||||
while(DELAY_BUFFER_SIZE > delay_index){}
|
||||
|
||||
//
|
||||
// Stop ePWMs, disabling SOCAs and freezing the counters
|
||||
//
|
||||
EPWM_disableADCTrigger(EPWM1_BASE, EPWM_SOC_A);
|
||||
EPWM_disableADCTrigger(EPWM2_BASE, EPWM_SOC_A);
|
||||
EPWM_setTimeBaseCounterMode(EPWM1_BASE, EPWM_COUNTER_MODE_STOP_FREEZE);
|
||||
EPWM_setTimeBaseCounterMode(EPWM2_BASE, EPWM_COUNTER_MODE_STOP_FREEZE);
|
||||
|
||||
//
|
||||
//software breakpoint
|
||||
//
|
||||
ESTOP0;
|
||||
|
||||
//
|
||||
//conversion[] will show which conversions were delayed
|
||||
//delay[] will show how long each conversion was delayed
|
||||
//conversion_count will show total number of conversions
|
||||
//conversion_count - DELAY_BUFFER_SIZE is the number of samples
|
||||
// that started immediately without any delay
|
||||
//
|
||||
}
|
||||
while(1);
|
||||
}
|
||||
|
||||
//
|
||||
// configureEPWM - Setup SOC and compare values for EPWM and set specified
|
||||
// period.
|
||||
//
|
||||
void configureEPWM(uint32_t epwmBase, uint16_t period)
|
||||
{
|
||||
//
|
||||
// Disable SOCA trigger
|
||||
//
|
||||
EPWM_disableADCTrigger(epwmBase, EPWM_SOC_A);
|
||||
|
||||
//
|
||||
// Trigger SOCA on CMPA up-count
|
||||
//
|
||||
EPWM_setADCTriggerSource(epwmBase, EPWM_SOC_A, EPWM_SOC_TBCTR_U_CMPA);
|
||||
|
||||
//
|
||||
// Generate pulse on 1st event
|
||||
//
|
||||
EPWM_setADCTriggerEventPrescale(epwmBase, EPWM_SOC_A, 1U);
|
||||
|
||||
//
|
||||
// Set compare A value to approximately half the period
|
||||
//
|
||||
EPWM_setCounterCompareValue(epwmBase, EPWM_COUNTER_COMPARE_A, period/2);
|
||||
|
||||
//
|
||||
// Set period as specified
|
||||
//
|
||||
EPWM_setTimeBasePeriod(epwmBase, period);
|
||||
|
||||
//
|
||||
// Set the local ePWM module clock divider to /1
|
||||
//
|
||||
EPWM_setClockPrescaler(epwmBase,
|
||||
EPWM_CLOCK_DIVIDER_1,
|
||||
EPWM_HSCLOCK_DIVIDER_1);
|
||||
|
||||
//
|
||||
// Freeze counter
|
||||
//
|
||||
EPWM_setTimeBaseCounterMode(epwmBase, EPWM_COUNTER_MODE_STOP_FREEZE);
|
||||
}
|
||||
|
||||
//
|
||||
// ADC A Interrupt 1 ISR - check for delayed conversions
|
||||
//
|
||||
__interrupt void adcA1ISR(void)
|
||||
{
|
||||
//
|
||||
//DLYSTAMP will read 2 if the sample was not delayed
|
||||
//
|
||||
if(2 < ADC_getPPBDelayTimeStamp(ADCA_BASE, ADC_PPB_NUMBER1))
|
||||
{
|
||||
//
|
||||
//if DLYSTAMP > 2, then the sample was delayed by (DLYSTAMP - 2)
|
||||
//cycles (SYSCLK)
|
||||
//
|
||||
conversion[delay_index] = conversion_count;
|
||||
delay[delay_index] = ADC_getPPBDelayTimeStamp(ADCA_BASE, ADC_PPB_NUMBER1) - 2;
|
||||
delay_index++;
|
||||
|
||||
//
|
||||
//corrective action(s) for delayed sample can occur here
|
||||
//...
|
||||
//
|
||||
}
|
||||
|
||||
//
|
||||
//read ADC sample here
|
||||
//...
|
||||
//
|
||||
|
||||
conversion_count++;
|
||||
|
||||
//
|
||||
// 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);
|
||||
}
|
||||
|
||||
//
|
||||
// ADC A Interrupt 2 ISR - dummy ISR. Occurs async. to ADC A ISR 1.
|
||||
//
|
||||
__interrupt void adcA2ISR(void)
|
||||
{
|
||||
//
|
||||
//read ADC sample here
|
||||
//...
|
||||
//
|
||||
|
||||
//
|
||||
// Clear the interrupt flag
|
||||
//
|
||||
ADC_clearInterruptStatus(ADCA_BASE, ADC_INT_NUMBER2);
|
||||
|
||||
//
|
||||
// Check if overflow has occurred
|
||||
//
|
||||
if(true == ADC_getInterruptOverflowStatus(ADCA_BASE, ADC_INT_NUMBER2))
|
||||
{
|
||||
ADC_clearInterruptOverflowStatus(ADCA_BASE, ADC_INT_NUMBER2);
|
||||
ADC_clearInterruptStatus(ADCA_BASE, ADC_INT_NUMBER2);
|
||||
}
|
||||
|
||||
//
|
||||
// Acknowledge the interrupt
|
||||
//
|
||||
Interrupt_clearACKGroup(INTERRUPT_ACK_GROUP10);
|
||||
}
|
||||
|
||||
//
|
||||
// End of file
|
||||
//
|
||||
@@ -0,0 +1,42 @@
|
||||
|
||||
/**
|
||||
* Import the modules used in this configuration.
|
||||
*/
|
||||
const adc = scripting.addModule("/driverlib/adc.js", {}, false);
|
||||
const adc1 = adc.addInstance();
|
||||
|
||||
/**
|
||||
* Write custom configuration values to the imported modules.
|
||||
*/
|
||||
adc1.$name = "myADC0";
|
||||
adc1.adcBase = "ADCA_BASE";
|
||||
|
||||
adc1.adcClockPrescaler = "ADC_CLK_DIV_4_0";
|
||||
adc1.interruptPulseMode = "ADC_PULSE_END_OF_CONV";
|
||||
|
||||
adc1.adcSignalMode = "ADC_MODE_SINGLE_ENDED";
|
||||
adc1.adcResolutionMode = "ADC_RESOLUTION_12BIT";
|
||||
|
||||
adc1.enabledSOCs = ["ADC_SOC_NUMBER0","ADC_SOC_NUMBER1"];
|
||||
|
||||
adc1.soc0Trigger = "ADC_TRIGGER_EPWM1_SOCA";
|
||||
adc1.soc1Trigger = "ADC_TRIGGER_EPWM2_SOCA";
|
||||
|
||||
adc1.soc0Channel = "ADC_CH_ADCIN0";
|
||||
adc1.soc1Channel = "ADC_CH_ADCIN2";
|
||||
|
||||
adc1.soc0SampleWindow = 15;
|
||||
adc1.soc1SampleWindow = 15;
|
||||
|
||||
adc1.enabledInts = ["ADC_INT_NUMBER1","ADC_INT_NUMBER2"];
|
||||
adc1.enableInterrupt1 = true;
|
||||
adc1.enableInterrupt2 = true;
|
||||
adc1.interrupt1SOCSource = "ADC_SOC_NUMBER0";
|
||||
adc1.interrupt2SOCSource = "ADC_SOC_NUMBER1";
|
||||
adc1.enabledPPBs = ["ADC_PPB_NUMBER1"];
|
||||
adc1.registerInterrupts = ["1","2"];
|
||||
adc1.adcInt1.enableInterrupt = true;
|
||||
adc1.adcInt1.interruptHandler = "adcA1ISR";
|
||||
adc1.adcInt2.interruptHandler = "adcA2ISR";
|
||||
adc1.adcInt2.enableInterrupt = true;
|
||||
|
||||
@@ -0,0 +1,40 @@
|
||||
<projectSpec>
|
||||
<project
|
||||
name="bgcrc_ex1_cpuinterrupt"
|
||||
device="TMS320F28388D"
|
||||
cgtVersion="22.6.1.LTS"
|
||||
products="sysconfig;C2000WARE"
|
||||
outputFormat="ELF"
|
||||
launchWizard="False"
|
||||
linkerCommandFile=""
|
||||
enableSysConfigTool="true"
|
||||
sysConfigBuildOptions="--product ${C2000WARE_ROOT}/.metadata/sdk.json --device F2838x --package 337bga --part F2838x_337bga"
|
||||
postBuildStep="
|
||||
echo "========= Build of the CLB simulation has moved to the CLB Tool. Click the '?' icon by the _Generate CLB Simulation File_ enable for more details (located in the Global Parameters of the Tile Design SysConfig module) ============="
|
||||
;if ${GENERATE_DIAGRAM} == 1 ${NODE_TOOL} "${C2000WARE_ROOT}/utilities/clb_tool/clb_syscfg/dot_file_libraries/clbDotUtility.js" "${C2000WARE_ROOT}/utilities/clb_tool/clb_syscfg/" "${BuildDirectory}/syscfg" "${BuildDirectory}/syscfg/clb.dot"
|
||||
;if ${GENERATE_DIAGRAM} == 1 mkdir "${BuildDirectory}/diagrams"
|
||||
;if ${GENERATE_DIAGRAM} == 1 ${NODE_TOOL} "${C2000WARE_ROOT}/driverlib/.meta/generate_diagrams.js" "${C2000WARE_ROOT}" "${BuildDirectory}/diagrams" "${BuildDirectory}/syscfg"
|
||||
"
|
||||
>
|
||||
<configuration name="CPU1_RAM" compilerBuildOptions= "--opt_level=off -I${C2000WARE_ROOT} -I${PROJECT_ROOT}/device -I${C2000WARE_DLIB_ROOT} -v28 -ml -mt --cla_support=cla2 --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="../bgcrc_ex1_cpuinterrupt.c" targetDirectory="" />
|
||||
<file action="copy" path="../bgcrc_ex1_cpuinterrupt.syscfg" targetDirectory="" />
|
||||
</project>
|
||||
</projectSpec>
|
||||
+40
@@ -0,0 +1,40 @@
|
||||
<projectSpec>
|
||||
<project
|
||||
name="bgcrc_ex2_cpubgcrc_basic"
|
||||
device="TMS320F28388D"
|
||||
cgtVersion="22.6.1.LTS"
|
||||
products="sysconfig;C2000WARE"
|
||||
outputFormat="ELF"
|
||||
launchWizard="False"
|
||||
linkerCommandFile=""
|
||||
enableSysConfigTool="true"
|
||||
sysConfigBuildOptions="--product ${C2000WARE_ROOT}/.metadata/sdk.json --device F2838x --package 337bga --part F2838x_337bga"
|
||||
postBuildStep="
|
||||
echo "========= Build of the CLB simulation has moved to the CLB Tool. Click the '?' icon by the _Generate CLB Simulation File_ enable for more details (located in the Global Parameters of the Tile Design SysConfig module) ============="
|
||||
;if ${GENERATE_DIAGRAM} == 1 ${NODE_TOOL} "${C2000WARE_ROOT}/utilities/clb_tool/clb_syscfg/dot_file_libraries/clbDotUtility.js" "${C2000WARE_ROOT}/utilities/clb_tool/clb_syscfg/" "${BuildDirectory}/syscfg" "${BuildDirectory}/syscfg/clb.dot"
|
||||
;if ${GENERATE_DIAGRAM} == 1 mkdir "${BuildDirectory}/diagrams"
|
||||
;if ${GENERATE_DIAGRAM} == 1 ${NODE_TOOL} "${C2000WARE_ROOT}/driverlib/.meta/generate_diagrams.js" "${C2000WARE_ROOT}" "${BuildDirectory}/diagrams" "${BuildDirectory}/syscfg"
|
||||
"
|
||||
>
|
||||
<configuration name="CPU1_RAM" compilerBuildOptions= "--opt_level=off -I${C2000WARE_ROOT} -I${PROJECT_ROOT}/device -I${C2000WARE_DLIB_ROOT} -v28 -ml -mt --cla_support=cla2 --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="../bgcrc_ex2_cpubgcrc_basic.c" targetDirectory="" />
|
||||
<file action="copy" path="../../empty_projects/c2000.syscfg" targetDirectory="" />
|
||||
</project>
|
||||
</projectSpec>
|
||||
+40
@@ -0,0 +1,40 @@
|
||||
<projectSpec>
|
||||
<project
|
||||
name="bgcrc_ex3_clabgcrc_crcmode"
|
||||
device="TMS320F28388D"
|
||||
cgtVersion="22.6.1.LTS"
|
||||
products="sysconfig;C2000WARE"
|
||||
outputFormat="ELF"
|
||||
launchWizard="False"
|
||||
linkerCommandFile=""
|
||||
enableSysConfigTool="true"
|
||||
sysConfigBuildOptions="--product ${C2000WARE_ROOT}/.metadata/sdk.json --device F2838x --package 337bga --part F2838x_337bga"
|
||||
postBuildStep="
|
||||
echo "========= Build of the CLB simulation has moved to the CLB Tool. Click the '?' icon by the _Generate CLB Simulation File_ enable for more details (located in the Global Parameters of the Tile Design SysConfig module) ============="
|
||||
;if ${GENERATE_DIAGRAM} == 1 ${NODE_TOOL} "${C2000WARE_ROOT}/utilities/clb_tool/clb_syscfg/dot_file_libraries/clbDotUtility.js" "${C2000WARE_ROOT}/utilities/clb_tool/clb_syscfg/" "${BuildDirectory}/syscfg" "${BuildDirectory}/syscfg/clb.dot"
|
||||
;if ${GENERATE_DIAGRAM} == 1 mkdir "${BuildDirectory}/diagrams"
|
||||
;if ${GENERATE_DIAGRAM} == 1 ${NODE_TOOL} "${C2000WARE_ROOT}/driverlib/.meta/generate_diagrams.js" "${C2000WARE_ROOT}" "${BuildDirectory}/diagrams" "${BuildDirectory}/syscfg"
|
||||
"
|
||||
>
|
||||
<configuration name="CPU1_RAM" compilerBuildOptions= "--opt_level=off -I${C2000WARE_ROOT} -I${PROJECT_ROOT}/device -I${C2000WARE_DLIB_ROOT} -v28 -ml -mt --cla_support=cla2 --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="../bgcrc_ex3_clabgcrc_crcmode.c" targetDirectory="" />
|
||||
<file action="copy" path="../../empty_projects/c2000.syscfg" targetDirectory="" />
|
||||
</project>
|
||||
</projectSpec>
|
||||
+40
@@ -0,0 +1,40 @@
|
||||
<projectSpec>
|
||||
<project
|
||||
name="bgcrc_ex4_clabgcrc_scrubmode"
|
||||
device="TMS320F28388D"
|
||||
cgtVersion="22.6.1.LTS"
|
||||
products="sysconfig;C2000WARE"
|
||||
outputFormat="ELF"
|
||||
launchWizard="False"
|
||||
linkerCommandFile=""
|
||||
enableSysConfigTool="true"
|
||||
sysConfigBuildOptions="--product ${C2000WARE_ROOT}/.metadata/sdk.json --device F2838x --package 337bga --part F2838x_337bga"
|
||||
postBuildStep="
|
||||
echo "========= Build of the CLB simulation has moved to the CLB Tool. Click the '?' icon by the _Generate CLB Simulation File_ enable for more details (located in the Global Parameters of the Tile Design SysConfig module) ============="
|
||||
;if ${GENERATE_DIAGRAM} == 1 ${NODE_TOOL} "${C2000WARE_ROOT}/utilities/clb_tool/clb_syscfg/dot_file_libraries/clbDotUtility.js" "${C2000WARE_ROOT}/utilities/clb_tool/clb_syscfg/" "${BuildDirectory}/syscfg" "${BuildDirectory}/syscfg/clb.dot"
|
||||
;if ${GENERATE_DIAGRAM} == 1 mkdir "${BuildDirectory}/diagrams"
|
||||
;if ${GENERATE_DIAGRAM} == 1 ${NODE_TOOL} "${C2000WARE_ROOT}/driverlib/.meta/generate_diagrams.js" "${C2000WARE_ROOT}" "${BuildDirectory}/diagrams" "${BuildDirectory}/syscfg"
|
||||
"
|
||||
>
|
||||
<configuration name="CPU1_RAM" compilerBuildOptions= "--opt_level=off -I${C2000WARE_ROOT} -I${PROJECT_ROOT}/device -I${C2000WARE_DLIB_ROOT} -v28 -ml -mt --cla_support=cla2 --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="../bgcrc_ex4_clabgcrc_scrubmode.c" targetDirectory="" />
|
||||
<file action="copy" path="../../empty_projects/c2000.syscfg" targetDirectory="" />
|
||||
</project>
|
||||
</projectSpec>
|
||||
@@ -0,0 +1,185 @@
|
||||
//#############################################################################
|
||||
//
|
||||
// FILE: bgcrc_ex1_cpuinterrupt.c
|
||||
//
|
||||
// TITLE: Background CRC computation with interrupt.
|
||||
//
|
||||
//! \addtogroup driver_example_list
|
||||
//! <h1> BGCRC CPU Interrupt Example </h1>
|
||||
//!
|
||||
//! This example demonstrates how to configure and trigger BGCRC from the CPU.
|
||||
//! BGCRC module is configured for 1 KB of GS0 RAM which is programmed with a
|
||||
//! known data. The pre-computed CRC value is used as the golden CRC value.
|
||||
//! Interrupt is generated once the computation is done and checks if no error
|
||||
//! flags are raised
|
||||
//! Calculation uses the 32-bit polynomial 0x04C11DB7 and seed value 0x00000000.
|
||||
//!
|
||||
//! \b External \b Connections \n
|
||||
//! - None.
|
||||
//!
|
||||
//! \b Watch \b Variables \n
|
||||
//! - pass - This should be 1.
|
||||
//! - runStatus - BGCRC running status. This will be BGCRC_ACTIVE if the module
|
||||
//! is running, BGCRC_IDLE if the module is idle
|
||||
//!
|
||||
//
|
||||
//#############################################################################
|
||||
//
|
||||
// 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 "board.h"
|
||||
|
||||
//
|
||||
// Globals
|
||||
//
|
||||
bool pass = false;
|
||||
|
||||
volatile uint32_t currentAddress = 0x0000;
|
||||
volatile bool runStatus = false;
|
||||
|
||||
#pragma DATA_SECTION(test_data_gs0, "ramgs0")
|
||||
#pragma DATA_ALIGN(test_data_gs0, 0x80)
|
||||
uint32_t test_data_gs0[myBGCRC0_BLOCKSIZE/4];
|
||||
const void *td_gs0 = test_data_gs0;
|
||||
//
|
||||
// Function Prototypes
|
||||
//
|
||||
__interrupt void bgcrcISR(void);
|
||||
|
||||
//
|
||||
// Main
|
||||
//
|
||||
void main(void)
|
||||
{
|
||||
int i;
|
||||
|
||||
//
|
||||
// Initialize device clock and peripherals
|
||||
//
|
||||
Device_init();
|
||||
|
||||
//
|
||||
// Initialize GPIO and configure the GPIO pin as a push-pull output
|
||||
//
|
||||
Device_initGPIO();
|
||||
|
||||
//
|
||||
// Disable global interrupts.
|
||||
//
|
||||
DINT;
|
||||
|
||||
//
|
||||
// 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();
|
||||
IER = 0x0000;
|
||||
IFR = 0x0000;
|
||||
//
|
||||
// Enable Global Interrupt (INTM) and realtime interrupt (DBGM)
|
||||
//
|
||||
EINT;
|
||||
ERTM;
|
||||
|
||||
//
|
||||
// Fill RAMGS0 with known data
|
||||
//
|
||||
for(i = 0; i < (myBGCRC0_BLOCKSIZE/4); i++)
|
||||
{
|
||||
test_data_gs0[i] = 0x1000 + i;
|
||||
}
|
||||
//
|
||||
// Set runStatus to true
|
||||
//
|
||||
runStatus = true;
|
||||
|
||||
//initialize sysconfig options
|
||||
//
|
||||
Board_init();
|
||||
|
||||
//
|
||||
// Loop Forever
|
||||
//
|
||||
while(1)
|
||||
{
|
||||
//
|
||||
// Check the run status and current address of the CRC calculation.
|
||||
//
|
||||
runStatus = BGCRC_getRunStatus(myBGCRC0_BASE);
|
||||
currentAddress = BGCRC_getCurrentAddress(myBGCRC0_BASE);
|
||||
}
|
||||
}
|
||||
|
||||
//
|
||||
// bgcrcISR - DONE interrupt from BGCRC.
|
||||
//
|
||||
__interrupt void
|
||||
bgcrcISR(void)
|
||||
{
|
||||
//
|
||||
// Check the status of the CRC calculation and set the global pass
|
||||
// variable. Check if no error flags are set.
|
||||
//
|
||||
if(BGCRC_getInterruptStatus(myBGCRC0_BASE) == (BGCRC_GLOBAL_INT | BGCRC_TEST_DONE))
|
||||
{
|
||||
pass = true;
|
||||
}
|
||||
|
||||
//
|
||||
// Clear the BGCRC interrupt flags.
|
||||
//
|
||||
BGCRC_clearInterruptStatus(myBGCRC0_BASE, (BGCRC_GLOBAL_INT | BGCRC_TEST_DONE | BGCRC_ALL_ERROR_FLAGS));
|
||||
|
||||
//
|
||||
// Acknowledge the PIE interrupt.
|
||||
//
|
||||
|
||||
Interrupt_clearACKGroup(INT_myBGCRC0_INTERRUPT_ACK_GROUP);
|
||||
|
||||
}
|
||||
|
||||
//
|
||||
// End of File
|
||||
//
|
||||
@@ -0,0 +1,29 @@
|
||||
/**
|
||||
* These arguments were used when this file was generated. They will be automatically applied on subsequent loads
|
||||
* via the GUI or CLI. Run CLI with '--help' for additional information on how to override these arguments.
|
||||
* @cliArgs --device "F28002x" --package "80QFP" --part "F28002x_80QFP" --product "C2000WARE@4.00.00.00"
|
||||
* @versions {"tool":"1.11.0+2225"}
|
||||
*/
|
||||
|
||||
/**
|
||||
* Import the modules used in this configuration.
|
||||
*/
|
||||
const bgcrc = scripting.addModule("/driverlib/bgcrc.js", {}, false);
|
||||
const bgcrc1 = bgcrc.addInstance();
|
||||
|
||||
/**
|
||||
* Write custom configuration values to the imported modules.
|
||||
*/
|
||||
bgcrc1.$name = "myBGCRC0";
|
||||
bgcrc1.goldVal = "0x8474ca32";
|
||||
bgcrc1.seedVal = "0";
|
||||
bgcrc1.intFlags = ["BGCRC_TEST_DONE"];
|
||||
bgcrc1.emuCtl = "BGCRC_EMUCTRL_FREE";
|
||||
bgcrc1.nmiMode = "BGCRC_NMI_DISABLE";
|
||||
bgcrc1.blockSize = "1024";
|
||||
bgcrc1.registerInterrupts = true;
|
||||
bgcrc1.startBGCRC = true;
|
||||
bgcrc1.startAddrInputMode = "VARIABLE";
|
||||
bgcrc1.startAddrVariable = "td_gs0";
|
||||
bgcrc1.bgcrcInt.enableInterrupt = true;
|
||||
bgcrc1.bgcrcInt.interruptHandler = "bgcrcISR";
|
||||
@@ -0,0 +1,471 @@
|
||||
//#############################################################################
|
||||
//
|
||||
// FILE: bgcrc_ex2_basic_cpubgcrc.c
|
||||
//
|
||||
// TITLE: Background CRC computation with interrupt.
|
||||
//
|
||||
//! \addtogroup driver_example_list
|
||||
//! <h1> BGCRC Example with Watchdog and Lock</h1>
|
||||
//!
|
||||
//! This example demonstrates how to configure and trigger BGCRC from the CPU.
|
||||
//! It also showcases how to configure the CRC watchdog and lock the
|
||||
//! registers after configuring the module. The watchdog is used as a diagnostic
|
||||
//! to check memory test completion within the expected time window. An error
|
||||
//! signal is generated if the test does not complete in the specified time
|
||||
//! window.
|
||||
//!
|
||||
//! The module is configured for 1kB of GS0 RAM which is programmed with
|
||||
//! random data. The golden CRC value for comparison is computed using software
|
||||
//! method. Interrupt is generated once the computation is done and checks if no
|
||||
//! error flags are raised. The NMI is enabled and is triggered if an error is
|
||||
//! detected.
|
||||
//!
|
||||
//! \b External \b Connections \n
|
||||
//! - None.
|
||||
//!
|
||||
//! \b Watch \b Variables \n
|
||||
//! - pass
|
||||
//! - bgcrcDone
|
||||
//!
|
||||
//
|
||||
//#############################################################################
|
||||
//
|
||||
// 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 <stdlib.h>
|
||||
#include <time.h>
|
||||
|
||||
//
|
||||
// Defines and globals
|
||||
//
|
||||
#define DATA_SIZE 256 // Total size = 256 * 4 = 1kB
|
||||
#define CRC_FAIL 0 // Set this as 1 to make the CRC check fail
|
||||
|
||||
uint32_t POLYNOMIAL = (uint32_t)0x04C11DB7;
|
||||
uint32_t crc32;
|
||||
uint32_t seed;
|
||||
uint32_t byteSwappedData;
|
||||
|
||||
volatile bool bgcrcDone = false;
|
||||
volatile bool bgcrcError = false;
|
||||
volatile uint32_t BgcrcNmiStatus = 0;
|
||||
volatile uint32_t intStatus =0;
|
||||
volatile bool Bgcrc_fail = false;
|
||||
volatile bool Bgcrc_uncorr_err = false;
|
||||
volatile bool Bgcrc_corr_err = false;
|
||||
volatile bool Bgcrc_Wd_underflow = false;
|
||||
volatile bool Bgcrc_Wd_overflow = false;
|
||||
volatile bool error_status_pin_diagnostic_failed = false;
|
||||
|
||||
bool pass = false;
|
||||
|
||||
#pragma DATA_SECTION(data,"ramgs0")
|
||||
#pragma DATA_ALIGN(data, 0x80)
|
||||
volatile uint32_t data[DATA_SIZE] = {0};
|
||||
|
||||
//
|
||||
// Function Prototypes
|
||||
//
|
||||
void dataInit(void);
|
||||
void bgcrcInit(void);
|
||||
void delay(uint32_t i);
|
||||
__interrupt void CPUbgcrcIsr(void);
|
||||
__interrupt void NMIbgcrcIsr(void);
|
||||
|
||||
//
|
||||
// Main
|
||||
//
|
||||
void main(void)
|
||||
{
|
||||
//
|
||||
// Initialize device clock and peripherals
|
||||
//
|
||||
Device_init();
|
||||
|
||||
//
|
||||
// Initialize GPIO and configure the GPIO pin as a push-pull output
|
||||
//
|
||||
Device_initGPIO();
|
||||
|
||||
//
|
||||
// Disable global interrupts.
|
||||
//
|
||||
DINT;
|
||||
|
||||
//
|
||||
// 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();
|
||||
IER = 0x0000;
|
||||
IFR = 0x0000;
|
||||
|
||||
//
|
||||
// Map the ISRs of the BGCRC interrupt and NMI.
|
||||
//
|
||||
Interrupt_register(INT_CPUCRC, CPUbgcrcIsr);
|
||||
Interrupt_register(INT_NMI, NMIbgcrcIsr);
|
||||
|
||||
//
|
||||
// Enable the BGCRC interrupt
|
||||
//
|
||||
Interrupt_enable(INT_CPUCRC);
|
||||
Interrupt_clearACKGroup(INTERRUPT_ACK_GROUP12);
|
||||
|
||||
//
|
||||
// Enable NMI
|
||||
//
|
||||
Interrupt_enable(INT_NMI);
|
||||
SysCtl_enableNMIGlobalInterrupt();
|
||||
SysCtl_setNMIWatchdogPeriod(0xFFFFU);
|
||||
|
||||
//
|
||||
// Enable Global Interrupt (INTM) and realtime interrupt (DBGM)
|
||||
//
|
||||
EINT;
|
||||
ERTM;
|
||||
|
||||
//
|
||||
// Initialize the data with random numbers
|
||||
//
|
||||
dataInit();
|
||||
|
||||
//
|
||||
// Initialize the BGCRC module
|
||||
//
|
||||
bgcrcInit();
|
||||
|
||||
delay(2000); // Expecting the BGCRC completion in this time
|
||||
|
||||
if(error_status_pin_diagnostic_failed == true )
|
||||
{
|
||||
//
|
||||
// Something is wrong with the error status pin
|
||||
// Need to reset the system
|
||||
//
|
||||
}
|
||||
|
||||
if((bgcrcDone == true) && (bgcrcError == false))
|
||||
{
|
||||
if((intStatus == BGCRC_TEST_DONE))
|
||||
{
|
||||
pass = true;
|
||||
}
|
||||
}
|
||||
|
||||
while(1);
|
||||
}
|
||||
|
||||
//
|
||||
// Fill the buffer with random data and compute CRC using SW method
|
||||
//
|
||||
void dataInit()
|
||||
{
|
||||
uint32_t tseed;
|
||||
uint32_t i,j;
|
||||
|
||||
//
|
||||
// Initialize the random number generator
|
||||
//
|
||||
tseed = time(NULL);
|
||||
srand(tseed);
|
||||
srand(rand());
|
||||
|
||||
seed = rand();
|
||||
seed = (uint32_t)(seed <<16) | rand(); // Initialize with seed
|
||||
crc32 = seed;
|
||||
|
||||
//
|
||||
// Initialize the Data_Buffer with 32 bit random data
|
||||
//
|
||||
for(i = 0; i < DATA_SIZE; i++)
|
||||
{
|
||||
data[i] = rand();
|
||||
data[i] = (data[i] << 16) | rand();
|
||||
}
|
||||
|
||||
//
|
||||
// Compute the Software CRC for validation
|
||||
//
|
||||
for(i = 0; i < DATA_SIZE; i++)
|
||||
{
|
||||
byteSwappedData = (((data[i] & (uint32_t)0x000000FFU) << 24) |
|
||||
((data[i] & (uint32_t)0x0000FF00U) << 8) |
|
||||
((data[i] & (uint32_t)0x00FF0000U) >> 8) |
|
||||
((data[i] & (uint32_t)0xFF000000U) >> 24)
|
||||
);
|
||||
|
||||
crc32 = byteSwappedData ^ crc32;
|
||||
|
||||
for(j = 0; j < 32; j++)
|
||||
{
|
||||
if(crc32 & (uint32_t)0x80000000U)
|
||||
{
|
||||
crc32 = ( (crc32 << 1) ^ POLYNOMIAL);
|
||||
}
|
||||
else
|
||||
{
|
||||
crc32 = (crc32 << 1);
|
||||
}
|
||||
crc32 = crc32 & (uint32_t)0xFFFFFFFFU;
|
||||
}
|
||||
}
|
||||
|
||||
#if CRC_FAIL == 1 // To make the BGCRC to fail
|
||||
crc32 = 0xdeadbeef; //This is to test the error NMIs and Pins
|
||||
#endif
|
||||
}
|
||||
|
||||
//
|
||||
// Init routine for BGCRC module
|
||||
//
|
||||
void bgcrcInit()
|
||||
{
|
||||
//
|
||||
// Unlock the BGCRC configuration in case it is locked CFG-1
|
||||
//
|
||||
BGCRC_unlockRegister(BGCRC_CPU_BASE, BGCRC_REG_CTRL1 |
|
||||
BGCRC_REG_WD_CFG |
|
||||
BGCRC_REG_INTEN |
|
||||
BGCRC_REG_SEED);
|
||||
|
||||
//
|
||||
// Unlock the BGCRC configuration in case it is locked CFG-2
|
||||
//
|
||||
BGCRC_unlockRegister(BGCRC_CPU_BASE, BGCRC_REG_EN |
|
||||
BGCRC_REG_CTRL2 |
|
||||
BGCRC_REG_START_ADDR |
|
||||
BGCRC_REG_GOLDEN |
|
||||
BGCRC_REG_WD_MIN |
|
||||
BGCRC_REG_WD_MAX);
|
||||
//
|
||||
// Enable NMI and set the emulation mode as soft.
|
||||
// The CRC module and the watchdog stops immediately on debug suspend
|
||||
//
|
||||
BGCRC_setConfig(BGCRC_CPU_BASE, BGCRC_NMI_ENABLE, BGCRC_EMUCTRL_SOFT);
|
||||
|
||||
//
|
||||
// Configure the CRC Watchdog
|
||||
// Watchdog window - Min : DATA_SIZE, Max : DATA_SIZE + 1
|
||||
//
|
||||
BGCRC_enableWatchdog(BGCRC_CPU_BASE);
|
||||
BGCRC_setWatchdogWindow(BGCRC_CPU_BASE, DATA_SIZE, DATA_SIZE + 1);
|
||||
|
||||
//
|
||||
// Configure the region
|
||||
//
|
||||
BGCRC_setRegion(BGCRC_CPU_BASE, (uint32_t)data,
|
||||
BGCRC_SIZE_KBYTES(1), BGCRC_CRC_MODE);
|
||||
|
||||
//
|
||||
// Set the seed value same as used in SW computation
|
||||
//
|
||||
BGCRC_setSeedValue(BGCRC_CPU_BASE, seed);
|
||||
|
||||
//
|
||||
// Initialize the golden value with previously computed CRC using software
|
||||
//
|
||||
BGCRC_setGoldenCRCValue(BGCRC_CPU_BASE, crc32);
|
||||
|
||||
//
|
||||
// Enable interrupts
|
||||
// No need to enable the NMIs as all the NMIs are enabled by default
|
||||
//
|
||||
BGCRC_enableInterrupt(BGCRC_CPU_BASE, BGCRC_TEST_DONE |
|
||||
BGCRC_CRC_FAIL |
|
||||
BGCRC_UNCORR_ERR |
|
||||
BGCRC_CORR_ERR |
|
||||
BGCRC_WD_UNDERFLOW |
|
||||
BGCRC_WD_OVERFLOW);
|
||||
|
||||
//
|
||||
// Lock Register configuration for CFG1
|
||||
//
|
||||
BGCRC_lockRegister(BGCRC_CPU_BASE, BGCRC_REG_CTRL1 |
|
||||
BGCRC_REG_WD_CFG |
|
||||
BGCRC_REG_INTEN |
|
||||
BGCRC_REG_SEED);
|
||||
|
||||
|
||||
//
|
||||
// Commit Register Lock for CFG1
|
||||
//
|
||||
BGCRC_commitRegisterLock(BGCRC_CPU_BASE, BGCRC_REG_CTRL1 |
|
||||
BGCRC_REG_WD_CFG |
|
||||
BGCRC_REG_INTEN |
|
||||
BGCRC_REG_SEED);
|
||||
|
||||
BGCRC_start(BGCRC_CPU_BASE);
|
||||
|
||||
//
|
||||
// Lock Register configuration for CFG2
|
||||
//
|
||||
BGCRC_lockRegister(BGCRC_CPU_BASE, BGCRC_REG_EN |
|
||||
BGCRC_REG_CTRL2 |
|
||||
BGCRC_REG_START_ADDR |
|
||||
BGCRC_REG_GOLDEN |
|
||||
BGCRC_REG_WD_MIN |
|
||||
BGCRC_REG_WD_MAX);
|
||||
}
|
||||
|
||||
//
|
||||
// CPUbgcrcIsr - DONE interrupt from BGCRC.
|
||||
//
|
||||
__interrupt void CPUbgcrcIsr(void)
|
||||
{
|
||||
bgcrcDone = true;
|
||||
|
||||
//
|
||||
// Read the interrupt status
|
||||
//
|
||||
intStatus= BGCRC_getInterruptStatus(BGCRC_CPU_BASE);
|
||||
intStatus &= ~BGCRC_GLOBAL_INT;
|
||||
|
||||
//
|
||||
// Clear interrupt status
|
||||
//
|
||||
BGCRC_clearInterruptStatus(BGCRC_CPU_BASE, BGCRC_GLOBAL_INT |
|
||||
BGCRC_TEST_DONE |
|
||||
BGCRC_ALL_ERROR_FLAGS);
|
||||
|
||||
Interrupt_clearACKGroup(INTERRUPT_ACK_GROUP12);
|
||||
}
|
||||
|
||||
//
|
||||
// NMIbgcrcIsr - NMI ISR
|
||||
//
|
||||
__interrupt void NMIbgcrcIsr(void)
|
||||
{
|
||||
uint32_t timeout = 20;
|
||||
BgcrcNmiStatus = BGCRC_getNMIStatus(BGCRC_CPU_BASE);
|
||||
|
||||
//
|
||||
// Safety diagnostic check
|
||||
//
|
||||
if(!SysCtl_isErrorTriggered())
|
||||
{
|
||||
//
|
||||
// If due to some fault the ERROR STS couldn't be triggered, force
|
||||
// the error status pin so that external host get to know the error
|
||||
//
|
||||
while((SysCtl_getErrorPinStatus() == 0) && (timeout > 0))
|
||||
{
|
||||
SysCtl_forceError();
|
||||
timeout--;
|
||||
}
|
||||
|
||||
if (timeout == 0)
|
||||
{
|
||||
//
|
||||
// Something is wrong with the error status pin
|
||||
//
|
||||
error_status_pin_diagnostic_failed = true;
|
||||
}
|
||||
}
|
||||
|
||||
if((BgcrcNmiStatus & BGCRC_CRC_FAIL) == BGCRC_CRC_FAIL)
|
||||
{
|
||||
//
|
||||
// CRC Fail NMI
|
||||
//
|
||||
Bgcrc_fail = true;
|
||||
BGCRC_clearNMIStatus(BGCRC_CPU_BASE, BGCRC_CRC_FAIL);
|
||||
}
|
||||
|
||||
if( (BgcrcNmiStatus&BGCRC_UNCORR_ERR) == BGCRC_UNCORR_ERR )
|
||||
{
|
||||
//
|
||||
// Uncorrectable Error NMI
|
||||
//
|
||||
Bgcrc_uncorr_err = true;
|
||||
BGCRC_clearNMIStatus(BGCRC_CPU_BASE, BGCRC_UNCORR_ERR);
|
||||
}
|
||||
|
||||
if(BgcrcNmiStatus&BGCRC_CORR_ERR == BGCRC_CORR_ERR)
|
||||
{
|
||||
//
|
||||
// Correctable Error NMI
|
||||
//
|
||||
Bgcrc_corr_err = true;
|
||||
BGCRC_clearNMIStatus(BGCRC_CPU_BASE, BGCRC_CORR_ERR);
|
||||
}
|
||||
|
||||
if(BgcrcNmiStatus&BGCRC_WD_UNDERFLOW == BGCRC_WD_UNDERFLOW)
|
||||
{
|
||||
//
|
||||
// Watchdog Underflow Error NMI
|
||||
//
|
||||
Bgcrc_Wd_underflow = true;
|
||||
BGCRC_clearNMIStatus(BGCRC_CPU_BASE, BGCRC_WD_UNDERFLOW);
|
||||
}
|
||||
|
||||
if(BgcrcNmiStatus&BGCRC_WD_OVERFLOW == BGCRC_WD_OVERFLOW)
|
||||
{
|
||||
//
|
||||
// Watchdog Overflow Error NMI
|
||||
//
|
||||
Bgcrc_Wd_overflow = true;
|
||||
BGCRC_clearNMIStatus(BGCRC_CPU_BASE, BGCRC_WD_OVERFLOW);
|
||||
}
|
||||
|
||||
SysCtl_clearAllNMIFlags();
|
||||
bgcrcError = true;
|
||||
}
|
||||
|
||||
//
|
||||
// Delay function
|
||||
//
|
||||
void delay(uint32_t i)
|
||||
{
|
||||
uint32_t j =i;
|
||||
while(j > 0)
|
||||
{
|
||||
j--;
|
||||
}
|
||||
}
|
||||
|
||||
//
|
||||
// End of File
|
||||
//
|
||||
@@ -0,0 +1,456 @@
|
||||
//#############################################################################
|
||||
//
|
||||
// FILE: bgcrc_ex2_basic_cpubgcrc.c
|
||||
//
|
||||
// TITLE: Background CRC computation with interrupt.
|
||||
//
|
||||
//! \addtogroup driver_example_list
|
||||
//! <h1> CLA-BGCRC Example in CRC mode </h1>
|
||||
//!
|
||||
//! This example demonstrates how to configure and trigger CLABGCRC from the CPU.
|
||||
//! It also showcases how to configure the CRC watchdog and lock the registers
|
||||
//! after configuring the module. The watchdog is used as a diagnostic to check
|
||||
//! memory test completion within the expected time window. An error signal is
|
||||
//! generated if the test does not complete in the specified time window.
|
||||
//!
|
||||
//! The module is configured for 1kB of CLA ROM memory. The golden CRC value
|
||||
//! for comparison is computed using software method. Interrupt is generated
|
||||
//! once the computation is done and checks if no error flags are raised. The
|
||||
//! NMI is enabled and is triggered if an error is detected.
|
||||
//!
|
||||
//! \b External \b Connections \n
|
||||
//! - None.
|
||||
//!
|
||||
//! \b Watch \b Variables \n
|
||||
//! - pass
|
||||
//! - bgcrcDone
|
||||
//!
|
||||
//
|
||||
//#############################################################################
|
||||
//
|
||||
// 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 <stdlib.h>
|
||||
#include <time.h>
|
||||
|
||||
//
|
||||
// Defines and globals
|
||||
//
|
||||
#define DATA_SIZE 256 // Total size = 256 * 4 = 1kB
|
||||
#define CLA_ROM_ADDR 0x1001080 // CPU view
|
||||
#define CLA_ROM_ADDR_BGCRC_VIEW 0xF080 // BGCRC_CLA view
|
||||
|
||||
uint32_t POLYNOMIAL = (uint32_t)0x04C11DB7;
|
||||
uint32_t crc32;
|
||||
uint32_t seed;
|
||||
uint32_t byteSwappedData;
|
||||
|
||||
volatile bool bgcrcDone = false;
|
||||
volatile bool bgcrcError = false;
|
||||
volatile uint32_t BgcrcNmiStatus = 0;
|
||||
volatile uint32_t intStatus =0;
|
||||
volatile bool Bgcrc_fail = false;
|
||||
volatile bool Bgcrc_uncorr_err = false;
|
||||
volatile bool Bgcrc_corr_err = false;
|
||||
volatile bool Bgcrc_Wd_underflow = false;
|
||||
volatile bool Bgcrc_Wd_overflow = false;
|
||||
volatile bool error_status_pin_diagnostic_failed = false;
|
||||
|
||||
bool pass = false;
|
||||
|
||||
//
|
||||
// Function Prototypes
|
||||
//
|
||||
void computeCRC_software(void);
|
||||
void bgcrcInit(void);
|
||||
void delay(uint32_t i);
|
||||
__interrupt void CLAbgcrcIsr(void);
|
||||
__interrupt void NMIbgcrcIsr(void);
|
||||
|
||||
//
|
||||
// Main
|
||||
//
|
||||
void main(void)
|
||||
{
|
||||
//
|
||||
// Initialize device clock and peripherals
|
||||
//
|
||||
Device_init();
|
||||
|
||||
//
|
||||
// Initialize GPIO and configure the GPIO pin as a push-pull output
|
||||
//
|
||||
Device_initGPIO();
|
||||
|
||||
//
|
||||
// Disable global interrupts.
|
||||
//
|
||||
DINT;
|
||||
|
||||
//
|
||||
// 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();
|
||||
IER = 0x0000;
|
||||
IFR = 0x0000;
|
||||
|
||||
//
|
||||
// Map the ISRs of the BGCRC interrupt and NMI.
|
||||
//
|
||||
Interrupt_register(INT_CLA1CRC, CLAbgcrcIsr);
|
||||
Interrupt_register(INT_NMI, NMIbgcrcIsr);
|
||||
|
||||
//
|
||||
// Enable the CRC interrupt in the PIE
|
||||
//
|
||||
Interrupt_enable(INT_CLA1CRC);
|
||||
Interrupt_clearACKGroup(INTERRUPT_ACK_GROUP12);
|
||||
|
||||
//
|
||||
// Enable NMI
|
||||
//
|
||||
Interrupt_enable(INT_NMI);
|
||||
SysCtl_clearAllNMIFlags();
|
||||
SysCtl_enableNMIGlobalInterrupt();
|
||||
SysCtl_setNMIWatchdogPeriod(0xFFFFU);
|
||||
|
||||
//
|
||||
// Enable Global Interrupt (INTM) and realtime interrupt (DBGM)
|
||||
//
|
||||
EINT;
|
||||
ERTM;
|
||||
|
||||
//
|
||||
// Initialize the data with random numbers
|
||||
//
|
||||
computeCRC_software();
|
||||
|
||||
//
|
||||
// Initialize the BGCRC module
|
||||
//
|
||||
bgcrcInit();
|
||||
|
||||
delay(2000); // Expecting the BGCRC completion in this time
|
||||
|
||||
if(error_status_pin_diagnostic_failed == true )
|
||||
{
|
||||
//
|
||||
// Something is wrong with the error status pin
|
||||
// Need to reset the system
|
||||
//
|
||||
}
|
||||
|
||||
if((bgcrcDone == true) && (bgcrcError == false))
|
||||
{
|
||||
if((intStatus == BGCRC_TEST_DONE))
|
||||
{
|
||||
pass = true;
|
||||
}
|
||||
}
|
||||
|
||||
while(1);
|
||||
}
|
||||
|
||||
//
|
||||
// SW method for computing CRC of CLA ROM memory data
|
||||
//
|
||||
void computeCRC_software()
|
||||
{
|
||||
uint32_t tseed;
|
||||
uint32_t i,j;
|
||||
|
||||
//
|
||||
// Initialize the random number generator
|
||||
//
|
||||
tseed = time(NULL);
|
||||
srand(tseed);
|
||||
srand(rand());
|
||||
|
||||
seed = rand();
|
||||
seed = (uint32_t)(seed << 16) | rand(); // Initialize with seed
|
||||
crc32 = seed;
|
||||
|
||||
//
|
||||
// Compute the Software CRC for validation
|
||||
//
|
||||
uint32_t current_data;
|
||||
for(i = 0; i < DATA_SIZE; i++)
|
||||
{
|
||||
current_data = HWREG(CLA_ROM_ADDR + 2 * i);
|
||||
|
||||
byteSwappedData = (((current_data & (uint32_t)0x000000FFU) << 24) |
|
||||
((current_data & (uint32_t)0x0000FF00U) << 8) |
|
||||
((current_data & (uint32_t)0x00FF0000U) >> 8) |
|
||||
((current_data & (uint32_t)0xFF000000U) >> 24)
|
||||
);
|
||||
|
||||
crc32 = byteSwappedData ^ crc32;
|
||||
|
||||
for(j = 0; j < 32; j++)
|
||||
{
|
||||
if(crc32 & (uint32_t)0x80000000U)
|
||||
{
|
||||
crc32 = ((crc32 << 1) ^ POLYNOMIAL);
|
||||
}
|
||||
else
|
||||
{
|
||||
crc32 = (crc32 << 1);
|
||||
}
|
||||
crc32 = crc32 & (uint32_t)0xFFFFFFFFU;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
//
|
||||
// Init routine for BGCRC module
|
||||
//
|
||||
void bgcrcInit()
|
||||
{
|
||||
//
|
||||
// Unlock the BGCRC configuration in case it is locked CFG-1
|
||||
//
|
||||
BGCRC_unlockRegister(BGCRC_CLA1_BASE, BGCRC_REG_CTRL1 |
|
||||
BGCRC_REG_WD_CFG |
|
||||
BGCRC_REG_INTEN |
|
||||
BGCRC_REG_SEED);
|
||||
|
||||
//
|
||||
// Unlock the BGCRC configuration in case it is locked CFG-2
|
||||
//
|
||||
BGCRC_unlockRegister(BGCRC_CLA1_BASE, BGCRC_REG_EN |
|
||||
BGCRC_REG_CTRL2 |
|
||||
BGCRC_REG_START_ADDR |
|
||||
BGCRC_REG_GOLDEN |
|
||||
BGCRC_REG_WD_MIN |
|
||||
BGCRC_REG_WD_MAX);
|
||||
//
|
||||
// Enable NMI and set the emulation mode as soft.
|
||||
// The CRC module and the watchdog stops immediately on debug suspend
|
||||
//
|
||||
BGCRC_setConfig(BGCRC_CLA1_BASE, BGCRC_NMI_ENABLE, BGCRC_EMUCTRL_SOFT);
|
||||
|
||||
//
|
||||
// Configure the CRC Watchdog
|
||||
// Watchdog window - Min : DATA_SIZE, Max : DATA_SIZE + 100
|
||||
//
|
||||
BGCRC_enableWatchdog(BGCRC_CLA1_BASE);
|
||||
BGCRC_setWatchdogWindow(BGCRC_CLA1_BASE, DATA_SIZE, DATA_SIZE + 100);
|
||||
|
||||
//
|
||||
// Configure the region
|
||||
//
|
||||
BGCRC_setRegion(BGCRC_CLA1_BASE, CLA_ROM_ADDR_BGCRC_VIEW,
|
||||
BGCRC_SIZE_KBYTES(1), BGCRC_CRC_MODE);
|
||||
|
||||
//
|
||||
// Set the seed value same as used in SW computation
|
||||
//
|
||||
BGCRC_setSeedValue(BGCRC_CLA1_BASE, seed);
|
||||
|
||||
//
|
||||
// Initialize the golden value with previously computed CRC using software
|
||||
//
|
||||
BGCRC_setGoldenCRCValue(BGCRC_CLA1_BASE, crc32);
|
||||
|
||||
//
|
||||
// Enable interrupts
|
||||
//
|
||||
BGCRC_enableInterrupt(BGCRC_CLA1_BASE, BGCRC_TEST_DONE |
|
||||
BGCRC_CRC_FAIL |
|
||||
BGCRC_UNCORR_ERR |
|
||||
BGCRC_CORR_ERR |
|
||||
BGCRC_WD_UNDERFLOW |
|
||||
BGCRC_WD_OVERFLOW);
|
||||
|
||||
//
|
||||
// Lock Register configuration for CFG1
|
||||
//
|
||||
BGCRC_lockRegister(BGCRC_CLA1_BASE, BGCRC_REG_CTRL1 |
|
||||
BGCRC_REG_WD_CFG |
|
||||
BGCRC_REG_INTEN |
|
||||
BGCRC_REG_SEED);
|
||||
|
||||
|
||||
//
|
||||
// Commit Register Lock for CFG1
|
||||
//
|
||||
BGCRC_commitRegisterLock(BGCRC_CLA1_BASE, BGCRC_REG_CTRL1 |
|
||||
BGCRC_REG_WD_CFG |
|
||||
BGCRC_REG_INTEN |
|
||||
BGCRC_REG_SEED);
|
||||
|
||||
BGCRC_start(BGCRC_CLA1_BASE);
|
||||
|
||||
//
|
||||
// Lock Register configuration for CFG2
|
||||
//
|
||||
BGCRC_lockRegister(BGCRC_CLA1_BASE, BGCRC_REG_EN |
|
||||
BGCRC_REG_CTRL2 |
|
||||
BGCRC_REG_START_ADDR |
|
||||
BGCRC_REG_GOLDEN |
|
||||
BGCRC_REG_WD_MIN |
|
||||
BGCRC_REG_WD_MAX);
|
||||
}
|
||||
|
||||
//
|
||||
// CLAbgcrcIsr - DONE interrupt from BGCRC.
|
||||
//
|
||||
__interrupt void CLAbgcrcIsr(void)
|
||||
{
|
||||
bgcrcDone = true;
|
||||
|
||||
//
|
||||
// Read the interrupt status
|
||||
//
|
||||
intStatus= BGCRC_getInterruptStatus(BGCRC_CLA1_BASE);
|
||||
intStatus &= ~BGCRC_GLOBAL_INT;
|
||||
|
||||
//
|
||||
// Clear interrupt status
|
||||
//
|
||||
BGCRC_clearInterruptStatus(BGCRC_CLA1_BASE, BGCRC_GLOBAL_INT |
|
||||
BGCRC_TEST_DONE |
|
||||
BGCRC_ALL_ERROR_FLAGS);
|
||||
|
||||
Interrupt_clearACKGroup(INTERRUPT_ACK_GROUP12);
|
||||
}
|
||||
|
||||
//
|
||||
// NMIbgcrcIsr - NMI ISR
|
||||
//
|
||||
__interrupt void NMIbgcrcIsr(void)
|
||||
{
|
||||
uint32_t timeout = 20;
|
||||
BgcrcNmiStatus = BGCRC_getNMIStatus(BGCRC_CLA1_BASE);
|
||||
|
||||
//
|
||||
// Safety diagnostic check
|
||||
//
|
||||
if(!SysCtl_isErrorTriggered())
|
||||
{
|
||||
//
|
||||
// If due to some fault the ERROR STS couldn't be triggered, force
|
||||
// the error status pin so that external host get to know the error
|
||||
//
|
||||
while((SysCtl_getErrorPinStatus() == 0) && (timeout > 0))
|
||||
{
|
||||
SysCtl_forceError();
|
||||
timeout--;
|
||||
}
|
||||
|
||||
if (timeout == 0)
|
||||
{
|
||||
//
|
||||
// Something is wrong with the error status pin
|
||||
//
|
||||
error_status_pin_diagnostic_failed = true;
|
||||
}
|
||||
}
|
||||
|
||||
if((BgcrcNmiStatus & BGCRC_CRC_FAIL) == BGCRC_CRC_FAIL)
|
||||
{
|
||||
//
|
||||
// CRC Fail NMI
|
||||
//
|
||||
Bgcrc_fail = true;
|
||||
BGCRC_clearNMIStatus(BGCRC_CLA1_BASE, BGCRC_CRC_FAIL);
|
||||
}
|
||||
|
||||
if((BgcrcNmiStatus & BGCRC_UNCORR_ERR) == BGCRC_UNCORR_ERR )
|
||||
{
|
||||
//
|
||||
// Uncorrectable Error NMI
|
||||
//
|
||||
Bgcrc_uncorr_err = true;
|
||||
BGCRC_clearNMIStatus(BGCRC_CLA1_BASE, BGCRC_UNCORR_ERR);
|
||||
}
|
||||
|
||||
if((BgcrcNmiStatus & BGCRC_CORR_ERR) == BGCRC_CORR_ERR)
|
||||
{
|
||||
//
|
||||
// Correctable Error NMI
|
||||
//
|
||||
Bgcrc_corr_err = true;
|
||||
BGCRC_clearNMIStatus(BGCRC_CLA1_BASE, BGCRC_CORR_ERR);
|
||||
}
|
||||
|
||||
if((BgcrcNmiStatus & BGCRC_WD_UNDERFLOW) == BGCRC_WD_UNDERFLOW)
|
||||
{
|
||||
//
|
||||
// Watchdog Underflow Error NMI
|
||||
//
|
||||
Bgcrc_Wd_underflow = true;
|
||||
BGCRC_clearNMIStatus(BGCRC_CLA1_BASE, BGCRC_WD_UNDERFLOW);
|
||||
}
|
||||
|
||||
if((BgcrcNmiStatus & BGCRC_WD_OVERFLOW) == BGCRC_WD_OVERFLOW)
|
||||
{
|
||||
//
|
||||
// Watchdog Overflow Error NMI
|
||||
//
|
||||
Bgcrc_Wd_overflow = true;
|
||||
BGCRC_clearNMIStatus(BGCRC_CLA1_BASE, BGCRC_WD_OVERFLOW);
|
||||
}
|
||||
|
||||
SysCtl_clearAllNMIFlags();
|
||||
bgcrcError = true;
|
||||
}
|
||||
|
||||
//
|
||||
// Delay function
|
||||
//
|
||||
void delay(uint32_t i)
|
||||
{
|
||||
uint32_t j =i;
|
||||
while(j > 0)
|
||||
{
|
||||
j--;
|
||||
}
|
||||
}
|
||||
|
||||
//
|
||||
// End of File
|
||||
//
|
||||
@@ -0,0 +1,384 @@
|
||||
//#############################################################################
|
||||
//
|
||||
// FILE: bgcrc_ex3_basic_clabgcrc.c
|
||||
//
|
||||
// TITLE: Background CRC computation with interrupt.
|
||||
//
|
||||
//! \addtogroup driver_example_list
|
||||
//! <h1> CLA-BGCRC Example in Scrub Mode </h1>
|
||||
//!
|
||||
//! This example demonstrates how to configure and trigger CLA-BGCRC in Scrub
|
||||
//! mode. In Scrub mode, CRC of data is not compared with the golden CRC. Error
|
||||
//! check is done using the ECC/Parity logic.
|
||||
//! It also showcases how to configure the CRC watchdog and lock the
|
||||
//! registers after configuring the module. The watchdog is used as a diagnostic
|
||||
//! to check memory test completion within the expected time window. An error
|
||||
//! signal is generated if the test does not complete in the specified time
|
||||
//! window.
|
||||
//!
|
||||
//! The module is configured for 256 bytes of CLA ROM memory. Interrupt is
|
||||
//! generated once the computation is done and checks if no error flags are
|
||||
//! raised. The NMI is enabled and is triggered if an error is detected.
|
||||
//!
|
||||
//! \b External \b Connections \n
|
||||
//! - None.
|
||||
//!
|
||||
//! \b Watch \b Variables \n
|
||||
//! - pass
|
||||
//! - bgcrcDone
|
||||
//!
|
||||
//
|
||||
//#############################################################################
|
||||
//
|
||||
// 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 and globals
|
||||
//
|
||||
#define DATA_SIZE 64 // 256 Bytes
|
||||
#define CLA_ROM_ADDR 0x1001080 // CPU view
|
||||
#define CLA_ROM_ADDR_BGCRC_VIEW 0xF080 // BGCRC_CLA view
|
||||
|
||||
volatile bool bgcrcDone = false;
|
||||
volatile bool bgcrcError = false;
|
||||
volatile uint32_t BgcrcNmiStatus = 0;
|
||||
volatile uint32_t intStatus =0;
|
||||
volatile bool Bgcrc_fail = false;
|
||||
volatile bool Bgcrc_uncorr_err = false;
|
||||
volatile bool Bgcrc_corr_err = false;
|
||||
volatile bool Bgcrc_Wd_underflow = false;
|
||||
volatile bool Bgcrc_Wd_overflow = false;
|
||||
volatile bool error_status_pin_diagnostic_failed = false;
|
||||
|
||||
bool pass = false;
|
||||
|
||||
//
|
||||
// Function Prototypes
|
||||
//
|
||||
void bgcrcInit(void);
|
||||
void delay(uint32_t i);
|
||||
__interrupt void CLAbgcrcIsr(void);
|
||||
__interrupt void NMIbgcrcIsr(void);
|
||||
|
||||
//
|
||||
// Main
|
||||
//
|
||||
void main(void)
|
||||
{
|
||||
//
|
||||
// Initialize device clock and peripherals
|
||||
//
|
||||
Device_init();
|
||||
|
||||
//
|
||||
// Initialize GPIO and configure the GPIO pin as a push-pull output
|
||||
//
|
||||
Device_initGPIO();
|
||||
|
||||
//
|
||||
// Disable global interrupts.
|
||||
//
|
||||
DINT;
|
||||
|
||||
//
|
||||
// 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();
|
||||
IER = 0x0000;
|
||||
IFR = 0x0000;
|
||||
|
||||
//
|
||||
// Map the ISRs of the BGCRC interrupt and NMI.
|
||||
//
|
||||
Interrupt_register(INT_CLA1CRC, CLAbgcrcIsr);
|
||||
Interrupt_register(INT_NMI, NMIbgcrcIsr);
|
||||
|
||||
//
|
||||
// Enable the CRC interrupt in the PIE
|
||||
//
|
||||
Interrupt_enable(INT_CLA1CRC);
|
||||
Interrupt_clearACKGroup(INTERRUPT_ACK_GROUP12);
|
||||
//
|
||||
// Enable NMI
|
||||
//
|
||||
Interrupt_enable(INT_NMI);
|
||||
SysCtl_enableNMIGlobalInterrupt();
|
||||
SysCtl_setNMIWatchdogPeriod(0xFFFFU);
|
||||
|
||||
//
|
||||
// Enable Global Interrupt (INTM) and realtime interrupt (DBGM)
|
||||
//
|
||||
EINT;
|
||||
ERTM;
|
||||
|
||||
//
|
||||
// Initialize the BGCRC module
|
||||
//
|
||||
bgcrcInit();
|
||||
|
||||
delay(2000); // Expecting the BGCRC completion in this time
|
||||
|
||||
if(error_status_pin_diagnostic_failed == true )
|
||||
{
|
||||
//
|
||||
// Something is wrong with the error status pin
|
||||
// Need to reset the system
|
||||
//
|
||||
}
|
||||
|
||||
if((bgcrcDone == true) && (bgcrcError == false))
|
||||
{
|
||||
if((intStatus == BGCRC_TEST_DONE))
|
||||
{
|
||||
pass = true;
|
||||
}
|
||||
}
|
||||
|
||||
while(1);
|
||||
}
|
||||
|
||||
//
|
||||
// Init routine for BGCRC module
|
||||
//
|
||||
void bgcrcInit()
|
||||
{
|
||||
//
|
||||
// Unlock the BGCRC configuration in case it is locked CFG-1
|
||||
//
|
||||
BGCRC_unlockRegister(BGCRC_CLA1_BASE, BGCRC_REG_CTRL1 |
|
||||
BGCRC_REG_WD_CFG |
|
||||
BGCRC_REG_INTEN |
|
||||
BGCRC_REG_SEED);
|
||||
|
||||
//
|
||||
// Unlock the BGCRC configuration in case it is locked CFG-2
|
||||
//
|
||||
BGCRC_unlockRegister(BGCRC_CLA1_BASE, BGCRC_REG_EN |
|
||||
BGCRC_REG_CTRL2 |
|
||||
BGCRC_REG_START_ADDR |
|
||||
BGCRC_REG_GOLDEN |
|
||||
BGCRC_REG_WD_MIN |
|
||||
BGCRC_REG_WD_MAX);
|
||||
//
|
||||
// Disable NMI and set the emulation mode as soft.
|
||||
// The CRC module and the watchdog stops immediately on debug suspend
|
||||
//
|
||||
BGCRC_setConfig(BGCRC_CLA1_BASE, BGCRC_NMI_ENABLE, BGCRC_EMUCTRL_SOFT);
|
||||
|
||||
//
|
||||
// Configure the CRC Watchdog
|
||||
// Watchdog window - Min : DATA_SIZE - 10, Max : DATA_SIZE + 100
|
||||
//
|
||||
BGCRC_enableWatchdog(BGCRC_CLA1_BASE);
|
||||
BGCRC_setWatchdogWindow(BGCRC_CLA1_BASE, DATA_SIZE - 10, DATA_SIZE + 100);
|
||||
|
||||
//
|
||||
// Configure the region.
|
||||
// Configure the module in Scrub mode. CRC of data is not compared with the
|
||||
// golden CRC. Error check is done using the ECC/Parity logic.
|
||||
//
|
||||
BGCRC_setRegion(BGCRC_CLA1_BASE, CLA_ROM_ADDR_BGCRC_VIEW,
|
||||
BGCRC_SIZE_BYTES_256, BGCRC_SCRUB_MODE);
|
||||
|
||||
|
||||
//
|
||||
// Enable interrupts
|
||||
//
|
||||
BGCRC_enableInterrupt(BGCRC_CLA1_BASE, BGCRC_TEST_DONE |
|
||||
BGCRC_CRC_FAIL |
|
||||
BGCRC_UNCORR_ERR |
|
||||
BGCRC_CORR_ERR |
|
||||
BGCRC_WD_UNDERFLOW |
|
||||
BGCRC_WD_OVERFLOW);
|
||||
|
||||
//
|
||||
// Lock Register configuration for CFG1
|
||||
//
|
||||
BGCRC_lockRegister(BGCRC_CLA1_BASE, BGCRC_REG_CTRL1 |
|
||||
BGCRC_REG_WD_CFG |
|
||||
BGCRC_REG_INTEN |
|
||||
BGCRC_REG_SEED);
|
||||
|
||||
|
||||
//
|
||||
// Commit Register Lock for CFG1
|
||||
//
|
||||
BGCRC_commitRegisterLock(BGCRC_CLA1_BASE, BGCRC_REG_CTRL1 |
|
||||
BGCRC_REG_WD_CFG |
|
||||
BGCRC_REG_INTEN |
|
||||
BGCRC_REG_SEED);
|
||||
|
||||
BGCRC_start(BGCRC_CLA1_BASE);
|
||||
|
||||
//
|
||||
// Lock Register configuration for CFG2
|
||||
//
|
||||
BGCRC_lockRegister(BGCRC_CLA1_BASE, BGCRC_REG_EN |
|
||||
BGCRC_REG_CTRL2 |
|
||||
BGCRC_REG_START_ADDR |
|
||||
BGCRC_REG_GOLDEN |
|
||||
BGCRC_REG_WD_MIN |
|
||||
BGCRC_REG_WD_MAX);
|
||||
}
|
||||
|
||||
//
|
||||
// CLAbgcrcIsr - DONE interrupt from BGCRC.
|
||||
//
|
||||
__interrupt void CLAbgcrcIsr (void)
|
||||
{
|
||||
bgcrcDone = true;
|
||||
|
||||
//
|
||||
// Read the interrupt status
|
||||
//
|
||||
intStatus= BGCRC_getInterruptStatus(BGCRC_CLA1_BASE);
|
||||
intStatus &= ~BGCRC_GLOBAL_INT;
|
||||
|
||||
//
|
||||
// Clear interrupt status
|
||||
//
|
||||
BGCRC_clearInterruptStatus(BGCRC_CLA1_BASE, BGCRC_TEST_DONE |
|
||||
BGCRC_ALL_ERROR_FLAGS);
|
||||
|
||||
Interrupt_clearACKGroup(INTERRUPT_ACK_GROUP12);
|
||||
}
|
||||
|
||||
//
|
||||
// NMIbgcrcIsr - NMI ISR
|
||||
//
|
||||
__interrupt void NMIbgcrcIsr(void)
|
||||
{
|
||||
uint32_t timeout = 20;
|
||||
BgcrcNmiStatus = BGCRC_getNMIStatus(BGCRC_CLA1_BASE);
|
||||
|
||||
//
|
||||
// Safety diagnostic check
|
||||
//
|
||||
if(!SysCtl_isErrorTriggered())
|
||||
{
|
||||
//
|
||||
// If due to some fault the ERROR STS couldn't be triggered, force
|
||||
// the error status pin so that external host get to know the error
|
||||
//
|
||||
while((SysCtl_getErrorPinStatus() == 0) && (timeout > 0))
|
||||
{
|
||||
SysCtl_forceError();
|
||||
timeout--;
|
||||
}
|
||||
|
||||
if (timeout == 0)
|
||||
{
|
||||
//
|
||||
// Something is wrong with the error status pin
|
||||
//
|
||||
error_status_pin_diagnostic_failed = true;
|
||||
}
|
||||
}
|
||||
|
||||
if((BgcrcNmiStatus & BGCRC_CRC_FAIL) == BGCRC_CRC_FAIL)
|
||||
{
|
||||
//
|
||||
// CRC Fail NMI
|
||||
//
|
||||
Bgcrc_fail = true;
|
||||
BGCRC_clearNMIStatus(BGCRC_CLA1_BASE, BGCRC_CRC_FAIL);
|
||||
}
|
||||
|
||||
if( (BgcrcNmiStatus & BGCRC_UNCORR_ERR) == BGCRC_UNCORR_ERR )
|
||||
{
|
||||
//
|
||||
// Uncorrectable Error NMI
|
||||
//
|
||||
Bgcrc_uncorr_err = true;
|
||||
BGCRC_clearNMIStatus(BGCRC_CLA1_BASE, BGCRC_UNCORR_ERR);
|
||||
}
|
||||
|
||||
if((BgcrcNmiStatus & BGCRC_CORR_ERR) == BGCRC_CORR_ERR)
|
||||
{
|
||||
//
|
||||
// Correctable Error NMI
|
||||
//
|
||||
Bgcrc_corr_err = true;
|
||||
BGCRC_clearNMIStatus(BGCRC_CLA1_BASE, BGCRC_CORR_ERR);
|
||||
}
|
||||
|
||||
if((BgcrcNmiStatus & BGCRC_WD_UNDERFLOW) == BGCRC_WD_UNDERFLOW)
|
||||
{
|
||||
//
|
||||
// Watchdog Underflow Error NMI
|
||||
//
|
||||
Bgcrc_Wd_underflow = true;
|
||||
BGCRC_clearNMIStatus(BGCRC_CLA1_BASE, BGCRC_WD_UNDERFLOW);
|
||||
}
|
||||
|
||||
if((BgcrcNmiStatus & BGCRC_WD_OVERFLOW) == BGCRC_WD_OVERFLOW)
|
||||
{
|
||||
//
|
||||
// Watchdog Overflow Error NMI
|
||||
//
|
||||
Bgcrc_Wd_overflow = true;
|
||||
BGCRC_clearNMIStatus(BGCRC_CLA1_BASE, BGCRC_WD_OVERFLOW);
|
||||
}
|
||||
|
||||
SysCtl_clearAllNMIFlags();
|
||||
bgcrcError = true;
|
||||
}
|
||||
|
||||
//
|
||||
// Delay function
|
||||
//
|
||||
void delay(uint32_t i)
|
||||
{
|
||||
uint32_t j =i;
|
||||
while(j > 0)
|
||||
{
|
||||
j--;
|
||||
}
|
||||
}
|
||||
//
|
||||
// End of File
|
||||
//
|
||||
+78
@@ -0,0 +1,78 @@
|
||||
<projectSpec>
|
||||
<project
|
||||
name="boot_ex1_cpu1_cpu2_cm_secure_flash_cpu1"
|
||||
device="TMS320F28388D"
|
||||
cgtVersion="22.6.1.LTS"
|
||||
products="C2000WARE"
|
||||
outputFormat="ELF"
|
||||
launchWizard="False"
|
||||
enableHexTool="True"
|
||||
linkerCommandFile=""
|
||||
>
|
||||
<configuration name="CPU1_FLASH" compilerBuildOptions="--opt_level=off -I${PROJECT_ROOT}/device -I${C2000WARE_DLIB_ROOT} -v28 -ml -mt --define=_FLASH --cla_support=cla2 --float_support=fpu64 --tmu_support=tmu0 --define=DEBUG --define=CPU1 --diag_warning=225 --diag_suppress=10063" linkerBuildOptions="--entry_point code_start --stack_size=0x100 --heap_size=0x200 " hexBuildOptions="--image --cmac="${PROJECT_ROOT}/boot_ex1_user_cmac_key.txt" --memwidth=16 --romwidth=16 "${PROJECT_ROOT}\boot_ex1_flash_hex_lnk_cpu1.cmd" --outfile "${BuildArtifactFileBaseName}.hex"" />
|
||||
<pathVariable name="C2000WARE_DLIB_ROOT" path="../../../../../../driverlib/f2838x/driverlib/" 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_FLASH_lnk_cpu1.cmd" targetDirectory="" applicableConfigurations="CPU1_FLASH" />
|
||||
<file action="copy" path="../../../../../../driverlib/f2838x/driverlib/" targetDirectory="device" excludeFromBuild="True" />
|
||||
<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="link" path="../../../../../../libraries/boot_rom/f2838x/revA/rom_symbol_libs/cpu1/secureZoneCode/F2838xCPU1_SecureZoneCode_Symbols_fpu32.lib" targetDirectory="" />
|
||||
<file action="copy" path="../boot_ex1_cpu1_cpu2_cm_secure_flash_cpu1.c" targetDirectory="" />
|
||||
<file action="copy" path="../boot_ex1_flash_hex_lnk_cpu1.cmd" targetDirectory="" excludeFromBuild="True" />
|
||||
<file action="copy" path="../boot_ex1_user_cmac_key.txt" targetDirectory="" excludeFromBuild="True" />
|
||||
</project>
|
||||
<project
|
||||
name="boot_ex1_cpu1_cpu2_cm_secure_flash_cpu2"
|
||||
device="TMS320F28388D"
|
||||
cgtVersion="22.6.1.LTS"
|
||||
products="C2000WARE"
|
||||
outputFormat="ELF"
|
||||
launchWizard="False"
|
||||
enableHexTool="True"
|
||||
linkerCommandFile=""
|
||||
>
|
||||
<configuration name="CPU2_FLASH" compilerBuildOptions="--opt_level=off -I${PROJECT_ROOT}/device -I${C2000WARE_DLIB_ROOT} -v28 -ml -mt --define=_FLASH --cla_support=cla2 --float_support=fpu64 --tmu_support=tmu0 --define=DEBUG --define=CPU2 --diag_warning=225 --diag_suppress=10063" linkerBuildOptions="--entry_point code_start --stack_size=0x100 --heap_size=0x200 " hexBuildOptions="--image --cmac="${PROJECT_ROOT}/boot_ex1_user_cmac_key.txt" --memwidth=16 --romwidth=16 "${PROJECT_ROOT}\boot_ex1_flash_hex_lnk_cpu2.cmd" --outfile "${BuildArtifactFileBaseName}.hex""/>
|
||||
<pathVariable name="C2000WARE_DLIB_ROOT" path="../../../../../../driverlib/f2838x/driverlib/" 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_FLASH_lnk_cpu2.cmd" targetDirectory="" applicableConfigurations="CPU2_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="link" path="../../../../../../libraries/boot_rom/f2838x/revA/rom_symbol_libs/cpu2/secureZoneCode/F2838xCPU2_SecureZoneCode_Symbols_fpu32.lib" targetDirectory="" />
|
||||
<file action="copy" path="../boot_ex1_cpu1_cpu2_cm_secure_flash_cpu2.c" targetDirectory="" />
|
||||
<file action="copy" path="../boot_ex1_flash_hex_lnk_cpu2.cmd" targetDirectory="" excludeFromBuild="True" />
|
||||
<file action="copy" path="../boot_ex1_user_cmac_key.txt" targetDirectory="" excludeFromBuild="True" />
|
||||
</project>
|
||||
<project
|
||||
name="boot_ex1_cpu1_cpu2_cm_secure_flash_cm"
|
||||
device="Cortex M.TMS320F28388D"
|
||||
cgtVersion="20.2.7.LTS"
|
||||
products="C2000WARE"
|
||||
endianness="little"
|
||||
launchWizard="False"
|
||||
enableHexTool="True"
|
||||
linkerCommandFile=""
|
||||
>
|
||||
<configuration name="CM_FLASH" compilerBuildOptions="--opt_level=off -I${PROJECT_ROOT}/device -I${C2000WARE_DLIB_ROOT} --define=DEBUG --float_support=none --define=_FLASH -mv7M4 -me --diag_warning=225 " linkerBuildOptions="--stack_size=512 --heap_size=1024 --library=libc.a " hexBuildOptions="--image --cmac="${PROJECT_ROOT}/boot_ex1_user_cmac_key.txt" --memwidth=8 --romwidth=8 "${PROJECT_ROOT}\boot_ex1_flash_hex_lnk_cm.cmd" --outfile "${BuildArtifactFileBaseName}.hex""/>
|
||||
<pathVariable name="C2000WARE_DLIB_ROOT" path="../../../../../../driverlib/f2838x/driverlib_cm/" scope="project" />
|
||||
<file action="copy" path="../../../../../../device_support/f2838x/common/include/driverlib_cm.h" targetDirectory="device" />
|
||||
<file action="copy" path="../../../../../../device_support/f2838x/common/include/cm.h" targetDirectory="device" />
|
||||
<file action="copy" path="../../../../../../device_support/f2838x/common/source/cm.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_FLASH_secure_boot_lnk_cm.cmd" targetDirectory="" applicableConfigurations="CM_FLASH" />
|
||||
<file action="copy" path="../../../../../../driverlib/f2838x/driverlib_cm/" targetDirectory="device" excludeFromBuild="True" />
|
||||
<file action="link" path="../../../../../../driverlib/f2838x/driverlib_cm/ccs/Debug/driverlib_cm.lib" targetDirectory="" />
|
||||
<file action="copy" path="../../../../../../device_support/f2838x/common/source/startup_cm.c" targetDirectory="" />
|
||||
<file action="link" path="../../../../../../libraries/boot_rom/f2838x/revA/rom_symbol_libs/cm/secureZoneCode/F2838xCM_SecureZoneCode_Symbols.lib" targetDirectory="" />
|
||||
<file action="copy" path="../boot_ex1_cpu1_cpu2_cm_secure_flash_cm.c" targetDirectory="" />
|
||||
<file action="copy" path="../boot_ex1_secure_startup_cm.asm" targetDirectory="" />
|
||||
<file action="copy" path="../boot_ex1_flash_hex_lnk_cm.cmd" targetDirectory="" excludeFromBuild="True" />
|
||||
<file action="copy" path="../boot_ex1_user_cmac_key.txt" targetDirectory="" excludeFromBuild="True" />
|
||||
</project>
|
||||
</projectSpec>
|
||||
+207
@@ -0,0 +1,207 @@
|
||||
//#############################################################################
|
||||
//
|
||||
// FILE: boot_ex1_cpu1_cpu2_cm_secure_flash_cm.c
|
||||
//
|
||||
// TITLE: Secure Flash Boot Example
|
||||
//! <h1> CM Secure Flash Boot </h1>
|
||||
//!
|
||||
//! This example demonstrates how to use the secure flash boot mode for CM.
|
||||
//! (Requires CPU1 example application)
|
||||
//!
|
||||
//! Secure flash boot performs a CMAC authentication on the entry sector of
|
||||
//! flash upon device boot up. If authentication passes, the application will
|
||||
//! begin execution. Learn more on the secure flash boot mode in the device
|
||||
//! technical reference manual.
|
||||
//!
|
||||
//! This project shows how to use the C2000 HEX Utility to generate a CMAC Tag
|
||||
//! based on a user CMAC key and embed the value into the flash application.
|
||||
//! Additionally, the example details the method to call the CMAC API from
|
||||
//! the user application to calculate CMAC on other flash sectors beyond the
|
||||
//! the application entry flash sector.
|
||||
//!
|
||||
//! Determining Pass/Fail without debugger connected:
|
||||
//! CM - ControlCARD LED3.
|
||||
//! - LED off = Secure Boot failed
|
||||
//! - LED On (Solid) = Secure Boot Passed, Full Flash CMAC failed
|
||||
//! - LED Blinking = Secure Boot Passed and Full Flash CMAC passed
|
||||
//!
|
||||
//! \b External \b Connections \n
|
||||
//! - None.
|
||||
//!
|
||||
//! \b Watch \b Variables \n
|
||||
//! - None.
|
||||
//!
|
||||
//!
|
||||
//#############################################################################
|
||||
//
|
||||
//
|
||||
//
|
||||
// C2000Ware v5.04.00.00
|
||||
//
|
||||
// Copyright (C) 2024 Texas Instruments Incorporated - http://www.ti.com
|
||||
//
|
||||
// Redistribution and use in source and binary forms, with or without
|
||||
// modification, are permitted provided that the following conditions
|
||||
// are met:
|
||||
//
|
||||
// Redistributions of source code must retain the above copyright
|
||||
// notice, this list of conditions and the following disclaimer.
|
||||
//
|
||||
// Redistributions in binary form must reproduce the above copyright
|
||||
// notice, this list of conditions and the following disclaimer in the
|
||||
// documentation and/or other materials provided with the
|
||||
// distribution.
|
||||
//
|
||||
// Neither the name of Texas Instruments Incorporated nor the names of
|
||||
// its contributors may be used to endorse or promote products derived
|
||||
// from this software without specific prior written permission.
|
||||
//
|
||||
// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
|
||||
// "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
|
||||
// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
|
||||
// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
|
||||
// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
|
||||
// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
|
||||
// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
|
||||
// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
|
||||
// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
||||
// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
|
||||
// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
// $
|
||||
//#############################################################################
|
||||
|
||||
//
|
||||
// Included Files
|
||||
//
|
||||
#include "driverlib_cm.h"
|
||||
#include "cm.h"
|
||||
|
||||
//
|
||||
// Defines
|
||||
//
|
||||
#define DEVICE_GPIO_PIN_LED3 145U
|
||||
#define CMAC_AUTH_PASS 0UL
|
||||
#define CMAC_AUTH_START_ADDRESS 0x00200000UL
|
||||
#define CMAC_AUTH_END_ADDRESS 0x00280000UL
|
||||
#define CMAC_AUTH_TAG_ADDRESS 0x00204004UL
|
||||
|
||||
//
|
||||
// Structure required for CMAC symbol reserving in memory.
|
||||
// Required for performing CMAC on non-entry sector of flash.
|
||||
//
|
||||
// Read more in the Assembly Language Tools User's Guide
|
||||
//
|
||||
struct CMAC_TAG
|
||||
{
|
||||
uint8_t tag[16];
|
||||
uint32_t start;
|
||||
uint32_t end;
|
||||
};
|
||||
|
||||
//
|
||||
// Create CMAC symbol for flash entry point 1 (0x00200000).
|
||||
//
|
||||
// Reserves memory for storing the golden CMAC tag that gets
|
||||
// generated by the HEX Utility.
|
||||
//
|
||||
#pragma RETAIN(cmac_sb_1)
|
||||
#pragma LOCATION(cmac_sb_1, 0x00200004)
|
||||
const uint8_t cmac_sb_1[16] = { 0 };
|
||||
|
||||
//
|
||||
// Create CMAC symbol for full length flash authentication.
|
||||
// The start and end CMAC_TAG struct members are zero, therefore
|
||||
// the CMAC algorithm runs over entire memory region specified in
|
||||
// the HEX directive.
|
||||
//
|
||||
// Note that the location 0x00204004 can be set to anywhere as long
|
||||
// as it is within the specified CMAC authentication memory.
|
||||
//
|
||||
// Reserves memory for storing the golden CMAC tag that gets
|
||||
// generated by the HEX Utility.
|
||||
//
|
||||
#pragma RETAIN(cmac_all)
|
||||
#pragma LOCATION(cmac_all, 0x00204004)
|
||||
const struct CMAC_TAG cmac_all = {{ 0 }, 0x0, 0x0};
|
||||
|
||||
//
|
||||
// Function Prototypes
|
||||
//
|
||||
uint32_t CMBROM_calculateCMAC(uint32_t startAddress,
|
||||
uint32_t endAddress,
|
||||
uint32_t tagAddress);
|
||||
|
||||
//
|
||||
// Main
|
||||
//
|
||||
void main(void)
|
||||
{
|
||||
uint32_t applicationCMACStatus = CMAC_AUTH_PASS;
|
||||
|
||||
//
|
||||
// Initialize device clock and peripherals
|
||||
//
|
||||
CM_init();
|
||||
|
||||
//
|
||||
// Initialize GPIO and configure the GPIO pin as a push-pull output
|
||||
//
|
||||
// This is configured by CPU1
|
||||
|
||||
//
|
||||
// Turn on LED3 to indicate CM has entered application
|
||||
//
|
||||
GPIO_writePin(DEVICE_GPIO_PIN_LED3, 1);
|
||||
|
||||
//
|
||||
// Call CMAC Authentication API to verify contents of all of
|
||||
// device flash.
|
||||
//
|
||||
// Upon failure, enter infinite loop.
|
||||
//
|
||||
applicationCMACStatus = CMBROM_calculateCMAC(CMAC_AUTH_START_ADDRESS,
|
||||
CMAC_AUTH_END_ADDRESS,
|
||||
CMAC_AUTH_TAG_ADDRESS);
|
||||
|
||||
if(CMAC_AUTH_PASS != applicationCMACStatus)
|
||||
{
|
||||
//
|
||||
// Application will get stuck here upon failure
|
||||
//
|
||||
while(1);
|
||||
}
|
||||
else
|
||||
{
|
||||
IPC_setFlagLtoR(IPC_CM_L_CPU1_R, IPC_FLAG1);
|
||||
}
|
||||
|
||||
//
|
||||
// Loop Forever
|
||||
//
|
||||
for(;;)
|
||||
{
|
||||
//
|
||||
// Turn on LED
|
||||
//
|
||||
GPIO_writePin(DEVICE_GPIO_PIN_LED3, 1);
|
||||
|
||||
//
|
||||
// Delay for 500000uS.
|
||||
//
|
||||
DEVICE_DELAY_US(500000);
|
||||
|
||||
//
|
||||
// Turn off LED
|
||||
//
|
||||
GPIO_writePin(DEVICE_GPIO_PIN_LED3, 0);
|
||||
|
||||
//
|
||||
// Delay for 500000uS.
|
||||
//
|
||||
DEVICE_DELAY_US(500000);
|
||||
}
|
||||
}
|
||||
|
||||
//
|
||||
// End of File
|
||||
//
|
||||
+311
@@ -0,0 +1,311 @@
|
||||
//#############################################################################
|
||||
//
|
||||
// FILE: boot_ex1_cpu1_cpu2_cm_secure_flash_cpu1.c
|
||||
//
|
||||
// TITLE: Secure Flash Boot Example
|
||||
//
|
||||
//! \addtogroup driver_example_list
|
||||
//! <h1> CPU1 Secure Flash Boot </h1>
|
||||
//!
|
||||
//! This example demonstrates how to use the secure flash boot mode for CPU1
|
||||
//! as well as release CPU2 and CM for secure flash boot.
|
||||
//!
|
||||
//! Secure flash boot performs a CMAC authentication on the entry sector of
|
||||
//! flash upon device boot up. If authentication passes, the application will
|
||||
//! begin execution. Learn more on the secure flash boot mode in the device
|
||||
//! technical reference manual.
|
||||
//!
|
||||
//! This project shows how to use the C2000 HEX Utility to generate a CMAC Tag
|
||||
//! based on a user CMAC key and embed the value into the flash application.
|
||||
//! Additionally, the example details the method to call the CMAC API from
|
||||
//! the user application to calculate CMAC on other flash sectors beyond the
|
||||
//! the application entry flash sector.
|
||||
//!
|
||||
//! How to Run:
|
||||
//! - Load application into CPU1 flash (as well as CPU2 and CM applications)
|
||||
//! - Disconnect and reconnect to only CPU1
|
||||
//! - In memory window, set address 0xD00/D01 to 0x5AFFFFFF and address 0xD04 to
|
||||
//! 0x000A (This sets emulation boot to secure flash boot)
|
||||
//! - Reset CPU1 via CCS and click resume
|
||||
//! - Observe the LEDs
|
||||
//!
|
||||
//! Determining Pass/Fail without debugger connected:
|
||||
//! \b CPU1 - ControlCARD LED1.
|
||||
//! - LED off = Secure Boot failed
|
||||
//! - LED On (Solid) = Secure Boot Passed, Full Flash CMAC failed
|
||||
//! - LED Blinking = Secure Boot Passed and Full Flash CMAC passed
|
||||
//! \b CPU2 - ControlCARD LED2.
|
||||
//! - LED off = Secure Boot failed
|
||||
//! - LED On (Solid) = Secure Boot Passed, Full Flash CMAC failed
|
||||
//! - LED Blinking = Secure Boot Passed and Full Flash CMAC passed
|
||||
//! \b CM - ControlCARD LED3.
|
||||
//! - LED off = Secure Boot failed
|
||||
//! - LED On (Solid) = Secure Boot Passed, Full Flash CMAC failed
|
||||
//! - LED Blinking = Secure Boot Passed and Full Flash CMAC passed
|
||||
//!
|
||||
//! \b External \b Connections \n
|
||||
//! - None.
|
||||
//!
|
||||
//! \b Watch \b Variables \n
|
||||
//! - cpu1_SuccessfullyBooted - True when CPU1 full flash CMAC authentication
|
||||
//! passes. Otherwise, false.
|
||||
//! - cpu2_SuccessfullyBooted - True when CPU2 full flash CMAC authentication
|
||||
//! passes and CPU1 receives IPC. Otherwise, false.
|
||||
//! - cm_SuccessfullyBooted - True when CM full flash CMAC authentication
|
||||
//! passes and CPU1 receives IPC. Otherwise, false.
|
||||
//!
|
||||
//
|
||||
//#############################################################################
|
||||
//
|
||||
//
|
||||
//
|
||||
// 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 CMAC_AUTH_PASS 0UL
|
||||
#define CMAC_AUTH_START_ADDRESS 0x00080000UL
|
||||
#define CMAC_AUTH_END_ADDRESS 0x000C0000UL
|
||||
#define CMAC_AUTH_TAG_ADDRESS 0x00087002UL
|
||||
|
||||
//
|
||||
// Globals
|
||||
//
|
||||
bool cpu1_SuccessfullyBooted = false;
|
||||
bool cpu2_SuccessfullyBooted = false;
|
||||
bool cm_SuccessfullyBooted = false;
|
||||
|
||||
//
|
||||
// Structure required for CMAC symbol reserving in memory.
|
||||
// Required for performing CMAC on non-entry sector of flash.
|
||||
//
|
||||
// Read more in the Assembly Language Tools User's Guide
|
||||
//
|
||||
struct CMAC_TAG
|
||||
{
|
||||
char tag[8];
|
||||
uint32_t start;
|
||||
uint32_t end;
|
||||
};
|
||||
|
||||
//
|
||||
// Create CMAC symbol for flash entry point 1 (0x80000).
|
||||
//
|
||||
// Reserves memory for storing the golden CMAC tag that gets
|
||||
// generated by the HEX Utility.
|
||||
//
|
||||
#pragma RETAIN(cmac_sb_1)
|
||||
#pragma LOCATION(cmac_sb_1, 0x080002)
|
||||
const char cmac_sb_1[8] = { 0 };
|
||||
|
||||
//
|
||||
// Create CMAC symbol for full length flash authentication.
|
||||
// The start and end CMAC_TAG struct members are zero, therefore
|
||||
// the CMAC algorithm runs over entire memory region specified in
|
||||
// the HEX directive.
|
||||
//
|
||||
// Note that the location 0x087002 can be set to anywhere as long
|
||||
// as it is within the specified CMAC authentication memory.
|
||||
//
|
||||
// Reserves memory for storing the golden CMAC tag that gets
|
||||
// generated by the HEX Utility.
|
||||
//
|
||||
#pragma RETAIN(cmac_all)
|
||||
#pragma LOCATION(cmac_all, 0x087002)
|
||||
const struct CMAC_TAG cmac_all = {{ 0 }, 0x0, 0x0};
|
||||
|
||||
//
|
||||
// Function Prototypes
|
||||
//
|
||||
uint32_t CPU1BROM_calculateCMAC(uint32_t startAddress,
|
||||
uint32_t endAddress,
|
||||
uint32_t tagAddress);
|
||||
__interrupt void appIPCHandler(void);
|
||||
|
||||
//
|
||||
// Main
|
||||
//
|
||||
void main(void)
|
||||
{
|
||||
uint32_t applicationCMACStatus = CMAC_AUTH_PASS;
|
||||
|
||||
//
|
||||
// Initialize device clock and peripherals
|
||||
//
|
||||
Device_init();
|
||||
|
||||
//
|
||||
// Initialize GPIO and configure the GPIO pins as a push-pull output
|
||||
//
|
||||
Device_initGPIO();
|
||||
GPIO_setPadConfig(DEVICE_GPIO_PIN_LED1, GPIO_PIN_TYPE_STD);
|
||||
GPIO_setDirectionMode(DEVICE_GPIO_PIN_LED1, GPIO_DIR_MODE_OUT);
|
||||
GPIO_setPadConfig(DEVICE_GPIO_PIN_LED2, GPIO_PIN_TYPE_STD);
|
||||
GPIO_setDirectionMode(DEVICE_GPIO_PIN_LED2, GPIO_DIR_MODE_OUT);
|
||||
GPIO_setPadConfig(DEVICE_GPIO_PIN_LED3, GPIO_PIN_TYPE_STD);
|
||||
GPIO_setDirectionMode(DEVICE_GPIO_PIN_LED3, GPIO_DIR_MODE_OUT);
|
||||
|
||||
//
|
||||
// Turn LEDS off and Allocate LED GPIOs to CPU2 and CM
|
||||
//
|
||||
GPIO_writePin(DEVICE_GPIO_PIN_LED2, 1);
|
||||
GPIO_writePin(DEVICE_GPIO_PIN_LED3, 0);
|
||||
GPIO_setMasterCore(DEVICE_GPIO_PIN_LED2, GPIO_CORE_CPU2);
|
||||
GPIO_setMasterCore(DEVICE_GPIO_PIN_LED3, GPIO_CORE_CM);
|
||||
|
||||
//
|
||||
// Turn on LED1 to indicate CPU1 has entered application
|
||||
//
|
||||
GPIO_writePin(DEVICE_GPIO_PIN_LED1, 0);
|
||||
|
||||
//
|
||||
// Call CMAC Authentication API to verify contents of all of
|
||||
// device flash.
|
||||
//
|
||||
// Upon failure, enter infinite loop.
|
||||
//
|
||||
applicationCMACStatus = CPU1BROM_calculateCMAC(CMAC_AUTH_START_ADDRESS,
|
||||
CMAC_AUTH_END_ADDRESS,
|
||||
CMAC_AUTH_TAG_ADDRESS);
|
||||
|
||||
if(CMAC_AUTH_PASS != applicationCMACStatus)
|
||||
{
|
||||
//
|
||||
// Application will get stuck here upon failure
|
||||
//
|
||||
while(1);
|
||||
}
|
||||
else
|
||||
{
|
||||
cpu1_SuccessfullyBooted = true;
|
||||
}
|
||||
|
||||
//
|
||||
// Secure Boot CPU2 core
|
||||
//
|
||||
Device_bootCPU2(BOOTMODE_BOOT_TO_SECURE_FLASH_SECTOR0);
|
||||
|
||||
//
|
||||
// Secure Boot CM core
|
||||
//
|
||||
Device_bootCM(BOOTMODE_BOOT_TO_SECURE_FLASH_SECTOR0);
|
||||
|
||||
//
|
||||
// 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();
|
||||
|
||||
//
|
||||
// Configure and Enable IPC interrupts
|
||||
//
|
||||
IPC_registerInterrupt(IPC_CPU1_L_CPU2_R, IPC_INT0, appIPCHandler);
|
||||
IPC_registerInterrupt(IPC_CPU1_L_CM_R, IPC_INT1, appIPCHandler);
|
||||
|
||||
//
|
||||
// Enable Global Interrupt (INTM) and realtime interrupt (DBGM)
|
||||
//
|
||||
EINT;
|
||||
ERTM;
|
||||
|
||||
//
|
||||
// Loop Forever - Blink LED to indicate full flash CMAC has passed
|
||||
//
|
||||
for(;;)
|
||||
{
|
||||
//
|
||||
// Turn on LED
|
||||
//
|
||||
GPIO_writePin(DEVICE_GPIO_PIN_LED1, 0);
|
||||
|
||||
//
|
||||
// Delay for a bit.
|
||||
//
|
||||
DEVICE_DELAY_US(500000);
|
||||
|
||||
//
|
||||
// Turn off LED
|
||||
//
|
||||
GPIO_writePin(DEVICE_GPIO_PIN_LED1, 1);
|
||||
|
||||
//
|
||||
// Delay for a bit.
|
||||
//
|
||||
DEVICE_DELAY_US(500000);
|
||||
}
|
||||
}
|
||||
|
||||
//
|
||||
// appIPCHandler - Handle notifications from CPU2 and CM when
|
||||
// their applications complete successfully
|
||||
//
|
||||
__interrupt void appIPCHandler(void)
|
||||
{
|
||||
if(IPC_isFlagBusyRtoL(IPC_CPU1_L_CPU2_R, IPC_FLAG0))
|
||||
{
|
||||
cpu2_SuccessfullyBooted = true;
|
||||
IPC_ackFlagRtoL(IPC_CPU1_L_CPU2_R, IPC_FLAG0);
|
||||
}
|
||||
else if(IPC_isFlagBusyRtoL(IPC_CPU1_L_CM_R, IPC_FLAG1))
|
||||
{
|
||||
cm_SuccessfullyBooted = true;
|
||||
IPC_ackFlagRtoL(IPC_CPU1_L_CM_R, IPC_FLAG1);
|
||||
}
|
||||
else
|
||||
{
|
||||
// No action
|
||||
}
|
||||
|
||||
//
|
||||
// Acknowledge this interrupt located in PIE group 1
|
||||
//
|
||||
Interrupt_clearACKGroup(INTERRUPT_ACK_GROUP1);
|
||||
}
|
||||
|
||||
//
|
||||
// End of File
|
||||
//
|
||||
+223
@@ -0,0 +1,223 @@
|
||||
//#############################################################################
|
||||
//
|
||||
// FILE: boot_ex1_cpu1_cpu2_cm_secure_flash_cpu2.c
|
||||
//
|
||||
// TITLE: Secure Flash Boot Example
|
||||
//! <h1> CPU2 Secure Flash Boot </h1>
|
||||
//!
|
||||
//! This example demonstrates how to use the secure flash boot mode for CPU2.
|
||||
//! (Requires CPU1 example application)
|
||||
//!
|
||||
//! Secure flash boot performs a CMAC authentication on the entry sector of
|
||||
//! flash upon device boot up. If authentication passes, the application will
|
||||
//! begin execution. Learn more on the secure flash boot mode in the device
|
||||
//! technical reference manual.
|
||||
//!
|
||||
//! This project shows how to use the C2000 HEX Utility to generate a CMAC Tag
|
||||
//! based on a user CMAC key and embed the value into the flash application.
|
||||
//! Additionally, the example details the method to call the CMAC API from
|
||||
//! the user application to calculate CMAC on other flash sectors beyond the
|
||||
//! the application entry flash sector.
|
||||
//!
|
||||
//! Determining Pass/Fail without debugger connected:
|
||||
//! CPU2 - ControlCARD LED2.
|
||||
//! - LED off = Secure Boot failed
|
||||
//! - LED On (Solid) = Secure Boot Passed, Full Flash CMAC failed
|
||||
//! - LED Blinking = Secure Boot Passed and Full Flash CMAC passed
|
||||
//!
|
||||
//! \b External \b Connections \n
|
||||
//! - None.
|
||||
//!
|
||||
//! \b Watch \b Variables \n
|
||||
//! - None.
|
||||
//!
|
||||
//!
|
||||
//#############################################################################
|
||||
//
|
||||
//
|
||||
//
|
||||
// C2000Ware v5.04.00.00
|
||||
//
|
||||
// Copyright (C) 2024 Texas Instruments Incorporated - http://www.ti.com
|
||||
//
|
||||
// Redistribution and use in source and binary forms, with or without
|
||||
// modification, are permitted provided that the following conditions
|
||||
// are met:
|
||||
//
|
||||
// Redistributions of source code must retain the above copyright
|
||||
// notice, this list of conditions and the following disclaimer.
|
||||
//
|
||||
// Redistributions in binary form must reproduce the above copyright
|
||||
// notice, this list of conditions and the following disclaimer in the
|
||||
// documentation and/or other materials provided with the
|
||||
// distribution.
|
||||
//
|
||||
// Neither the name of Texas Instruments Incorporated nor the names of
|
||||
// its contributors may be used to endorse or promote products derived
|
||||
// from this software without specific prior written permission.
|
||||
//
|
||||
// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
|
||||
// "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
|
||||
// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
|
||||
// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
|
||||
// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
|
||||
// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
|
||||
// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
|
||||
// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
|
||||
// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
||||
// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
|
||||
// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
// $
|
||||
//#############################################################################
|
||||
|
||||
//
|
||||
// Included Files
|
||||
//
|
||||
#include "driverlib.h"
|
||||
#include "device.h"
|
||||
|
||||
//
|
||||
// Defines
|
||||
//
|
||||
#define CMAC_AUTH_PASS 0UL
|
||||
#define CMAC_AUTH_START_ADDRESS 0x00080000UL
|
||||
#define CMAC_AUTH_END_ADDRESS 0x000C0000UL
|
||||
#define CMAC_AUTH_TAG_ADDRESS 0x00087002UL
|
||||
|
||||
//
|
||||
// Structure required for CMAC symbol reserving in memory.
|
||||
// Required for performing CMAC on non-entry sector of flash.
|
||||
//
|
||||
// Read more in the Assembly Language Tools User's Guide
|
||||
//
|
||||
struct CMAC_TAG
|
||||
{
|
||||
char tag[8];
|
||||
uint32_t start;
|
||||
uint32_t end;
|
||||
};
|
||||
|
||||
//
|
||||
// Create CMAC symbol for flash entry point 1 (0x80000).
|
||||
//
|
||||
// Reserves memory for storing the golden CMAC tag that gets
|
||||
// generated by the HEX Utility.
|
||||
//
|
||||
#pragma RETAIN(cmac_sb_1)
|
||||
#pragma LOCATION(cmac_sb_1, 0x080002)
|
||||
const char cmac_sb_1[8] = { 0 };
|
||||
|
||||
//
|
||||
// Create CMAC symbol for full length flash authentication.
|
||||
// The start and end CMAC_TAG struct members are zero, therefore
|
||||
// the CMAC algorithm runs over entire memory region specified in
|
||||
// the HEX directive.
|
||||
//
|
||||
// Note that the location 0x087002 can be set to anywhere as long
|
||||
// as it is within the specified CMAC authentication memory.
|
||||
//
|
||||
// Reserves memory for storing the golden CMAC tag that gets
|
||||
// generated by the HEX Utility.
|
||||
//
|
||||
#pragma RETAIN(cmac_all)
|
||||
#pragma LOCATION(cmac_all, 0x087002)
|
||||
const struct CMAC_TAG cmac_all = {{ 0 }, 0x0, 0x0};
|
||||
|
||||
//
|
||||
// Function Prototypes
|
||||
//
|
||||
uint32_t CPU2BROM_calculateCMAC(uint32_t startAddress,
|
||||
uint32_t endAddress,
|
||||
uint32_t tagAddress);
|
||||
|
||||
//
|
||||
// Main
|
||||
//
|
||||
void main(void)
|
||||
{
|
||||
uint32_t applicationCMACStatus = CMAC_AUTH_PASS;
|
||||
|
||||
//
|
||||
// Initialize device clock and peripherals
|
||||
//
|
||||
Device_init();
|
||||
|
||||
//
|
||||
// Initialize GPIO and configure the GPIO pin as a push-pull output
|
||||
//
|
||||
// This is configured by CPU1
|
||||
|
||||
//
|
||||
// Turn on LED2 to indicate CPU2 has entered application
|
||||
//
|
||||
GPIO_writePin(DEVICE_GPIO_PIN_LED2, 0);
|
||||
|
||||
//
|
||||
// Call CMAC Authentication API to verify contents of all of
|
||||
// device flash.
|
||||
//
|
||||
// Upon failure, enter infinite loop.
|
||||
//
|
||||
applicationCMACStatus = CPU2BROM_calculateCMAC(CMAC_AUTH_START_ADDRESS,
|
||||
CMAC_AUTH_END_ADDRESS,
|
||||
CMAC_AUTH_TAG_ADDRESS);
|
||||
|
||||
if(CMAC_AUTH_PASS != applicationCMACStatus)
|
||||
{
|
||||
//
|
||||
// Application will get stuck here upon failure
|
||||
//
|
||||
while(1);
|
||||
}
|
||||
else
|
||||
{
|
||||
IPC_setFlagLtoR(IPC_CPU2_L_CPU1_R, IPC_FLAG0);
|
||||
}
|
||||
|
||||
//
|
||||
// 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;
|
||||
|
||||
//
|
||||
// Loop Forever
|
||||
//
|
||||
for(;;)
|
||||
{
|
||||
//
|
||||
// Turn on LED
|
||||
//
|
||||
GPIO_writePin(DEVICE_GPIO_PIN_LED2, 0);
|
||||
|
||||
//
|
||||
// Delay for a bit.
|
||||
//
|
||||
DEVICE_DELAY_US(500000);
|
||||
|
||||
//
|
||||
// Turn off LED
|
||||
//
|
||||
GPIO_writePin(DEVICE_GPIO_PIN_LED2, 1);
|
||||
|
||||
//
|
||||
// Delay for a bit.
|
||||
//
|
||||
DEVICE_DELAY_US(500000);
|
||||
}
|
||||
}
|
||||
|
||||
//
|
||||
// End of File
|
||||
//
|
||||
@@ -0,0 +1,8 @@
|
||||
/* CM Flash sectors */
|
||||
|
||||
/* HEX directive required by HEX utility to generate the golden CMAC tag */
|
||||
/* with one entry that represents all the allocated flash memory */
|
||||
ROMS
|
||||
{
|
||||
FLASH_SECTOR0_13: o=0x00200000 l=0x00080000, fill = 0xFFFFFFFF /* If fill not specified, then default is all 0s */
|
||||
}
|
||||
@@ -0,0 +1,8 @@
|
||||
/* CPU1 Flash sectors */
|
||||
|
||||
/* HEX directive required by HEX utility to generate the golden CMAC tag */
|
||||
/* with one entry that represents all the allocated flash memory */
|
||||
ROMS
|
||||
{
|
||||
FLASH_SECTOR0_13: o=0x00080000 l=0x00040000, fill = 0xFFFF /* If fill not specified, then default is all 0s */
|
||||
}
|
||||
@@ -0,0 +1,8 @@
|
||||
/* CPU2 Flash sectors */
|
||||
|
||||
/* HEX directive required by HEX utility to generate the golden CMAC tag */
|
||||
/* with one entry that represents all the allocated flash memory */
|
||||
ROMS
|
||||
{
|
||||
FLASH_SECTOR0_13: o=0x00080000 l=0x00040000, fill = 0xFFFF /* If fill not specified, then default is all 0s */
|
||||
}
|
||||
@@ -0,0 +1,49 @@
|
||||
;;###########################################################################
|
||||
;;
|
||||
;; FILE: secure_startup_cm.asm
|
||||
;;
|
||||
;; TITLE: Application Reset Branch for Secure Flash Boot Entry Point
|
||||
;;
|
||||
;;###########################################################################
|
||||
;;
|
||||
;// 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.
|
||||
;// $
|
||||
;;###########################################################################
|
||||
.global _c_int00
|
||||
|
||||
;
|
||||
; This is the code that gets called when the processor first starts execution
|
||||
; following a reset event.
|
||||
;
|
||||
.retain ".secureReset"
|
||||
.sect ".secureReset"
|
||||
b.w _c_int00
|
||||
@@ -0,0 +1 @@
|
||||
0xFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF
|
||||
@@ -0,0 +1,41 @@
|
||||
<projectSpec>
|
||||
<project
|
||||
name="can_ex1_loopback"
|
||||
device="TMS320F28388D"
|
||||
cgtVersion="22.6.1.LTS"
|
||||
products="sysconfig;C2000WARE"
|
||||
outputFormat="ELF"
|
||||
launchWizard="False"
|
||||
linkerCommandFile=""
|
||||
enableSysConfigTool="true"
|
||||
sysConfigBuildOptions="--product ${C2000WARE_ROOT}/.metadata/sdk.json --device F2838x --package 337bga --part F2838x_337bga"
|
||||
postBuildStep="
|
||||
echo "========= Build of the CLB simulation has moved to the CLB Tool. Click the '?' icon by the _Generate CLB Simulation File_ enable for more details (located in the Global Parameters of the Tile Design SysConfig module) ============="
|
||||
;if ${GENERATE_DIAGRAM} == 1 ${NODE_TOOL} "${C2000WARE_ROOT}/utilities/clb_tool/clb_syscfg/dot_file_libraries/clbDotUtility.js" "${C2000WARE_ROOT}/utilities/clb_tool/clb_syscfg/" "${BuildDirectory}/syscfg" "${BuildDirectory}/syscfg/clb.dot"
|
||||
;if ${GENERATE_DIAGRAM} == 1 mkdir "${BuildDirectory}/diagrams"
|
||||
;if ${GENERATE_DIAGRAM} == 1 ${NODE_TOOL} "${C2000WARE_ROOT}/driverlib/.meta/generate_diagrams.js" "${C2000WARE_ROOT}" "${BuildDirectory}/diagrams" "${BuildDirectory}/syscfg"
|
||||
"
|
||||
>
|
||||
<configuration name="CPU1_RAM" compilerBuildOptions= "--opt_level=off -I${C2000WARE_ROOT} -I${PROJECT_ROOT}/device -I${C2000WARE_DLIB_ROOT} -v28 -ml -mt --cla_support=cla2 --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="../can_ex1_loopback.c" targetDirectory="" />
|
||||
<file action="copy" path="../can_ex1_loopback.syscfg" targetDirectory="" />
|
||||
</project>
|
||||
</projectSpec>
|
||||
|
||||
+40
@@ -0,0 +1,40 @@
|
||||
<projectSpec>
|
||||
<project
|
||||
name="can_ex2_loopback_interrupts"
|
||||
device="TMS320F28388D"
|
||||
cgtVersion="22.6.1.LTS"
|
||||
products="sysconfig;C2000WARE"
|
||||
outputFormat="ELF"
|
||||
launchWizard="False"
|
||||
linkerCommandFile=""
|
||||
enableSysConfigTool="true"
|
||||
sysConfigBuildOptions="--product ${C2000WARE_ROOT}/.metadata/sdk.json --device F2838x --package 337bga --part F2838x_337bga"
|
||||
postBuildStep="
|
||||
echo "========= Build of the CLB simulation has moved to the CLB Tool. Click the '?' icon by the _Generate CLB Simulation File_ enable for more details (located in the Global Parameters of the Tile Design SysConfig module) ============="
|
||||
;if ${GENERATE_DIAGRAM} == 1 ${NODE_TOOL} "${C2000WARE_ROOT}/utilities/clb_tool/clb_syscfg/dot_file_libraries/clbDotUtility.js" "${C2000WARE_ROOT}/utilities/clb_tool/clb_syscfg/" "${BuildDirectory}/syscfg" "${BuildDirectory}/syscfg/clb.dot"
|
||||
;if ${GENERATE_DIAGRAM} == 1 mkdir "${BuildDirectory}/diagrams"
|
||||
;if ${GENERATE_DIAGRAM} == 1 ${NODE_TOOL} "${C2000WARE_ROOT}/driverlib/.meta/generate_diagrams.js" "${C2000WARE_ROOT}" "${BuildDirectory}/diagrams" "${BuildDirectory}/syscfg"
|
||||
"
|
||||
>
|
||||
<configuration name="CPU1_RAM" compilerBuildOptions= "--opt_level=off -I${C2000WARE_ROOT} -I${PROJECT_ROOT}/device -I${C2000WARE_DLIB_ROOT} -v28 -ml -mt --cla_support=cla2 --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="../can_ex2_loopback_interrupts.c" targetDirectory="" />
|
||||
<file action="copy" path="../../empty_projects/c2000.syscfg" targetDirectory="" />
|
||||
</project>
|
||||
</projectSpec>
|
||||
+40
@@ -0,0 +1,40 @@
|
||||
<projectSpec>
|
||||
<project
|
||||
name="can_ex3_external_transmit"
|
||||
device="TMS320F28388D"
|
||||
cgtVersion="22.6.1.LTS"
|
||||
products="sysconfig;C2000WARE"
|
||||
outputFormat="ELF"
|
||||
launchWizard="False"
|
||||
linkerCommandFile=""
|
||||
enableSysConfigTool="true"
|
||||
sysConfigBuildOptions="--product ${C2000WARE_ROOT}/.metadata/sdk.json --device F2838x --package 337bga --part F2838x_337bga"
|
||||
postBuildStep="
|
||||
echo "========= Build of the CLB simulation has moved to the CLB Tool. Click the '?' icon by the _Generate CLB Simulation File_ enable for more details (located in the Global Parameters of the Tile Design SysConfig module) ============="
|
||||
;if ${GENERATE_DIAGRAM} == 1 ${NODE_TOOL} "${C2000WARE_ROOT}/utilities/clb_tool/clb_syscfg/dot_file_libraries/clbDotUtility.js" "${C2000WARE_ROOT}/utilities/clb_tool/clb_syscfg/" "${BuildDirectory}/syscfg" "${BuildDirectory}/syscfg/clb.dot"
|
||||
;if ${GENERATE_DIAGRAM} == 1 mkdir "${BuildDirectory}/diagrams"
|
||||
;if ${GENERATE_DIAGRAM} == 1 ${NODE_TOOL} "${C2000WARE_ROOT}/driverlib/.meta/generate_diagrams.js" "${C2000WARE_ROOT}" "${BuildDirectory}/diagrams" "${BuildDirectory}/syscfg"
|
||||
"
|
||||
>
|
||||
<configuration name="CPU1_RAM" compilerBuildOptions= "--opt_level=off -I${C2000WARE_ROOT} -I${PROJECT_ROOT}/device -I${C2000WARE_DLIB_ROOT} -v28 -ml -mt --cla_support=cla2 --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="../can_ex3_external_transmit.c" targetDirectory="" />
|
||||
<file action="copy" path="../../empty_projects/c2000.syscfg" targetDirectory="" />
|
||||
</project>
|
||||
</projectSpec>
|
||||
@@ -0,0 +1,40 @@
|
||||
<projectSpec>
|
||||
<project
|
||||
name="can_ex4_loopback_dma"
|
||||
device="TMS320F28388D"
|
||||
cgtVersion="22.6.1.LTS"
|
||||
products="sysconfig;C2000WARE"
|
||||
outputFormat="ELF"
|
||||
launchWizard="False"
|
||||
linkerCommandFile=""
|
||||
enableSysConfigTool="true"
|
||||
sysConfigBuildOptions="--product ${C2000WARE_ROOT}/.metadata/sdk.json --device F2838x --package 337bga --part F2838x_337bga"
|
||||
postBuildStep="
|
||||
echo "========= Build of the CLB simulation has moved to the CLB Tool. Click the '?' icon by the _Generate CLB Simulation File_ enable for more details (located in the Global Parameters of the Tile Design SysConfig module) ============="
|
||||
;if ${GENERATE_DIAGRAM} == 1 ${NODE_TOOL} "${C2000WARE_ROOT}/utilities/clb_tool/clb_syscfg/dot_file_libraries/clbDotUtility.js" "${C2000WARE_ROOT}/utilities/clb_tool/clb_syscfg/" "${BuildDirectory}/syscfg" "${BuildDirectory}/syscfg/clb.dot"
|
||||
;if ${GENERATE_DIAGRAM} == 1 mkdir "${BuildDirectory}/diagrams"
|
||||
;if ${GENERATE_DIAGRAM} == 1 ${NODE_TOOL} "${C2000WARE_ROOT}/driverlib/.meta/generate_diagrams.js" "${C2000WARE_ROOT}" "${BuildDirectory}/diagrams" "${BuildDirectory}/syscfg"
|
||||
"
|
||||
>
|
||||
<configuration name="CPU1_RAM" compilerBuildOptions= "--opt_level=off -I${C2000WARE_ROOT} -I${PROJECT_ROOT}/device -I${C2000WARE_DLIB_ROOT} -v28 -ml -mt --cla_support=cla2 --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="../can_ex4_loopback_dma.c" targetDirectory="" />
|
||||
<file action="copy" path="../../empty_projects/c2000.syscfg" targetDirectory="" />
|
||||
</project>
|
||||
</projectSpec>
|
||||
@@ -0,0 +1,40 @@
|
||||
<projectSpec>
|
||||
<project
|
||||
name="can_ex5_transmit_receive"
|
||||
device="TMS320F28388D"
|
||||
cgtVersion="22.6.1.LTS"
|
||||
products="sysconfig;C2000WARE"
|
||||
outputFormat="ELF"
|
||||
launchWizard="False"
|
||||
linkerCommandFile=""
|
||||
enableSysConfigTool="true"
|
||||
sysConfigBuildOptions="--product ${C2000WARE_ROOT}/.metadata/sdk.json --device F2838x --package 337bga --part F2838x_337bga"
|
||||
postBuildStep="
|
||||
echo "========= Build of the CLB simulation has moved to the CLB Tool. Click the '?' icon by the _Generate CLB Simulation File_ enable for more details (located in the Global Parameters of the Tile Design SysConfig module) ============="
|
||||
;if ${GENERATE_DIAGRAM} == 1 ${NODE_TOOL} "${C2000WARE_ROOT}/utilities/clb_tool/clb_syscfg/dot_file_libraries/clbDotUtility.js" "${C2000WARE_ROOT}/utilities/clb_tool/clb_syscfg/" "${BuildDirectory}/syscfg" "${BuildDirectory}/syscfg/clb.dot"
|
||||
;if ${GENERATE_DIAGRAM} == 1 mkdir "${BuildDirectory}/diagrams"
|
||||
;if ${GENERATE_DIAGRAM} == 1 ${NODE_TOOL} "${C2000WARE_ROOT}/driverlib/.meta/generate_diagrams.js" "${C2000WARE_ROOT}" "${BuildDirectory}/diagrams" "${BuildDirectory}/syscfg"
|
||||
"
|
||||
>
|
||||
<configuration name="CPU1_RAM" compilerBuildOptions= "--opt_level=off -I${C2000WARE_ROOT} -I${PROJECT_ROOT}/device -I${C2000WARE_DLIB_ROOT} -v28 -ml -mt --cla_support=cla2 --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="../can_ex5_transmit_receive.c" targetDirectory="" />
|
||||
<file action="copy" path="../../empty_projects/c2000.syscfg" targetDirectory="" />
|
||||
</project>
|
||||
</projectSpec>
|
||||
@@ -0,0 +1,40 @@
|
||||
<projectSpec>
|
||||
<project
|
||||
name="can_ex6_error_generation"
|
||||
device="TMS320F28388D"
|
||||
cgtVersion="22.6.1.LTS"
|
||||
products="sysconfig;C2000WARE"
|
||||
outputFormat="ELF"
|
||||
launchWizard="False"
|
||||
linkerCommandFile=""
|
||||
enableSysConfigTool="true"
|
||||
sysConfigBuildOptions="--product ${C2000WARE_ROOT}/.metadata/sdk.json --device F2838x --package 337bga --part F2838x_337bga"
|
||||
postBuildStep="
|
||||
echo "========= Build of the CLB simulation has moved to the CLB Tool. Click the '?' icon by the _Generate CLB Simulation File_ enable for more details (located in the Global Parameters of the Tile Design SysConfig module) ============="
|
||||
;if ${GENERATE_DIAGRAM} == 1 ${NODE_TOOL} "${C2000WARE_ROOT}/utilities/clb_tool/clb_syscfg/dot_file_libraries/clbDotUtility.js" "${C2000WARE_ROOT}/utilities/clb_tool/clb_syscfg/" "${BuildDirectory}/syscfg" "${BuildDirectory}/syscfg/clb.dot"
|
||||
;if ${GENERATE_DIAGRAM} == 1 mkdir "${BuildDirectory}/diagrams"
|
||||
;if ${GENERATE_DIAGRAM} == 1 ${NODE_TOOL} "${C2000WARE_ROOT}/driverlib/.meta/generate_diagrams.js" "${C2000WARE_ROOT}" "${BuildDirectory}/diagrams" "${BuildDirectory}/syscfg"
|
||||
"
|
||||
>
|
||||
<configuration name="CPU1_RAM" compilerBuildOptions= "--opt_level=off -I${C2000WARE_ROOT} -I${PROJECT_ROOT}/device -I${C2000WARE_DLIB_ROOT} -v28 -ml -mt --cla_support=cla2 --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="../can_ex6_error_generation.c" targetDirectory="" />
|
||||
<file action="copy" path="../../empty_projects/c2000.syscfg" targetDirectory="" />
|
||||
</project>
|
||||
</projectSpec>
|
||||
+41
@@ -0,0 +1,41 @@
|
||||
<projectSpec>
|
||||
<project
|
||||
name="can_ex7_loopback_tx_rx_remote_frame"
|
||||
device="TMS320F28388D"
|
||||
cgtVersion="22.6.1.LTS"
|
||||
products="sysconfig;C2000WARE"
|
||||
outputFormat="ELF"
|
||||
launchWizard="False"
|
||||
linkerCommandFile=""
|
||||
enableSysConfigTool="true"
|
||||
sysConfigBuildOptions="--product ${C2000WARE_ROOT}/.metadata/sdk.json --device F2838x --package 337bga --part F2838x_337bga"
|
||||
postBuildStep="
|
||||
echo "========= Build of the CLB simulation has moved to the CLB Tool. Click the '?' icon by the _Generate CLB Simulation File_ enable for more details (located in the Global Parameters of the Tile Design SysConfig module) ============="
|
||||
;if ${GENERATE_DIAGRAM} == 1 ${NODE_TOOL} "${C2000WARE_ROOT}/utilities/clb_tool/clb_syscfg/dot_file_libraries/clbDotUtility.js" "${C2000WARE_ROOT}/utilities/clb_tool/clb_syscfg/" "${BuildDirectory}/syscfg" "${BuildDirectory}/syscfg/clb.dot"
|
||||
;if ${GENERATE_DIAGRAM} == 1 mkdir "${BuildDirectory}/diagrams"
|
||||
;if ${GENERATE_DIAGRAM} == 1 ${NODE_TOOL} "${C2000WARE_ROOT}/driverlib/.meta/generate_diagrams.js" "${C2000WARE_ROOT}" "${BuildDirectory}/diagrams" "${BuildDirectory}/syscfg"
|
||||
"
|
||||
>
|
||||
<configuration name="CPU1_RAM" compilerBuildOptions= "--opt_level=off -I${C2000WARE_ROOT} -I${PROJECT_ROOT}/device -I${C2000WARE_DLIB_ROOT} -v28 -ml -mt --cla_support=cla2 --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="../can_ex7_loopback_tx_rx_remote_frame.c" targetDirectory="" />
|
||||
<file action="copy" path="../can_ex7_loopback_tx_rx_remote_frame.syscfg" targetDirectory="" />
|
||||
</project>
|
||||
</projectSpec>
|
||||
|
||||
@@ -0,0 +1,41 @@
|
||||
<projectSpec>
|
||||
<project
|
||||
name="can_ex8_mask"
|
||||
device="TMS320F28388D"
|
||||
cgtVersion="22.6.1.LTS"
|
||||
products="sysconfig;C2000WARE"
|
||||
outputFormat="ELF"
|
||||
launchWizard="False"
|
||||
linkerCommandFile=""
|
||||
enableSysConfigTool="true"
|
||||
sysConfigBuildOptions="--product ${C2000WARE_ROOT}/.metadata/sdk.json --device F2838x --package 337bga --part F2838x_337bga"
|
||||
postBuildStep="
|
||||
echo "========= Build of the CLB simulation has moved to the CLB Tool. Click the '?' icon by the _Generate CLB Simulation File_ enable for more details (located in the Global Parameters of the Tile Design SysConfig module) ============="
|
||||
;if ${GENERATE_DIAGRAM} == 1 ${NODE_TOOL} "${C2000WARE_ROOT}/utilities/clb_tool/clb_syscfg/dot_file_libraries/clbDotUtility.js" "${C2000WARE_ROOT}/utilities/clb_tool/clb_syscfg/" "${BuildDirectory}/syscfg" "${BuildDirectory}/syscfg/clb.dot"
|
||||
;if ${GENERATE_DIAGRAM} == 1 mkdir "${BuildDirectory}/diagrams"
|
||||
;if ${GENERATE_DIAGRAM} == 1 ${NODE_TOOL} "${C2000WARE_ROOT}/driverlib/.meta/generate_diagrams.js" "${C2000WARE_ROOT}" "${BuildDirectory}/diagrams" "${BuildDirectory}/syscfg"
|
||||
"
|
||||
>
|
||||
<configuration name="CPU1_RAM" compilerBuildOptions= "--opt_level=off -I${C2000WARE_ROOT} -I${PROJECT_ROOT}/device -I${C2000WARE_DLIB_ROOT} -v28 -ml -mt --cla_support=cla2 --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="../can_ex8_mask.c" targetDirectory="" />
|
||||
<file action="copy" path="../../empty_projects/c2000.syscfg" targetDirectory="" />
|
||||
</project>
|
||||
</projectSpec>
|
||||
|
||||
@@ -0,0 +1,207 @@
|
||||
//#############################################################################
|
||||
//
|
||||
// FILE: can_ex1_loopback.c
|
||||
//
|
||||
// TITLE: CAN External Loopback Example
|
||||
//
|
||||
//! \addtogroup driver_example_list
|
||||
//! <h1> CAN External Loopback </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. Please refer to details of the External Loopback
|
||||
//! Test Mode in the CAN Chapter in the Technical Reference Manual. Refer
|
||||
//! to [Programming Examples and Debug Strategies for
|
||||
//! the DCAN Module](www.ti.com/lit/SPRACE5) for useful information about
|
||||
//! this example
|
||||
//!
|
||||
//! \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
|
||||
//!
|
||||
//
|
||||
//#############################################################################
|
||||
//
|
||||
//
|
||||
//
|
||||
// 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 "board.h"
|
||||
|
||||
//
|
||||
// Defines
|
||||
//
|
||||
#define MSG_DATA_LENGTH 2
|
||||
|
||||
//
|
||||
// Globals
|
||||
//
|
||||
volatile unsigned long msgCount = 0;
|
||||
|
||||
//
|
||||
// Main
|
||||
//
|
||||
void main(void)
|
||||
{
|
||||
uint16_t txMsgData[2], rxMsgData[2];
|
||||
|
||||
//
|
||||
// Initialize device clock and peripherals
|
||||
//
|
||||
Device_init();
|
||||
|
||||
//
|
||||
// Initialize GPIO and configure GPIO pins for CANTX/CANRX
|
||||
//
|
||||
Device_initGPIO();
|
||||
|
||||
//
|
||||
// Allocated shared peripheral to C28x
|
||||
//
|
||||
SysCtl_allocateSharedPeripheral(SYSCTL_PALLOCATE_CAN_A,0x0U);
|
||||
SysCtl_allocateSharedPeripheral(SYSCTL_PALLOCATE_CAN_B,0x0U);
|
||||
|
||||
//
|
||||
// Board initialization
|
||||
//
|
||||
Board_init();
|
||||
|
||||
//
|
||||
// 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;
|
||||
|
||||
//
|
||||
// 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(myCAN0_BASE, 1, MSG_DATA_LENGTH, txMsgData);
|
||||
|
||||
//
|
||||
// Delay before receiving the data
|
||||
//
|
||||
DEVICE_DELAY_US(500000);
|
||||
|
||||
//
|
||||
// Read CAN message object 2 and check for new data
|
||||
//
|
||||
if (CAN_readMessage(myCAN0_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
|
||||
{
|
||||
//
|
||||
// Increment message received counter
|
||||
//
|
||||
msgCount++;
|
||||
}
|
||||
}
|
||||
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,19 @@
|
||||
/**
|
||||
* Import the modules used in this configuration.
|
||||
*/
|
||||
const can = scripting.addModule("/driverlib/can.js", {}, false);
|
||||
const can1 = can.addInstance();
|
||||
|
||||
/**
|
||||
* Write custom configuration values to the imported modules.
|
||||
*/
|
||||
can1.$name = "myCAN0";
|
||||
can1.msgObjsUsed = [1,2];
|
||||
can1.enableLoopback = true;
|
||||
can1.loopbackMode = "CAN_TEST_EXL";
|
||||
can1.msgObj1.$name = "msgObj0";
|
||||
can1.msgObj1.msgID = 4;
|
||||
can1.msgObj1.msgType = "CAN_MSG_OBJ_TYPE_TX";
|
||||
can1.msgObj1.msgLen = 2;
|
||||
can1.msgObj2.$name = "msgObj1";
|
||||
can1.msgObj2.msgID = 4;
|
||||
@@ -0,0 +1,405 @@
|
||||
//#############################################################################
|
||||
//
|
||||
// FILE: can_ex2_loopback_interrupts.c
|
||||
//
|
||||
// TITLE: CAN External Loopback with Interrupts Example
|
||||
//
|
||||
//! \addtogroup driver_example_list
|
||||
//! <h1> CAN External Loopback with Interrupts </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 4 byte message that contains an incrementing pattern. A CAN interrupt
|
||||
//! handler is used to confirm message transmission and count the number of
|
||||
//! messages that have been sent.
|
||||
//!
|
||||
//! 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. Please refer to details of the External Loopback
|
||||
//! Test Mode in the CAN Chapter in the Technical Reference Manual. Refer
|
||||
//! to [Programming Examples and Debug Strategies for
|
||||
//! the DCAN Module](www.ti.com/lit/SPRACE5) for useful information about
|
||||
//! this example
|
||||
//!
|
||||
//! \b External \b Connections \n
|
||||
//! - None.
|
||||
//!
|
||||
//! \b Watch \b Variables \n
|
||||
//! - txMsgCount - A counter for the number of messages sent
|
||||
//! - rxMsgCount - A counter for the number of messages received
|
||||
//! - txMsgData - An array with the data being sent
|
||||
//! - rxMsgData - An array with the data that was received
|
||||
//! - errorFlag - A flag that indicates an error has occurred
|
||||
//!
|
||||
//
|
||||
//#############################################################################
|
||||
//
|
||||
//
|
||||
//
|
||||
// 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 4
|
||||
#define TX_MSG_OBJ_ID 1
|
||||
#define RX_MSG_OBJ_ID 2
|
||||
|
||||
//
|
||||
// Globals
|
||||
//
|
||||
volatile uint32_t txMsgCount = 0;
|
||||
volatile uint32_t rxMsgCount = 0;
|
||||
volatile uint32_t errorFlag = 0;
|
||||
uint16_t txMsgData[4];
|
||||
uint16_t rxMsgData[4];
|
||||
|
||||
//
|
||||
// Function Prototypes
|
||||
//
|
||||
__interrupt void canISR(void);
|
||||
|
||||
//
|
||||
// Main
|
||||
//
|
||||
void main(void)
|
||||
{
|
||||
//
|
||||
// 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);
|
||||
|
||||
//
|
||||
// Allocated shared peripheral to C28x
|
||||
//
|
||||
SysCtl_allocateSharedPeripheral(SYSCTL_PALLOCATE_CAN_A,0x0U);
|
||||
SysCtl_allocateSharedPeripheral(SYSCTL_PALLOCATE_CAN_B,0x0U);
|
||||
|
||||
//
|
||||
// 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, 20);
|
||||
|
||||
//
|
||||
// Enable interrupts on the CAN peripheral.
|
||||
//
|
||||
CAN_enableInterrupt(CANA_BASE, CAN_INT_IE0 | CAN_INT_ERROR |
|
||||
CAN_INT_STATUS);
|
||||
|
||||
//
|
||||
// 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;
|
||||
|
||||
//
|
||||
// Interrupts that are used in this example are re-mapped to
|
||||
// ISR functions found within this file.
|
||||
// This registers the interrupt handler in PIE vector table.
|
||||
//
|
||||
Interrupt_register(INT_CANA0, &canISR);
|
||||
|
||||
//
|
||||
// Enable the CAN interrupt signal
|
||||
//
|
||||
Interrupt_enable(INT_CANA0);
|
||||
CAN_enableGlobalInterrupt(CANA_BASE, CAN_GLOBAL_INT_CANINT0);
|
||||
|
||||
//
|
||||
// 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: 0x1
|
||||
// Message Frame: Standard
|
||||
// Message Type: Transmit
|
||||
// Message ID Mask: 0x0
|
||||
// Message Object Flags: Transmit Interrupt
|
||||
// Message Data Length: 4 Bytes
|
||||
//
|
||||
CAN_setupMessageObject(CANA_BASE, TX_MSG_OBJ_ID, 0x1, CAN_MSG_FRAME_STD,
|
||||
CAN_MSG_OBJ_TYPE_TX, 0, CAN_MSG_OBJ_TX_INT_ENABLE,
|
||||
MSG_DATA_LENGTH);
|
||||
|
||||
//
|
||||
// Initialize the receive message object used for receiving CAN messages.
|
||||
// Message Object Parameters:
|
||||
// Message Object ID Number: 2
|
||||
// Message Identifier: 0x1
|
||||
// Message Frame: Standard
|
||||
// Message Type: Receive
|
||||
// Message ID Mask: 0x0
|
||||
// Message Object Flags: Receive Interrupt
|
||||
// Message Data Length: 4 Bytes (Note that DLC field is a "don't care"
|
||||
// for a Receive mailbox
|
||||
//
|
||||
CAN_setupMessageObject(CANA_BASE, RX_MSG_OBJ_ID, 0x1, CAN_MSG_FRAME_STD,
|
||||
CAN_MSG_OBJ_TYPE_RX, 0, CAN_MSG_OBJ_RX_INT_ENABLE,
|
||||
MSG_DATA_LENGTH);
|
||||
|
||||
//
|
||||
// Initialize the transmit message object data buffer to be sent
|
||||
//
|
||||
txMsgData[0] = 0x12;
|
||||
txMsgData[1] = 0x34;
|
||||
txMsgData[2] = 0x56;
|
||||
txMsgData[3] = 0x78;
|
||||
|
||||
//
|
||||
// Start CAN module operations
|
||||
//
|
||||
CAN_startModule(CANA_BASE);
|
||||
|
||||
//
|
||||
// Loop Forever - A new message will be sent once per second.
|
||||
//
|
||||
for(;;)
|
||||
{
|
||||
//
|
||||
// Check the error flag to see if errors occurred
|
||||
//
|
||||
if(errorFlag)
|
||||
{
|
||||
asm(" ESTOP0");
|
||||
}
|
||||
|
||||
//
|
||||
// Verify that the number of transmitted messages equal the number of
|
||||
// messages received before sending a new message
|
||||
//
|
||||
if(txMsgCount == rxMsgCount)
|
||||
{
|
||||
CAN_sendMessage(CANA_BASE, TX_MSG_OBJ_ID, MSG_DATA_LENGTH,
|
||||
txMsgData);
|
||||
}
|
||||
else
|
||||
{
|
||||
errorFlag = 1;
|
||||
}
|
||||
|
||||
//
|
||||
// Delay 1 second before continuing
|
||||
//
|
||||
DEVICE_DELAY_US(1000000);
|
||||
|
||||
//
|
||||
// Increment the value in the transmitted message data.
|
||||
//
|
||||
txMsgData[0] += 0x01;
|
||||
txMsgData[1] += 0x01;
|
||||
txMsgData[2] += 0x01;
|
||||
txMsgData[3] += 0x01;
|
||||
|
||||
//
|
||||
// Reset data if exceeds a byte
|
||||
//
|
||||
if(txMsgData[0] > 0xFF)
|
||||
{
|
||||
txMsgData[0] = 0;
|
||||
}
|
||||
if(txMsgData[1] > 0xFF)
|
||||
{
|
||||
txMsgData[1] = 0;
|
||||
}
|
||||
if(txMsgData[2] > 0xFF)
|
||||
{
|
||||
txMsgData[2] = 0;
|
||||
}
|
||||
if(txMsgData[3] > 0xFF)
|
||||
{
|
||||
txMsgData[3] = 0;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
//
|
||||
// CAN ISR - The interrupt service routine called when a CAN interrupt is
|
||||
// triggered. It checks for the cause of the interrupt, and
|
||||
// maintains a count of all messages that have been transmitted.
|
||||
//
|
||||
__interrupt void
|
||||
canISR(void)
|
||||
{
|
||||
uint32_t status;
|
||||
|
||||
//
|
||||
// Read the CAN interrupt status to find the cause of the interrupt
|
||||
//
|
||||
status = CAN_getInterruptCause(CANA_BASE);
|
||||
|
||||
//
|
||||
// If the cause is a controller status interrupt, then get the status
|
||||
//
|
||||
if(status == CAN_INT_INT0ID_STATUS)
|
||||
{
|
||||
//
|
||||
// Read the controller status. This will return a field of status
|
||||
// error bits that can indicate various errors. Error processing
|
||||
// is not done in this example for simplicity. Refer to the
|
||||
// API documentation for details about the error status bits.
|
||||
// The act of reading this status will clear the interrupt.
|
||||
//
|
||||
status = CAN_getStatus(CANA_BASE);
|
||||
|
||||
//
|
||||
// Check to see if an error occurred.
|
||||
//
|
||||
if(((status & ~(CAN_STATUS_TXOK | CAN_STATUS_RXOK)) != 7) &&
|
||||
((status & ~(CAN_STATUS_TXOK | CAN_STATUS_RXOK)) != 0))
|
||||
{
|
||||
//
|
||||
// Set a flag to indicate some errors may have occurred.
|
||||
//
|
||||
errorFlag = 1;
|
||||
}
|
||||
}
|
||||
|
||||
//
|
||||
// Check if the cause is the transmit message object 1
|
||||
//
|
||||
else if(status == TX_MSG_OBJ_ID)
|
||||
{
|
||||
//
|
||||
// Getting to this point means that the TX interrupt occurred on
|
||||
// message object 1, and the message TX is complete. Clear the
|
||||
// message object interrupt.
|
||||
//
|
||||
CAN_clearInterruptStatus(CANA_BASE, TX_MSG_OBJ_ID);
|
||||
|
||||
//
|
||||
// Increment a counter to keep track of how many messages have been
|
||||
// sent. In a real application this could be used to set flags to
|
||||
// indicate when a message is sent.
|
||||
//
|
||||
txMsgCount++;
|
||||
|
||||
//
|
||||
// Since the message was sent, clear any error flags.
|
||||
//
|
||||
errorFlag = 0;
|
||||
}
|
||||
|
||||
//
|
||||
// Check if the cause is the receive message object 2
|
||||
//
|
||||
else if(status == RX_MSG_OBJ_ID)
|
||||
{
|
||||
//
|
||||
// Get the received message
|
||||
//
|
||||
CAN_readMessage(CANA_BASE, RX_MSG_OBJ_ID, rxMsgData);
|
||||
|
||||
//
|
||||
// Getting to this point means that the RX interrupt occurred on
|
||||
// message object 2, and the message RX is complete. Clear the
|
||||
// message object interrupt.
|
||||
//
|
||||
CAN_clearInterruptStatus(CANA_BASE, RX_MSG_OBJ_ID);
|
||||
|
||||
//
|
||||
// Increment a counter to keep track of how many messages have been
|
||||
// received. In a real application this could be used to set flags to
|
||||
// indicate when a message is received.
|
||||
//
|
||||
rxMsgCount++;
|
||||
|
||||
//
|
||||
// Since the message was received, clear any error flags.
|
||||
//
|
||||
errorFlag = 0;
|
||||
}
|
||||
|
||||
//
|
||||
// If something unexpected caused the interrupt, this would handle it.
|
||||
//
|
||||
else
|
||||
{
|
||||
//
|
||||
// Spurious interrupt handling can go here.
|
||||
//
|
||||
}
|
||||
|
||||
//
|
||||
// Clear the global interrupt flag for the CAN interrupt line
|
||||
//
|
||||
CAN_clearGlobalInterruptStatus(CANA_BASE, CAN_GLOBAL_INT_CANINT0);
|
||||
|
||||
//
|
||||
// Acknowledge this interrupt located in group 9
|
||||
//
|
||||
Interrupt_clearACKGroup(INTERRUPT_ACK_GROUP9);
|
||||
}
|
||||
|
||||
//
|
||||
// End of File
|
||||
//
|
||||
@@ -0,0 +1,383 @@
|
||||
//#############################################################################
|
||||
//
|
||||
// FILE: can_ex3_external_transmit.c
|
||||
//
|
||||
// TITLE: CAN External Transmit Example
|
||||
//
|
||||
//! \addtogroup driver_example_list
|
||||
//! <h1> CAN-A to CAN-B External Transmit </h1>
|
||||
//!
|
||||
//! This example initializes CAN module A and CAN module B for external
|
||||
//! communication. CAN-A module is setup to transmit incrementing data for "n"
|
||||
//! number of times to the CAN-B module, where "n" is the value of TXCOUNT.
|
||||
//! CAN-B module is setup to trigger an interrupt service routine (ISR) when
|
||||
//! data is received. An error flag will be set if the transmitted data doesn't
|
||||
//! match the received data.
|
||||
//!
|
||||
//! \note Both CAN modules on the device need to be connected to each other
|
||||
//! via CAN transceivers.
|
||||
//!
|
||||
//! \b Hardware \b Required \n
|
||||
//! - A C2000 board with two CAN transceivers
|
||||
//!
|
||||
//! \b External \b Connections \n
|
||||
//! - ControlCARD CANA is on DEVICE_GPIO_PIN_CANTXA (CANTXA)
|
||||
//! - and DEVICE_GPIO_PIN_CANRXA (CANRXA)
|
||||
//! - ControlCARD CANB is on DEVICE_GPIO_PIN_CANTXB (CANTXB)
|
||||
//! - and DEVICE_GPIO_PIN_CANRXB (CANRXB)
|
||||
//!
|
||||
//! \b Watch \b Variables \n
|
||||
//! - TXCOUNT - Adjust to set the number of messages to be transmitted
|
||||
//! - txMsgCount - A counter for the number of messages sent
|
||||
//! - rxMsgCount - A counter for the number of messages received
|
||||
//! - txMsgData - An array with the data being sent
|
||||
//! - rxMsgData - An array with the data that was received
|
||||
//! - errorFlag - A flag that indicates an error has occurred
|
||||
//!
|
||||
//
|
||||
//#############################################################################
|
||||
//
|
||||
//
|
||||
//
|
||||
// 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 TXCOUNT 100
|
||||
#define MSG_DATA_LENGTH 4
|
||||
#define TX_MSG_OBJ_ID 1
|
||||
#define RX_MSG_OBJ_ID 1
|
||||
|
||||
//
|
||||
// Globals
|
||||
//
|
||||
volatile unsigned long i;
|
||||
volatile uint32_t txMsgCount = 0;
|
||||
volatile uint32_t rxMsgCount = 0;
|
||||
volatile uint32_t errorFlag = 0;
|
||||
uint16_t txMsgData[4];
|
||||
uint16_t rxMsgData[4];
|
||||
|
||||
//
|
||||
// Function Prototypes
|
||||
//
|
||||
__interrupt void canbISR(void);
|
||||
|
||||
//
|
||||
// Main
|
||||
//
|
||||
void main(void)
|
||||
{
|
||||
//
|
||||
// Initialize device clock and peripherals
|
||||
//
|
||||
Device_init();
|
||||
|
||||
//
|
||||
// Initialize GPIO and configure GPIO pins for CANTX/CANRX
|
||||
// on module A and B
|
||||
//
|
||||
Device_initGPIO();
|
||||
GPIO_setPinConfig(DEVICE_GPIO_CFG_CANRXA);
|
||||
GPIO_setPinConfig(DEVICE_GPIO_CFG_CANTXA);
|
||||
GPIO_setPinConfig(DEVICE_GPIO_CFG_CANRXB);
|
||||
GPIO_setPinConfig(DEVICE_GPIO_CFG_CANTXB);
|
||||
|
||||
//
|
||||
// Initialize the CAN controllers
|
||||
//
|
||||
CAN_initModule(CANA_BASE);
|
||||
CAN_initModule(CANB_BASE);
|
||||
|
||||
//
|
||||
// Set up the CAN bus bit rate to 500kHz for each module
|
||||
// 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, 20);
|
||||
CAN_setBitRate(CANB_BASE, DEVICE_SYSCLK_FREQ, 500000, 20);
|
||||
|
||||
//
|
||||
// Enable interrupts on the CAN B peripheral.
|
||||
//
|
||||
CAN_enableInterrupt(CANB_BASE, CAN_INT_IE0 | CAN_INT_ERROR |
|
||||
CAN_INT_STATUS);
|
||||
|
||||
//
|
||||
// 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;
|
||||
|
||||
//
|
||||
// Interrupts that are used in this example are re-mapped to
|
||||
// ISR functions found within this file.
|
||||
// This registers the interrupt handler in PIE vector table.
|
||||
//
|
||||
Interrupt_register(INT_CANB0, &canbISR);
|
||||
|
||||
//
|
||||
// Enable the CAN-B interrupt signal
|
||||
//
|
||||
Interrupt_enable(INT_CANB0);
|
||||
CAN_enableGlobalInterrupt(CANB_BASE, CAN_GLOBAL_INT_CANINT0);
|
||||
|
||||
//
|
||||
// Initialize the transmit message object used for sending CAN messages.
|
||||
// Message Object Parameters:
|
||||
// CAN Module: A
|
||||
// Message Object ID Number: 1
|
||||
// Message Identifier: 0x15555555
|
||||
// Message Frame: Extended
|
||||
// Message Type: Transmit
|
||||
// Message ID Mask: 0x0
|
||||
// Message Object Flags: None
|
||||
// Message Data Length: 4 Bytes (Note that DLC field is a "don't care"
|
||||
// for a Receive mailbox
|
||||
//
|
||||
CAN_setupMessageObject(CANA_BASE, TX_MSG_OBJ_ID, 0x15555555,
|
||||
CAN_MSG_FRAME_EXT, 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:
|
||||
// CAN Module: B
|
||||
// Message Object ID Number: 1
|
||||
// Message Identifier: 0x15555555
|
||||
// Message Frame: Extended
|
||||
// Message Type: Receive
|
||||
// Message ID Mask: 0x0
|
||||
// Message Object Flags: Receive Interrupt
|
||||
// Message Data Length: 4 Bytes
|
||||
//
|
||||
CAN_setupMessageObject(CANB_BASE, RX_MSG_OBJ_ID, 0x15555555,
|
||||
CAN_MSG_FRAME_EXT, CAN_MSG_OBJ_TYPE_RX, 0,
|
||||
CAN_MSG_OBJ_RX_INT_ENABLE, MSG_DATA_LENGTH);
|
||||
|
||||
//
|
||||
// Initialize the transmit message object data buffer to be sent
|
||||
//
|
||||
txMsgData[0] = 0x12;
|
||||
txMsgData[1] = 0x34;
|
||||
txMsgData[2] = 0x56;
|
||||
txMsgData[3] = 0x78;
|
||||
|
||||
//
|
||||
// Start CAN module A and B operations
|
||||
//
|
||||
CAN_startModule(CANA_BASE);
|
||||
CAN_startModule(CANB_BASE);
|
||||
|
||||
//
|
||||
// Transmit messages from CAN-A to CAN-B
|
||||
//
|
||||
for(i = 0; i < TXCOUNT; i++)
|
||||
{
|
||||
//
|
||||
// Check the error flag to see if errors occurred
|
||||
//
|
||||
if(errorFlag)
|
||||
{
|
||||
asm(" ESTOP0");
|
||||
}
|
||||
|
||||
//
|
||||
// Verify that the number of transmitted messages equal the number of
|
||||
// messages received before sending a new message
|
||||
//
|
||||
if(txMsgCount == rxMsgCount)
|
||||
{
|
||||
CAN_sendMessage(CANA_BASE, TX_MSG_OBJ_ID, MSG_DATA_LENGTH,
|
||||
txMsgData);
|
||||
txMsgCount++;
|
||||
}
|
||||
else
|
||||
{
|
||||
errorFlag = 1;
|
||||
}
|
||||
|
||||
//
|
||||
// Delay 0.25 second before continuing
|
||||
//
|
||||
DEVICE_DELAY_US(250000);
|
||||
|
||||
//
|
||||
// Increment the value in the transmitted message data.
|
||||
//
|
||||
txMsgData[0] += 0x01;
|
||||
txMsgData[1] += 0x01;
|
||||
txMsgData[2] += 0x01;
|
||||
txMsgData[3] += 0x01;
|
||||
|
||||
//
|
||||
// Reset data if exceeds a byte
|
||||
//
|
||||
if(txMsgData[0] > 0xFF)
|
||||
{
|
||||
txMsgData[0] = 0;
|
||||
}
|
||||
if(txMsgData[1] > 0xFF)
|
||||
{
|
||||
txMsgData[1] = 0;
|
||||
}
|
||||
if(txMsgData[2] > 0xFF)
|
||||
{
|
||||
txMsgData[2] = 0;
|
||||
}
|
||||
if(txMsgData[3] > 0xFF)
|
||||
{
|
||||
txMsgData[3] = 0;
|
||||
}
|
||||
}
|
||||
|
||||
//
|
||||
// Stop application
|
||||
//
|
||||
asm(" ESTOP0");
|
||||
}
|
||||
|
||||
//
|
||||
// CAN B ISR - The interrupt service routine called when a CAN interrupt is
|
||||
// triggered on CAN module B.
|
||||
//
|
||||
__interrupt void
|
||||
canbISR(void)
|
||||
{
|
||||
uint32_t status;
|
||||
|
||||
//
|
||||
// Read the CAN-B interrupt status to find the cause of the interrupt
|
||||
//
|
||||
status = CAN_getInterruptCause(CANB_BASE);
|
||||
|
||||
//
|
||||
// If the cause is a controller status interrupt, then get the status
|
||||
//
|
||||
if(status == CAN_INT_INT0ID_STATUS)
|
||||
{
|
||||
//
|
||||
// Read the controller status. This will return a field of status
|
||||
// error bits that can indicate various errors. Error processing
|
||||
// is not done in this example for simplicity. Refer to the
|
||||
// API documentation for details about the error status bits.
|
||||
// The act of reading this status will clear the interrupt.
|
||||
//
|
||||
status = CAN_getStatus(CANB_BASE);
|
||||
|
||||
//
|
||||
// Check to see if an error occurred.
|
||||
//
|
||||
if(((status & ~(CAN_STATUS_RXOK)) != CAN_STATUS_LEC_MSK) &&
|
||||
((status & ~(CAN_STATUS_RXOK)) != CAN_STATUS_LEC_NONE))
|
||||
{
|
||||
//
|
||||
// Set a flag to indicate some errors may have occurred.
|
||||
//
|
||||
errorFlag = 1;
|
||||
}
|
||||
}
|
||||
//
|
||||
// Check if the cause is the CAN-B receive message object 1
|
||||
//
|
||||
else if(status == RX_MSG_OBJ_ID)
|
||||
{
|
||||
//
|
||||
// Get the received message
|
||||
//
|
||||
CAN_readMessage(CANB_BASE, RX_MSG_OBJ_ID, rxMsgData);
|
||||
|
||||
//
|
||||
// Getting to this point means that the RX interrupt occurred on
|
||||
// message object 1, and the message RX is complete. Clear the
|
||||
// message object interrupt.
|
||||
//
|
||||
CAN_clearInterruptStatus(CANB_BASE, RX_MSG_OBJ_ID);
|
||||
|
||||
//
|
||||
// Increment a counter to keep track of how many messages have been
|
||||
// received. In a real application this could be used to set flags to
|
||||
// indicate when a message is received.
|
||||
//
|
||||
rxMsgCount++;
|
||||
|
||||
//
|
||||
// Since the message was received, clear any error flags.
|
||||
//
|
||||
errorFlag = 0;
|
||||
}
|
||||
//
|
||||
// If something unexpected caused the interrupt, this would handle it.
|
||||
//
|
||||
else
|
||||
{
|
||||
//
|
||||
// Spurious interrupt handling can go here.
|
||||
//
|
||||
}
|
||||
|
||||
//
|
||||
// Clear the global interrupt flag for the CAN interrupt line
|
||||
//
|
||||
CAN_clearGlobalInterruptStatus(CANB_BASE, CAN_GLOBAL_INT_CANINT0);
|
||||
|
||||
//
|
||||
// Acknowledge this interrupt located in group 9
|
||||
//
|
||||
Interrupt_clearACKGroup(INTERRUPT_ACK_GROUP9);
|
||||
}
|
||||
|
||||
//
|
||||
// End of File
|
||||
//
|
||||
@@ -0,0 +1,432 @@
|
||||
//#############################################################################
|
||||
//
|
||||
// FILE: can_ex4_loopback_dma.c
|
||||
//
|
||||
// TITLE: CAN External Loopback with DMA Example
|
||||
//
|
||||
//! \addtogroup driver_example_list
|
||||
//! <h1> CAN External Loopback with DMA </h1>
|
||||
//!
|
||||
//! This example sets up the CAN module to transmit and receive
|
||||
//! messages on the CAN bus. The CAN module is set to transmit a 4 byte
|
||||
//! message internally. An interrupt is used to assert the DMA request line
|
||||
//! which then triggers the DMA to transfer the received data from the CAN
|
||||
//! interface register to the receive buffer array. A data check is performed
|
||||
//! once the transfer is complete.
|
||||
//!
|
||||
//! 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. Please refer to details of the External Loopback
|
||||
//! Test Mode in the CAN Chapter in the Technical Reference Manual. Please
|
||||
//! refer to the appnote Programming Examples and Debug Strategies for
|
||||
//! the DCAN Module (www.ti.com/lit/SPRACE5) for useful information about
|
||||
//! this example
|
||||
//!
|
||||
//! \b External \b Connections \n
|
||||
//! - None.
|
||||
//!
|
||||
//! \b Watch \b Variables \n
|
||||
//! - txMsgCount - A counter for the number of messages sent
|
||||
//! - rxMsgCount - A counter for the number of messages received
|
||||
//! - txMsgData - An array with the data being sent
|
||||
//! - rxMsgData - An array with the data that was received
|
||||
//!
|
||||
//
|
||||
//#############################################################################
|
||||
//
|
||||
//
|
||||
//
|
||||
// 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 4
|
||||
#define TX_MSG_OBJ_ID 1
|
||||
#define RX_MSG_OBJ_ID 2
|
||||
#define DMA_BURST 2
|
||||
#define DMA_TRANSFER 1
|
||||
#define CAN_IF2 2
|
||||
|
||||
//
|
||||
// Globals
|
||||
//
|
||||
volatile uint32_t txMsgCount = 0;
|
||||
volatile uint32_t rxMsgCount = 0;
|
||||
uint16_t txMsgData[4] = {0x12, 0x34, 0x56, 0x78};
|
||||
uint16_t rxMsgData[2] = {0xFFFF, 0xFFFF};
|
||||
volatile uint16_t done = 0;
|
||||
|
||||
// Place buffers in GSRAM
|
||||
#pragma DATA_SECTION(txMsgData, "ramgs0");
|
||||
#pragma DATA_SECTION(rxMsgData, "ramgs0");
|
||||
|
||||
//
|
||||
// Function Prototypes
|
||||
//
|
||||
void initDMA(void);
|
||||
__interrupt void dmaCh5ISR(void);
|
||||
__interrupt void canISR(void);
|
||||
|
||||
//
|
||||
// Main
|
||||
//
|
||||
void main(void)
|
||||
{
|
||||
//
|
||||
// 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);
|
||||
|
||||
//
|
||||
// Allocated shared peripheral to C28x
|
||||
//
|
||||
SysCtl_allocateSharedPeripheral(SYSCTL_PALLOCATE_CAN_A,0x0U);
|
||||
SysCtl_allocateSharedPeripheral(SYSCTL_PALLOCATE_CAN_B,0x0U);
|
||||
|
||||
//
|
||||
// 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, 20);
|
||||
|
||||
//
|
||||
// Enable interrupts on the CAN peripheral.
|
||||
//
|
||||
CAN_enableInterrupt(CANA_BASE, CAN_INT_IE0 | CAN_INT_ERROR |
|
||||
CAN_INT_STATUS);
|
||||
|
||||
//
|
||||
// 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;
|
||||
|
||||
//
|
||||
// Interrupts that are used in this example are re-mapped to
|
||||
// ISR functions found within this file.
|
||||
// This registers the interrupt handler in PIE vector table.
|
||||
//
|
||||
Interrupt_register(INT_CANA0, &canISR);
|
||||
Interrupt_register(INT_DMA_CH5, &dmaCh5ISR);
|
||||
|
||||
//
|
||||
// Setup the DMA for CAN use
|
||||
//
|
||||
initDMA();
|
||||
|
||||
//
|
||||
// Enable the CAN DMA request lines for IF1, IF2, and IF3
|
||||
//
|
||||
CAN_enableDMARequests(CANA_BASE);
|
||||
|
||||
//
|
||||
// Enable the CAN and DMA interrupt signal
|
||||
//
|
||||
Interrupt_enable(INT_DMA_CH5);
|
||||
Interrupt_enable(INT_CANA0);
|
||||
CAN_enableGlobalInterrupt(CANA_BASE, CAN_GLOBAL_INT_CANINT0);
|
||||
|
||||
//
|
||||
// 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: 0x1
|
||||
// Message Frame: Standard
|
||||
// Message Type: Transmit
|
||||
// Message ID Mask: 0x0
|
||||
// Message Object Flags: Transmit Interrupt
|
||||
// Message Data Length: 4 Bytes
|
||||
//
|
||||
CAN_setupMessageObject(CANA_BASE, TX_MSG_OBJ_ID, 0x1, CAN_MSG_FRAME_STD,
|
||||
CAN_MSG_OBJ_TYPE_TX, 0, CAN_MSG_OBJ_TX_INT_ENABLE,
|
||||
MSG_DATA_LENGTH);
|
||||
|
||||
//
|
||||
// Initialize the receive message object used for receiving CAN messages.
|
||||
// Message Object Parameters:
|
||||
// Message Object ID Number: 2
|
||||
// Message Identifier: 0x1
|
||||
// Message Frame: Standard
|
||||
// Message Type: Receive
|
||||
// Message ID Mask: 0x0
|
||||
// Message Object Flags: Receive Interrupt
|
||||
// Message Data Length: 4 Bytes (Note that DLC field is a "don't care"
|
||||
// for a Receive mailbox
|
||||
//
|
||||
CAN_setupMessageObject(CANA_BASE, RX_MSG_OBJ_ID, 0x1, CAN_MSG_FRAME_STD,
|
||||
CAN_MSG_OBJ_TYPE_RX, 0, CAN_MSG_OBJ_RX_INT_ENABLE,
|
||||
MSG_DATA_LENGTH);
|
||||
|
||||
//
|
||||
// Start CAN module operations
|
||||
//
|
||||
CAN_startModule(CANA_BASE);
|
||||
|
||||
//
|
||||
// Start the DMA channel
|
||||
//
|
||||
DMA_startChannel(DMA_CH5_BASE);
|
||||
|
||||
//
|
||||
// Transmit the CAN message
|
||||
//
|
||||
CAN_sendMessage(CANA_BASE, TX_MSG_OBJ_ID, MSG_DATA_LENGTH,
|
||||
txMsgData);
|
||||
|
||||
//
|
||||
// Wait until the CAN message is received and the DMA transfer is complete
|
||||
//
|
||||
while(!done);
|
||||
|
||||
//
|
||||
// When the DMA transfer is complete, the program will stop here
|
||||
//
|
||||
ESTOP0;
|
||||
}
|
||||
|
||||
//
|
||||
// initDMA - Initialize the DMA controller and configure DMA channel 5 to
|
||||
// transfer the received CAN data into the specified RX buffer
|
||||
//
|
||||
void initDMA()
|
||||
{
|
||||
//
|
||||
// Initialize DMA
|
||||
//
|
||||
DMA_initController();
|
||||
|
||||
//
|
||||
// Configure DMA Ch5 for RX. When the CAN asserts the DMA line, the DMA
|
||||
// will transfer the contents of the IF2 data register into the RX buffer
|
||||
//
|
||||
DMA_configAddresses(DMA_CH5_BASE, rxMsgData,
|
||||
(uint16_t *)(CANA_BASE + CAN_O_IF2DATA));
|
||||
DMA_configBurst(DMA_CH5_BASE, DMA_BURST, 2, 1);
|
||||
DMA_configTransfer(DMA_CH5_BASE, DMA_TRANSFER, 0, 0);
|
||||
DMA_configMode(DMA_CH5_BASE, DMA_TRIGGER_CANAIF2, DMA_CFG_ONESHOT_DISABLE |
|
||||
DMA_CFG_CONTINUOUS_DISABLE | DMA_CFG_SIZE_16BIT);
|
||||
|
||||
//
|
||||
// Configure DMA Ch5 interrupts
|
||||
//
|
||||
DMA_setInterruptMode(DMA_CH5_BASE, DMA_INT_AT_END);
|
||||
DMA_enableInterrupt(DMA_CH5_BASE);
|
||||
DMA_enableTrigger(DMA_CH5_BASE);
|
||||
}
|
||||
|
||||
//
|
||||
// CAN ISR - The interrupt service routine called when a CAN interrupt is
|
||||
// triggered. It checks for the cause of the interrupt, and
|
||||
// maintains a count of all messages that have been transmitted.
|
||||
//
|
||||
__interrupt void
|
||||
canISR(void)
|
||||
{
|
||||
uint32_t status;
|
||||
|
||||
//
|
||||
// Read the CAN interrupt status to find the cause of the interrupt
|
||||
//
|
||||
status = CAN_getInterruptCause(CANA_BASE);
|
||||
|
||||
//
|
||||
// If the cause is a controller status interrupt, then get the status
|
||||
//
|
||||
if(status == CAN_INT_INT0ID_STATUS)
|
||||
{
|
||||
//
|
||||
// Read the controller status. This will return a field of status
|
||||
// error bits that can indicate various errors. Error processing
|
||||
// is not done in this example for simplicity. Refer to the
|
||||
// API documentation for details about the error status bits.
|
||||
// The act of reading this status will clear the interrupt.
|
||||
//
|
||||
status = CAN_getStatus(CANA_BASE);
|
||||
|
||||
//
|
||||
// Check to see if an error occurred.
|
||||
//
|
||||
if(((status & ~(CAN_STATUS_TXOK | CAN_STATUS_RXOK)) != 7) &&
|
||||
((status & ~(CAN_STATUS_TXOK | CAN_STATUS_RXOK)) != 0))
|
||||
{
|
||||
// Something went wrong. rData doesn't contain expected data.
|
||||
ESTOP0;
|
||||
}
|
||||
}
|
||||
|
||||
//
|
||||
// Check if the cause is the transmit message object 1
|
||||
//
|
||||
else if(status == TX_MSG_OBJ_ID)
|
||||
{
|
||||
//
|
||||
// Getting to this point means that the TX interrupt occurred on
|
||||
// message object 1, and the message TX is complete. Clear the
|
||||
// message object interrupt.
|
||||
//
|
||||
CAN_clearInterruptStatus(CANA_BASE, TX_MSG_OBJ_ID);
|
||||
|
||||
//
|
||||
// Increment a counter to keep track of how many messages have been
|
||||
// sent. In a real application this could be used to set flags to
|
||||
// indicate when a message is sent.
|
||||
//
|
||||
txMsgCount++;
|
||||
}
|
||||
|
||||
//
|
||||
// Check if the cause is the receive message object 2
|
||||
//
|
||||
else if(status == RX_MSG_OBJ_ID)
|
||||
{
|
||||
//
|
||||
// Assert the DMA request line for IF2 register for the message object
|
||||
//
|
||||
CAN_transferMessage(CANA_BASE, CAN_IF2, RX_MSG_OBJ_ID, false, true);
|
||||
|
||||
//
|
||||
// Getting to this point means that the RX interrupt occurred on
|
||||
// message object 2, and the message RX is complete. Clear the
|
||||
// message object interrupt.
|
||||
//
|
||||
CAN_clearInterruptStatus(CANA_BASE, RX_MSG_OBJ_ID);
|
||||
|
||||
//
|
||||
// Increment a counter to keep track of how many messages have been
|
||||
// received. In a real application this could be used to set flags to
|
||||
// indicate when a message is received.
|
||||
//
|
||||
rxMsgCount++;
|
||||
}
|
||||
|
||||
//
|
||||
// If something unexpected caused the interrupt, this would handle it.
|
||||
//
|
||||
else
|
||||
{
|
||||
//
|
||||
// Spurious interrupt handling can go here.
|
||||
//
|
||||
}
|
||||
|
||||
//
|
||||
// Clear the global interrupt flag for the CAN interrupt line
|
||||
//
|
||||
CAN_clearGlobalInterruptStatus(CANA_BASE, CAN_GLOBAL_INT_CANINT0);
|
||||
|
||||
//
|
||||
// Acknowledge this interrupt located in group 9
|
||||
//
|
||||
Interrupt_clearACKGroup(INTERRUPT_ACK_GROUP9);
|
||||
}
|
||||
|
||||
//
|
||||
// DMA Channel 5 ISR - The interrupt service routine called when the DMA
|
||||
// channel completes the transfer of data into the buffer.
|
||||
//
|
||||
__interrupt void dmaCh5ISR(void)
|
||||
{
|
||||
uint16_t i, txWordData, txIndex = 0;
|
||||
|
||||
//
|
||||
// Stop the DMA channel operations and acknowledge interrupt
|
||||
//
|
||||
DMA_stopChannel(DMA_CH5_BASE);
|
||||
Interrupt_clearACKGroup(INTERRUPT_ACK_GROUP7);
|
||||
|
||||
//
|
||||
// Check for data integrity
|
||||
//
|
||||
for(i = 0; i < 2; i++)
|
||||
{
|
||||
//
|
||||
// Combine two bytes of CAN TX data into a single word for error
|
||||
// checking since the DMA transfers data as words into the RX buffer.
|
||||
//
|
||||
txWordData = txMsgData[txIndex] + (txMsgData[txIndex + 1] << 8U);
|
||||
|
||||
if(rxMsgData[i] != txWordData)
|
||||
{
|
||||
// Something went wrong. rxMsgData doesn't contain expected data.
|
||||
ESTOP0;
|
||||
}
|
||||
|
||||
txIndex+=2;
|
||||
}
|
||||
|
||||
done = 1;
|
||||
return;
|
||||
}
|
||||
|
||||
//
|
||||
// End of File
|
||||
//
|
||||
@@ -0,0 +1,400 @@
|
||||
//#############################################################################
|
||||
//
|
||||
// FILE: can_ex5_transmit_receive.c
|
||||
//
|
||||
// TITLE: CAN Configuration for Transmit and Receive.
|
||||
//
|
||||
//! \addtogroup driver_example_list
|
||||
//! <h1> CAN Transmit and Receive Configurations </h1>
|
||||
//!
|
||||
//! This example shows the basic setup of CAN in order to transmit or receive
|
||||
//! messages on the CAN bus with a specific Message ID. The CAN Controller is
|
||||
//! configured according to the selection of the define.
|
||||
//!
|
||||
//! When the TRANSMIT define is selected, the CAN Controller acts as a
|
||||
//! Transmitter and sends data to the second CAN Controller connected
|
||||
//! externally.If TRANMSIT is not defined the CAN Controller acts as a Receiver
|
||||
//! and waits for message to be transmitted by the External CAN Controller.
|
||||
//! Refer to [Programming Examples and Debug Strategies for
|
||||
//! the DCAN Module](www.ti.com/lit/SPRACE5) for useful information about
|
||||
//! this example
|
||||
//!
|
||||
//! \note CAN modules on the device need to be connected to via CAN
|
||||
//! transceivers.
|
||||
//!
|
||||
//! \b Hardware \b Required \n
|
||||
//! - A C2000 board with CAN transceiver.
|
||||
//!
|
||||
//! \b External \b Connections \n
|
||||
//! - ControlCARD CANA is on DEVICE_GPIO_PIN_CANTXA (CANTXA)
|
||||
//! - and DEVICE_GPIO_PIN_CANRXA (CANRXA)
|
||||
//!
|
||||
//! \b Watch \b Variables \b Transmit \Configuration \n
|
||||
//! - MSGCOUNT - Adjust to set the number of messages
|
||||
//! - txMsgCount - A counter for the number of messages sent
|
||||
//! - txMsgData - An array with the data being sent
|
||||
//! - errorFlag - A flag that indicates an error has occurred
|
||||
//! - rxMsgCount - Has the initial value as No. of Messages to be received
|
||||
//! and decrements with each message.
|
||||
//!
|
||||
//
|
||||
//#############################################################################
|
||||
|
||||
//
|
||||
// Included Files
|
||||
//
|
||||
#include "driverlib.h"
|
||||
#include "device.h"
|
||||
|
||||
//
|
||||
// Comment to Make the CAN Controller work as a Receiver.
|
||||
//
|
||||
#define TRANSMIT
|
||||
|
||||
//
|
||||
// Defines
|
||||
//
|
||||
#ifdef TRANSMIT
|
||||
#define TX_MSG_OBJ_ID 1
|
||||
#else
|
||||
#define RX_MSG_OBJ_ID 1
|
||||
#endif
|
||||
#define MSG_DATA_LENGTH 4
|
||||
#define MSGCOUNT 10
|
||||
|
||||
//
|
||||
// Globals
|
||||
//
|
||||
#ifdef TRANSMIT
|
||||
volatile uint32_t txMsgCount = 0;
|
||||
uint32_t txMsgSuccessful = 1;
|
||||
uint16_t txMsgData[4];
|
||||
#else
|
||||
volatile uint32_t rxMsgCount = MSGCOUNT;
|
||||
uint16_t rxMsgData[4];
|
||||
#endif
|
||||
volatile unsigned long i;
|
||||
volatile uint32_t errorFlag = 0;
|
||||
|
||||
//
|
||||
// Function Prototypes
|
||||
//
|
||||
__interrupt void canaISR(void);
|
||||
|
||||
//
|
||||
// Main
|
||||
//
|
||||
void main(void)
|
||||
{
|
||||
//
|
||||
// Initialize device clock and peripherals
|
||||
//
|
||||
Device_init();
|
||||
|
||||
//
|
||||
// Initialize GPIO and configure GPIO pins for CANTX/CANRX
|
||||
// on module A.
|
||||
//
|
||||
Device_initGPIO();
|
||||
GPIO_setPinConfig(DEVICE_GPIO_CFG_CANRXA);
|
||||
GPIO_setPinConfig(DEVICE_GPIO_CFG_CANTXA);
|
||||
|
||||
//
|
||||
// Allocated shared peripheral to C28x
|
||||
//
|
||||
SysCtl_allocateSharedPeripheral(SYSCTL_PALLOCATE_CAN_A,0x0U);
|
||||
SysCtl_allocateSharedPeripheral(SYSCTL_PALLOCATE_CAN_B,0x0U);
|
||||
|
||||
//
|
||||
// Initialize the CAN controllers
|
||||
//
|
||||
CAN_initModule(CANA_BASE);
|
||||
|
||||
//
|
||||
// Set up the CAN bus bit rate to 500kHz for each module
|
||||
// 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, 20);
|
||||
|
||||
//
|
||||
// Enable interrupts on the CAN A peripheral.
|
||||
//
|
||||
CAN_enableInterrupt(CANA_BASE, CAN_INT_IE0 | CAN_INT_ERROR |
|
||||
CAN_INT_STATUS);
|
||||
|
||||
//
|
||||
// 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;
|
||||
|
||||
//
|
||||
// Interrupts that are used in this example are re-mapped to
|
||||
// ISR functions found within this file.
|
||||
// This registers the interrupt handler in PIE vector table.
|
||||
//
|
||||
Interrupt_register(INT_CANA0,&canaISR);
|
||||
|
||||
//
|
||||
// Enable the CAN-A interrupt signal
|
||||
//
|
||||
Interrupt_enable(INT_CANA0);
|
||||
|
||||
CAN_enableGlobalInterrupt(CANA_BASE, CAN_GLOBAL_INT_CANINT0);
|
||||
|
||||
#ifdef TRANSMIT
|
||||
//
|
||||
// Initialize the transmit message object used for sending CAN messages.
|
||||
// Message Object Parameters:
|
||||
// CAN Module: A
|
||||
// Message Object ID Number: 1
|
||||
// Message Identifier: 0x15555555
|
||||
// Message Frame: Extended
|
||||
// Message Type: Transmit
|
||||
// Message ID Mask: 0x0
|
||||
// Message Object Flags: None
|
||||
// Message Data Length: 4 Bytes
|
||||
//
|
||||
CAN_setupMessageObject(CANA_BASE, TX_MSG_OBJ_ID, 0x15555555,
|
||||
CAN_MSG_FRAME_EXT, CAN_MSG_OBJ_TYPE_TX, 0,
|
||||
CAN_MSG_OBJ_TX_INT_ENABLE, MSG_DATA_LENGTH);
|
||||
//
|
||||
// Initialize the transmit message object data buffer to be sent
|
||||
//
|
||||
txMsgData[0] = 0x12;
|
||||
txMsgData[1] = 0x34;
|
||||
txMsgData[2] = 0x56;
|
||||
txMsgData[3] = 0x78;
|
||||
#else
|
||||
//
|
||||
// Initialize the receive message object used for receiving CAN messages.
|
||||
// Message Object Parameters:
|
||||
// CAN Module: A
|
||||
// Message Object ID Number: 1
|
||||
// Message Identifier: 0x15555555
|
||||
// Message Frame: Extended
|
||||
// Message Type: Receive
|
||||
// Message ID Mask: 0x0
|
||||
// Message Object Flags: Receive Interrupt
|
||||
// Message Data Length: 4 Bytes (Note that DLC field is a "don't care"
|
||||
// for a Receive mailbox
|
||||
//
|
||||
CAN_setupMessageObject(CANA_BASE, RX_MSG_OBJ_ID, 0x15555555,
|
||||
CAN_MSG_FRAME_EXT, CAN_MSG_OBJ_TYPE_RX, 0,
|
||||
CAN_MSG_OBJ_RX_INT_ENABLE, MSG_DATA_LENGTH);
|
||||
#endif
|
||||
|
||||
//
|
||||
// Start CAN module A operations
|
||||
//
|
||||
CAN_startModule(CANA_BASE);
|
||||
|
||||
#ifdef TRANSMIT
|
||||
//
|
||||
// Transmit messages from CAN-A.
|
||||
//
|
||||
for(i = 0; i < MSGCOUNT; i++)
|
||||
{
|
||||
//
|
||||
// Check the error flag to see if errors occurred
|
||||
//
|
||||
if(errorFlag)
|
||||
{
|
||||
asm(" ESTOP0");
|
||||
}
|
||||
|
||||
//
|
||||
// Transmit the message.
|
||||
//
|
||||
CAN_sendMessage(CANA_BASE, TX_MSG_OBJ_ID, MSG_DATA_LENGTH,
|
||||
txMsgData);
|
||||
|
||||
//
|
||||
// Delay 0.25 second before continuing
|
||||
//
|
||||
DEVICE_DELAY_US(250000);
|
||||
|
||||
while(txMsgSuccessful);
|
||||
//
|
||||
// Increment the value in the transmitted message data.
|
||||
//
|
||||
txMsgData[0] += 0x01;
|
||||
txMsgData[1] += 0x01;
|
||||
txMsgData[2] += 0x01;
|
||||
txMsgData[3] += 0x01;
|
||||
|
||||
//
|
||||
// Reset data if exceeds a byte
|
||||
//
|
||||
if(txMsgData[0] > 0xFF)
|
||||
{
|
||||
txMsgData[0] = 0;
|
||||
}
|
||||
if(txMsgData[1] > 0xFF)
|
||||
{
|
||||
txMsgData[1] = 0;
|
||||
}
|
||||
if(txMsgData[2] > 0xFF)
|
||||
{
|
||||
txMsgData[2] = 0;
|
||||
}
|
||||
if(txMsgData[3] > 0xFF)
|
||||
{
|
||||
txMsgData[3] = 0;
|
||||
}
|
||||
|
||||
//
|
||||
// Update the flag for next message.
|
||||
//
|
||||
txMsgSuccessful = 1;
|
||||
}
|
||||
#else
|
||||
//
|
||||
// Loop to keep receiving data from another CAN Controller.
|
||||
//
|
||||
while(rxMsgCount)
|
||||
{
|
||||
}
|
||||
#endif
|
||||
|
||||
//
|
||||
// Stop application after completion.
|
||||
//
|
||||
asm(" ESTOP0");
|
||||
}
|
||||
|
||||
//
|
||||
// CAN A ISR - The interrupt service routine called when a CAN interrupt is
|
||||
// triggered on CAN module A.
|
||||
//
|
||||
__interrupt void
|
||||
canaISR(void)
|
||||
{
|
||||
uint32_t status;
|
||||
|
||||
//
|
||||
// Read the CAN-B interrupt status to find the cause of the interrupt
|
||||
//
|
||||
status = CAN_getInterruptCause(CANA_BASE);
|
||||
|
||||
//
|
||||
// If the cause is a controller status interrupt, then get the status
|
||||
//
|
||||
if(status == CAN_INT_INT0ID_STATUS)
|
||||
{
|
||||
//
|
||||
// Read the controller status. This will return a field of status
|
||||
// error bits that can indicate various errors. Error processing
|
||||
// is not done in this example for simplicity. Refer to the
|
||||
// API documentation for details about the error status bits.
|
||||
// The act of reading this status will clear the interrupt.
|
||||
//
|
||||
status = CAN_getStatus(CANA_BASE);
|
||||
|
||||
//
|
||||
// Check to see if an error occurred.
|
||||
//
|
||||
#ifdef TRANSMIT
|
||||
if(((status & ~(CAN_STATUS_TXOK)) != CAN_STATUS_LEC_MSK) &&
|
||||
((status & ~(CAN_STATUS_TXOK)) != CAN_STATUS_LEC_NONE))
|
||||
#else
|
||||
if(((status & ~(CAN_STATUS_RXOK)) != CAN_STATUS_LEC_MSK) &&
|
||||
((status & ~(CAN_STATUS_RXOK)) != CAN_STATUS_LEC_NONE))
|
||||
#endif
|
||||
{
|
||||
//
|
||||
// Set a flag to indicate some errors may have occurred.
|
||||
//
|
||||
errorFlag = 1;
|
||||
}
|
||||
}
|
||||
#ifdef TRANSMIT
|
||||
else if(status == TX_MSG_OBJ_ID)
|
||||
{
|
||||
//
|
||||
// Getting to this point means that the TX interrupt occurred on
|
||||
// message object 1, and the message TX is complete. Clear the
|
||||
// message object interrupt.
|
||||
//
|
||||
CAN_clearInterruptStatus(CANA_BASE, TX_MSG_OBJ_ID);
|
||||
|
||||
//
|
||||
// Increment a counter to keep track of how many messages have been
|
||||
// transmitted. In a real application this could be used to set flags to
|
||||
// indicate when a message is transmitted.
|
||||
//
|
||||
txMsgCount++;
|
||||
|
||||
//
|
||||
// Since the message was transmitted, clear any error flags.
|
||||
//
|
||||
errorFlag = 0;
|
||||
|
||||
//
|
||||
// Clear the message transmitted successful Flag.
|
||||
//
|
||||
txMsgSuccessful = 0;
|
||||
}
|
||||
#else
|
||||
else if(status == RX_MSG_OBJ_ID)
|
||||
{
|
||||
//
|
||||
// Get the received message
|
||||
//
|
||||
CAN_readMessage(CANA_BASE, RX_MSG_OBJ_ID, rxMsgData);
|
||||
|
||||
//
|
||||
// Getting to this point means that the RX interrupt occurred on
|
||||
// message object 1, and the message RX is complete. Clear the
|
||||
// message object interrupt.
|
||||
//
|
||||
CAN_clearInterruptStatus(CANA_BASE, RX_MSG_OBJ_ID);
|
||||
|
||||
//
|
||||
// Decrement the counter after a message has been received.
|
||||
//
|
||||
rxMsgCount--;
|
||||
|
||||
//
|
||||
// Since the message was received, clear any error flags.
|
||||
//
|
||||
errorFlag = 0;
|
||||
}
|
||||
#endif
|
||||
//
|
||||
// If something unexpected caused the interrupt, this would handle it.
|
||||
//
|
||||
else
|
||||
{
|
||||
//
|
||||
// Spurious interrupt handling can go here.
|
||||
//
|
||||
}
|
||||
|
||||
//
|
||||
// Clear the global interrupt flag for the CAN interrupt line
|
||||
//
|
||||
CAN_clearGlobalInterruptStatus(CANA_BASE, CAN_GLOBAL_INT_CANINT0);
|
||||
|
||||
//
|
||||
// Acknowledge this interrupt located in group 9
|
||||
//
|
||||
Interrupt_clearACKGroup(INTERRUPT_ACK_GROUP9);
|
||||
}
|
||||
|
||||
//
|
||||
// End of File
|
||||
//
|
||||
@@ -0,0 +1,742 @@
|
||||
//#############################################################################
|
||||
//
|
||||
// FILE: can_ex6_error_generation.c
|
||||
//
|
||||
// TITLE: CAN Error Generation over GPIO Example
|
||||
//
|
||||
//! \addtogroup driver_example_list
|
||||
//! <h1> CAN Error Generation Example </h1>
|
||||
//!
|
||||
//!
|
||||
//! This example demonstrates the ways of handling CAN Error conditions
|
||||
//! It generates the CAN Packets and sends them over GPIO
|
||||
//! It is looped back externally to be received in CAN module
|
||||
//! The CAN Interrupt service routine reads the Error status and
|
||||
//! demonstrates how different Error conditions can be detected
|
||||
//!
|
||||
//! Change ERR_CFG define to the different Error Scenarios and run the
|
||||
//! example. The corresponding Error Flag will be set in status variable
|
||||
//! of canaISR() routine.
|
||||
//! Uses a CPU Timer(Timer 0) for periodic timer interrupt of CANBITRATE uSec
|
||||
//! On the Timer interrupt it sends the required CAN Frame type with
|
||||
//! the specified error conditions
|
||||
//! \note CAN modules on the device need to be connected to via CAN
|
||||
//! transceivers.
|
||||
//!
|
||||
//! Please refer to the application note titled "Configurable Error Generator
|
||||
//! for Controller Area Network" at [Configurable Error Generator for
|
||||
//! Controller Area Network](https://www.ti.com/lit/pdf/spracq3) for further
|
||||
//! details on this example
|
||||
//!
|
||||
//! \b External \b Connections \n
|
||||
//! - ControlCARD GPIOTX_PIN should be connected to
|
||||
//! - DEVICE_GPIO_PIN_CANRXA(CANRXA)
|
||||
//!
|
||||
//! \b Watch \b Variables \b Transmit \Configuration \n
|
||||
//! - status - variable in canaISR for checking error Status
|
||||
//!
|
||||
//
|
||||
//#############################################################################
|
||||
//!
|
||||
|
||||
//
|
||||
// Included Files
|
||||
//
|
||||
#include "driverlib.h"
|
||||
#include "device.h"
|
||||
|
||||
volatile uint32_t rxMsgCount = 0;
|
||||
volatile uint32_t errorFlag = 0;
|
||||
uint16_t txMsgData[8], rxMsgData[8]= {0,0,0,0,0,0,0,0};
|
||||
|
||||
//
|
||||
// Function Prototypes
|
||||
//
|
||||
int16_t generateCANFrame(uint32_t errCfg, int16_t remote_frame, int16_t bitNErr,
|
||||
int16_t dataByteNum, int16_t gpio);
|
||||
void selectGPIO(int16_t gpio);
|
||||
void initCPUTimers(void);
|
||||
void configCPUTimer(uint32_t cpuTimer, float freq, float bitrate);
|
||||
|
||||
//
|
||||
//Interrupt Service Routines
|
||||
//
|
||||
__interrupt void canaISR(void);
|
||||
__interrupt void cpuTimer0ISR(void);
|
||||
|
||||
//
|
||||
//Global Variables
|
||||
//
|
||||
int16_t stream[200];
|
||||
uint32_t canstream[200];
|
||||
uint16_t crcRg;
|
||||
int16_t crcNext,nbits,samebits;
|
||||
int16_t nxtBit, prev_bit, canBit=0;
|
||||
uint32_t arbID;
|
||||
int16_t bitpos=0, errpos=0, stuffbits=0;
|
||||
|
||||
#define TX_MSG_OBJ_ID 1
|
||||
#define RX_MSG_OBJ_ID 2
|
||||
|
||||
// Definitions - do not change values in this section
|
||||
#define CAN_FRAME 0
|
||||
#define REMOTE_REQUEST 1
|
||||
#define CAN_GPIO_MODE 0
|
||||
#define CAN_DATALBCK_MODE 1
|
||||
|
||||
//
|
||||
// CAN error definitions
|
||||
// Use any of these defines for ERR_CFG
|
||||
//
|
||||
//No Error is generated for this define
|
||||
//
|
||||
#define NO_ERR 0
|
||||
//
|
||||
//Bit 0/ CRC Error is generated for this Error define
|
||||
//
|
||||
#define FF_SRS_ERR 1
|
||||
//
|
||||
//Form Error is generated for this Error define
|
||||
//
|
||||
#define FF_IDE_ERR 2
|
||||
//
|
||||
//Form Error is generated for this Error define
|
||||
//
|
||||
#define FF_RTR_ERR 3
|
||||
//
|
||||
//Bit 0/ CRC Error is generated for this Error define
|
||||
//
|
||||
#define FF_R1_ERR 4
|
||||
//
|
||||
//Bit 0/ CRC Error is generated for this Error define
|
||||
//
|
||||
#define FF_R0_ERR 5
|
||||
//
|
||||
//Bit 0/ CRC Error is generated for this Error define
|
||||
//
|
||||
#define MSGID_ERR 6
|
||||
//
|
||||
//Bit 0/ CRC Error is generated for this Error define
|
||||
//
|
||||
#define DATA_ERR 8
|
||||
//
|
||||
//Bit 0/ CRC Error is generated for this Error define
|
||||
//
|
||||
#define CRC_ERR 9
|
||||
//
|
||||
//Form Error is generated for this Error define
|
||||
//
|
||||
#define STUFF_BITS_ERR 10
|
||||
|
||||
//
|
||||
//Default No Error
|
||||
//Change this NO_ERR to required Error Type as above
|
||||
//
|
||||
#define ERR_CFG FF_IDE_ERR
|
||||
|
||||
// Message data length
|
||||
#define MSG_DATA_LENGTH 4
|
||||
// CAN bit rate
|
||||
#define CANBITRATE 500000
|
||||
|
||||
// Define if GPIO CAN Frame Emulation (CAN_GPIO_MODE) or Internal CAN Data Loopback mode (CAN_DATALBCK_MODE)
|
||||
// CAN_GPIO_MODE: GPIOTX_PIN will output the emulated CAN frame which can be observed externally
|
||||
// CAN_DATALBCK_MODE: The GPIO mapped to CANRX_PAD will receive the emulated CAN frame internally. Using this
|
||||
// mode will not allow for external monitoring of emulated CAN frames. The CANRX_PAD defined should be
|
||||
// driven high when in this mode either externally or through the internal pull up.
|
||||
#define CAN_EMULATION_MODE CAN_DATALBCK_MODE
|
||||
|
||||
|
||||
// CAN channel setup
|
||||
// GPIO Pin to emulate CAN bit stream
|
||||
#define GPIOTX_PIN 4
|
||||
|
||||
// GPIO assignment for CANRX
|
||||
#define CANRX_PAD DEVICE_GPIO_CFG_CANRXA
|
||||
|
||||
// GPIOPORT and PIN calculation from channel assignments
|
||||
#define GPIOPORT (GPIOTX_PIN/32)
|
||||
#define GPIORX_PIN ((((CANRX_PAD >> 8) & 0xFFU) + ((CANRX_PAD >> 16) - 0x6U))>>1)
|
||||
|
||||
//
|
||||
// Main
|
||||
//
|
||||
void main(void)
|
||||
{
|
||||
int16_t frame_length;
|
||||
|
||||
//
|
||||
// Initialize System Control and device clock and peripherals
|
||||
//
|
||||
Device_init();
|
||||
|
||||
//
|
||||
// Configure GPIO pin that will be emulated as CANTX
|
||||
//
|
||||
GPIO_setPinConfig(GPIO_4_GPIO4);
|
||||
|
||||
//
|
||||
// Initialize CAN DATA
|
||||
//
|
||||
arbID = 0x1914A75B;
|
||||
|
||||
txMsgData[0] = 0x95;
|
||||
txMsgData[1] = 0x1A;
|
||||
txMsgData[2] = 0x23;
|
||||
txMsgData[3] = 0x45;
|
||||
txMsgData[4] = 0x67;
|
||||
txMsgData[5] = 0x89;
|
||||
txMsgData[6] = 0xAB;
|
||||
txMsgData[7] = 0xCD;
|
||||
|
||||
frame_length = generateCANFrame(ERR_CFG, CAN_FRAME, 0, 0, GPIOTX_PIN);
|
||||
|
||||
GPIO_setPinConfig(CANRX_PAD);
|
||||
|
||||
//
|
||||
// Allocated shared peripheral to C28x
|
||||
//
|
||||
SysCtl_allocateSharedPeripheral(SYSCTL_PALLOCATE_CAN_A,0x0U);
|
||||
SysCtl_allocateSharedPeripheral(SYSCTL_PALLOCATE_CAN_B,0x0U);
|
||||
|
||||
CAN_initModule(CANA_BASE);
|
||||
|
||||
CAN_setBitRate(CANA_BASE, DEVICE_SYSCLK_FREQ, CANBITRATE, 20);
|
||||
|
||||
CAN_enableInterrupt(CANA_BASE, CAN_INT_IE0 | CAN_INT_ERROR |
|
||||
CAN_INT_STATUS);
|
||||
|
||||
//
|
||||
// Initialize PIE, clear PIE registers, disable and clear all
|
||||
// CPU interrupts and flags
|
||||
//
|
||||
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;
|
||||
|
||||
//
|
||||
// Interrupts that are used in this example are re-mapped to
|
||||
// ISR functions found within this file.
|
||||
// This registers the interrupt handler in PIE vector table.
|
||||
//
|
||||
Interrupt_register(INT_CANA0, &canaISR);
|
||||
Interrupt_register(INT_TIMER0, &cpuTimer0ISR);
|
||||
|
||||
//
|
||||
// Initializes the Device Peripheral. For this example, only initialize the
|
||||
// Cpu Timers.
|
||||
//
|
||||
initCPUTimers();
|
||||
|
||||
//
|
||||
// Configure CPU-Timer 0 interrupt every second:
|
||||
// CANBITRATE Period (in uSeconds)
|
||||
//
|
||||
configCPUTimer(CPUTIMER0_BASE, DEVICE_SYSCLK_FREQ, CANBITRATE);
|
||||
|
||||
//
|
||||
// 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);
|
||||
|
||||
//
|
||||
// Enables CPU int1 which is connected to CPU-Timer 0,
|
||||
// Enable TINT0 in the PIE: Group 1 interrupt 7
|
||||
//
|
||||
Interrupt_enable(INT_TIMER0);
|
||||
|
||||
//
|
||||
// Enable the CAN interrupt signal
|
||||
//
|
||||
Interrupt_enable(INT_CANA0);
|
||||
CAN_enableGlobalInterrupt(CANA_BASE, CAN_GLOBAL_INT_CANINT0);
|
||||
|
||||
//
|
||||
//RX set up
|
||||
//
|
||||
CAN_setupMessageObject(CANA_BASE, RX_MSG_OBJ_ID, arbID, CAN_MSG_FRAME_EXT,
|
||||
CAN_MSG_OBJ_TYPE_RX, 0, CAN_MSG_OBJ_RX_INT_ENABLE,
|
||||
MSG_DATA_LENGTH);
|
||||
|
||||
//
|
||||
// Start CAN module operations
|
||||
//
|
||||
CAN_startModule(CANA_BASE);
|
||||
|
||||
canBit = 0;
|
||||
|
||||
//
|
||||
// Start CPU-Timer 0
|
||||
//
|
||||
CPUTimer_startTimer(CPUTIMER0_BASE);
|
||||
|
||||
for(;;)
|
||||
{
|
||||
if(canBit >= frame_length)
|
||||
canBit = 0;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
int16_t generateCANFrame(uint32_t errCfg, int16_t remote_frame,
|
||||
int16_t bitNErr, int16_t dataByteNum, int16_t gpio)
|
||||
{
|
||||
uint32_t i, j, idLSB, idMSB;
|
||||
int16_t xtd, idndx, dlcndx, datndx, nstuffbits;
|
||||
|
||||
// initialize stream and canstream
|
||||
for(i = 0;i < 200;i++)
|
||||
{
|
||||
stream[i] = -1;
|
||||
canstream[i] = 0xFFFFFFFF;
|
||||
}
|
||||
|
||||
// arbID
|
||||
if(arbID > 0x7FF)
|
||||
{
|
||||
idLSB = arbID & 0x3FFFF;
|
||||
idMSB = ((arbID & 0x1FFFFFFF) >> 18) & 0x7FF;
|
||||
|
||||
stream[0] = 0;
|
||||
for(i = 0;i < 11;i++)
|
||||
stream[1 + i] = ((idMSB >> (10 - i)) & 1)?1:0;
|
||||
// SRS bit position
|
||||
if(errCfg == FF_SRS_ERR)
|
||||
bitpos = i + 1;
|
||||
// SRS bit
|
||||
stream[1 + i] = 1;
|
||||
// IDE bit position
|
||||
if(errCfg == FF_IDE_ERR)
|
||||
bitpos = i + 2;
|
||||
// IDE bit
|
||||
stream[2 + i] = 1;
|
||||
for(i = 0;i < 18;i++)
|
||||
stream[14 + i]=((idLSB >> (17 - i)) & 1 )?1:0;
|
||||
|
||||
idndx = 32;
|
||||
xtd = 1;
|
||||
|
||||
}
|
||||
else
|
||||
{
|
||||
idLSB = arbID & 0x7FF;
|
||||
stream[0] = 0;
|
||||
for(i = 0;i < 11;i++)
|
||||
stream[1 + i] = ((idLSB >> (10 -i )) & 1) ? 1:0;
|
||||
|
||||
idndx = 12;
|
||||
xtd = 0;
|
||||
}
|
||||
// If errCfg value is MSGID_ERR, or DATA_ERR or CRC_ERR, ensure that bitNErr is valid
|
||||
if(errCfg == MSGID_ERR)
|
||||
{
|
||||
if(arbID > 0x7FF)
|
||||
{
|
||||
if(bitNErr > 28)
|
||||
// bitNErr VALUE is not valid - change to valid value
|
||||
ESTOP0;
|
||||
}
|
||||
else
|
||||
{
|
||||
if(bitNErr > 11)
|
||||
// bitNErr VALUE is not valid - change to valid value
|
||||
ESTOP0;
|
||||
}
|
||||
}
|
||||
|
||||
//
|
||||
//If errCfg value is DATA_ERR
|
||||
//check for valid bit position bitNErr and dataByteNum value
|
||||
//
|
||||
if(errCfg == DATA_ERR)
|
||||
{
|
||||
if(dataByteNum > (MSG_DATA_LENGTH - 1))
|
||||
// dataByteNum value is not valid - change to valid value
|
||||
ESTOP0;
|
||||
if(bitNErr > 7)
|
||||
// bitNErr value is not valid - change to valid value
|
||||
ESTOP0;
|
||||
}
|
||||
// if errCfg value is CRC_ERR, check for valid bit position bitNErr
|
||||
if(errCfg == DATA_ERR)
|
||||
{
|
||||
if(bitNErr > 14)
|
||||
// bitNErr value is not valid - change to valid value
|
||||
ESTOP0;
|
||||
}
|
||||
|
||||
//RTR, r1, r0 = 0 for now
|
||||
// RTR bit position
|
||||
if(errCfg == FF_RTR_ERR) bitpos = idndx;
|
||||
// RTR bit
|
||||
stream[idndx] = (!remote_frame)?0:1;
|
||||
// R1 bit position
|
||||
if(errCfg == FF_R1_ERR)
|
||||
bitpos = idndx + 1;
|
||||
// R1 bit
|
||||
stream[idndx + 1] = 0;
|
||||
// R0 bit position
|
||||
if(errCfg==FF_R0_ERR)
|
||||
bitpos = idndx + 2;
|
||||
// R0 bit
|
||||
stream[idndx + 2] = 0;
|
||||
|
||||
//DLC
|
||||
dlcndx = (xtd)?35:15;
|
||||
for(i = 0;i < 4;i++)
|
||||
stream[dlcndx + i]=((MSG_DATA_LENGTH >> (3 - i)) & 1)? 1: 0;
|
||||
//DATA (up to 8 bytes
|
||||
if(!remote_frame)
|
||||
{
|
||||
datndx = (xtd)?39:19;
|
||||
for(i = 0;i < MSG_DATA_LENGTH;i++)
|
||||
{
|
||||
for(j=0;j<8;j++)
|
||||
stream[datndx + (i * 8) + j] =
|
||||
((txMsgData[i] >> (7 - j)) & 1)?1:0;
|
||||
}
|
||||
}
|
||||
|
||||
//determine how long the bitstream is
|
||||
i = 0;
|
||||
nxtBit = stream[i];
|
||||
while(nxtBit == 0 || nxtBit == 1)
|
||||
nxtBit=stream[i++];
|
||||
nbits=--i;
|
||||
|
||||
crcRg = 0;
|
||||
for(i = 0;i < nbits;i++)
|
||||
{
|
||||
nxtBit = stream[i];
|
||||
crcNext = nxtBit ^ ((crcRg & 0x4000) >> 14);
|
||||
crcRg=(crcRg << 1) & 0x7FFE;
|
||||
if(crcNext)
|
||||
{
|
||||
crcRg = crcRg ^ 0x4599; // CAN-15 CRC polynomial
|
||||
}
|
||||
}
|
||||
|
||||
// Invert bitNErr position in MSGID
|
||||
if(errCfg == MSGID_ERR)
|
||||
{
|
||||
bitpos = idndx - 1 - bitNErr;
|
||||
stream[bitpos] = (stream[bitpos] == 1)?0:1;
|
||||
|
||||
}
|
||||
|
||||
// SRS ERROR
|
||||
if(errCfg == FF_SRS_ERR)
|
||||
stream[bitpos] = 0;
|
||||
// IDE ERROR
|
||||
if(errCfg == FF_IDE_ERR)
|
||||
stream[bitpos] = 0;
|
||||
// RTR ERROR
|
||||
if(errCfg == FF_RTR_ERR)
|
||||
stream[bitpos] = 1;
|
||||
// R1 ERROR
|
||||
if(errCfg == FF_R1_ERR)
|
||||
stream[bitpos] = 1;
|
||||
// R0 ERROR
|
||||
if(errCfg == FF_R0_ERR)
|
||||
stream[bitpos] = 1;
|
||||
|
||||
// Invert bitNErr position in the data byte pointed by dataByteNum
|
||||
if(errCfg == DATA_ERR)
|
||||
{
|
||||
bitpos = datndx + (7 - bitNErr) + (dataByteNum * 8);
|
||||
stream[bitpos] = (stream[bitpos] == 1)?0:1;
|
||||
}
|
||||
|
||||
//Append CRC bits (15) + delimiter
|
||||
for(i = 0;i < 15;i++)
|
||||
{
|
||||
stream[nbits + i]=((crcRg >> (14 - i)) & 1)?1:0;
|
||||
}
|
||||
|
||||
// add CRC delimiter
|
||||
stream[nbits + i] = 1;
|
||||
nbits += 1;
|
||||
|
||||
// Invert bitNErr position in the 15-bit CRC
|
||||
if(errCfg==CRC_ERR)
|
||||
{
|
||||
bitpos = nbits + 13 - bitNErr;
|
||||
stream[bitpos] = stream[bitpos] == 1?0:1;
|
||||
}
|
||||
|
||||
//
|
||||
//Stuff bits: check for 5 consecutive bit states
|
||||
//then insert opposite bit state if this occurs
|
||||
//
|
||||
prev_bit = stream[0];
|
||||
canstream[0] = stream[0];
|
||||
j = 1;
|
||||
samebits = 0;
|
||||
nstuffbits = 0;
|
||||
for(i = 1;i < (nbits + 15);i++)
|
||||
{
|
||||
canstream[j++] = stream[i];
|
||||
//determine position of flipped bit
|
||||
if(i == bitpos)
|
||||
errpos = j - 1;
|
||||
if(prev_bit == stream[i])
|
||||
{
|
||||
if(!samebits)
|
||||
samebits = 2;
|
||||
else
|
||||
samebits++;
|
||||
|
||||
if(samebits == 5)
|
||||
{
|
||||
if(errCfg != STUFF_BITS_ERR)
|
||||
canstream[j++] = (stream[i] == 1) ? 0:1;
|
||||
samebits = 0;
|
||||
nstuffbits++;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
samebits = 0;
|
||||
}
|
||||
prev_bit = canstream[j - 1];
|
||||
}
|
||||
stuffbits = nstuffbits;
|
||||
i = 0;
|
||||
nxtBit = canstream[i];
|
||||
while(nxtBit == 0 || nxtBit == 1)
|
||||
nxtBit=canstream[i++];
|
||||
nbits=--i;
|
||||
|
||||
// Append 20 recessive bits at the end of the bitstream
|
||||
for(i = 0;i < 14;i++)
|
||||
if(i==0)
|
||||
canstream[nbits + i] = 0;
|
||||
else
|
||||
canstream[nbits + i] = 1;
|
||||
|
||||
// format stream as 32-bit location
|
||||
for(i = 0;i <(nbits + 14);i++)
|
||||
{
|
||||
if(CAN_EMULATION_MODE==CAN_GPIO_MODE)
|
||||
{
|
||||
if(gpio <= 15)
|
||||
{
|
||||
canstream[i] = (canstream[i]==1)?(uint32_t)(1 << gpio):0;
|
||||
}
|
||||
if(gpio > 15 && gpio <= 31)
|
||||
{
|
||||
canstream[i] =
|
||||
(canstream[i]==1) ?
|
||||
(uint32_t)(0x10000 << (gpio - 16)) : 0;
|
||||
|
||||
}
|
||||
if(gpio > 31 && gpio <= 44)
|
||||
{
|
||||
canstream[i] =
|
||||
(canstream[i] == 1) ?(uint32_t)( 1 << (gpio - 32)):0;
|
||||
}
|
||||
}
|
||||
else
|
||||
canstream[i] = (canstream[i]==0) ?
|
||||
GPIO_PIN_TYPE_INVERT : GPIO_PIN_TYPE_STD;
|
||||
|
||||
}
|
||||
|
||||
return (nbits + 14);
|
||||
}
|
||||
|
||||
//
|
||||
// initCPUTimers - This function initializes all three CPU timers
|
||||
// to a known state.
|
||||
//
|
||||
void
|
||||
initCPUTimers(void)
|
||||
{
|
||||
//
|
||||
// Initialize timer period to maximum
|
||||
//
|
||||
CPUTimer_setPeriod(CPUTIMER0_BASE, 0xFFFFFFFF);
|
||||
|
||||
//
|
||||
// Initialize pre-scale counter to divide by 1 (SYSCLKOUT)
|
||||
//
|
||||
CPUTimer_setPreScaler(CPUTIMER0_BASE, 0);
|
||||
|
||||
//
|
||||
// Make sure timer is stopped
|
||||
//
|
||||
CPUTimer_stopTimer(CPUTIMER0_BASE);
|
||||
|
||||
//
|
||||
// Reload all counter register with period value
|
||||
//
|
||||
CPUTimer_reloadTimerCounter(CPUTIMER0_BASE);
|
||||
|
||||
}
|
||||
|
||||
//
|
||||
// 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 bitrate)
|
||||
{
|
||||
uint32_t temp;
|
||||
|
||||
//
|
||||
// Initialize timer period:
|
||||
//
|
||||
temp = (uint32_t)(freq / bitrate);
|
||||
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);
|
||||
|
||||
}
|
||||
|
||||
__interrupt void
|
||||
canaISR(void)
|
||||
{
|
||||
uint32_t status;
|
||||
|
||||
//
|
||||
// Read the CAN-A interrupt status to find the cause of the interrupt
|
||||
//
|
||||
status = CAN_getInterruptCause(CANA_BASE);
|
||||
|
||||
//
|
||||
// If the cause is a controller status interrupt, then get the status
|
||||
//
|
||||
if(status == CAN_INT_INT0ID_STATUS)
|
||||
{
|
||||
//
|
||||
// Read the controller status. This will return a field of status
|
||||
// error bits that can indicate various errors. Error processing
|
||||
// is not done in this example for simplicity. Refer to the
|
||||
// API documentation for details about the error status bits.
|
||||
// The act of reading this status will clear the interrupt.
|
||||
//
|
||||
status = CAN_getStatus(CANA_BASE);
|
||||
// uncomment below in order to inspect LEC in CAN_ES
|
||||
//ESTOP0;
|
||||
|
||||
|
||||
//
|
||||
// Check to see if an error occurred.
|
||||
//
|
||||
if(((status & ~(CAN_STATUS_RXOK)) != CAN_STATUS_LEC_MSK) &&
|
||||
((status & ~(CAN_STATUS_RXOK)) != CAN_STATUS_LEC_NONE))
|
||||
{
|
||||
//
|
||||
// Set a flag to indicate some errors may have occurred.
|
||||
//
|
||||
errorFlag = 1;
|
||||
// uncomment below in order to inspect LEC in CAN_ES if error occurs
|
||||
//ESTOP0;
|
||||
}
|
||||
}
|
||||
//
|
||||
// Check if the cause is the CAN-B receive message object 1
|
||||
//
|
||||
else if(status == RX_MSG_OBJ_ID)
|
||||
{
|
||||
//
|
||||
// Get the received message
|
||||
//
|
||||
CAN_readMessage(CANA_BASE, RX_MSG_OBJ_ID, rxMsgData);
|
||||
|
||||
//
|
||||
// Getting to this point means that the RX interrupt occurred on
|
||||
// message object 1, and the message RX is complete. Clear the
|
||||
// message object interrupt.
|
||||
//
|
||||
CAN_clearInterruptStatus(CANA_BASE, RX_MSG_OBJ_ID);
|
||||
|
||||
//
|
||||
// Increment a counter to keep track of how many messages have been
|
||||
// received. In a real application this could be used to set flags to
|
||||
// indicate when a message is received.
|
||||
//
|
||||
rxMsgCount++;
|
||||
|
||||
//
|
||||
// Since the message was received, clear any error flags.
|
||||
//
|
||||
errorFlag = 0;
|
||||
}
|
||||
//
|
||||
// If something unexpected caused the interrupt, this would handle it.
|
||||
//
|
||||
else
|
||||
{
|
||||
//
|
||||
// Spurious interrupt handling can go here.
|
||||
//
|
||||
}
|
||||
|
||||
//
|
||||
// Clear the global interrupt flag for the CAN interrupt line
|
||||
//
|
||||
CAN_clearGlobalInterruptStatus(CANA_BASE, CAN_GLOBAL_INT_CANINT0);
|
||||
|
||||
//
|
||||
// Acknowledge this interrupt located in group 9
|
||||
//
|
||||
Interrupt_clearACKGroup(INTERRUPT_ACK_GROUP9);
|
||||
//ESTOP0;
|
||||
|
||||
}
|
||||
|
||||
//
|
||||
// cpuTimer0ISR - Counter for CpuTimer0
|
||||
//
|
||||
__interrupt void
|
||||
cpuTimer0ISR(void)
|
||||
{
|
||||
|
||||
//
|
||||
// Write canstream data to GPIO port selected
|
||||
//
|
||||
if (CAN_EMULATION_MODE == CAN_GPIO_MODE)
|
||||
GPIO_writePortData((GPIO_Port)GPIOPORT, canstream[canBit++]);
|
||||
else
|
||||
GPIO_setPadConfig(GPIORX_PIN, canstream[canBit++]);
|
||||
//
|
||||
// Acknowledge this interrupt to receive more interrupts from group 1
|
||||
//
|
||||
Interrupt_clearACKGroup(INTERRUPT_ACK_GROUP1);
|
||||
}
|
||||
|
||||
|
||||
//
|
||||
// End of File
|
||||
//
|
||||
@@ -0,0 +1,203 @@
|
||||
//#############################################################################
|
||||
//
|
||||
// FILE: can_ex7_loopback_tx_rx_remote_frame.c
|
||||
//
|
||||
// TITLE: CAN Remote Request Loopback Example
|
||||
//
|
||||
//! \addtogroup driver_example_list
|
||||
//! <h1> CAN Remote Request Loopback </h1>
|
||||
//!
|
||||
//! This example shows the basic setup of CAN in order to transmit a remote frame
|
||||
//! and get a response for the remote frame and store it in a receive Object.
|
||||
//! The CAN peripheral is configured to transmit remote request frame and a
|
||||
//! remote answer frame messages with a specific CAN ID. Message object 3 is
|
||||
//! configured to transmit a remote request. Message object 2 is configured as
|
||||
//! a remote answer object with filter mask such that it accepts remote frame
|
||||
//! with any message ID and transmit's remote answer with message ID 7 and data
|
||||
//! length 8. Message object 1 is configured as a received object with filter
|
||||
//! message ID 7 so as to store the remote answer data transmitted by message
|
||||
//! object 2.
|
||||
//!
|
||||
//! 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. Please refer to details of the External Loopback
|
||||
//! Test Mode in the CAN Chapter in the Technical Reference Manual.
|
||||
//!
|
||||
//! \b External \b Connections \n
|
||||
//! - None.
|
||||
//!
|
||||
//! \b Watch \b Variables \n
|
||||
//! - txMsgData - An array with the data being sent
|
||||
//! - rxMsgData - An array with the data that was received
|
||||
//!
|
||||
//
|
||||
//#############################################################################
|
||||
//
|
||||
//
|
||||
//
|
||||
// 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 "board.h"
|
||||
|
||||
//
|
||||
// Defines
|
||||
//
|
||||
#define MSG_DATA_LENGTH 2
|
||||
|
||||
//
|
||||
// Globals
|
||||
//
|
||||
volatile unsigned long msgCount = 0;
|
||||
|
||||
//
|
||||
// Main
|
||||
//
|
||||
void main(void)
|
||||
{
|
||||
uint16_t rxMsgData[8];
|
||||
|
||||
//
|
||||
// Initialize device clock and peripherals
|
||||
//
|
||||
Device_init();
|
||||
|
||||
//
|
||||
// Initialize GPIO and configure GPIO pins for CANTX/CANRX
|
||||
//
|
||||
Device_initGPIO();
|
||||
|
||||
//
|
||||
// Board initialization
|
||||
//
|
||||
Board_init();
|
||||
|
||||
//
|
||||
// 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;
|
||||
|
||||
//
|
||||
// Start CAN module operations
|
||||
//
|
||||
CAN_startModule(myCAN0_BASE);
|
||||
|
||||
//
|
||||
// Setup receive buffers
|
||||
//
|
||||
*(uint16_t *)rxMsgData = 0;
|
||||
|
||||
while((HWREGH(myCAN0_BASE + CAN_O_IF1CMD) & CAN_IF1CMD_BUSY) ==
|
||||
CAN_IF1CMD_BUSY)
|
||||
{
|
||||
}
|
||||
|
||||
//
|
||||
// Write to IF1DATA & IF1DATB registers send buffer
|
||||
//
|
||||
HWREG_BP(myCAN0_BASE + CAN_O_IF1DATA) = 0x76543210UL;
|
||||
HWREG_BP(myCAN0_BASE + CAN_O_IF1DATB) = 0xFEDCBA98UL;
|
||||
|
||||
//
|
||||
// Transfer to MBX RAM (refer to IFxCMD bit field for explanation).
|
||||
// Configuring message object 2 to respond to a remote frame with
|
||||
// a data length 8 bytes.
|
||||
//
|
||||
HWREG_BP(myCAN0_BASE + CAN_O_IF1CMD) = 0x00830002UL;
|
||||
|
||||
//
|
||||
// Wait for busy bit to clear
|
||||
//
|
||||
while((HWREGH(myCAN0_BASE + CAN_O_IF1CMD) & CAN_IF1CMD_BUSY) ==
|
||||
CAN_IF1CMD_BUSY)
|
||||
{
|
||||
}
|
||||
//
|
||||
// Loop Forever - Send and Receive data continuously
|
||||
//
|
||||
for(;;)
|
||||
{
|
||||
//
|
||||
// Send CAN remote request frame from message object 3
|
||||
//
|
||||
CAN_sendRemoteRequestMessage(myCAN0_BASE, 3);
|
||||
|
||||
//
|
||||
// Delay before receiving the data
|
||||
//
|
||||
DEVICE_DELAY_US(1000000);
|
||||
|
||||
//
|
||||
// Read CAN message object 1 and check for new data
|
||||
// received by the response to the remote request from
|
||||
// message object 2
|
||||
//
|
||||
if (CAN_readMessage(myCAN0_BASE, 1, rxMsgData))
|
||||
{
|
||||
//
|
||||
// Check that received data matches sent data.
|
||||
// Device will halt here during debug .
|
||||
//
|
||||
asm(" ESTOP0");
|
||||
}
|
||||
else
|
||||
{
|
||||
//
|
||||
// Device will halt here during debug if no new data was received.
|
||||
//
|
||||
asm(" ESTOP0");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
//
|
||||
// End of File
|
||||
//
|
||||
+26
@@ -0,0 +1,26 @@
|
||||
/**
|
||||
* Import the modules used in this configuration.
|
||||
*/
|
||||
const can = scripting.addModule("/driverlib/can.js", {}, false);
|
||||
const can1 = can.addInstance();
|
||||
|
||||
/**
|
||||
* Write custom configuration values to the imported modules.
|
||||
*/
|
||||
can1.$name = "myCAN0";
|
||||
can1.enableLoopback = true;
|
||||
can1.loopbackMode = "CAN_TEST_EXL";
|
||||
can1.msgObjsUsed = [1,2,3];
|
||||
can1.msgObj1.$name = "msgObj0";
|
||||
can1.msgObj1.msgLen = 8;
|
||||
can1.msgObj1.frameType = "CAN_MSG_FRAME_EXT";
|
||||
can1.msgObj1.msgID = 5;
|
||||
can1.msgObj2.$name = "msgObj1";
|
||||
can1.msgObj2.msgLen = 8;
|
||||
can1.msgObj2.frameType = "CAN_MSG_FRAME_EXT";
|
||||
can1.msgObj2.msgID = 5;
|
||||
can1.msgObj2.msgType = "CAN_MSG_OBJ_TYPE_RXTX_REMOTE";
|
||||
can1.msgObj3.$name = "msgObj2";
|
||||
can1.msgObj3.frameType = "CAN_MSG_FRAME_EXT";
|
||||
can1.msgObj3.msgType = "CAN_MSG_OBJ_TYPE_TX_REMOTE";
|
||||
can1.msgObj3.msgID = 7;
|
||||
@@ -0,0 +1,192 @@
|
||||
//#############################################################################
|
||||
//
|
||||
// FILE: can_ex8_mask.c
|
||||
//
|
||||
// TITLE: CAN Acceptance Mask Example
|
||||
//
|
||||
//! \addtogroup driver_example_list
|
||||
//! <h1> CAN example that illustrates the usage of Mask registers </h1>
|
||||
//!
|
||||
//! This example initializes CAN module A for Reception. When a frame with a
|
||||
//! matching filter criterion is received, the data will be copied in mailbox 1
|
||||
//! and LED will be toggled a few times and the code gets ready for the next
|
||||
//! frame. If a message of any other MSGID is received, an ACK will be provided
|
||||
//! Completion of reception is determined by polling CAN_NDAT_21 register.
|
||||
//! No interrupts are used. Refer to [Programming Examples and Debug
|
||||
//! Strategies for the DCAN Module](www.ti.com/lit/SPRACE5) for useful
|
||||
//! information about this example
|
||||
//!
|
||||
//! \b Hardware \b Required \n
|
||||
//! - An external CAN node that transmits to CAN-A on the C2000 MCU
|
||||
//!
|
||||
//!
|
||||
//! \b Watch \b Variables \n
|
||||
//! - rxMsgCount - A counter for the number of messages received
|
||||
//! - rxMsgData - An array with the data that was received
|
||||
//!
|
||||
//
|
||||
//#############################################################################
|
||||
//
|
||||
//
|
||||
//
|
||||
// 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 0 // "Don't care" for a Receive mailbox
|
||||
#define RX_MSG_OBJ_ID 1 // Use mailbox 1
|
||||
|
||||
//
|
||||
// Globals
|
||||
//
|
||||
uint16_t rxMsgData[8]; // Buffer for received data
|
||||
uint16_t Toggle_ctr; // GPIO toggle counter
|
||||
volatile uint32_t rxMsgCount = 0;
|
||||
|
||||
//
|
||||
// Main
|
||||
//
|
||||
void main(void)
|
||||
{
|
||||
//
|
||||
// Initialize device clock and peripherals
|
||||
//
|
||||
Device_init();
|
||||
|
||||
//
|
||||
// Initialize GPIO
|
||||
//
|
||||
Device_initGPIO();
|
||||
|
||||
//
|
||||
// Configure GPIO pins for CANTX/CANRX
|
||||
//
|
||||
GPIO_setPinConfig(DEVICE_GPIO_CFG_CANRXA);
|
||||
GPIO_setPinConfig(DEVICE_GPIO_CFG_CANTXA);
|
||||
|
||||
//
|
||||
// Configure GPIO pin which is toggled upon message reception
|
||||
//
|
||||
GPIO_setPadConfig(DEVICE_GPIO_PIN_LED1, GPIO_PIN_TYPE_STD);
|
||||
GPIO_setDirectionMode(DEVICE_GPIO_PIN_LED1, GPIO_DIR_MODE_OUT);
|
||||
|
||||
//
|
||||
// Initialize the receive buffer to a known value
|
||||
//
|
||||
rxMsgData[0] = 0xDEAD;
|
||||
rxMsgData[1] = 0xDEAD;
|
||||
rxMsgData[2] = 0xDEAD;
|
||||
rxMsgData[3] = 0xDEAD;
|
||||
rxMsgData[4] = 0xDEAD;
|
||||
rxMsgData[5] = 0xDEAD;
|
||||
rxMsgData[6] = 0xDEAD;
|
||||
rxMsgData[7] = 0xDEAD;
|
||||
|
||||
//
|
||||
// Initialize the CAN controller
|
||||
//
|
||||
CAN_initModule(CANA_BASE);
|
||||
|
||||
//
|
||||
// Set up the CAN bus bit rate to 500kbps for each module
|
||||
// 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 the receive message object used for receiving CAN messages.
|
||||
// Possible flags: CAN_MSG_OBJ_NO_FLAGS, CAN_MSG_OBJ_USE_EXT_FILTER,
|
||||
// CAN_MSG_OBJ_USE_DIR_FILTER
|
||||
// Message Object Parameters:
|
||||
// CAN Module: A
|
||||
// Message Object ID Number: 1
|
||||
// Message Identifier: 0x1F9FFFFA
|
||||
// Message Frame: Extended
|
||||
// Message Type: Receive
|
||||
// Message ID Mask: 0x1F000000
|
||||
// Message Object Flags: UMask, MXtd, MDir
|
||||
// Message Object flag CAN_MSG_OBJ_USE_ID_FILTER enables usage
|
||||
// of msgIDMask parameter for Message Identifier based filtering
|
||||
// Message Object flag CAN_MSG_OBJ_USE_EXT_FILTER enables usage
|
||||
// of frameType parameter for Message Frame based filtering
|
||||
// Message Data Length: "Don't care" for a Receive mailbox
|
||||
CAN_setupMessageObject(CANA_BASE, RX_MSG_OBJ_ID, 0x1F9FFFFA,
|
||||
CAN_MSG_FRAME_EXT, CAN_MSG_OBJ_TYPE_RX, 0x1F000000,
|
||||
(CAN_MSG_OBJ_USE_ID_FILTER | CAN_MSG_OBJ_NO_FLAGS |
|
||||
CAN_MSG_OBJ_USE_EXT_FILTER), MSG_DATA_LENGTH);
|
||||
|
||||
//
|
||||
// Start CAN module A operations
|
||||
//
|
||||
CAN_startModule(CANA_BASE);
|
||||
|
||||
//
|
||||
// Start reception - Just wait for data from another node
|
||||
//
|
||||
while(1)
|
||||
{
|
||||
//
|
||||
// Poll bit0 in CAN_NDAT_21 register to check completion of Reception
|
||||
//
|
||||
if((HWREG_BP(CANA_BASE + CAN_O_NDAT_21)) == 0x00000001)
|
||||
{
|
||||
//
|
||||
// Get the received message
|
||||
//
|
||||
asm(" NOP");
|
||||
CAN_readMessage(CANA_BASE, RX_MSG_OBJ_ID, rxMsgData);
|
||||
|
||||
rxMsgCount++;
|
||||
for(Toggle_ctr=0; Toggle_ctr<100; Toggle_ctr++)
|
||||
{
|
||||
GPIO_togglePin(DEVICE_GPIO_PIN_LED1);
|
||||
DEVICE_DELAY_US(100000);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
//
|
||||
// End of File
|
||||
//
|
||||
@@ -0,0 +1,42 @@
|
||||
<projectSpec>
|
||||
<project
|
||||
name="cla_ex1_asin"
|
||||
device="TMS320F28388D"
|
||||
cgtVersion="22.6.1.LTS"
|
||||
products="sysconfig;C2000WARE"
|
||||
outputFormat="ELF"
|
||||
launchWizard="False"
|
||||
linkerCommandFile=""
|
||||
enableSysConfigTool="true"
|
||||
sysConfigBuildOptions="--product ${C2000WARE_ROOT}/.metadata/sdk.json --device F2838x --package 337bga --part F2838x_337bga"
|
||||
postBuildStep="
|
||||
echo "========= Build of the CLB simulation has moved to the CLB Tool. Click the '?' icon by the _Generate CLB Simulation File_ enable for more details (located in the Global Parameters of the Tile Design SysConfig module) ============="
|
||||
;if ${GENERATE_DIAGRAM} == 1 ${NODE_TOOL} "${C2000WARE_ROOT}/utilities/clb_tool/clb_syscfg/dot_file_libraries/clbDotUtility.js" "${C2000WARE_ROOT}/utilities/clb_tool/clb_syscfg/" "${BuildDirectory}/syscfg" "${BuildDirectory}/syscfg/clb.dot"
|
||||
;if ${GENERATE_DIAGRAM} == 1 mkdir "${BuildDirectory}/diagrams"
|
||||
;if ${GENERATE_DIAGRAM} == 1 ${NODE_TOOL} "${C2000WARE_ROOT}/driverlib/.meta/generate_diagrams.js" "${C2000WARE_ROOT}" "${BuildDirectory}/diagrams" "${BuildDirectory}/syscfg"
|
||||
"
|
||||
>
|
||||
<configuration name="CPU1_RAM" compilerBuildOptions= "--opt_level=off -I${C2000WARE_ROOT} -I${PROJECT_ROOT}/device -I${C2000WARE_DLIB_ROOT} -v28 -ml -mt --cla_support=cla2 --cla_background_task=off --cla_signed_compare_workaround=on --define=RAM --float_support=fpu64 --tmu_support=tmu0 --define=CPU1 --gen_func_subsections=on --diag_warning=225 --diag_suppress=10063" linkerBuildOptions="--entry_point code_start --stack_size=0x3F8 --heap_size=0x200 --define=RAM -i${C2000WARE_ROOT} -i${PROJECT_BUILD_DIR}/syscfg -lc2000ware_libraries.cmd.genlibs " />
|
||||
<configuration name="CPU1_FLASH" compilerBuildOptions="--opt_level=off -I${C2000WARE_ROOT} -I${PROJECT_ROOT}/device -I${C2000WARE_DLIB_ROOT} --define=_FLASH -v28 -ml -mt --cla_support=cla2 --cla_background_task=off --cla_signed_compare_workaround=on --float_support=fpu64 --tmu_support=tmu0 --define=CPU1 --gen_func_subsections=on --diag_warning=225 --diag_suppress=10063" linkerBuildOptions="--entry_point code_start --stack_size=0x3F8 --heap_size=0x200 --define=_FLASH -i${C2000WARE_ROOT} -i${PROJECT_BUILD_DIR}/syscfg -lc2000ware_libraries.cmd.genlibs " />
|
||||
|
||||
<pathVariable name="C2000WARE_DLIB_ROOT" path="../../../../../../driverlib/f2838x/driverlib/" scope="project" />
|
||||
<pathVariable name="C2000WARE_ROOT" path="../../../../../../" scope="project" />
|
||||
<pathVariable name="CLB_SYSCFG_ROOT" path="../../../../../../utilities/clb_tool/clb_syscfg/" scope="project" />
|
||||
<pathVariable name="SYSTEMC_INSTALL" path="../../../../../../utilities/clb_tool/clb_syscfg/systemc-2.3.3" scope="project" />
|
||||
<pathVariable name="CLB_SIM_COMPILER" path="C:/TDM-GCC-64/bin" scope="project" />
|
||||
<buildVariable name="GENERATE_DIAGRAM" value="0" scope="project" />
|
||||
<file action="copy" path="../../../../../../device_support/f2838x/common/include/driverlib.h" targetDirectory="device" />
|
||||
<file action="copy" path="../../../../../../device_support/f2838x/common/include/device.h" targetDirectory="device" />
|
||||
<file action="copy" path="../../../../../../device_support/f2838x/common/source/device.c" targetDirectory="device" />
|
||||
<file action="copy" path="../../../../../../device_support/f2838x/common/targetConfigs/TMS320F28388D.ccxml" targetDirectory="targetConfigs" />
|
||||
<file action="copy" path="../../../../../../device_support/f2838x/common/cmd/2838x_RAM_CLA_lnk_cpu1.cmd" targetDirectory="" applicableConfigurations="CPU1_RAM" />
|
||||
<file action="copy" path="../../../../../../device_support/f2838x/common/cmd/2838x_FLASH_CLA_lnk_cpu1.cmd" targetDirectory="" applicableConfigurations="CPU1_FLASH" />
|
||||
<file action="copy" path="../../../../../../device_support/f2838x/common/source/f2838x_codestartbranch.asm" targetDirectory="device" />
|
||||
<file action="link" path="../../../../../../driverlib/f2838x/driverlib/ccs/Debug/driverlib.lib" targetDirectory="" />
|
||||
<file action="copy" path="../../../../../../driverlib/f2838x/driverlib/" targetDirectory="device" excludeFromBuild="True" />
|
||||
<file action="copy" path="../asin.cla" targetDirectory="" />
|
||||
<file action="copy" path="../cla_ex1_asin.c" targetDirectory="" />
|
||||
<file action="copy" path="../cla_ex1_asin_shared.h" targetDirectory="" />
|
||||
<file action="copy" path="../cla_ex1_asin.syscfg" targetDirectory="" />
|
||||
</project>
|
||||
</projectSpec>
|
||||
@@ -0,0 +1,42 @@
|
||||
<projectSpec>
|
||||
<project
|
||||
name="cla_ex2_atan"
|
||||
device="TMS320F28388D"
|
||||
cgtVersion="22.6.1.LTS"
|
||||
products="sysconfig;C2000WARE"
|
||||
outputFormat="ELF"
|
||||
launchWizard="False"
|
||||
linkerCommandFile=""
|
||||
enableSysConfigTool="true"
|
||||
sysConfigBuildOptions="--product ${C2000WARE_ROOT}/.metadata/sdk.json --device F2838x --package 337bga --part F2838x_337bga"
|
||||
postBuildStep="
|
||||
echo "========= Build of the CLB simulation has moved to the CLB Tool. Click the '?' icon by the _Generate CLB Simulation File_ enable for more details (located in the Global Parameters of the Tile Design SysConfig module) ============="
|
||||
;if ${GENERATE_DIAGRAM} == 1 ${NODE_TOOL} "${C2000WARE_ROOT}/utilities/clb_tool/clb_syscfg/dot_file_libraries/clbDotUtility.js" "${C2000WARE_ROOT}/utilities/clb_tool/clb_syscfg/" "${BuildDirectory}/syscfg" "${BuildDirectory}/syscfg/clb.dot"
|
||||
;if ${GENERATE_DIAGRAM} == 1 mkdir "${BuildDirectory}/diagrams"
|
||||
;if ${GENERATE_DIAGRAM} == 1 ${NODE_TOOL} "${C2000WARE_ROOT}/driverlib/.meta/generate_diagrams.js" "${C2000WARE_ROOT}" "${BuildDirectory}/diagrams" "${BuildDirectory}/syscfg"
|
||||
"
|
||||
>
|
||||
<configuration name="CPU1_RAM" compilerBuildOptions= "--opt_level=off -I${C2000WARE_ROOT} -I${PROJECT_ROOT}/device -I${C2000WARE_DLIB_ROOT} -v28 -ml -mt --cla_support=cla2 --cla_background_task=off --cla_signed_compare_workaround=on --define=RAM --float_support=fpu64 --tmu_support=tmu0 --define=CPU1 --gen_func_subsections=on --diag_warning=225 --diag_suppress=10063" linkerBuildOptions="--entry_point code_start --stack_size=0x3F8 --heap_size=0x200 --define=RAM -i${C2000WARE_ROOT} -i${PROJECT_BUILD_DIR}/syscfg -lc2000ware_libraries.cmd.genlibs " />
|
||||
<configuration name="CPU1_FLASH" compilerBuildOptions="--opt_level=off -I${C2000WARE_ROOT} -I${PROJECT_ROOT}/device -I${C2000WARE_DLIB_ROOT} --define=_FLASH -v28 -ml -mt --cla_support=cla2 --cla_background_task=off --cla_signed_compare_workaround=on --float_support=fpu64 --tmu_support=tmu0 --define=CPU1 --gen_func_subsections=on --diag_warning=225 --diag_suppress=10063" linkerBuildOptions="--entry_point code_start --stack_size=0x3F8 --heap_size=0x200 --define=_FLASH -i${C2000WARE_ROOT} -i${PROJECT_BUILD_DIR}/syscfg -lc2000ware_libraries.cmd.genlibs " />
|
||||
|
||||
<pathVariable name="C2000WARE_DLIB_ROOT" path="../../../../../../driverlib/f2838x/driverlib/" scope="project" />
|
||||
<pathVariable name="C2000WARE_ROOT" path="../../../../../../" scope="project" />
|
||||
<pathVariable name="CLB_SYSCFG_ROOT" path="../../../../../../utilities/clb_tool/clb_syscfg/" scope="project" />
|
||||
<pathVariable name="SYSTEMC_INSTALL" path="../../../../../../utilities/clb_tool/clb_syscfg/systemc-2.3.3" scope="project" />
|
||||
<pathVariable name="CLB_SIM_COMPILER" path="C:/TDM-GCC-64/bin" scope="project" />
|
||||
<buildVariable name="GENERATE_DIAGRAM" value="0" scope="project" />
|
||||
<file action="copy" path="../../../../../../device_support/f2838x/common/include/driverlib.h" targetDirectory="device" />
|
||||
<file action="copy" path="../../../../../../device_support/f2838x/common/include/device.h" targetDirectory="device" />
|
||||
<file action="copy" path="../../../../../../device_support/f2838x/common/source/device.c" targetDirectory="device" />
|
||||
<file action="copy" path="../../../../../../device_support/f2838x/common/targetConfigs/TMS320F28388D.ccxml" targetDirectory="targetConfigs" />
|
||||
<file action="copy" path="../../../../../../device_support/f2838x/common/cmd/2838x_RAM_CLA_lnk_cpu1.cmd" targetDirectory="" applicableConfigurations="CPU1_RAM" />
|
||||
<file action="copy" path="../../../../../../device_support/f2838x/common/cmd/2838x_FLASH_CLA_lnk_cpu1.cmd" targetDirectory="" applicableConfigurations="CPU1_FLASH" />
|
||||
<file action="copy" path="../../../../../../device_support/f2838x/common/source/f2838x_codestartbranch.asm" targetDirectory="device" />
|
||||
<file action="link" path="../../../../../../driverlib/f2838x/driverlib/ccs/Debug/driverlib.lib" targetDirectory="" />
|
||||
<file action="copy" path="../../../../../../driverlib/f2838x/driverlib/" targetDirectory="device" excludeFromBuild="True" />
|
||||
<file action="copy" path="../atan.cla" targetDirectory="" />
|
||||
<file action="copy" path="../cla_ex2_atan.c" targetDirectory="" />
|
||||
<file action="copy" path="../cla_ex2_atan_shared.h" targetDirectory="" />
|
||||
<file action="copy" path="../cla_ex2_atan.syscfg" targetDirectory="" />
|
||||
</project>
|
||||
</projectSpec>
|
||||
+42
@@ -0,0 +1,42 @@
|
||||
<projectSpec>
|
||||
<project
|
||||
name="cla_ex3_background_nesting_task"
|
||||
device="TMS320F28388D"
|
||||
cgtVersion="22.6.1.LTS"
|
||||
products="sysconfig;C2000WARE"
|
||||
outputFormat="ELF"
|
||||
launchWizard="False"
|
||||
linkerCommandFile=""
|
||||
enableSysConfigTool="true"
|
||||
sysConfigBuildOptions="--product ${C2000WARE_ROOT}/.metadata/sdk.json --device F2838x --package 337bga --part F2838x_337bga"
|
||||
postBuildStep="
|
||||
echo "========= Build of the CLB simulation has moved to the CLB Tool. Click the '?' icon by the _Generate CLB Simulation File_ enable for more details (located in the Global Parameters of the Tile Design SysConfig module) ============="
|
||||
;if ${GENERATE_DIAGRAM} == 1 ${NODE_TOOL} "${C2000WARE_ROOT}/utilities/clb_tool/clb_syscfg/dot_file_libraries/clbDotUtility.js" "${C2000WARE_ROOT}/utilities/clb_tool/clb_syscfg/" "${BuildDirectory}/syscfg" "${BuildDirectory}/syscfg/clb.dot"
|
||||
;if ${GENERATE_DIAGRAM} == 1 mkdir "${BuildDirectory}/diagrams"
|
||||
;if ${GENERATE_DIAGRAM} == 1 ${NODE_TOOL} "${C2000WARE_ROOT}/driverlib/.meta/generate_diagrams.js" "${C2000WARE_ROOT}" "${BuildDirectory}/diagrams" "${BuildDirectory}/syscfg"
|
||||
"
|
||||
>
|
||||
<configuration name="CPU1_RAM" compilerBuildOptions= "--opt_level=0 -I${C2000WARE_ROOT} -I${PROJECT_ROOT}/device -I${C2000WARE_DLIB_ROOT} -v28 -ml -mt --cla_support=cla2 --cla_background_task=on --cla_signed_compare_workaround=on --define=RAM --float_support=fpu64 --tmu_support=tmu0 --define=CPU1 --gen_func_subsections=on --diag_warning=225 --diag_suppress=10063" linkerBuildOptions="--entry_point code_start --stack_size=0x3F8 --heap_size=0x200 --define=RAM -i${C2000WARE_ROOT} -i${PROJECT_BUILD_DIR}/syscfg -lc2000ware_libraries.cmd.genlibs " />
|
||||
<configuration name="CPU1_FLASH" compilerBuildOptions="--opt_level=0 -I${C2000WARE_ROOT} -I${PROJECT_ROOT}/device -I${C2000WARE_DLIB_ROOT} --define=_FLASH -v28 -ml -mt --cla_support=cla2 --cla_background_task=on --cla_signed_compare_workaround=on --float_support=fpu64 --tmu_support=tmu0 --define=CPU1 --gen_func_subsections=on --diag_warning=225 --diag_suppress=10063" linkerBuildOptions="--entry_point code_start --stack_size=0x3F8 --heap_size=0x200 --define=_FLASH -i${C2000WARE_ROOT} -i${PROJECT_BUILD_DIR}/syscfg -lc2000ware_libraries.cmd.genlibs " />
|
||||
|
||||
<pathVariable name="C2000WARE_DLIB_ROOT" path="../../../../../../driverlib/f2838x/driverlib/" scope="project" />
|
||||
<pathVariable name="C2000WARE_ROOT" path="../../../../../../" scope="project" />
|
||||
<pathVariable name="CLB_SYSCFG_ROOT" path="../../../../../../utilities/clb_tool/clb_syscfg/" scope="project" />
|
||||
<pathVariable name="SYSTEMC_INSTALL" path="../../../../../../utilities/clb_tool/clb_syscfg/systemc-2.3.3" scope="project" />
|
||||
<pathVariable name="CLB_SIM_COMPILER" path="C:/TDM-GCC-64/bin" scope="project" />
|
||||
<buildVariable name="GENERATE_DIAGRAM" value="0" scope="project" />
|
||||
<file action="copy" path="../../../../../../device_support/f2838x/common/include/driverlib.h" targetDirectory="device" />
|
||||
<file action="copy" path="../../../../../../device_support/f2838x/common/include/device.h" targetDirectory="device" />
|
||||
<file action="copy" path="../../../../../../device_support/f2838x/common/source/device.c" targetDirectory="device" />
|
||||
<file action="copy" path="../../../../../../device_support/f2838x/common/targetConfigs/TMS320F28388D.ccxml" targetDirectory="targetConfigs" />
|
||||
<file action="copy" path="../../../../../../device_support/f2838x/common/cmd/2838x_RAM_CLA_lnk_cpu1.cmd" targetDirectory="" applicableConfigurations="CPU1_RAM" />
|
||||
<file action="copy" path="../../../../../../device_support/f2838x/common/cmd/2838x_FLASH_CLA_lnk_cpu1.cmd" targetDirectory="" applicableConfigurations="CPU1_FLASH" />
|
||||
<file action="copy" path="../../../../../../device_support/f2838x/common/source/f2838x_codestartbranch.asm" targetDirectory="device" />
|
||||
<file action="link" path="../../../../../../driverlib/f2838x/driverlib/ccs/Debug/driverlib.lib" targetDirectory="" />
|
||||
<file action="copy" path="../../../../../../driverlib/f2838x/driverlib/" targetDirectory="device" excludeFromBuild="True" />
|
||||
<file action="copy" path="../cla_ex3_background_nesting_task.c" targetDirectory="" />
|
||||
<file action="copy" path="../cla_ex3_background_nesting_task_cla.cla" targetDirectory="" />
|
||||
<file action="copy" path="../cla_ex3_background_nesting_task_shared.h" targetDirectory="" />
|
||||
<file action="copy" path="../cla_ex3_background_nesting_task.syscfg" targetDirectory="" />
|
||||
</project>
|
||||
</projectSpec>
|
||||
@@ -0,0 +1,42 @@
|
||||
<projectSpec>
|
||||
<project
|
||||
name="cla_ex4_pwm_control"
|
||||
device="TMS320F28388D"
|
||||
cgtVersion="22.6.1.LTS"
|
||||
products="sysconfig;C2000WARE"
|
||||
outputFormat="ELF"
|
||||
launchWizard="False"
|
||||
linkerCommandFile=""
|
||||
enableSysConfigTool="true"
|
||||
sysConfigBuildOptions="--product ${C2000WARE_ROOT}/.metadata/sdk.json --device F2838x --package 337bga --part F2838x_337bga"
|
||||
postBuildStep="
|
||||
echo "========= Build of the CLB simulation has moved to the CLB Tool. Click the '?' icon by the _Generate CLB Simulation File_ enable for more details (located in the Global Parameters of the Tile Design SysConfig module) ============="
|
||||
;if ${GENERATE_DIAGRAM} == 1 ${NODE_TOOL} "${C2000WARE_ROOT}/utilities/clb_tool/clb_syscfg/dot_file_libraries/clbDotUtility.js" "${C2000WARE_ROOT}/utilities/clb_tool/clb_syscfg/" "${BuildDirectory}/syscfg" "${BuildDirectory}/syscfg/clb.dot"
|
||||
;if ${GENERATE_DIAGRAM} == 1 mkdir "${BuildDirectory}/diagrams"
|
||||
;if ${GENERATE_DIAGRAM} == 1 ${NODE_TOOL} "${C2000WARE_ROOT}/driverlib/.meta/generate_diagrams.js" "${C2000WARE_ROOT}" "${BuildDirectory}/diagrams" "${BuildDirectory}/syscfg"
|
||||
"
|
||||
>
|
||||
<configuration name="CPU1_RAM" compilerBuildOptions= "--opt_level=off -I${C2000WARE_ROOT} -I${PROJECT_ROOT}/device -I${C2000WARE_DLIB_ROOT} -v28 -ml -mt --cla_support=cla2 --cla_background_task=off --cla_signed_compare_workaround=on --define=RAM --float_support=fpu64 --tmu_support=tmu0 --define=CPU1 --gen_func_subsections=on --diag_warning=225 --diag_suppress=10063" linkerBuildOptions="--entry_point code_start --stack_size=0x3F8 --heap_size=0x200 --define=RAM -i${C2000WARE_ROOT} -i${PROJECT_BUILD_DIR}/syscfg -lc2000ware_libraries.cmd.genlibs " />
|
||||
<configuration name="CPU1_FLASH" compilerBuildOptions="--opt_level=off -I${C2000WARE_ROOT} -I${PROJECT_ROOT}/device -I${C2000WARE_DLIB_ROOT} --define=_FLASH -v28 -ml -mt --cla_support=cla2 --cla_background_task=off --cla_signed_compare_workaround=on --float_support=fpu64 --tmu_support=tmu0 --define=CPU1 --gen_func_subsections=on --diag_warning=225 --diag_suppress=10063" linkerBuildOptions="--entry_point code_start --stack_size=0x3F8 --heap_size=0x200 --define=_FLASH -i${C2000WARE_ROOT} -i${PROJECT_BUILD_DIR}/syscfg -lc2000ware_libraries.cmd.genlibs " />
|
||||
|
||||
<pathVariable name="C2000WARE_DLIB_ROOT" path="../../../../../../driverlib/f2838x/driverlib/" scope="project" />
|
||||
<pathVariable name="C2000WARE_ROOT" path="../../../../../../" scope="project" />
|
||||
<pathVariable name="CLB_SYSCFG_ROOT" path="../../../../../../utilities/clb_tool/clb_syscfg/" scope="project" />
|
||||
<pathVariable name="SYSTEMC_INSTALL" path="../../../../../../utilities/clb_tool/clb_syscfg/systemc-2.3.3" scope="project" />
|
||||
<pathVariable name="CLB_SIM_COMPILER" path="C:/TDM-GCC-64/bin" scope="project" />
|
||||
<buildVariable name="GENERATE_DIAGRAM" value="0" scope="project" />
|
||||
<file action="copy" path="../../../../../../device_support/f2838x/common/include/driverlib.h" targetDirectory="device" />
|
||||
<file action="copy" path="../../../../../../device_support/f2838x/common/include/device.h" targetDirectory="device" />
|
||||
<file action="copy" path="../../../../../../device_support/f2838x/common/source/device.c" targetDirectory="device" />
|
||||
<file action="copy" path="../../../../../../device_support/f2838x/common/targetConfigs/TMS320F28388D.ccxml" targetDirectory="targetConfigs" />
|
||||
<file action="copy" path="../../../../../../device_support/f2838x/common/cmd/2838x_RAM_CLA_lnk_cpu1.cmd" targetDirectory="" applicableConfigurations="CPU1_RAM" />
|
||||
<file action="copy" path="../../../../../../device_support/f2838x/common/cmd/2838x_FLASH_CLA_lnk_cpu1.cmd" targetDirectory="" applicableConfigurations="CPU1_FLASH" />
|
||||
<file action="copy" path="../../../../../../device_support/f2838x/common/source/f2838x_codestartbranch.asm" targetDirectory="device" />
|
||||
<file action="link" path="../../../../../../driverlib/f2838x/driverlib/ccs/Debug/driverlib.lib" targetDirectory="" />
|
||||
<file action="copy" path="../../../../../../driverlib/f2838x/driverlib/" targetDirectory="device" excludeFromBuild="True" />
|
||||
<file action="copy" path="../cla_ex4_pwm_control.c" targetDirectory="" />
|
||||
<file action="copy" path="../cla_ex4_pwm_control_cla.cla" targetDirectory="" />
|
||||
<file action="copy" path="../cla_ex4_pwm_control_shared.h" targetDirectory="" />
|
||||
<file action="copy" path="../cla_ex4_pwm_control.syscfg" targetDirectory="" />
|
||||
</project>
|
||||
</projectSpec>
|
||||
@@ -0,0 +1,42 @@
|
||||
<projectSpec>
|
||||
<project
|
||||
name="cla_ex5_adc_just_in_time"
|
||||
device="TMS320F28388D"
|
||||
cgtVersion="22.6.1.LTS"
|
||||
products="sysconfig;C2000WARE"
|
||||
outputFormat="ELF"
|
||||
launchWizard="False"
|
||||
linkerCommandFile=""
|
||||
enableSysConfigTool="true"
|
||||
sysConfigBuildOptions="--product ${C2000WARE_ROOT}/.metadata/sdk.json --device F2838x --package 337bga --part F2838x_337bga"
|
||||
postBuildStep="
|
||||
echo "========= Build of the CLB simulation has moved to the CLB Tool. Click the '?' icon by the _Generate CLB Simulation File_ enable for more details (located in the Global Parameters of the Tile Design SysConfig module) ============="
|
||||
;if ${GENERATE_DIAGRAM} == 1 ${NODE_TOOL} "${C2000WARE_ROOT}/utilities/clb_tool/clb_syscfg/dot_file_libraries/clbDotUtility.js" "${C2000WARE_ROOT}/utilities/clb_tool/clb_syscfg/" "${BuildDirectory}/syscfg" "${BuildDirectory}/syscfg/clb.dot"
|
||||
;if ${GENERATE_DIAGRAM} == 1 mkdir "${BuildDirectory}/diagrams"
|
||||
;if ${GENERATE_DIAGRAM} == 1 ${NODE_TOOL} "${C2000WARE_ROOT}/driverlib/.meta/generate_diagrams.js" "${C2000WARE_ROOT}" "${BuildDirectory}/diagrams" "${BuildDirectory}/syscfg"
|
||||
"
|
||||
>
|
||||
<configuration name="CPU1_RAM" compilerBuildOptions= "--opt_level=off -I${C2000WARE_ROOT} -I${PROJECT_ROOT}/device -I${C2000WARE_DLIB_ROOT} -v28 -ml -mt --cla_support=cla2 --cla_background_task=off --cla_signed_compare_workaround=on --define=RAM --float_support=fpu64 --tmu_support=tmu0 --define=CPU1 --gen_func_subsections=on --diag_warning=225 --diag_suppress=10063" linkerBuildOptions="--entry_point code_start --stack_size=0x3F8 --heap_size=0x200 --define=RAM -i${C2000WARE_ROOT} -i${PROJECT_BUILD_DIR}/syscfg -lc2000ware_libraries.cmd.genlibs " />
|
||||
<configuration name="CPU1_FLASH" compilerBuildOptions="--opt_level=off -I${C2000WARE_ROOT} -I${PROJECT_ROOT}/device -I${C2000WARE_DLIB_ROOT} --define=_FLASH -v28 -ml -mt --cla_support=cla2 --cla_background_task=off --cla_signed_compare_workaround=on --float_support=fpu64 --tmu_support=tmu0 --define=CPU1 --gen_func_subsections=on --diag_warning=225 --diag_suppress=10063" linkerBuildOptions="--entry_point code_start --stack_size=0x3F8 --heap_size=0x200 --define=_FLASH -i${C2000WARE_ROOT} -i${PROJECT_BUILD_DIR}/syscfg -lc2000ware_libraries.cmd.genlibs " />
|
||||
|
||||
<pathVariable name="C2000WARE_DLIB_ROOT" path="../../../../../../driverlib/f2838x/driverlib/" scope="project" />
|
||||
<pathVariable name="C2000WARE_ROOT" path="../../../../../../" scope="project" />
|
||||
<pathVariable name="CLB_SYSCFG_ROOT" path="../../../../../../utilities/clb_tool/clb_syscfg/" scope="project" />
|
||||
<pathVariable name="SYSTEMC_INSTALL" path="../../../../../../utilities/clb_tool/clb_syscfg/systemc-2.3.3" scope="project" />
|
||||
<pathVariable name="CLB_SIM_COMPILER" path="C:/TDM-GCC-64/bin" scope="project" />
|
||||
<buildVariable name="GENERATE_DIAGRAM" value="0" scope="project" />
|
||||
<file action="copy" path="../../../../../../device_support/f2838x/common/include/driverlib.h" targetDirectory="device" />
|
||||
<file action="copy" path="../../../../../../device_support/f2838x/common/include/device.h" targetDirectory="device" />
|
||||
<file action="copy" path="../../../../../../device_support/f2838x/common/source/device.c" targetDirectory="device" />
|
||||
<file action="copy" path="../../../../../../device_support/f2838x/common/targetConfigs/TMS320F28388D.ccxml" targetDirectory="targetConfigs" />
|
||||
<file action="copy" path="../../../../../../device_support/f2838x/common/cmd/2838x_RAM_CLA_lnk_cpu1.cmd" targetDirectory="" applicableConfigurations="CPU1_RAM" />
|
||||
<file action="copy" path="../../../../../../device_support/f2838x/common/cmd/2838x_FLASH_CLA_lnk_cpu1.cmd" targetDirectory="" applicableConfigurations="CPU1_FLASH" />
|
||||
<file action="copy" path="../../../../../../device_support/f2838x/common/source/f2838x_codestartbranch.asm" targetDirectory="device" />
|
||||
<file action="link" path="../../../../../../driverlib/f2838x/driverlib/ccs/Debug/driverlib.lib" targetDirectory="" />
|
||||
<file action="copy" path="../../../../../../driverlib/f2838x/driverlib/" targetDirectory="device" excludeFromBuild="True" />
|
||||
<file action="copy" path="../cla_ex5_adc_just_in_time.c" targetDirectory="" />
|
||||
<file action="copy" path="../cla_ex5_adc_just_in_time_cla.cla" targetDirectory="" />
|
||||
<file action="copy" path="../cla_ex5_adc_just_in_time_shared.h" targetDirectory="" />
|
||||
<file action="copy" path="../cla_ex5_adc_just_in_time.syscfg" targetDirectory="" />
|
||||
</project>
|
||||
</projectSpec>
|
||||
@@ -0,0 +1,43 @@
|
||||
<projectSpec>
|
||||
<project
|
||||
name="cla_ex6_cpu_offloading"
|
||||
device="TMS320F28388D"
|
||||
cgtVersion="22.6.1.LTS"
|
||||
products="sysconfig;C2000WARE"
|
||||
outputFormat="ELF"
|
||||
launchWizard="False"
|
||||
linkerCommandFile=""
|
||||
enableSysConfigTool="true"
|
||||
sysConfigBuildOptions="--product ${C2000WARE_ROOT}/.metadata/sdk.json --device F2838x --package 337bga --part F2838x_337bga"
|
||||
postBuildStep="
|
||||
echo "========= Build of the CLB simulation has moved to the CLB Tool. Click the '?' icon by the _Generate CLB Simulation File_ enable for more details (located in the Global Parameters of the Tile Design SysConfig module) ============="
|
||||
;if ${GENERATE_DIAGRAM} == 1 ${NODE_TOOL} "${C2000WARE_ROOT}/utilities/clb_tool/clb_syscfg/dot_file_libraries/clbDotUtility.js" "${C2000WARE_ROOT}/utilities/clb_tool/clb_syscfg/" "${BuildDirectory}/syscfg" "${BuildDirectory}/syscfg/clb.dot"
|
||||
;if ${GENERATE_DIAGRAM} == 1 mkdir "${BuildDirectory}/diagrams"
|
||||
;if ${GENERATE_DIAGRAM} == 1 ${NODE_TOOL} "${C2000WARE_ROOT}/driverlib/.meta/generate_diagrams.js" "${C2000WARE_ROOT}" "${BuildDirectory}/diagrams" "${BuildDirectory}/syscfg"
|
||||
"
|
||||
>
|
||||
<configuration name="CPU1_RAM" compilerBuildOptions= "--opt_level=off -I${C2000WARE_ROOT} -I${PROJECT_ROOT}/device -I${C2000WARE_DLIB_ROOT} -I${C2000WARE_DCL_ROOT}/c28/include --define=run_loop1_cla=1 -v28 -ml -mt --cla_support=cla2 --cla_background_task=off --cla_signed_compare_workaround=on --define=RAM --float_support=fpu64 --tmu_support=tmu0 --define=CPU1 --gen_func_subsections=on --diag_warning=225 --diag_suppress=10063" linkerBuildOptions="--entry_point code_start --stack_size=0x3F8 --heap_size=0x200 --define=RAM -i${C2000WARE_ROOT} -i${PROJECT_BUILD_DIR}/syscfg -lc2000ware_libraries.cmd.genlibs " />
|
||||
<configuration name="CPU1_FLASH" compilerBuildOptions="--opt_level=off -I${C2000WARE_ROOT} -I${PROJECT_ROOT}/device -I${C2000WARE_DLIB_ROOT} --define=_FLASH -I${C2000WARE_DCL_ROOT}/c28/include --define=run_loop1_cla=1 -v28 -ml -mt --cla_support=cla2 --cla_background_task=off --cla_signed_compare_workaround=on --float_support=fpu64 --tmu_support=tmu0 --define=CPU1 --gen_func_subsections=on --diag_warning=225 --diag_suppress=10063" linkerBuildOptions="--entry_point code_start --stack_size=0x3F8 --heap_size=0x200 --define=_FLASH -i${C2000WARE_ROOT} -i${PROJECT_BUILD_DIR}/syscfg -lc2000ware_libraries.cmd.genlibs " />
|
||||
|
||||
<pathVariable name="C2000WARE_DLIB_ROOT" path="../../../../../../driverlib/f2838x/driverlib/" scope="project" />
|
||||
<pathVariable name="C2000WARE_ROOT" path="../../../../../../" scope="project" />
|
||||
<pathVariable name="CLB_SYSCFG_ROOT" path="../../../../../../utilities/clb_tool/clb_syscfg/" scope="project" />
|
||||
<pathVariable name="SYSTEMC_INSTALL" path="../../../../../../utilities/clb_tool/clb_syscfg/systemc-2.3.3" scope="project" />
|
||||
<pathVariable name="CLB_SIM_COMPILER" path="C:/TDM-GCC-64/bin" scope="project" />
|
||||
<buildVariable name="GENERATE_DIAGRAM" value="0" scope="project" />
|
||||
<pathVariable name="C2000WARE_DCL_ROOT" path="../../../../../../libraries/control/DCL/" scope="project" />
|
||||
<file action="copy" path="../../../../../../device_support/f2838x/common/include/driverlib.h" targetDirectory="device" />
|
||||
<file action="copy" path="../../../../../../device_support/f2838x/common/include/device.h" targetDirectory="device" />
|
||||
<file action="copy" path="../../../../../../device_support/f2838x/common/source/device.c" targetDirectory="device" />
|
||||
<file action="copy" path="../../../../../../device_support/f2838x/common/targetConfigs/TMS320F28388D.ccxml" targetDirectory="targetConfigs" />
|
||||
<file action="copy" path="../../../../../../device_support/f2838x/common/cmd/2838x_RAM_CLA_lnk_cpu1.cmd" targetDirectory="" applicableConfigurations="CPU1_RAM" />
|
||||
<file action="copy" path="../../../../../../device_support/f2838x/common/cmd/2838x_FLASH_CLA_lnk_cpu1.cmd" targetDirectory="" applicableConfigurations="CPU1_FLASH" />
|
||||
<file action="copy" path="../../../../../../device_support/f2838x/common/source/f2838x_codestartbranch.asm" targetDirectory="device" />
|
||||
<file action="link" path="../../../../../../driverlib/f2838x/driverlib/ccs/Debug/driverlib.lib" targetDirectory="" />
|
||||
<file action="copy" path="../../../../../../driverlib/f2838x/driverlib/" targetDirectory="device" excludeFromBuild="True" />
|
||||
<file action="copy" path="../cla_ex6_cpu_offloading.c" targetDirectory="" />
|
||||
<file action="copy" path="../cla_ex6_cpu_offloading_cla.cla" targetDirectory="" />
|
||||
<file action="copy" path="../cla_ex6_cpu_offloading_shared.h" targetDirectory="" />
|
||||
<file action="copy" path="../cla_ex6_cpu_offloading.syscfg" targetDirectory="" />
|
||||
</project>
|
||||
</projectSpec>
|
||||
+42
@@ -0,0 +1,42 @@
|
||||
<projectSpec>
|
||||
<project
|
||||
name="cla_ex7_shared_resource_handling"
|
||||
device="TMS320F28388D"
|
||||
cgtVersion="22.6.1.LTS"
|
||||
products="sysconfig;C2000WARE"
|
||||
outputFormat="ELF"
|
||||
launchWizard="False"
|
||||
linkerCommandFile=""
|
||||
enableSysConfigTool="true"
|
||||
sysConfigBuildOptions="--product ${C2000WARE_ROOT}/.metadata/sdk.json --device F2838x --package 337bga --part F2838x_337bga"
|
||||
postBuildStep="
|
||||
echo "========= Build of the CLB simulation has moved to the CLB Tool. Click the '?' icon by the _Generate CLB Simulation File_ enable for more details (located in the Global Parameters of the Tile Design SysConfig module) ============="
|
||||
;if ${GENERATE_DIAGRAM} == 1 ${NODE_TOOL} "${C2000WARE_ROOT}/utilities/clb_tool/clb_syscfg/dot_file_libraries/clbDotUtility.js" "${C2000WARE_ROOT}/utilities/clb_tool/clb_syscfg/" "${BuildDirectory}/syscfg" "${BuildDirectory}/syscfg/clb.dot"
|
||||
;if ${GENERATE_DIAGRAM} == 1 mkdir "${BuildDirectory}/diagrams"
|
||||
;if ${GENERATE_DIAGRAM} == 1 ${NODE_TOOL} "${C2000WARE_ROOT}/driverlib/.meta/generate_diagrams.js" "${C2000WARE_ROOT}" "${BuildDirectory}/diagrams" "${BuildDirectory}/syscfg"
|
||||
"
|
||||
>
|
||||
<configuration name="CPU1_RAM" compilerBuildOptions= "--opt_level=2 -I${C2000WARE_ROOT} -I${PROJECT_ROOT}/device -I${C2000WARE_DLIB_ROOT} -v28 -ml -mt --cla_support=cla2 --cla_background_task=off --cla_signed_compare_workaround=on --define=RAM --float_support=fpu64 --tmu_support=tmu0 --define=CPU1 --gen_func_subsections=on --diag_warning=225 --diag_suppress=10063" linkerBuildOptions="--entry_point code_start --stack_size=0x3F8 --heap_size=0x200 --define=RAM -i${C2000WARE_ROOT} -i${PROJECT_BUILD_DIR}/syscfg -lc2000ware_libraries.cmd.genlibs " />
|
||||
<configuration name="CPU1_FLASH" compilerBuildOptions="--opt_level=2 -I${C2000WARE_ROOT} -I${PROJECT_ROOT}/device -I${C2000WARE_DLIB_ROOT} --define=_FLASH -v28 -ml -mt --cla_support=cla2 --cla_background_task=off --cla_signed_compare_workaround=on --float_support=fpu64 --tmu_support=tmu0 --define=CPU1 --gen_func_subsections=on --diag_warning=225 --diag_suppress=10063" linkerBuildOptions="--entry_point code_start --stack_size=0x3F8 --heap_size=0x200 --define=_FLASH -i${C2000WARE_ROOT} -i${PROJECT_BUILD_DIR}/syscfg -lc2000ware_libraries.cmd.genlibs " />
|
||||
|
||||
<pathVariable name="C2000WARE_DLIB_ROOT" path="../../../../../../driverlib/f2838x/driverlib/" scope="project" />
|
||||
<pathVariable name="C2000WARE_ROOT" path="../../../../../../" scope="project" />
|
||||
<pathVariable name="CLB_SYSCFG_ROOT" path="../../../../../../utilities/clb_tool/clb_syscfg/" scope="project" />
|
||||
<pathVariable name="SYSTEMC_INSTALL" path="../../../../../../utilities/clb_tool/clb_syscfg/systemc-2.3.3" scope="project" />
|
||||
<pathVariable name="CLB_SIM_COMPILER" path="C:/TDM-GCC-64/bin" scope="project" />
|
||||
<buildVariable name="GENERATE_DIAGRAM" value="0" scope="project" />
|
||||
<file action="copy" path="../../../../../../device_support/f2838x/common/include/driverlib.h" targetDirectory="device" />
|
||||
<file action="copy" path="../../../../../../device_support/f2838x/common/include/device.h" targetDirectory="device" />
|
||||
<file action="copy" path="../../../../../../device_support/f2838x/common/source/device.c" targetDirectory="device" />
|
||||
<file action="copy" path="../../../../../../device_support/f2838x/common/targetConfigs/TMS320F28388D.ccxml" targetDirectory="targetConfigs" />
|
||||
<file action="copy" path="../../../../../../device_support/f2838x/common/cmd/2838x_RAM_CLA_lnk_cpu1.cmd" targetDirectory="" applicableConfigurations="CPU1_RAM" />
|
||||
<file action="copy" path="../../../../../../device_support/f2838x/common/cmd/2838x_FLASH_CLA_lnk_cpu1.cmd" targetDirectory="" applicableConfigurations="CPU1_FLASH" />
|
||||
<file action="copy" path="../../../../../../device_support/f2838x/common/source/f2838x_codestartbranch.asm" targetDirectory="device" />
|
||||
<file action="link" path="../../../../../../driverlib/f2838x/driverlib/ccs/Debug/driverlib.lib" targetDirectory="" />
|
||||
<file action="copy" path="../../../../../../driverlib/f2838x/driverlib/" targetDirectory="device" excludeFromBuild="True" />
|
||||
<file action="copy" path="../cla_ex7_shared_resource_handling.c" targetDirectory="" />
|
||||
<file action="copy" path="../cla_ex7_shared_resource_handling_cla.cla" targetDirectory="" />
|
||||
<file action="copy" path="../cla_ex7_shared_resource_handling.h" targetDirectory="" />
|
||||
<file action="copy" path="../cla_ex7_shared_resource_handling.syscfg" targetDirectory="" />
|
||||
</project>
|
||||
</projectSpec>
|
||||
@@ -0,0 +1,164 @@
|
||||
//#############################################################################
|
||||
// \file asin.cla
|
||||
//
|
||||
// \brief Arc Sine Example
|
||||
//
|
||||
//#############################################################################
|
||||
//
|
||||
// C2000Ware v5.04.00.00
|
||||
//
|
||||
// Copyright (C) 2024 Texas Instruments Incorporated - http://www.ti.com
|
||||
//
|
||||
// Redistribution and use in source and binary forms, with or without
|
||||
// modification, are permitted provided that the following conditions
|
||||
// are met:
|
||||
//
|
||||
// Redistributions of source code must retain the above copyright
|
||||
// notice, this list of conditions and the following disclaimer.
|
||||
//
|
||||
// Redistributions in binary form must reproduce the above copyright
|
||||
// notice, this list of conditions and the following disclaimer in the
|
||||
// documentation and/or other materials provided with the
|
||||
// distribution.
|
||||
//
|
||||
// Neither the name of Texas Instruments Incorporated nor the names of
|
||||
// its contributors may be used to endorse or promote products derived
|
||||
// from this software without specific prior written permission.
|
||||
//
|
||||
// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
|
||||
// "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
|
||||
// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
|
||||
// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
|
||||
// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
|
||||
// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
|
||||
// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
|
||||
// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
|
||||
// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
||||
// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
|
||||
// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
// $
|
||||
//#############################################################################
|
||||
|
||||
|
||||
//
|
||||
// Included Files
|
||||
//
|
||||
#include "cla_ex1_asin_shared.h"
|
||||
|
||||
//
|
||||
// Defines
|
||||
//
|
||||
|
||||
//
|
||||
// Globals
|
||||
//
|
||||
// Note that the globals defined in the .cla source are global to the cla source
|
||||
// file. i.e. they may be shared across tasks. All of the data shared between
|
||||
// the CLA and the C28x CPU must be defined in the C (or C++) code, and not the
|
||||
// CLA code.
|
||||
//
|
||||
|
||||
//
|
||||
// Function Definitions
|
||||
//
|
||||
//Task 1 : Calculate asin(X)
|
||||
// Description:
|
||||
// Step(1): Calculate absolute of the input X
|
||||
//
|
||||
// Step(2): Use the upper 6-bits of input "X" value as an
|
||||
// index into the table to obtain the coefficients
|
||||
// for a second order equation:
|
||||
//
|
||||
// _FPUasinTable:
|
||||
// CoeffA0[0]
|
||||
// CoeffA1[0]
|
||||
// CoeffA2[0]
|
||||
// .
|
||||
// .
|
||||
// CoeffA0[63]
|
||||
// CoeffA1[63]
|
||||
// CoeffA2[63]
|
||||
//
|
||||
// Step(3): Calculate the angle using the following equation:
|
||||
//
|
||||
// arctan(Ratio) = A0 + A1*Ratio + A2*Ratio*Ratio
|
||||
// arctan(Ratio) = A0 + Ratio(A1 + A2*Ratio)
|
||||
//
|
||||
// Step(4): The final angle is determined as follows:
|
||||
//
|
||||
// if( X < 0 )
|
||||
// Angle = -Angle
|
||||
__interrupt void Cla1Task1 ( void )
|
||||
{
|
||||
//
|
||||
//Local Variables
|
||||
//
|
||||
int xTblIdx; //integer valued Table index
|
||||
float A0,A1,A2; //Table coefficients
|
||||
float *entry;
|
||||
float result;
|
||||
|
||||
//
|
||||
//Preprocessing
|
||||
//
|
||||
__mdebugstop();
|
||||
xTblIdx = fVal * TABLE_SIZE_M_1; //convert table index to u16-bits
|
||||
xTblIdx = xTblIdx * 3; //Table is ordered as 3 32-bit coefficients, the
|
||||
//index points to these triplets, hence the *3*sizeof(float)
|
||||
entry = &CLAasinTable[xTblIdx];
|
||||
A0 = *entry++;
|
||||
A1 = *entry++;
|
||||
A2 = *entry;
|
||||
|
||||
|
||||
result = A0 + fVal*(A1 + A2*fVal);
|
||||
|
||||
//
|
||||
//Post processing
|
||||
//
|
||||
if(fVal < 0)
|
||||
{
|
||||
result = - result;
|
||||
}
|
||||
|
||||
fResult = result;
|
||||
}
|
||||
|
||||
interrupt void Cla1Task2 ( void )
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
interrupt void Cla1Task3 ( void )
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
interrupt void Cla1Task4 ( void )
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
interrupt void Cla1Task5 ( void )
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
interrupt void Cla1Task6 ( void )
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
interrupt void Cla1Task7 ( void )
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
interrupt void Cla1Task8 ( void )
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
//
|
||||
// End of file
|
||||
//
|
||||
@@ -0,0 +1,189 @@
|
||||
//#############################################################################
|
||||
// \file atan.cla
|
||||
//
|
||||
// \brief Arc Tangent Example
|
||||
//
|
||||
//#############################################################################
|
||||
//
|
||||
// C2000Ware v5.04.00.00
|
||||
//
|
||||
// Copyright (C) 2024 Texas Instruments Incorporated - http://www.ti.com
|
||||
//
|
||||
// Redistribution and use in source and binary forms, with or without
|
||||
// modification, are permitted provided that the following conditions
|
||||
// are met:
|
||||
//
|
||||
// Redistributions of source code must retain the above copyright
|
||||
// notice, this list of conditions and the following disclaimer.
|
||||
//
|
||||
// Redistributions in binary form must reproduce the above copyright
|
||||
// notice, this list of conditions and the following disclaimer in the
|
||||
// documentation and/or other materials provided with the
|
||||
// distribution.
|
||||
//
|
||||
// Neither the name of Texas Instruments Incorporated nor the names of
|
||||
// its contributors may be used to endorse or promote products derived
|
||||
// from this software without specific prior written permission.
|
||||
//
|
||||
// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
|
||||
// "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
|
||||
// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
|
||||
// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
|
||||
// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
|
||||
// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
|
||||
// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
|
||||
// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
|
||||
// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
||||
// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
|
||||
// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
// $
|
||||
//#############################################################################
|
||||
|
||||
//
|
||||
// Included Files
|
||||
//
|
||||
#include "cla_ex2_atan_shared.h"
|
||||
|
||||
//
|
||||
// Defines
|
||||
//
|
||||
|
||||
//
|
||||
// Globals
|
||||
//
|
||||
// Note that the globals defined in the .cla source are global to the cla source
|
||||
// file. i.e. they may be shared across tasks. All of the data shared between
|
||||
// the CLA and the C28x CPU must be defined in the C (or C++) code, and not the
|
||||
// CLA code.
|
||||
//
|
||||
|
||||
//
|
||||
// Function Definitions
|
||||
//
|
||||
//Task 1 : Calculate atan(Y)
|
||||
// Description:
|
||||
// Step(1): if( 1.0 >= abs(Y) )
|
||||
// Numerator = abs(Y)
|
||||
// Denominator = 1.0
|
||||
// else
|
||||
// Numerator = 1.0
|
||||
// Denominator = abs(Y)
|
||||
//
|
||||
// Step(2): Ratio = Numerator/Denominator
|
||||
//
|
||||
// Note: Ratio range = 0.0 to 1.0
|
||||
//
|
||||
// Step(3): Use the upper 6-bits of the "Ratio" value as an
|
||||
// index into the table to obtain the coefficients
|
||||
// for a second order equation:
|
||||
//
|
||||
// _FPUatan2Table:
|
||||
// CoeffA0[0]
|
||||
// CoeffA1[0]
|
||||
// CoeffA2[0]
|
||||
// .
|
||||
// .
|
||||
// CoeffA0[63]
|
||||
// CoeffA1[63]
|
||||
// CoeffA2[63]
|
||||
//
|
||||
// Step(4): Calculate the angle using the following equation:
|
||||
//
|
||||
// arctan(Ratio) = A0 + A1*Ratio + A2*Ratio*Ratio
|
||||
// arctan(Ratio) = A0 + Ratio(A1 + A2*Ratio)
|
||||
//
|
||||
// Step(5): The final angle is determined as follows:
|
||||
//
|
||||
// if( Y >= 0 and 1.0 >= abs(Y) )
|
||||
// Angle = arctan(abs(Y)/1.0)
|
||||
// if( Y >= 0 and 1.0 < abs(Y) )
|
||||
// Angle = PI/2 - arctan(1.0/abs(Y))
|
||||
// if( Y < 0 )
|
||||
// Angle = -Angle
|
||||
__interrupt void Cla1Task1 ( void )
|
||||
{
|
||||
//
|
||||
//Local Variables
|
||||
//
|
||||
unsigned int uxTblIdx; //unsigned integer valued Table index
|
||||
float ratio;
|
||||
float num,den;
|
||||
float A0,A1,A2; //Table coefficients
|
||||
float *base;
|
||||
float result;
|
||||
|
||||
//
|
||||
//Preprocessing
|
||||
//
|
||||
__mdebugstop();
|
||||
num = __mminf32(fabsf(fVal),1.0f);
|
||||
den = __mmaxf32(fabsf(fVal),1.0f);
|
||||
|
||||
ratio = (num/den); //Expected the newton raphson algo for better
|
||||
//accuracy on the divide
|
||||
uxTblIdx = ratio * TABLE_SIZE_M_1 * 3; //convert table index to u16-bits
|
||||
uxTblIdx = uxTblIdx * 3; //Table is ordered as 3 32-bit coefficients, the
|
||||
//index points to these triplets, hence the *3*sizeof(float)
|
||||
|
||||
base = &CLAatan2Table[uxTblIdx];
|
||||
A0 = *base++;
|
||||
A1 = *base++;
|
||||
A2 = *base;
|
||||
|
||||
result = A0 + ratio*(A1 + A2*ratio);
|
||||
|
||||
//
|
||||
//Post processing
|
||||
//
|
||||
if(fabsf(fVal) > 1.0f)
|
||||
{
|
||||
result = PIBYTWO - result;
|
||||
}
|
||||
|
||||
if(fVal < 0.0f)
|
||||
{
|
||||
result = -result;
|
||||
}
|
||||
|
||||
fResult = result;
|
||||
}
|
||||
|
||||
interrupt void Cla1Task2 ( void )
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
interrupt void Cla1Task3 ( void )
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
interrupt void Cla1Task4 ( void )
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
interrupt void Cla1Task5 ( void )
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
interrupt void Cla1Task6 ( void )
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
interrupt void Cla1Task7 ( void )
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
interrupt void Cla1Task8 ( void )
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
//
|
||||
// End of file
|
||||
//
|
||||
|
||||
@@ -0,0 +1,424 @@
|
||||
//###########################################################################
|
||||
//
|
||||
// FILE: cla_ex1_asin.c
|
||||
//
|
||||
// TITLE: CLA Arcsine Example
|
||||
//
|
||||
//! \addtogroup driver_example_list
|
||||
//! <h1>CLA \f$arcsine(x)\f$ using a lookup table (cla_asin_cpu01)</h1>
|
||||
//!
|
||||
//! In this example, Task 1 of the CLA will calculate the arcsine of
|
||||
//! an input argument in the range (-1.0 to 1.0) using a lookup table.
|
||||
//!
|
||||
//! Note that since this example does not use background CLA task, the compile
|
||||
//! flag cla_background_task is turned off for this project. Set this flag as
|
||||
//! on to enable background CLA task. The option is available in Project
|
||||
//! Properties -> C2000 Build -> C2000 Compiler -> Advanced Options -> Runtime
|
||||
//! Model Options.
|
||||
//!
|
||||
//! \b Memory \b Allocation \n
|
||||
//! - CLA1 Math Tables (RAMLS0)
|
||||
//! - CLAasinTable - Lookup table
|
||||
//! - CLA1 to CPU Message RAM
|
||||
//! - fResult - Result of the lookup algorithm
|
||||
//! - CPU to CLA1 Message RAM
|
||||
//! - fVal - Sample input to the lookup algorithm
|
||||
//!
|
||||
//! \b Watch \b Variables \n
|
||||
//! - fVal - Argument to task 1
|
||||
//! - fResult - Result of \f$arcsin(fVal)\f$
|
||||
//!
|
||||
//
|
||||
//###########################################################################
|
||||
//
|
||||
// C2000Ware v5.04.00.00
|
||||
//
|
||||
// Copyright (C) 2024 Texas Instruments Incorporated - http://www.ti.com
|
||||
//
|
||||
// Redistribution and use in source and binary forms, with or without
|
||||
// modification, are permitted provided that the following conditions
|
||||
// are met:
|
||||
//
|
||||
// Redistributions of source code must retain the above copyright
|
||||
// notice, this list of conditions and the following disclaimer.
|
||||
//
|
||||
// Redistributions in binary form must reproduce the above copyright
|
||||
// notice, this list of conditions and the following disclaimer in the
|
||||
// documentation and/or other materials provided with the
|
||||
// distribution.
|
||||
//
|
||||
// Neither the name of Texas Instruments Incorporated nor the names of
|
||||
// its contributors may be used to endorse or promote products derived
|
||||
// from this software without specific prior written permission.
|
||||
//
|
||||
// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
|
||||
// "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
|
||||
// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
|
||||
// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
|
||||
// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
|
||||
// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
|
||||
// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
|
||||
// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
|
||||
// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
||||
// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
|
||||
// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
// $
|
||||
//###########################################################################
|
||||
|
||||
//
|
||||
// Included Files
|
||||
//
|
||||
#include "driverlib.h"
|
||||
#include "device.h"
|
||||
#include "cla_ex1_asin_shared.h"
|
||||
#include "board.h"
|
||||
|
||||
//
|
||||
// Defines
|
||||
//
|
||||
#define WAITSTEP asm(" RPT #255 || NOP")
|
||||
|
||||
//
|
||||
// Globals
|
||||
//
|
||||
|
||||
//
|
||||
//Task 1 (C) Variables
|
||||
// NOTE: Do not initialize the Message RAM variables globally, they will be
|
||||
// reset during the message ram initialization phase in the CLA memory
|
||||
// configuration routine
|
||||
//
|
||||
#ifdef __cplusplus
|
||||
#pragma DATA_SECTION("CpuToCla1MsgRAM");
|
||||
float fVal;
|
||||
#pragma DATA_SECTION("Cla1ToCpuMsgRAM");
|
||||
float fResult;
|
||||
#else
|
||||
#pragma DATA_SECTION(fVal,"CpuToCla1MsgRAM");
|
||||
float fVal;
|
||||
#pragma DATA_SECTION(fResult,"Cla1ToCpuMsgRAM");
|
||||
float fResult;
|
||||
#endif //__cplusplus
|
||||
float y[BUFFER_SIZE];
|
||||
|
||||
//
|
||||
//Task 2 (C) Variables
|
||||
//
|
||||
|
||||
//
|
||||
//Task 3 (C) Variables
|
||||
//
|
||||
|
||||
//
|
||||
//Task 4 (C) Variables
|
||||
//
|
||||
|
||||
//
|
||||
//Task 5 (C) Variables
|
||||
//
|
||||
|
||||
//
|
||||
//Task 6 (C) Variables
|
||||
//
|
||||
|
||||
//
|
||||
//Task 7 (C) Variables
|
||||
//
|
||||
|
||||
//
|
||||
//Task 8 (C) Variables
|
||||
//
|
||||
|
||||
//
|
||||
//Common (C) Variables
|
||||
//The Exponential table
|
||||
//
|
||||
#ifdef __cplusplus
|
||||
#pragma DATA_SECTION("CLADataLS0")
|
||||
#else
|
||||
#pragma DATA_SECTION(CLAasinTable,"CLADataLS0")
|
||||
#endif //__cplusplus
|
||||
float CLAasinTable[]={
|
||||
0.0, 1.0, 0.0,
|
||||
0.000000636202, 0.999877862610, 0.007815361896,
|
||||
0.000005099694, 0.999510644409, 0.015647916155,
|
||||
0.000017268312, 0.998895919094, 0.023514960332,
|
||||
0.000041121765, 0.998029615282, 0.031434003631,
|
||||
0.000080794520, 0.996905974725, 0.039422875916,
|
||||
0.000140631089, 0.995517492804, 0.047499840611,
|
||||
0.000225244584, 0.993854840311, 0.055683712914,
|
||||
0.000339579512, 0.991906765146, 0.063993984848,
|
||||
0.000488979852, 0.989659972212, 0.072450958820,
|
||||
0.000679263611, 0.987098979366, 0.081075891529,
|
||||
0.000916805182, 0.984205946802, 0.089891150305,
|
||||
0.001208627040, 0.980960476685, 0.098920384204,
|
||||
0.001562502549, 0.977339379243, 0.108188712551,
|
||||
0.001987071928, 0.973316400729, 0.117722933997,
|
||||
0.002491973784, 0.968861907789, 0.127551759665,
|
||||
0.003087995053, 0.963942521723, 0.137706074532,
|
||||
0.003787242692, 0.958520694794, 0.148219231941,
|
||||
0.004603341138, 0.952554219267, 0.159127386977,
|
||||
0.005551660294, 0.945995657913, 0.170469875522,
|
||||
0.006649579796, 0.938791682505, 0.182289647088,
|
||||
0.007916796475, 0.930882303984, 0.194633761132,
|
||||
0.009375683410, 0.922199974574, 0.207553958472,
|
||||
0.011051710808, 0.912668537890, 0.221107321885,
|
||||
0.012973941175, 0.902201997769, 0.235357042896,
|
||||
0.015175614174, 0.890703070035, 0.250373315541,
|
||||
0.017694840102, 0.878061473098, 0.266234382514,
|
||||
0.020575425537, 0.864151902887, 0.283027765009,
|
||||
0.023867860513, 0.848831624374, 0.300851714968,
|
||||
0.027630504055, 0.831937595031, 0.319816937941,
|
||||
0.031931014547, 0.813283013821, 0.340048646894,
|
||||
0.036848083955, 0.792653161200, 0.361689022958,
|
||||
0.042473551274, 0.769800358920, 0.384900179460,
|
||||
0.048914992206, 0.744437830278, 0.409867752228,
|
||||
0.056298910750, 0.716232177740, 0.436805274317,
|
||||
0.064774696786, 0.684794109766, 0.465959540059,
|
||||
0.074519565699, 0.649666934178, 0.497617226179,
|
||||
0.085744766889, 0.610312179660, 0.532113122767,
|
||||
0.098703445606, 0.566091493186, 0.569840443472,
|
||||
0.113700678529, 0.516243664372, 0.611263845480,
|
||||
0.131106395009, 0.459855210927, 0.656936015611,
|
||||
0.151372169232, 0.395822366759, 0.707518998893,
|
||||
0.175053263659, 0.322801460177, 0.763811905770,
|
||||
0.202837883870, 0.239143420888, 0.826787304376,
|
||||
0.235586468765, 0.142806299514, 0.897639596948,
|
||||
0.274385149825, 0.031236880585, 0.977850174820,
|
||||
0.320619535938, -0.098791845166, 1.069276441800,
|
||||
0.376078169620, -0.251407364538, 1.174275392129,
|
||||
0.443100143614, -0.431959397725, 1.295878193174,
|
||||
0.524789871827, -0.647485610469, 1.438041695773,
|
||||
0.625336471263, -0.907400624736, 1.606018804842,
|
||||
0.750500589935, -1.224540947101, 1.806917563896,
|
||||
0.908377657341, -1.616794995066, 2.050569262035,
|
||||
1.110633894185, -2.109729648039, 2.350920816737,
|
||||
1.374584721437, -2.740985157716, 2.728353889708,
|
||||
1.726848242753, -3.567962877198, 3.213722960014,
|
||||
2.210117561056, -4.682006534082, 3.855770086891,
|
||||
2.896554011854, -6.236312386687, 4.735651038017,
|
||||
3.916505715382, -8.505488022524, 5.997790945975,
|
||||
5.526855868703, -12.026617159136, 7.922628470498,
|
||||
8.298197116322, -17.983705080358, 11.123941286820,
|
||||
13.741706072449, -29.488929624542, 17.203344479111,
|
||||
27.202707817485, -57.466598393615, 31.741016484669,
|
||||
83.158101335898, -171.803399517566, 90.149831709374
|
||||
};
|
||||
|
||||
float asin_expected[BUFFER_SIZE]={
|
||||
1.570796, 1.393789, 1.320141, 1.263401, 1.215375,
|
||||
1.172892, 1.134327, 1.098718, 1.065436, 1.034046,
|
||||
1.004232, 0.9757544, 0.9484279, 0.9221048, 0.8966658,
|
||||
0.8720123, 0.8480621, 0.8247454, 0.8020028, 0.7797828,
|
||||
0.7580408, 0.7367374, 0.7158381, 0.6953120, 0.6751316,
|
||||
0.6552721, 0.6357113, 0.6164289, 0.5974064, 0.5786270,
|
||||
0.5600753, 0.5417370, 0.5235988, 0.5056486, 0.4878751,
|
||||
0.4702678, 0.4528166, 0.4355124, 0.4183464, 0.4013104,
|
||||
0.3843968, 0.3675981, 0.3509074, 0.3343180, 0.3178237,
|
||||
0.3014185, 0.2850964, 0.2688521, 0.2526802, 0.2365756,
|
||||
0.2205333, 0.2045484, 0.1886164, 0.1727327, 0.1568929,
|
||||
0.1410927, 0.1253278, 0.1095943, 0.09388787, 0.07820469,
|
||||
0.06254076, 0.04689218, 0.03125509, 0.01562564
|
||||
};
|
||||
|
||||
uint16_t pass = 0;
|
||||
uint16_t fail = 0;
|
||||
|
||||
//
|
||||
// Function Prototypes
|
||||
//
|
||||
void CLA_runTest(void);
|
||||
__interrupt void cla1Isr1();
|
||||
__interrupt void cla1Isr2();
|
||||
__interrupt void cla1Isr3();
|
||||
__interrupt void cla1Isr4();
|
||||
__interrupt void cla1Isr5();
|
||||
__interrupt void cla1Isr6();
|
||||
__interrupt void cla1Isr7();
|
||||
__interrupt void cla1Isr8();
|
||||
|
||||
//
|
||||
// Main
|
||||
//
|
||||
void main(void)
|
||||
{
|
||||
|
||||
//
|
||||
// Intialize device clock and peripherals
|
||||
//
|
||||
Device_init();
|
||||
|
||||
//
|
||||
// Disable pin locks and enable internal pullups.
|
||||
//
|
||||
//Device_initGPIO(); //skipped for this example
|
||||
|
||||
//
|
||||
// Initialize PIE and clear PIE registers. Disables CPU interrupts
|
||||
//
|
||||
Interrupt_initModule();
|
||||
|
||||
//
|
||||
// Initialize the PIE vector table with pointers to the shell Interrupt
|
||||
// Service Routines (ISR).
|
||||
//
|
||||
Interrupt_initVectorTable();
|
||||
|
||||
//
|
||||
// Initialize resources
|
||||
//
|
||||
Board_init();
|
||||
|
||||
//
|
||||
// Enable Global Interrupt (INTM) and realtime interrupt (DBGM)
|
||||
//
|
||||
EINT;
|
||||
ERTM;
|
||||
|
||||
//
|
||||
// Run the test
|
||||
//
|
||||
CLA_runTest();
|
||||
|
||||
for(;;)
|
||||
{
|
||||
}
|
||||
}
|
||||
|
||||
//
|
||||
// CLA_runTest - Execute CLA task tests for specified vectors
|
||||
//
|
||||
void CLA_runTest(void)
|
||||
{
|
||||
int16_t i;
|
||||
float error;
|
||||
|
||||
for(i = 0; i < BUFFER_SIZE; i++)
|
||||
{
|
||||
fVal= (float)(BUFFER_SIZE - i)/(float)BUFFER_SIZE;
|
||||
CLA_forceTasks(CLA1_BASE,CLA_TASKFLAG_1);
|
||||
WAITSTEP;
|
||||
y[i] = fResult;
|
||||
error = fabsf(asin_expected[i]-y[i]);
|
||||
|
||||
if(error < 0.1f)
|
||||
{
|
||||
pass++;
|
||||
}
|
||||
else
|
||||
{
|
||||
fail++;
|
||||
}
|
||||
}
|
||||
|
||||
#if 0
|
||||
|
||||
CLA_forceTasks(CLA1_BASE,CLA_TASKFLAG_2);
|
||||
WAITSTEP;
|
||||
|
||||
CLA_forceTasks(CLA1_BASE,CLA_TASKFLAG_3);
|
||||
WAITSTEP;
|
||||
|
||||
CLA_forceTasks(CLA1_BASE,CLA_TASKFLAG_4);
|
||||
WAITSTEP;
|
||||
|
||||
CLA_forceTasks(CLA1_BASE,CLA_TASKFLAG_5);
|
||||
WAITSTEP;
|
||||
|
||||
CLA_forceTasks(CLA1_BASE,CLA_TASKFLAG_6);
|
||||
WAITSTEP;
|
||||
|
||||
CLA_forceTasks(CLA1_BASE,CLA_TASKFLAG_7);
|
||||
WAITSTEP;
|
||||
|
||||
CLA_forceTasks(CLA1_BASE,CLA_TASKFLAG_8);
|
||||
WAITSTEP;
|
||||
#endif
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
//
|
||||
// cla1Isr1 - CLA1 ISR 1
|
||||
//
|
||||
|
||||
__interrupt void cla1Isr1 ()
|
||||
{
|
||||
//
|
||||
// Acknowledge the end-of-task interrupt for task 1
|
||||
//
|
||||
Interrupt_clearACKGroup(INTERRUPT_ACK_GROUP11);
|
||||
|
||||
//
|
||||
// Uncomment to halt debugger and stop here
|
||||
//
|
||||
// asm(" ESTOP0");
|
||||
}
|
||||
|
||||
//
|
||||
// cla1Isr2 - CLA1 ISR 2
|
||||
//
|
||||
__interrupt void cla1Isr2 ()
|
||||
{
|
||||
asm(" ESTOP0");
|
||||
}
|
||||
|
||||
//
|
||||
// cla1Isr3 - CLA1 ISR 3
|
||||
//
|
||||
__interrupt void cla1Isr3 ()
|
||||
{
|
||||
asm(" ESTOP0");
|
||||
}
|
||||
|
||||
//
|
||||
// cla1Isr4 - CLA1 ISR 4
|
||||
//
|
||||
__interrupt void cla1Isr4 ()
|
||||
{
|
||||
asm(" ESTOP0");
|
||||
}
|
||||
|
||||
//
|
||||
// cla1Isr5 - CLA1 ISR 5
|
||||
//
|
||||
__interrupt void cla1Isr5 ()
|
||||
{
|
||||
asm(" ESTOP0");
|
||||
}
|
||||
|
||||
//
|
||||
// cla1Isr6 - CLA1 ISR 6
|
||||
//
|
||||
__interrupt void cla1Isr6 ()
|
||||
{
|
||||
asm(" ESTOP0");
|
||||
}
|
||||
|
||||
//
|
||||
// cla1Isr7 - CLA1 ISR 7
|
||||
//
|
||||
__interrupt void cla1Isr7 ()
|
||||
{
|
||||
asm(" ESTOP0");
|
||||
}
|
||||
|
||||
//
|
||||
// cla1Isr8 - CLA1 ISR 8
|
||||
//
|
||||
__interrupt void cla1Isr8 ()
|
||||
{
|
||||
//
|
||||
// Acknowledge the end-of-task interrupt for task 8
|
||||
//
|
||||
Interrupt_clearACKGroup(INTERRUPT_ACK_GROUP11);
|
||||
//
|
||||
// Uncomment to halt debugger and stop here
|
||||
//
|
||||
// asm(" ESTOP0");
|
||||
}
|
||||
|
||||
//
|
||||
// End of file
|
||||
//
|
||||
@@ -0,0 +1,19 @@
|
||||
|
||||
/**
|
||||
* Import the modules used in this configuration.
|
||||
*/
|
||||
const cla = scripting.addModule("/driverlib/cla.js", {}, false);
|
||||
const cla1 = cla.addInstance();
|
||||
const memcfg = scripting.addModule("/driverlib/memcfg.js");
|
||||
|
||||
/**
|
||||
* Write custom configuration values to the imported modules.
|
||||
*/
|
||||
cla1.$name = "myCLA0";
|
||||
|
||||
|
||||
memcfg.config_MEMCFG_SECT_LS5 = "CLA_prog";
|
||||
memcfg.config_MEMCFG_SECT_LS0 = "CLA_data";
|
||||
memcfg.config_MEMCFG_SECT_LS1 = "CLA_data";
|
||||
memcfg.init_MEMCFG_SECT_MSGCPUTOCLA1 = true;
|
||||
memcfg.init_MEMCFG_SECT_MSGCLA1TOCPU = true;
|
||||
@@ -0,0 +1,133 @@
|
||||
#ifndef _CLA_ASIN_SHARED_H_
|
||||
#define _CLA_ASIN_SHARED_H_
|
||||
//#############################################################################
|
||||
//
|
||||
// FILE: cla_ex1_asin_shared.h
|
||||
//
|
||||
// TITLE: CLA arcsine example header file.
|
||||
//
|
||||
//#############################################################################
|
||||
//
|
||||
// C2000Ware v5.04.00.00
|
||||
//
|
||||
// Copyright (C) 2024 Texas Instruments Incorporated - http://www.ti.com
|
||||
//
|
||||
// Redistribution and use in source and binary forms, with or without
|
||||
// modification, are permitted provided that the following conditions
|
||||
// are met:
|
||||
//
|
||||
// Redistributions of source code must retain the above copyright
|
||||
// notice, this list of conditions and the following disclaimer.
|
||||
//
|
||||
// Redistributions in binary form must reproduce the above copyright
|
||||
// notice, this list of conditions and the following disclaimer in the
|
||||
// documentation and/or other materials provided with the
|
||||
// distribution.
|
||||
//
|
||||
// Neither the name of Texas Instruments Incorporated nor the names of
|
||||
// its contributors may be used to endorse or promote products derived
|
||||
// from this software without specific prior written permission.
|
||||
//
|
||||
// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
|
||||
// "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
|
||||
// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
|
||||
// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
|
||||
// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
|
||||
// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
|
||||
// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
|
||||
// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
|
||||
// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
||||
// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
|
||||
// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
// $
|
||||
//#############################################################################
|
||||
|
||||
|
||||
//
|
||||
// Included Files
|
||||
//
|
||||
#include <stdint.h>
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
//
|
||||
// Defines
|
||||
//
|
||||
#define BUFFER_SIZE 64
|
||||
#define TABLE_SIZE 64
|
||||
#define TABLE_SIZE_M_1 TABLE_SIZE-1
|
||||
#define PIBYTWO 1.570796327
|
||||
#define PI 3.141592653589
|
||||
#define INV2PI 0.159154943
|
||||
|
||||
//
|
||||
// Globals
|
||||
//
|
||||
|
||||
//
|
||||
//Task 1 (C) Variables
|
||||
//
|
||||
extern float y[]; //Result vector
|
||||
extern float fVal; //Holds the input argument to the task
|
||||
extern float fResult; //The arsine of the input argument
|
||||
|
||||
//
|
||||
//Task 2 (C) Variables
|
||||
//
|
||||
|
||||
//
|
||||
//Task 3 (C) Variables
|
||||
//
|
||||
|
||||
//
|
||||
//Task 4 (C) Variables
|
||||
//
|
||||
|
||||
//
|
||||
//Task 5 (C) Variables
|
||||
//
|
||||
|
||||
//
|
||||
//Task 6 (C) Variables
|
||||
//
|
||||
|
||||
//
|
||||
//Task 7 (C) Variables
|
||||
//
|
||||
|
||||
//
|
||||
//Task 8 (C) Variables
|
||||
//
|
||||
|
||||
//
|
||||
//Common (C) Variables
|
||||
//
|
||||
extern float CLAasinTable[]; //The arcsine lookup table
|
||||
|
||||
//
|
||||
// Function Prototypes
|
||||
//
|
||||
// The following are symbols defined in the CLA assembly code
|
||||
// Including them in the shared header file makes them
|
||||
// .global and the main CPU can make use of them.
|
||||
//
|
||||
__interrupt void Cla1Task1();
|
||||
__interrupt void Cla1Task2();
|
||||
__interrupt void Cla1Task3();
|
||||
__interrupt void Cla1Task4();
|
||||
__interrupt void Cla1Task5();
|
||||
__interrupt void Cla1Task6();
|
||||
__interrupt void Cla1Task7();
|
||||
__interrupt void Cla1Task8();
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif // extern "C"
|
||||
|
||||
#endif //end of _CLA_ASIN_SHARED_H_ definition
|
||||
|
||||
//
|
||||
// End of file
|
||||
//
|
||||
@@ -0,0 +1,441 @@
|
||||
//###########################################################################
|
||||
//
|
||||
// FILE: cla_ex2_atan.c
|
||||
//
|
||||
// TITLE: CLA ArcTan Example for F2837xD.
|
||||
//
|
||||
//! \addtogroup driver_example_list
|
||||
//! <h1>CLA \f$arctangent(x)\f$ using a lookup table (cla_atan_cpu01)</h1>
|
||||
//!
|
||||
//! In this example, Task 1 of the CLA will calculate the arctangent of
|
||||
//! an input argument using a lookup table.
|
||||
//!
|
||||
//! Note that since this example does not use background CLA task, the compile
|
||||
//! flag cla_background_task is turned off for this project. Set this flag as
|
||||
//! on to enable background CLA task. The option is available in Project
|
||||
//! Properties -> C2000 Build -> C2000 Compiler -> Advanced Options -> Runtime
|
||||
//! Model Options.
|
||||
//!
|
||||
//! \b Memory \b Allocation \n
|
||||
//! - CLA1 Math Tables (RAMLS0)
|
||||
//! - CLAatan2Table - Lookup table
|
||||
//! - CLA1 to CPU Message RAM
|
||||
//! - fResult - Result of the lookup algorithm
|
||||
//! - CPU to CLA1 Message RAM
|
||||
//! - fNum - Numerator of sample input
|
||||
//! - fDen - Denominator of sample input
|
||||
//!
|
||||
//! \b Watch \b Variables \n
|
||||
//! - fVal - Argument to task 1
|
||||
//! - fResult - Result of \f$arctan(fVal)\f$
|
||||
//!
|
||||
//
|
||||
//###########################################################################
|
||||
//
|
||||
//
|
||||
//
|
||||
// C2000Ware v5.04.00.00
|
||||
//
|
||||
// Copyright (C) 2024 Texas Instruments Incorporated - http://www.ti.com
|
||||
//
|
||||
// Redistribution and use in source and binary forms, with or without
|
||||
// modification, are permitted provided that the following conditions
|
||||
// are met:
|
||||
//
|
||||
// Redistributions of source code must retain the above copyright
|
||||
// notice, this list of conditions and the following disclaimer.
|
||||
//
|
||||
// Redistributions in binary form must reproduce the above copyright
|
||||
// notice, this list of conditions and the following disclaimer in the
|
||||
// documentation and/or other materials provided with the
|
||||
// distribution.
|
||||
//
|
||||
// Neither the name of Texas Instruments Incorporated nor the names of
|
||||
// its contributors may be used to endorse or promote products derived
|
||||
// from this software without specific prior written permission.
|
||||
//
|
||||
// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
|
||||
// "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
|
||||
// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
|
||||
// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
|
||||
// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
|
||||
// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
|
||||
// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
|
||||
// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
|
||||
// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
||||
// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
|
||||
// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
// $
|
||||
//###########################################################################
|
||||
|
||||
//
|
||||
// Included Files
|
||||
//
|
||||
#include "driverlib.h"
|
||||
#include "device.h"
|
||||
#include "cla_ex2_atan_shared.h"
|
||||
#include "board.h"
|
||||
//
|
||||
// Defines
|
||||
//
|
||||
#define WAITSTEP asm(" RPT #255 || NOP")
|
||||
|
||||
//
|
||||
// Globals
|
||||
//
|
||||
|
||||
//
|
||||
//Task 1 (C) Variables
|
||||
// NOTE: Do not initialize the Message RAM variables globally, they will be
|
||||
// reset during the message ram initialization phase in the CLA memory
|
||||
// configuration routine
|
||||
//
|
||||
#ifdef __cplusplus
|
||||
|
||||
#pragma DATA_SECTION("CpuToCla1MsgRAM");
|
||||
float fVal;
|
||||
#pragma DATA_SECTION("CpuToCla1MsgRAM")
|
||||
float PIBYTWO;
|
||||
#pragma DATA_SECTION("Cla1ToCpuMsgRAM");
|
||||
float fResult;
|
||||
|
||||
#else
|
||||
|
||||
#pragma DATA_SECTION(fVal,"CpuToCla1MsgRAM");
|
||||
float fVal;
|
||||
#pragma DATA_SECTION(PIBYTWO,"CpuToCla1MsgRAM")
|
||||
float PIBYTWO = 1.570796327;
|
||||
#pragma DATA_SECTION(fResult,"Cla1ToCpuMsgRAM");
|
||||
float fResult;
|
||||
#endif //__cplusplus
|
||||
float y[BUFFER_SIZE];
|
||||
|
||||
//
|
||||
//Task 2 (C) Variables
|
||||
//
|
||||
|
||||
//
|
||||
//Task 3 (C) Variables
|
||||
//
|
||||
|
||||
//
|
||||
//Task 4 (C) Variables
|
||||
//
|
||||
|
||||
//
|
||||
//Task 5 (C) Variables
|
||||
//
|
||||
|
||||
//
|
||||
//Task 6 (C) Variables
|
||||
//
|
||||
|
||||
//
|
||||
//Task 7 (C) Variables
|
||||
//
|
||||
|
||||
//
|
||||
//Task 8 (C) Variables
|
||||
//
|
||||
|
||||
//
|
||||
//Common (C) Variables
|
||||
//The Exponential table
|
||||
//
|
||||
#ifdef __cplusplus
|
||||
#pragma DATA_SECTION("CLADataLS0")
|
||||
#else
|
||||
#pragma DATA_SECTION(CLAatan2Table,"CLADataLS0")
|
||||
#endif //__cplusplus
|
||||
float CLAatan2Table[]={
|
||||
0.000000000000, 1.000040679675, -0.007811069750,
|
||||
-0.000003807022, 1.000528067772, -0.023410345493,
|
||||
-0.000018968310, 1.001498568106, -0.038941197075,
|
||||
-0.000052831927, 1.002943680965, -0.054358563160,
|
||||
-0.000112417996, 1.004850785788, -0.069618206649,
|
||||
-0.000204295885, 1.007203293243, -0.084677028723,
|
||||
-0.000334469493, 1.009980843501, -0.099493367628,
|
||||
-0.000508272606, 1.013159547023, -0.114027278430,
|
||||
-0.000730276035, 1.016712263449, -0.128240790343,
|
||||
-0.001004207980, 1.020608913557, -0.142098138715,
|
||||
-0.001332888717, 1.024816818801, -0.155565969259,
|
||||
-0.001718180431, 1.029301062569, -0.168613512667,
|
||||
-0.002160952612, 1.034024867135, -0.181212728329,
|
||||
-0.002661063159, 1.038949980222, -0.193338416410,
|
||||
-0.003217354977, 1.044037065160, -0.204968298146,
|
||||
-0.003827667546, 1.049246088868, -0.216083064706,
|
||||
-0.004488862702, 1.054536702192, -0.226666395507,
|
||||
-0.005196863579, 1.059868607573, -0.236704947279,
|
||||
-0.005946705500, 1.065201909527, -0.246188315613,
|
||||
-0.006732597422, 1.070497443994, -0.255108971022,
|
||||
-0.007547992413, 1.075717083222, -0.263462171840,
|
||||
-0.008385665599, 1.080824013499, -0.271245856476,
|
||||
-0.009237797924, 1.085782983693, -0.278460517693,
|
||||
-0.010096064139, 1.090560523211, -0.285109061650,
|
||||
-0.010951723407, 1.095125128557, -0.291196654447,
|
||||
-0.011795711029, 1.099447418304, -0.296730558920,
|
||||
-0.012618729873, 1.103500256784, -0.301719964310,
|
||||
-0.013411340199, 1.107258847274, -0.306175811325,
|
||||
-0.014164046711, 1.110700795887, -0.310110614947,
|
||||
-0.014867381831, 1.113806147717, -0.313538287176,
|
||||
-0.015511984298, 1.116557397059, -0.316473961655,
|
||||
-0.016088672395, 1.118939473766, -0.318933821948,
|
||||
-0.016588511229, 1.120939707956, -0.320934934991,
|
||||
-0.017002873645, 1.122547775367, -0.322495091022,
|
||||
-0.017323494499, 1.123755625749, -0.323632651068,
|
||||
-0.017542518140, 1.124557396633, -0.324366402860,
|
||||
-0.017652539065, 1.124949314810, -0.324715425833,
|
||||
-0.017646635823, 1.124929587773, -0.324698965683,
|
||||
-0.017518398344, 1.124498287266, -0.324336318787,
|
||||
-0.017261948920, 1.123657226955, -0.323646726613,
|
||||
-0.016871957164, 1.122409836098, -0.322649280139,
|
||||
-0.016343649294, 1.120761030918, -0.321362834119,
|
||||
-0.015672812166, 1.118717085258, -0.319805931024,
|
||||
-0.014855792451, 1.116285501852, -0.317996734279,
|
||||
-0.013889491441, 1.113474885484, -0.315952970460,
|
||||
-0.012771355912, 1.110294819035, -0.313691879968,
|
||||
-0.011499365513, 1.106755743329, -0.311230175714,
|
||||
-0.010072017131, 1.102868841531, -0.308584009287,
|
||||
-0.008488306656, 1.098645928648, -0.305768944066,
|
||||
-0.006747708579, 1.094099346648, -0.302799934724,
|
||||
-0.004850153815, 1.089241865523, -0.299691312610,
|
||||
-0.002796006119, 1.084086590517, -0.296456776409,
|
||||
-0.000586037441, 1.078646875666, -0.293109387609,
|
||||
0.001778597452, 1.072936243727, -0.289661570229,
|
||||
0.004296386804, 1.066968312440, -0.286125114351,
|
||||
0.006965487894, 1.060756727064, -0.282511182960,
|
||||
0.009783753017, 1.054315099009, -0.278830321668,
|
||||
0.012748755207, 1.047656950440, -0.275092470943,
|
||||
0.015857813546, 1.040795664582, -0.271306980411,
|
||||
0.019108017893, 1.033744441476, -0.267482624928,
|
||||
0.022496252887, 1.026516258989, -0.263627622089,
|
||||
0.026019221162, 1.019123838651, -0.259749650860,
|
||||
0.029673465636, 1.011579616186, -0.255855871106,
|
||||
0.033455390838, 1.003895716322, -0.251952943763,
|
||||
0.037361283212, 0.996083931611, -0.248047051426
|
||||
};
|
||||
|
||||
float atan_expected[BUFFER_SIZE]={
|
||||
1.5395565, 1.5385494, 1.5374753, 1.5363272,
|
||||
1.5350972, 1.5337762, 1.5323538, 1.5308176,
|
||||
1.5291537, 1.5273454, 1.5253731, 1.5232133,
|
||||
1.5208379, 1.5182133, 1.5152978, 1.5120405,
|
||||
1.5083776, 1.5042281, 1.4994888, 1.4940244,
|
||||
1.4876550, 1.4801364, 1.4711276, 1.4601392,
|
||||
1.4464413, 1.4288993, 1.4056476, 1.3734008,
|
||||
1.3258177, 1.2490457, 1.1071488, 0.7853982,
|
||||
0.0000000, -0.7853982, -1.1071488, -1.2490457,
|
||||
-1.3258177, -1.3734008, -1.4056476, -1.4288993,
|
||||
-1.4464413, -1.4601392, -1.4711276, -1.4801364,
|
||||
-1.4876550, -1.4940244, -1.4994888, -1.5042281,
|
||||
-1.5083776, -1.5120405, -1.5152978, -1.5182133,
|
||||
-1.5208379, -1.5232133, -1.5253731, -1.5273454,
|
||||
-1.5291537, -1.5308176, -1.5323538, -1.5337762,
|
||||
-1.5350972, -1.5363272, -1.5374753, -1.5385494
|
||||
};
|
||||
|
||||
uint16_t pass = 0;
|
||||
uint16_t fail = 0;
|
||||
|
||||
//
|
||||
// Function Prototypes
|
||||
//
|
||||
void CLA_runTest(void);
|
||||
__interrupt void cla1Isr1();
|
||||
__interrupt void cla1Isr2();
|
||||
__interrupt void cla1Isr3();
|
||||
__interrupt void cla1Isr4();
|
||||
__interrupt void cla1Isr5();
|
||||
__interrupt void cla1Isr6();
|
||||
__interrupt void cla1Isr7();
|
||||
__interrupt void cla1Isr8();
|
||||
|
||||
//
|
||||
// Main
|
||||
//
|
||||
void main(void)
|
||||
{
|
||||
//
|
||||
// Initialize device clock and peripherals
|
||||
//
|
||||
Device_init();
|
||||
|
||||
//
|
||||
// Disable pin locks and enable internal pullups.
|
||||
//
|
||||
//Device_initGPIO(); //skipped for this example
|
||||
|
||||
//
|
||||
// Initialize PIE and clear PIE registers. Disables CPU interrupts
|
||||
//
|
||||
Interrupt_initModule();
|
||||
|
||||
//
|
||||
// Initialize the PIE vector table with pointers to the shell Interrupt
|
||||
// Service Routines (ISR).
|
||||
//
|
||||
Interrupt_initVectorTable();
|
||||
|
||||
//
|
||||
// Initialize resources
|
||||
//
|
||||
Board_init();
|
||||
|
||||
//
|
||||
// Enable Global Interrupts (INTM) and realtime interrupt (DGBM)
|
||||
//
|
||||
EINT;
|
||||
ERTM;
|
||||
|
||||
//
|
||||
// Run the test
|
||||
//
|
||||
CLA_runTest();
|
||||
|
||||
for(;;)
|
||||
{
|
||||
}
|
||||
}
|
||||
|
||||
//
|
||||
// CLA_runTest - Execute CLA task tests for specified vectors
|
||||
//
|
||||
void CLA_runTest(void)
|
||||
{
|
||||
int16_t i;
|
||||
float error;
|
||||
|
||||
//
|
||||
// Initialize the CPUToCLA1MsgRam variables here
|
||||
//
|
||||
PIBYTWO = 1.570796327;
|
||||
|
||||
for(i = 0; i < BUFFER_SIZE; i++)
|
||||
{
|
||||
fVal = (float)((BUFFER_SIZE/2) - i);
|
||||
|
||||
CLA_forceTasks(CLA1_BASE,CLA_TASKFLAG_1);
|
||||
WAITSTEP;
|
||||
y[i] = fResult;
|
||||
error = fabsf(atan_expected[i]-y[i]);
|
||||
|
||||
if(error < 0.001f)
|
||||
{
|
||||
pass++;
|
||||
}
|
||||
else
|
||||
{
|
||||
fail++;
|
||||
}
|
||||
}
|
||||
|
||||
#if 0
|
||||
|
||||
CLA_forceTasks(CLA1_BASE,CLA_TASKFLAG_2);
|
||||
WAITSTEP;
|
||||
|
||||
CLA_forceTasks(CLA1_BASE,CLA_TASKFLAG_3);
|
||||
WAITSTEP;
|
||||
|
||||
CLA_forceTasks(CLA1_BASE,CLA_TASKFLAG_4);
|
||||
WAITSTEP;
|
||||
|
||||
CLA_forceTasks(CLA1_BASE,CLA_TASKFLAG_5);
|
||||
WAITSTEP;
|
||||
|
||||
CLA_forceTasks(CLA1_BASE,CLA_TASKFLAG_6);
|
||||
WAITSTEP;
|
||||
|
||||
CLA_forceTasks(CLA1_BASE,CLA_TASKFLAG_7);
|
||||
WAITSTEP;
|
||||
|
||||
CLA_forceTasks(CLA1_BASE,CLA_TASKFLAG_8);
|
||||
WAITSTEP;
|
||||
#endif
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
//
|
||||
// cla1Isr1 - CLA1 ISR 1
|
||||
//
|
||||
__interrupt void cla1Isr1 ()
|
||||
{
|
||||
//
|
||||
// Acknowledge the end-of-task interrupt for task 1
|
||||
//
|
||||
Interrupt_clearACKGroup(INTERRUPT_ACK_GROUP11);
|
||||
|
||||
//
|
||||
// Uncomment to halt debugger and stop here
|
||||
//
|
||||
// asm(" ESTOP0");
|
||||
}
|
||||
|
||||
//
|
||||
// cla1Isr2 - CLA1 ISR 2
|
||||
//
|
||||
__interrupt void cla1Isr2 ()
|
||||
{
|
||||
asm(" ESTOP0");
|
||||
}
|
||||
|
||||
//
|
||||
// cla1Isr3 - CLA1 ISR 3
|
||||
//
|
||||
__interrupt void cla1Isr3 ()
|
||||
{
|
||||
asm(" ESTOP0");
|
||||
}
|
||||
|
||||
//
|
||||
// cla1Isr4 - CLA1 ISR 4
|
||||
//
|
||||
__interrupt void cla1Isr4 ()
|
||||
{
|
||||
asm(" ESTOP0");
|
||||
}
|
||||
|
||||
//
|
||||
// cla1Isr5 - CLA1 ISR 5
|
||||
//
|
||||
__interrupt void cla1Isr5 ()
|
||||
{
|
||||
asm(" ESTOP0");
|
||||
}
|
||||
|
||||
//
|
||||
// cla1Isr6 - CLA1 ISR 6
|
||||
//
|
||||
__interrupt void cla1Isr6 ()
|
||||
{
|
||||
asm(" ESTOP0");
|
||||
}
|
||||
|
||||
//
|
||||
// cla1Isr7 - CLA1 ISR 7
|
||||
//
|
||||
__interrupt void cla1Isr7 ()
|
||||
{
|
||||
asm(" ESTOP0");
|
||||
}
|
||||
|
||||
//
|
||||
// cla1Isr8 - CLA1 ISR 8
|
||||
//
|
||||
__interrupt void cla1Isr8 ()
|
||||
{
|
||||
//
|
||||
// Acknowledge the end-of-task interrupt for task 8
|
||||
//
|
||||
Interrupt_clearACKGroup(INTERRUPT_ACK_GROUP11);
|
||||
//
|
||||
// Uncomment to halt debugger and stop here
|
||||
//
|
||||
// asm(" ESTOP0");
|
||||
}
|
||||
|
||||
//
|
||||
// End of file
|
||||
//
|
||||
@@ -0,0 +1,19 @@
|
||||
|
||||
/**
|
||||
* Import the modules used in this configuration.
|
||||
*/
|
||||
const cla = scripting.addModule("/driverlib/cla.js", {}, false);
|
||||
const cla1 = cla.addInstance();
|
||||
const memcfg = scripting.addModule("/driverlib/memcfg.js");
|
||||
|
||||
/**
|
||||
* Write custom configuration values to the imported modules.
|
||||
*/
|
||||
cla1.$name = "myCLA0";
|
||||
|
||||
|
||||
memcfg.config_MEMCFG_SECT_LS5 = "CLA_prog";
|
||||
memcfg.config_MEMCFG_SECT_LS0 = "CLA_data";
|
||||
memcfg.config_MEMCFG_SECT_LS1 = "CLA_data";
|
||||
memcfg.init_MEMCFG_SECT_MSGCPUTOCLA1 = true;
|
||||
memcfg.init_MEMCFG_SECT_MSGCLA1TOCPU = true;
|
||||
Loaded 100 of 14950 files, more files were not shown because too many files have changed in this diff.
Show more
Reference in new issue
Block a user