Update repo

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

No files matched your search

@@ -0,0 +1,43 @@
<projectSpec>
<project
name="hrpwm_ex1_duty_sfo"
device="TMS320F28388D"
cgtVersion="22.6.1.LTS"
products="sysconfig;C2000WARE"
outputFormat="ELF"
launchWizard="False"
linkerCommandFile=""
enableSysConfigTool="true"
sysConfigBuildOptions="--product ${C2000WARE_ROOT}/.metadata/sdk.json --device F2838x --package 337bga --part F2838x_337bga"
postBuildStep="
echo &quot;========= Build of the CLB simulation has moved to the CLB Tool. Click the '?' icon by the _Generate CLB Simulation File_ enable for more details (located in the Global Parameters of the Tile Design SysConfig module) =============&quot;
;if ${GENERATE_DIAGRAM} == 1 ${NODE_TOOL} &quot;${C2000WARE_ROOT}/utilities/clb_tool/clb_syscfg/dot_file_libraries/clbDotUtility.js&quot; &quot;${C2000WARE_ROOT}/utilities/clb_tool/clb_syscfg/&quot; &quot;${BuildDirectory}/syscfg&quot; &quot;${BuildDirectory}/syscfg/clb.dot&quot;
;if ${GENERATE_DIAGRAM} == 1 mkdir &quot;${BuildDirectory}/diagrams&quot;
;if ${GENERATE_DIAGRAM} == 1 ${NODE_TOOL} &quot;${C2000WARE_ROOT}/driverlib/.meta/generate_diagrams.js&quot; &quot;${C2000WARE_ROOT}&quot; &quot;${BuildDirectory}/diagrams&quot; &quot;${BuildDirectory}/syscfg&quot;
"
>
<configuration name="CPU1_RAM" compilerBuildOptions= "--opt_level=off -I${C2000WARE_ROOT} -I${PROJECT_ROOT}/device -I${C2000WARE_DLIB_ROOT} -I${C2000WARE_SFO_INCLUDE} -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 -I${C2000WARE_SFO_INCLUDE} -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" />
<pathVariable name="C2000WARE_SFO_INCLUDE" path="../../../../../../libraries/calibration/hrpwm/f2838x/include/" scope="project" />
<file action="link" path="../../../../../../libraries/calibration/hrpwm/f2838x/lib/SFO_v8_fpu_lib_build_c28_driverlib.lib" targetDirectory="" />
<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="../hrpwm_ex1_duty_sfo.c" targetDirectory="" />
<file action="copy" path="../hrpwm_ex1_duty_sfo.syscfg" targetDirectory="" />
</project>
</projectSpec>
@@ -0,0 +1,43 @@
<projectSpec>
<project
name="hrpwm_ex2_slider"
device="TMS320F28388D"
cgtVersion="22.6.1.LTS"
products="sysconfig;C2000WARE"
outputFormat="ELF"
launchWizard="False"
linkerCommandFile=""
enableSysConfigTool="true"
sysConfigBuildOptions="--product ${C2000WARE_ROOT}/.metadata/sdk.json --device F2838x --package 337bga --part F2838x_337bga"
postBuildStep="
echo &quot;========= Build of the CLB simulation has moved to the CLB Tool. Click the '?' icon by the _Generate CLB Simulation File_ enable for more details (located in the Global Parameters of the Tile Design SysConfig module) =============&quot;
;if ${GENERATE_DIAGRAM} == 1 ${NODE_TOOL} &quot;${C2000WARE_ROOT}/utilities/clb_tool/clb_syscfg/dot_file_libraries/clbDotUtility.js&quot; &quot;${C2000WARE_ROOT}/utilities/clb_tool/clb_syscfg/&quot; &quot;${BuildDirectory}/syscfg&quot; &quot;${BuildDirectory}/syscfg/clb.dot&quot;
;if ${GENERATE_DIAGRAM} == 1 mkdir &quot;${BuildDirectory}/diagrams&quot;
;if ${GENERATE_DIAGRAM} == 1 ${NODE_TOOL} &quot;${C2000WARE_ROOT}/driverlib/.meta/generate_diagrams.js&quot; &quot;${C2000WARE_ROOT}&quot; &quot;${BuildDirectory}/diagrams&quot; &quot;${BuildDirectory}/syscfg&quot;
"
>
<configuration name="CPU1_RAM" compilerBuildOptions= "--opt_level=off -I${C2000WARE_ROOT} -I${PROJECT_ROOT}/device -I${C2000WARE_DLIB_ROOT} -I${C2000WARE_SFO_INCLUDE} -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 -I${C2000WARE_SFO_INCLUDE} -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" />
<pathVariable name="C2000WARE_SFO_INCLUDE" path="../../../../../../libraries/calibration/hrpwm/f2838x/include/" scope="project" />
<file action="link" path="../../../../../../libraries/calibration/hrpwm/f2838x/lib/SFO_v8_fpu_lib_build_c28_driverlib.lib" targetDirectory="" />
<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="../hrpwm_ex2_slider.c" targetDirectory="" />
<file action="copy" path="../hrpwm_ex2_slider.syscfg" targetDirectory="" />
</project>
</projectSpec>
@@ -0,0 +1,43 @@
<projectSpec>
<project
name="hrpwm_ex3_prd_updown_sfo"
device="TMS320F28388D"
cgtVersion="22.6.1.LTS"
products="sysconfig;C2000WARE"
outputFormat="ELF"
launchWizard="False"
linkerCommandFile=""
enableSysConfigTool="true"
sysConfigBuildOptions="--product ${C2000WARE_ROOT}/.metadata/sdk.json --device F2838x --package 337bga --part F2838x_337bga"
postBuildStep="
echo &quot;========= Build of the CLB simulation has moved to the CLB Tool. Click the '?' icon by the _Generate CLB Simulation File_ enable for more details (located in the Global Parameters of the Tile Design SysConfig module) =============&quot;
;if ${GENERATE_DIAGRAM} == 1 ${NODE_TOOL} &quot;${C2000WARE_ROOT}/utilities/clb_tool/clb_syscfg/dot_file_libraries/clbDotUtility.js&quot; &quot;${C2000WARE_ROOT}/utilities/clb_tool/clb_syscfg/&quot; &quot;${BuildDirectory}/syscfg&quot; &quot;${BuildDirectory}/syscfg/clb.dot&quot;
;if ${GENERATE_DIAGRAM} == 1 mkdir &quot;${BuildDirectory}/diagrams&quot;
;if ${GENERATE_DIAGRAM} == 1 ${NODE_TOOL} &quot;${C2000WARE_ROOT}/driverlib/.meta/generate_diagrams.js&quot; &quot;${C2000WARE_ROOT}&quot; &quot;${BuildDirectory}/diagrams&quot; &quot;${BuildDirectory}/syscfg&quot;
"
>
<configuration name="CPU1_RAM" compilerBuildOptions= "--opt_level=off -I${C2000WARE_ROOT} -I${PROJECT_ROOT}/device -I${C2000WARE_DLIB_ROOT} -I${C2000WARE_SFO_INCLUDE} -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 -I${C2000WARE_SFO_INCLUDE} -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" />
<pathVariable name="C2000WARE_SFO_INCLUDE" path="../../../../../../libraries/calibration/hrpwm/f2838x/include/" scope="project" />
<file action="link" path="../../../../../../libraries/calibration/hrpwm/f2838x/lib/SFO_v8_fpu_lib_build_c28_driverlib.lib" targetDirectory="" />
<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="../hrpwm_ex3_prd_updown_sfo.c" targetDirectory="" />
<file action="copy" path="../hrpwm_ex3_prd_updown_sfo.syscfg" targetDirectory="" />
</project>
</projectSpec>
@@ -0,0 +1,43 @@
<projectSpec>
<project
name="hrpwm_ex4_duty_updown_sfo"
device="TMS320F28388D"
cgtVersion="22.6.1.LTS"
products="sysconfig;C2000WARE"
outputFormat="ELF"
launchWizard="False"
linkerCommandFile=""
enableSysConfigTool="true"
sysConfigBuildOptions="--product ${C2000WARE_ROOT}/.metadata/sdk.json --device F2838x --package 337bga --part F2838x_337bga"
postBuildStep="
echo &quot;========= Build of the CLB simulation has moved to the CLB Tool. Click the '?' icon by the _Generate CLB Simulation File_ enable for more details (located in the Global Parameters of the Tile Design SysConfig module) =============&quot;
;if ${GENERATE_DIAGRAM} == 1 ${NODE_TOOL} &quot;${C2000WARE_ROOT}/utilities/clb_tool/clb_syscfg/dot_file_libraries/clbDotUtility.js&quot; &quot;${C2000WARE_ROOT}/utilities/clb_tool/clb_syscfg/&quot; &quot;${BuildDirectory}/syscfg&quot; &quot;${BuildDirectory}/syscfg/clb.dot&quot;
;if ${GENERATE_DIAGRAM} == 1 mkdir &quot;${BuildDirectory}/diagrams&quot;
;if ${GENERATE_DIAGRAM} == 1 ${NODE_TOOL} &quot;${C2000WARE_ROOT}/driverlib/.meta/generate_diagrams.js&quot; &quot;${C2000WARE_ROOT}&quot; &quot;${BuildDirectory}/diagrams&quot; &quot;${BuildDirectory}/syscfg&quot;
"
>
<configuration name="CPU1_RAM" compilerBuildOptions= "--opt_level=off -I${C2000WARE_ROOT} -I${PROJECT_ROOT}/device -I${C2000WARE_DLIB_ROOT} -I${C2000WARE_SFO_INCLUDE} -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 -I${C2000WARE_SFO_INCLUDE} -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" />
<pathVariable name="C2000WARE_SFO_INCLUDE" path="../../../../../../libraries/calibration/hrpwm/f2838x/include/" scope="project" />
<file action="link" path="../../../../../../libraries/calibration/hrpwm/f2838x/lib/SFO_v8_fpu_lib_build_c28_driverlib.lib" targetDirectory="" />
<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="../hrpwm_ex4_duty_updown_sfo.c" targetDirectory="" />
<file action="copy" path="../hrpwm_ex4_duty_updown_sfo.syscfg" targetDirectory="" />
</project>
</projectSpec>
@@ -0,0 +1,44 @@
<projectSpec>
<project
name="hrpwm_ex5_slider_qformat"
device="TMS320F28388D"
cgtVersion="22.6.1.LTS"
products="sysconfig;C2000WARE"
outputFormat="ELF"
launchWizard="False"
linkerCommandFile=""
enableSysConfigTool="true"
sysConfigBuildOptions="--product ${C2000WARE_ROOT}/.metadata/sdk.json --device F2838x --package 337bga --part F2838x_337bga"
postBuildStep="
echo &quot;========= Build of the CLB simulation has moved to the CLB Tool. Click the '?' icon by the _Generate CLB Simulation File_ enable for more details (located in the Global Parameters of the Tile Design SysConfig module) =============&quot;
;if ${GENERATE_DIAGRAM} == 1 ${NODE_TOOL} &quot;${C2000WARE_ROOT}/utilities/clb_tool/clb_syscfg/dot_file_libraries/clbDotUtility.js&quot; &quot;${C2000WARE_ROOT}/utilities/clb_tool/clb_syscfg/&quot; &quot;${BuildDirectory}/syscfg&quot; &quot;${BuildDirectory}/syscfg/clb.dot&quot;
;if ${GENERATE_DIAGRAM} == 1 mkdir &quot;${BuildDirectory}/diagrams&quot;
;if ${GENERATE_DIAGRAM} == 1 ${NODE_TOOL} &quot;${C2000WARE_ROOT}/driverlib/.meta/generate_diagrams.js&quot; &quot;${C2000WARE_ROOT}&quot; &quot;${BuildDirectory}/diagrams&quot; &quot;${BuildDirectory}/syscfg&quot;
"
>
<configuration name="CPU1_RAM" compilerBuildOptions= "--opt_level=off -I${C2000WARE_ROOT} -I${PROJECT_ROOT}/device -I${C2000WARE_DLIB_ROOT} -I${C2000WARE_SFO_INCLUDE} -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 -I${C2000WARE_SFO_INCLUDE} -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" />
<pathVariable name="C2000WARE_SFO_INCLUDE" path="../../../../../../libraries/calibration/hrpwm/f2838x/include/" scope="project" />
<file action="link" path="../../../../../../libraries/calibration/hrpwm/f2838x/lib/SFO_v8_fpu_lib_build_c28_driverlib.lib" targetDirectory="" />
<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="../hrpwm_ex5_slider_qformat.c" targetDirectory="" />
<file action="copy" path="../hrpwm_ex5_slider_qformat.syscfg" targetDirectory="" />
<file action="copy" path="../hrpwm_slider.gel" targetDirectory="" />
</project>
</projectSpec>
@@ -0,0 +1,43 @@
<projectSpec>
<project
name="hrpwm_ex6_duty_sfo_qformat"
device="TMS320F28388D"
cgtVersion="22.6.1.LTS"
products="sysconfig;C2000WARE"
outputFormat="ELF"
launchWizard="False"
linkerCommandFile=""
enableSysConfigTool="true"
sysConfigBuildOptions="--product ${C2000WARE_ROOT}/.metadata/sdk.json --device F2838x --package 337bga --part F2838x_337bga"
postBuildStep="
echo &quot;========= Build of the CLB simulation has moved to the CLB Tool. Click the '?' icon by the _Generate CLB Simulation File_ enable for more details (located in the Global Parameters of the Tile Design SysConfig module) =============&quot;
;if ${GENERATE_DIAGRAM} == 1 ${NODE_TOOL} &quot;${C2000WARE_ROOT}/utilities/clb_tool/clb_syscfg/dot_file_libraries/clbDotUtility.js&quot; &quot;${C2000WARE_ROOT}/utilities/clb_tool/clb_syscfg/&quot; &quot;${BuildDirectory}/syscfg&quot; &quot;${BuildDirectory}/syscfg/clb.dot&quot;
;if ${GENERATE_DIAGRAM} == 1 mkdir &quot;${BuildDirectory}/diagrams&quot;
;if ${GENERATE_DIAGRAM} == 1 ${NODE_TOOL} &quot;${C2000WARE_ROOT}/driverlib/.meta/generate_diagrams.js&quot; &quot;${C2000WARE_ROOT}&quot; &quot;${BuildDirectory}/diagrams&quot; &quot;${BuildDirectory}/syscfg&quot;
"
>
<configuration name="CPU1_RAM" compilerBuildOptions= "--opt_level=off -I${C2000WARE_ROOT} -I${PROJECT_ROOT}/device -I${C2000WARE_DLIB_ROOT} -I${C2000WARE_SFO_INCLUDE} -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 -I${C2000WARE_SFO_INCLUDE} -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" />
<pathVariable name="C2000WARE_SFO_INCLUDE" path="../../../../../../libraries/calibration/hrpwm/f2838x/include/" scope="project" />
<file action="link" path="../../../../../../libraries/calibration/hrpwm/f2838x/lib/SFO_v8_fpu_lib_build_c28_driverlib.lib" targetDirectory="" />
<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="../hrpwm_ex6_duty_sfo_qformat.c" targetDirectory="" />
<file action="copy" path="../hrpwm_ex6_duty_sfo_qformat.syscfg" targetDirectory="" />
</project>
</projectSpec>
@@ -0,0 +1,43 @@
<projectSpec>
<project
name="hrpwm_ex7_prd_updown_sfo_qformat"
device="TMS320F28388D"
cgtVersion="22.6.1.LTS"
products="sysconfig;C2000WARE"
outputFormat="ELF"
launchWizard="False"
linkerCommandFile=""
enableSysConfigTool="true"
sysConfigBuildOptions="--product ${C2000WARE_ROOT}/.metadata/sdk.json --device F2838x --package 337bga --part F2838x_337bga"
postBuildStep="
echo &quot;========= Build of the CLB simulation has moved to the CLB Tool. Click the '?' icon by the _Generate CLB Simulation File_ enable for more details (located in the Global Parameters of the Tile Design SysConfig module) =============&quot;
;if ${GENERATE_DIAGRAM} == 1 ${NODE_TOOL} &quot;${C2000WARE_ROOT}/utilities/clb_tool/clb_syscfg/dot_file_libraries/clbDotUtility.js&quot; &quot;${C2000WARE_ROOT}/utilities/clb_tool/clb_syscfg/&quot; &quot;${BuildDirectory}/syscfg&quot; &quot;${BuildDirectory}/syscfg/clb.dot&quot;
;if ${GENERATE_DIAGRAM} == 1 mkdir &quot;${BuildDirectory}/diagrams&quot;
;if ${GENERATE_DIAGRAM} == 1 ${NODE_TOOL} &quot;${C2000WARE_ROOT}/driverlib/.meta/generate_diagrams.js&quot; &quot;${C2000WARE_ROOT}&quot; &quot;${BuildDirectory}/diagrams&quot; &quot;${BuildDirectory}/syscfg&quot;
"
>
<configuration name="CPU1_RAM" compilerBuildOptions= "--opt_level=off -I${C2000WARE_ROOT} -I${PROJECT_ROOT}/device -I${C2000WARE_DLIB_ROOT} -I${C2000WARE_SFO_INCLUDE} -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 -I${C2000WARE_SFO_INCLUDE} -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" />
<pathVariable name="C2000WARE_SFO_INCLUDE" path="../../../../../../libraries/calibration/hrpwm/f2838x/include/" scope="project" />
<file action="link" path="../../../../../../libraries/calibration/hrpwm/f2838x/lib/SFO_v8_fpu_lib_build_c28_driverlib.lib" targetDirectory="" />
<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="../hrpwm_ex7_prd_updown_sfo_qformat.c" targetDirectory="" />
<file action="copy" path="../hrpwm_ex7_prd_updown_sfo_qformat.syscfg" targetDirectory="" />
</project>
</projectSpec>
@@ -0,0 +1,43 @@
<projectSpec>
<project
name="hrpwm_ex9_dutyhr_updown_deadband_sfo"
device="TMS320F28388D"
cgtVersion="22.6.1.LTS"
products="sysconfig;C2000WARE"
outputFormat="ELF"
launchWizard="False"
linkerCommandFile=""
enableSysConfigTool="true"
sysConfigBuildOptions="--product ${C2000WARE_ROOT}/.metadata/sdk.json --device F2838x --package 337bga --part F2838x_337bga"
postBuildStep="
echo &quot;========= Build of the CLB simulation has moved to the CLB Tool. Click the '?' icon by the _Generate CLB Simulation File_ enable for more details (located in the Global Parameters of the Tile Design SysConfig module) =============&quot;
;if ${GENERATE_DIAGRAM} == 1 ${NODE_TOOL} &quot;${C2000WARE_ROOT}/utilities/clb_tool/clb_syscfg/dot_file_libraries/clbDotUtility.js&quot; &quot;${C2000WARE_ROOT}/utilities/clb_tool/clb_syscfg/&quot; &quot;${BuildDirectory}/syscfg&quot; &quot;${BuildDirectory}/syscfg/clb.dot&quot;
;if ${GENERATE_DIAGRAM} == 1 mkdir &quot;${BuildDirectory}/diagrams&quot;
;if ${GENERATE_DIAGRAM} == 1 ${NODE_TOOL} &quot;${C2000WARE_ROOT}/driverlib/.meta/generate_diagrams.js&quot; &quot;${C2000WARE_ROOT}&quot; &quot;${BuildDirectory}/diagrams&quot; &quot;${BuildDirectory}/syscfg&quot;
"
>
<configuration name="CPU1_RAM" compilerBuildOptions= "--opt_level=off -I${C2000WARE_ROOT} -I${PROJECT_ROOT}/device -I${C2000WARE_DLIB_ROOT} -I${C2000WARE_SFO_INCLUDE} -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 -I${C2000WARE_SFO_INCLUDE} -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" />
<pathVariable name="C2000WARE_SFO_INCLUDE" path="../../../../../../libraries/calibration/hrpwm/f2838x/include/" scope="project" />
<file action="link" path="../../../../../../libraries/calibration/hrpwm/f2838x/lib/SFO_v8_fpu_lib_build_c28_driverlib.lib" targetDirectory="" />
<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="../hrpwm_ex9_dutyhr_updown_deadband_sfo.c" targetDirectory="" />
<file action="copy" path="../hrpwm_ex9_dutyhr_updown_deadband_sfo.syscfg" targetDirectory="" />
</project>
</projectSpec>
@@ -0,0 +1,268 @@
//#############################################################################
//
// FILE: hrpwm_ex1_duty_sfo.c
//
// TITLE: HRPWM Duty Control with SFO.
//
//! \addtogroup driver_example_list
//! <h1>HRPWM Duty Control with SFO</h1>
//!
//! This example modifies the MEP control registers to show edge displacement
//! for high-resolution period with ePWM in Up count mode
//! due to the HRPWM control extension of the respective ePWM module.
//!
//! This example calls the following TI's MEP Scale Factor Optimizer (SFO)
//! software library V8 functions:
//!
//! \b int \b SFO(); \n
//! - updates MEP_ScaleFactor dynamically when HRPWM is in use
//! - updates HRMSTEP register (exists only in EPwm1Regs register space)
//! with MEP_ScaleFactor value
//! - returns 2 if error: MEP_ScaleFactor is greater than maximum value of 255
//! (Auto-conversion may not function properly under this condition)
//! - returns 1 when complete for the specified channel
//! - returns 0 if not complete for the specified channel
//!
//! This example is intended to explain the HRPWM capabilities. The code can be
//! optimized for code efficiency. Refer to TI's Digital power application
//! examples and TI Digital Power Supply software libraries for details.
//!
//! \b External \b Connections \n
//! - Monitor ePWM1/2/3/4 A/B pins on an oscilloscope.
//
//#############################################################################
//
//
//
// 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 "board.h"
#include "sfo_v8.h"
#define EPWM_TIMER_TBPRD 100UL
#define MIN_HRPWM_DUTY_PERCENT 4.0/((float32_t)EPWM_TIMER_TBPRD)*100.0
//
// Defines
//
#define LAST_EPWM_INDEX_FOR_EXAMPLE 5
//
// Globals
//
float32_t dutyFine = MIN_HRPWM_DUTY_PERCENT;
uint16_t status;
int MEP_ScaleFactor; // Global variable used by the SFO library
// Result can be used for all HRPWM channels
// This variable is also copied to HRMSTEP
// register by SFO() function.
volatile uint32_t ePWM[] =
{0, myEPWM1_BASE, myEPWM2_BASE, myEPWM3_BASE, myEPWM4_BASE};
//
// Function Prototypes
//
void error(void);
//__interrupt void epwm1ISR(void);
//__interrupt void epwm2ISR(void);
//__interrupt void epwm3ISR(void);
//__interrupt void epwm4ISR(void);
//
// Main
//
void main(void)
{
uint16_t i = 0;
//
// Initialize device clock and peripherals
//
Device_init();
//
// Disable pin locks and enable internal pull ups.
//
Device_initGPIO();
//
// Initialize PIE and clear PIE registers. Disables CPU interrupts.
//
Interrupt_initModule();
//
// Initialize the PIE vector table with pointers to the shell Interrupt
// Service Routines (ISR).
//
Interrupt_initVectorTable();
//
// Assign the interrupt service routines to ePWM interrupts
//
//Interrupt_register(INT_EPWM1, &epwm1ISR);
//Interrupt_register(INT_EPWM2, &epwm2ISR);
//Interrupt_register(INT_EPWM3, &epwm3ISR);
//Interrupt_register(INT_EPWM4, &epwm4ISR);
//
// Calling SFO() updates the HRMSTEP register with calibrated MEP_ScaleFactor.
// HRMSTEP must be populated with a scale factor value prior to enabling
// high resolution period control.
//
while(status == SFO_INCOMPLETE)
{
status = SFO();
if(status == SFO_ERROR)
{
error(); // SFO function returns 2 if an error occurs & # of MEP
} // steps/coarse step exceeds maximum of 255.
}
//
// Disable sync(Freeze clock to PWM as well)
//
SysCtl_disablePeripheral(SYSCTL_PERIPH_CLK_TBCLKSYNC);
//
// Initialize the EPWM GPIO Pins and change the XBAR inputs from using GPIO0
//
Board_init();
//
// Enable sync and clock to PWM
//
SysCtl_enablePeripheral(SYSCTL_PERIPH_CLK_TBCLKSYNC);
// Enable ePWM interrupts
//
//Interrupt_enable(INT_EPWM1);
//Interrupt_enable(INT_EPWM2);
//Interrupt_enable(INT_EPWM3);
//Interrupt_enable(INT_EPWM4);
//
// Enable Global Interrupt (INTM) and realtime interrupt (DBGM)
//
EINT;
ERTM;
for(;;)
{
//
// Sweep DutyFine
//
for(dutyFine = MIN_HRPWM_DUTY_PERCENT; dutyFine < 99.9; dutyFine += 0.01)
{
DEVICE_DELAY_US(1000);
for(i=1; i<LAST_EPWM_INDEX_FOR_EXAMPLE; i++)
{
float32_t count = (dutyFine * (float32_t)(EPWM_TIMER_TBPRD << 8))/100;
uint32_t compCount = (count);
HRPWM_setCounterCompareValue(ePWM[i], HRPWM_COUNTER_COMPARE_A, compCount);
HRPWM_setCounterCompareValue(ePWM[i], HRPWM_COUNTER_COMPARE_B, compCount);
}
//
// Call the scale factor optimizer lib function SFO()
// periodically to track for any change due to temp/voltage.
// This function generates MEP_ScaleFactor by running the
// MEP calibration module in the HRPWM logic. This scale
// factor can be used for all HRPWM channels. The SFO()
// function also updates the HRMSTEP register with the
// scale factor value.
//
status = SFO(); // in background, MEP calibration module
// continuously updates MEP_ScaleFactor
if (status == SFO_ERROR)
{
error(); // SFO function returns 2 if an error occurs & #
// of MEP steps/coarse step
} // exceeds maximum of 255.
}
}
}
//
// epwm1ISR - ePWM 1 ISR
//
//__interrupt void epwm1ISR(void)
//{
// EPWM_clearEventTriggerInterruptFlag(EPWM1_BASE);
// Interrupt_clearACKGroup(INTERRUPT_ACK_GROUP3);
//}
//
// epwm2ISR - ePWM 2 ISR
//
//__interrupt void epwm2ISR(void)
//{
// EPWM_clearEventTriggerInterruptFlag(EPWM2_BASE);
// Interrupt_clearACKGroup(INTERRUPT_ACK_GROUP3);
//}
//
// epwm3ISR - ePWM 3 ISR
//
//__interrupt void epwm3ISR(void)
//{
// EPWM_clearEventTriggerInterruptFlag(EPWM3_BASE);
// Interrupt_clearACKGroup(INTERRUPT_ACK_GROUP3);
//}
//
// epwm4ISR - ePWM 4 ISR
//
//__interrupt void epwm4ISR(void)
//{
// EPWM_clearEventTriggerInterruptFlag(EPWM4_BASE);
// Interrupt_clearACKGroup(INTERRUPT_ACK_GROUP3);
//}
//
// error - Halt debugger when called
//
void error (void)
{
ESTOP0; // Stop here and handle error
}
@@ -0,0 +1,95 @@
/**
* Import the modules used in this configuration.
*/
const epwm = scripting.addModule("/driverlib/epwm.js", {}, false);
const epwm1 = epwm.addInstance();
const epwm2 = epwm.addInstance();
const epwm3 = epwm.addInstance();
const epwm4 = epwm.addInstance();
const inputxbar = scripting.addModule("/driverlib/inputxbar.js", {}, false);
const inputxbar1 = inputxbar.addInstance();
/**
* Write custom configuration values to the imported modules.
*/
epwm1.$name = "myEPWM1";
epwm1.hrpwm_edgeModeA = "HRPWM_MEP_CTRL_FALLING_EDGE";
epwm1.hrpwm_edgeModeB = "HRPWM_MEP_CTRL_FALLING_EDGE";
epwm1.epwmTimebase_counterMode = "EPWM_COUNTER_MODE_UP";
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.epwmActionQualifier_EPWM_AQ_OUTPUT_B_ON_TIMEBASE_ZERO = "EPWM_AQ_OUTPUT_HIGH";
epwm1.epwmActionQualifier_EPWM_AQ_OUTPUT_B_ON_TIMEBASE_UP_CMPA = "EPWM_AQ_OUTPUT_LOW";
epwm1.epwmTimebase_emulationMode = "EPWM_EMULATION_FREE_RUN";
epwm1.epwmTimebase_hsClockDiv = "EPWM_HSCLOCK_DIVIDER_1";
epwm1.hrpwm_enable = true;
epwm1.hrpwm_autoConv = true;
epwm1.epwmTimebase_period = 99;
epwm1.hrpwm_cmpaHR = 50;
epwm1.hrpwm_cmpbHR = 50;
epwm1.epwm.$assign = "EPWM1";
epwm1.epwm.epwmaPin.$assign = "GPIO0";
epwm1.epwm.epwmbPin.$assign = "GPIO1";
epwm2.$name = "myEPWM2";
epwm2.epwmTimebase_emulationMode = "EPWM_EMULATION_FREE_RUN";
epwm2.epwmTimebase_period = 100;
epwm2.epwmTimebase_counterMode = "EPWM_COUNTER_MODE_UP";
epwm2.epwmActionQualifier_EPWM_AQ_OUTPUT_A_ON_TIMEBASE_ZERO = "EPWM_AQ_OUTPUT_HIGH";
epwm2.epwmActionQualifier_EPWM_AQ_OUTPUT_A_ON_TIMEBASE_UP_CMPA = "EPWM_AQ_OUTPUT_LOW";
epwm2.epwmActionQualifier_EPWM_AQ_OUTPUT_B_ON_TIMEBASE_ZERO = "EPWM_AQ_OUTPUT_HIGH";
epwm2.epwmActionQualifier_EPWM_AQ_OUTPUT_B_ON_TIMEBASE_UP_CMPA = "EPWM_AQ_OUTPUT_LOW";
epwm2.hrpwm_enable = true;
epwm2.hrpwm_autoConv = true;
epwm2.hrpwm_edgeModeA = "HRPWM_MEP_CTRL_FALLING_EDGE";
epwm2.hrpwm_edgeModeB = "HRPWM_MEP_CTRL_FALLING_EDGE";
epwm2.hrpwm_cmpaHR = 50;
epwm2.hrpwm_cmpbHR = 50;
epwm2.epwmTimebase_hsClockDiv = "EPWM_HSCLOCK_DIVIDER_1";
epwm2.epwm.$assign = "EPWM2";
epwm2.epwm.epwmaPin.$assign = "GPIO2";
epwm2.epwm.epwmbPin.$assign = "GPIO3";
epwm3.$name = "myEPWM3";
epwm3.epwmTimebase_period = 100;
epwm3.epwmTimebase_emulationMode = "EPWM_EMULATION_FREE_RUN";
epwm3.epwmTimebase_counterMode = "EPWM_COUNTER_MODE_UP";
epwm3.epwmActionQualifier_EPWM_AQ_OUTPUT_A_ON_TIMEBASE_ZERO = "EPWM_AQ_OUTPUT_HIGH";
epwm3.epwmActionQualifier_EPWM_AQ_OUTPUT_A_ON_TIMEBASE_UP_CMPA = "EPWM_AQ_OUTPUT_LOW";
epwm3.epwmActionQualifier_EPWM_AQ_OUTPUT_B_ON_TIMEBASE_ZERO = "EPWM_AQ_OUTPUT_HIGH";
epwm3.epwmActionQualifier_EPWM_AQ_OUTPUT_B_ON_TIMEBASE_UP_CMPB = "EPWM_AQ_OUTPUT_LOW";
epwm3.hrpwm_enable = true;
epwm3.hrpwm_edgeModeA = "HRPWM_MEP_CTRL_FALLING_EDGE";
epwm3.hrpwm_edgeModeB = "HRPWM_MEP_CTRL_FALLING_EDGE";
epwm3.hrpwm_cmpaHR = 50;
epwm3.hrpwm_cmpbHR = 50;
epwm3.epwmTimebase_hsClockDiv = "EPWM_HSCLOCK_DIVIDER_1";
epwm3.hrpwm_autoConv = true;
epwm3.epwm.$assign = "EPWM3";
epwm3.epwm.epwmaPin.$assign = "GPIO4";
epwm3.epwm.epwmbPin.$assign = "GPIO5";
epwm4.$name = "myEPWM4";
epwm4.epwmTimebase_emulationMode = "EPWM_EMULATION_FREE_RUN";
epwm4.epwmTimebase_counterMode = "EPWM_COUNTER_MODE_UP";
epwm4.epwmTimebase_period = 100;
epwm4.epwmActionQualifier_EPWM_AQ_OUTPUT_A_ON_TIMEBASE_ZERO = "EPWM_AQ_OUTPUT_HIGH";
epwm4.epwmActionQualifier_EPWM_AQ_OUTPUT_A_ON_TIMEBASE_UP_CMPA = "EPWM_AQ_OUTPUT_LOW";
epwm4.epwmActionQualifier_EPWM_AQ_OUTPUT_B_ON_TIMEBASE_ZERO = "EPWM_AQ_OUTPUT_HIGH";
epwm4.epwmActionQualifier_EPWM_AQ_OUTPUT_B_ON_TIMEBASE_UP_CMPB = "EPWM_AQ_OUTPUT_LOW";
epwm4.hrpwm_enable = true;
epwm4.hrpwm_edgeModeA = "HRPWM_MEP_CTRL_FALLING_EDGE";
epwm4.hrpwm_edgeModeB = "HRPWM_MEP_CTRL_FALLING_EDGE";
epwm4.hrpwm_cmpaHR = 50;
epwm4.hrpwm_cmpbHR = 50;
epwm4.epwmTimebase_hsClockDiv = "EPWM_HSCLOCK_DIVIDER_1";
epwm4.hrpwm_autoConv = true;
epwm4.epwm.$assign = "EPWM4";
epwm4.epwm.epwmaPin.$assign = "GPIO6";
epwm4.epwm.epwmbPin.$assign = "GPIO7";
inputxbar1.$name = "myINPUTXBAR5";
inputxbar1.inputsUsed = ["inputxbar5Gpio","inputxbar6Gpio"];
inputxbar1.inputxbar5Gpio = "GPIO56";
inputxbar1.inputxbar6Gpio = "GPIO56";
@@ -0,0 +1,148 @@
//#############################################################################
//
// FILE: hrpwm_ex2_slider.c
//
// TITLE: HRPWM Slider.
//
//! \addtogroup driver_example_list
//! <h1>HRPWM Slider</h1>
//!
//! This example modifies the MEP control registers to show edge displacement
//! due to HRPWM. Control blocks of the respective ePWM module channel A and B
//! will have fine edge movement due to HRPWM logic.
//!
//! Monitor ePWM1 A/B pins on an oscilloscope.
//
//
//#############################################################################
//
//
//
// 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 "board.h"
//
// Defines
//
//
// Globals
//
#define EPWM_TIMER_TBPRD 100
uint16_t dutyFine = 1;
uint16_t previousDutyFine = 1;
uint16_t status;
//
// Function Prototypes
//
void error(void);
//
// Main
//
void main(void)
{
//
// Initialize device clock and peripherals
//
Device_init();
//
// Disable pin locks and enable internal pull ups.
//
Device_initGPIO();
//
// Initialize PIE and clear PIE registers. Disables CPU interrupts.
//
Interrupt_initModule();
//
// Initialize the PIE vector table with pointers to the shell Interrupt
// Service Routines (ISR).
//
Interrupt_initVectorTable();
//
// Disable sync(Freeze clock to PWM as well)
//
SysCtl_disablePeripheral(SYSCTL_PERIPH_CLK_TBCLKSYNC);
//
// Initialize the EPWM GPIOs and CHANGE XBAR inputs from using GPIO0
//
Board_init();
//
// Enable sync and clock to PWM
//
SysCtl_enablePeripheral(SYSCTL_PERIPH_CLK_TBCLKSYNC);
//
// Enable Global Interrupt (INTM) and realtime interrupt (DBGM)
//
EINT;
ERTM;
for(;;)
{
if (dutyFine != previousDutyFine)
{
HRPWM_setCounterCompareValue(myEPWM1_BASE, HRPWM_COUNTER_COMPARE_A,
(EPWM_TIMER_TBPRD/2 << 8) | dutyFine);
HRPWM_setCounterCompareValue(myEPWM1_BASE, HRPWM_COUNTER_COMPARE_B,
(EPWM_TIMER_TBPRD/2 << 8) | dutyFine);
previousDutyFine = dutyFine;
}
}
}
//
// error - Halt debugger when called
//
void error (void)
{
ESTOP0; // Stop here and handle error
}
@@ -0,0 +1,34 @@
/**
* Import the modules used in this configuration.
*/
const epwm = scripting.addModule("/driverlib/epwm.js", {}, false);
const epwm1 = epwm.addInstance();
const inputxbar = scripting.addModule("/driverlib/inputxbar.js", {}, false);
const inputxbar1 = inputxbar.addInstance();
/**
* Write custom configuration values to the imported modules.
*/
epwm1.$name = "myEPWM1";
epwm1.epwmTimebase_hsClockDiv = "EPWM_HSCLOCK_DIVIDER_1";
epwm1.hrpwm_enable = true;
epwm1.hrpwm_edgeModeA = "HRPWM_MEP_CTRL_RISING_EDGE";
epwm1.hrpwm_edgeModeB = "HRPWM_MEP_CTRL_RISING_EDGE";
epwm1.epwmTimebase_counterMode = "EPWM_COUNTER_MODE_UP";
epwm1.epwmActionQualifier_EPWM_AQ_OUTPUT_A_ON_TIMEBASE_PERIOD = "EPWM_AQ_OUTPUT_HIGH";
epwm1.epwmActionQualifier_EPWM_AQ_OUTPUT_A_ON_TIMEBASE_UP_CMPA = "EPWM_AQ_OUTPUT_LOW";
epwm1.epwmActionQualifier_EPWM_AQ_OUTPUT_B_ON_TIMEBASE_PERIOD = "EPWM_AQ_OUTPUT_HIGH";
epwm1.epwmActionQualifier_EPWM_AQ_OUTPUT_B_ON_TIMEBASE_UP_CMPA = "EPWM_AQ_OUTPUT_LOW";
epwm1.epwmCounterCompare_cmpB = 50;
epwm1.epwmCounterCompare_cmpA = 50;
epwm1.epwmTimebase_period = 100;
epwm1.epwm.$assign = "EPWM1";
epwm1.epwm.epwmaPin.$assign = "GPIO0";
epwm1.epwm.epwmbPin.$assign = "GPIO1";
inputxbar1.$name = "myINPUTXBAR5";
inputxbar1.inputsUsed = ["inputxbar5Gpio","inputxbar6Gpio"];
inputxbar1.inputxbar5Gpio = "GPIO56";
inputxbar1.inputxbar6Gpio = "GPIO56";
@@ -0,0 +1,209 @@
//#############################################################################
//
// FILE: hrpwm_ex3_prdupdown_sfo.c
//
// TITLE: HRPWM Period Control.
//
//! \addtogroup driver_example_list
//! <h1>HRPWM Period Control</h1>
//!
//! This example modifies the MEP control registers to show edge displacement
//! for high-resolution period with ePWM in Up-Down count mode
//! due to the HRPWM control extension of the respective ePWM module.
//!
//! This example calls the following TI's MEP Scale Factor Optimizer (SFO)
//! software library V8 functions:
//!
//! \b int \b SFO(); \n
//! - updates MEP_ScaleFactor dynamically when HRPWM is in use
//! - updates HRMSTEP register (exists only in EPwm1Regs register space)
//! with MEP_ScaleFactor value
//! - returns 2 if error: MEP_ScaleFactor is greater than maximum value of 255
//! (Auto-conversion may not function properly under this condition)
//! - returns 1 when complete for the specified channel
//! - returns 0 if not complete for the specified channel
//!
//! This example is intended to explain the HRPWM capabilities. The code can be
//! optimized for code efficiency. Refer to TI's Digital power application
//! examples and TI Digital Power Supply software libraries for details.
//!
//! \b External \b Connections \n
//! - Monitor ePWM1/2/3/4 A/B pins on an oscilloscope.
//
//#############################################################################
//
//
//
// 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 "board.h"
#include "sfo_v8.h"
//
// Defines
//
#define EPWM_TIMER_TBPRD 20UL
#define LAST_EPWM_INDEX_FOR_EXAMPLE 5
#define MIN_HRPWM_PRD_PERCENT 0.2
#define EPWM_TIMER_TBPRD 20
//
// Globals
//
float32_t periodFine = MIN_HRPWM_PRD_PERCENT;
uint16_t status;
int MEP_ScaleFactor; // Global variable used by the SFO library
// Result can be used for all HRPWM channels
// This variable is also copied to HRMSTEP
// register by SFO() function.
volatile uint32_t ePWM[] =
{0, myEPWM1_BASE, myEPWM2_BASE, myEPWM3_BASE, myEPWM4_BASE};
//
// Function Prototypes
//
void error(void);
//
// Main
//
void main(void)
{
uint16_t i = 0;
//
// Initialize device clock and peripherals
//
Device_init();
//
// Disable pin locks and enable internal pull ups.
//
Device_initGPIO();
//
// Initialize PIE and clear PIE registers. Disables CPU interrupts.
//
Interrupt_initModule();
//
// Initialize the PIE vector table with pointers to the shell Interrupt
// Service Routines (ISR).
//
Interrupt_initVectorTable();
//
// Calling SFO() updates the HRMSTEP register with calibrated MEP_ScaleFactor.
// HRMSTEP must be populated with a scale factor value prior to enabling
// high resolution period control.
//
while(status == SFO_INCOMPLETE)
{
status = SFO();
if(status == SFO_ERROR)
{
error(); // SFO function returns 2 if an error occurs & # of MEP
} // steps/coarse step exceeds maximum of 255.
}
//
// Disable sync(Freeze clock to PWM as well)
//
SysCtl_disablePeripheral(SYSCTL_PERIPH_CLK_TBCLKSYNC);
//
// Initialize EPWM GPIOs and change XBAR inputs from using GPIO0
//
Board_init();
//
// Enable sync and clock to PWM
//
SysCtl_enablePeripheral(SYSCTL_PERIPH_CLK_TBCLKSYNC);
//
// Enable Global Interrupt (INTM) and realtime interrupt (DBGM)
//
EINT;
ERTM;
for(;;)
{
//
// Sweep DutyFine
//
for(periodFine = MIN_HRPWM_PRD_PERCENT; periodFine < 0.9; periodFine += 0.01)
{
DEVICE_DELAY_US(1000);
for(i=1; i<LAST_EPWM_INDEX_FOR_EXAMPLE; i++)
{
float32_t count = ((EPWM_TIMER_TBPRD-1) << 8UL) + (float32_t)(periodFine * 256);
uint32_t compCount = count;
HRPWM_setTimeBasePeriod(ePWM[i], compCount);
}
//
// Call the scale factor optimizer lib function SFO()
// periodically to track for any change due to temp/voltage.
// This function generates MEP_ScaleFactor by running the
// MEP calibration module in the HRPWM logic. This scale
// factor can be used for all HRPWM channels. The SFO()
// function also updates the HRMSTEP register with the
// scale factor value.
//
status = SFO(); // in background, MEP calibration module
// continuously updates MEP_ScaleFactor
if (status == SFO_ERROR)
{
error(); // SFO function returns 2 if an error occurs & #
// of MEP steps/coarse step
} // exceeds maximum of 255.
}
}
}
//
// error - Halt debugger when called
//
void error (void)
{
ESTOP0; // Stop here and handle error
}
@@ -0,0 +1,115 @@
/**
* Import the modules used in this configuration.
*/
const epwm = scripting.addModule("/driverlib/epwm.js", {}, false);
const epwm1 = epwm.addInstance();
const epwm2 = epwm.addInstance();
const epwm3 = epwm.addInstance();
const epwm4 = epwm.addInstance();
const inputxbar = scripting.addModule("/driverlib/inputxbar.js", {}, false);
const inputxbar1 = inputxbar.addInstance();
/**
* Write custom configuration values to the imported modules.
*/
epwm1.$name = "myEPWM1";
epwm1.epwmTimebase_hsClockDiv = "EPWM_HSCLOCK_DIVIDER_1";
epwm1.epwmTimebase_period = 20;
epwm1.epwmCounterCompare_cmpA = 10;
epwm1.epwmCounterCompare_cmpB = 10;
epwm1.epwmTimebase_counterMode = "EPWM_COUNTER_MODE_UP_DOWN";
epwm1.epwmActionQualifier_EPWM_AQ_OUTPUT_A_ON_TIMEBASE_DOWN_CMPA = "EPWM_AQ_OUTPUT_LOW";
epwm1.epwmActionQualifier_EPWM_AQ_OUTPUT_B_ON_TIMEBASE_UP_CMPB = "EPWM_AQ_OUTPUT_HIGH";
epwm1.epwmActionQualifier_EPWM_AQ_OUTPUT_B_ON_TIMEBASE_DOWN_CMPB = "EPWM_AQ_OUTPUT_LOW";
epwm1.hrpwm_enable = true;
epwm1.hrpwm_autoConv = true;
epwm1.hrpwm_edgeModeA = "HRPWM_MEP_CTRL_RISING_AND_FALLING_EDGE";
epwm1.hrpwm_edgeModeB = "HRPWM_MEP_CTRL_RISING_AND_FALLING_EDGE";
epwm1.hrpwm_HRLoadB = "HRPWM_LOAD_ON_CNTR_ZERO_PERIOD";
epwm1.hrpwm_HRLoadA = "HRPWM_LOAD_ON_CNTR_ZERO_PERIOD";
epwm1.hrpwm_periodEnable = true;
epwm1.epwmCounterCompare_shadowLoadModeCMPB = "EPWM_COMP_LOAD_ON_CNTR_ZERO_PERIOD";
epwm1.epwmCounterCompare_shadowLoadModeCMPA = "EPWM_COMP_LOAD_ON_CNTR_ZERO_PERIOD";
epwm1.epwmActionQualifier_EPWM_AQ_OUTPUT_A_ON_TIMEBASE_UP_CMPA = "EPWM_AQ_OUTPUT_HIGH";
epwm1.epwmTimebase_forceSyncPulse = true;
epwm1.epwm.$assign = "EPWM1";
epwm1.epwm.epwmaPin.$assign = "GPIO0";
epwm1.epwm.epwmbPin.$assign = "GPIO1";
epwm2.$name = "myEPWM2";
epwm2.epwmTimebase_hsClockDiv = "EPWM_HSCLOCK_DIVIDER_1";
epwm2.epwmTimebase_period = 20;
epwm2.epwmCounterCompare_cmpA = 10;
epwm2.epwmCounterCompare_cmpB = 10;
epwm2.epwmTimebase_counterMode = "EPWM_COUNTER_MODE_UP_DOWN";
epwm2.epwmActionQualifier_EPWM_AQ_OUTPUT_A_ON_TIMEBASE_DOWN_CMPA = "EPWM_AQ_OUTPUT_LOW";
epwm2.epwmActionQualifier_EPWM_AQ_OUTPUT_B_ON_TIMEBASE_UP_CMPB = "EPWM_AQ_OUTPUT_HIGH";
epwm2.epwmActionQualifier_EPWM_AQ_OUTPUT_B_ON_TIMEBASE_DOWN_CMPB = "EPWM_AQ_OUTPUT_LOW";
epwm2.hrpwm_enable = true;
epwm2.hrpwm_autoConv = true;
epwm2.hrpwm_edgeModeA = "HRPWM_MEP_CTRL_RISING_AND_FALLING_EDGE";
epwm2.hrpwm_edgeModeB = "HRPWM_MEP_CTRL_RISING_AND_FALLING_EDGE";
epwm2.hrpwm_HRLoadB = "HRPWM_LOAD_ON_CNTR_ZERO_PERIOD";
epwm2.hrpwm_HRLoadA = "HRPWM_LOAD_ON_CNTR_ZERO_PERIOD";
epwm2.hrpwm_periodEnable = true;
epwm2.epwmCounterCompare_shadowLoadModeCMPB = "EPWM_COMP_LOAD_ON_CNTR_ZERO_PERIOD";
epwm2.epwmCounterCompare_shadowLoadModeCMPA = "EPWM_COMP_LOAD_ON_CNTR_ZERO_PERIOD";
epwm2.epwmActionQualifier_EPWM_AQ_OUTPUT_A_ON_TIMEBASE_UP_CMPA = "EPWM_AQ_OUTPUT_HIGH";
epwm2.epwmTimebase_forceSyncPulse = true;
epwm2.epwm.$assign = "EPWM2";
epwm2.epwm.epwmaPin.$assign = "GPIO2";
epwm2.epwm.epwmbPin.$assign = "GPIO3";
epwm3.$name = "myEPWM3";
epwm3.epwmTimebase_hsClockDiv = "EPWM_HSCLOCK_DIVIDER_1";
epwm3.epwmTimebase_period = 20;
epwm3.epwmCounterCompare_cmpA = 10;
epwm3.epwmCounterCompare_cmpB = 10;
epwm3.epwmTimebase_counterMode = "EPWM_COUNTER_MODE_UP_DOWN";
epwm3.epwmActionQualifier_EPWM_AQ_OUTPUT_A_ON_TIMEBASE_DOWN_CMPA = "EPWM_AQ_OUTPUT_LOW";
epwm3.epwmActionQualifier_EPWM_AQ_OUTPUT_B_ON_TIMEBASE_UP_CMPB = "EPWM_AQ_OUTPUT_HIGH";
epwm3.epwmActionQualifier_EPWM_AQ_OUTPUT_B_ON_TIMEBASE_DOWN_CMPB = "EPWM_AQ_OUTPUT_LOW";
epwm3.hrpwm_enable = true;
epwm3.hrpwm_autoConv = true;
epwm3.hrpwm_edgeModeA = "HRPWM_MEP_CTRL_RISING_AND_FALLING_EDGE";
epwm3.hrpwm_edgeModeB = "HRPWM_MEP_CTRL_RISING_AND_FALLING_EDGE";
epwm3.hrpwm_HRLoadB = "HRPWM_LOAD_ON_CNTR_ZERO_PERIOD";
epwm3.hrpwm_HRLoadA = "HRPWM_LOAD_ON_CNTR_ZERO_PERIOD";
epwm3.hrpwm_periodEnable = true;
epwm3.epwmCounterCompare_shadowLoadModeCMPB = "EPWM_COMP_LOAD_ON_CNTR_ZERO_PERIOD";
epwm3.epwmCounterCompare_shadowLoadModeCMPA = "EPWM_COMP_LOAD_ON_CNTR_ZERO_PERIOD";
epwm3.epwmActionQualifier_EPWM_AQ_OUTPUT_A_ON_TIMEBASE_UP_CMPA = "EPWM_AQ_OUTPUT_HIGH";
epwm3.epwmTimebase_forceSyncPulse = true;
epwm3.epwm.$assign = "EPWM3";
epwm3.epwm.epwmaPin.$assign = "GPIO4";
epwm3.epwm.epwmbPin.$assign = "GPIO5";
epwm4.$name = "myEPWM4";
epwm4.epwmTimebase_hsClockDiv = "EPWM_HSCLOCK_DIVIDER_1";
epwm4.epwmTimebase_period = 20;
epwm4.epwmCounterCompare_cmpA = 10;
epwm4.epwmCounterCompare_cmpB = 10;
epwm4.epwmTimebase_counterMode = "EPWM_COUNTER_MODE_UP_DOWN";
epwm4.epwmActionQualifier_EPWM_AQ_OUTPUT_A_ON_TIMEBASE_DOWN_CMPA = "EPWM_AQ_OUTPUT_LOW";
epwm4.epwmActionQualifier_EPWM_AQ_OUTPUT_B_ON_TIMEBASE_UP_CMPB = "EPWM_AQ_OUTPUT_HIGH";
epwm4.epwmActionQualifier_EPWM_AQ_OUTPUT_B_ON_TIMEBASE_DOWN_CMPB = "EPWM_AQ_OUTPUT_LOW";
epwm4.hrpwm_enable = true;
epwm4.hrpwm_autoConv = true;
epwm4.hrpwm_edgeModeA = "HRPWM_MEP_CTRL_RISING_AND_FALLING_EDGE";
epwm4.hrpwm_edgeModeB = "HRPWM_MEP_CTRL_RISING_AND_FALLING_EDGE";
epwm4.hrpwm_HRLoadB = "HRPWM_LOAD_ON_CNTR_ZERO_PERIOD";
epwm4.hrpwm_HRLoadA = "HRPWM_LOAD_ON_CNTR_ZERO_PERIOD";
epwm4.hrpwm_periodEnable = true;
epwm4.epwmCounterCompare_shadowLoadModeCMPB = "EPWM_COMP_LOAD_ON_CNTR_ZERO_PERIOD";
epwm4.epwmCounterCompare_shadowLoadModeCMPA = "EPWM_COMP_LOAD_ON_CNTR_ZERO_PERIOD";
epwm4.epwmActionQualifier_EPWM_AQ_OUTPUT_A_ON_TIMEBASE_UP_CMPA = "EPWM_AQ_OUTPUT_HIGH";
epwm4.epwmTimebase_forceSyncPulse = true;
epwm4.epwm.$assign = "EPWM4";
epwm4.epwm.epwmaPin.$assign = "GPIO6";
epwm4.epwm.epwmbPin.$assign = "GPIO7";
inputxbar1.$name = "myINPUTXBAR5";
inputxbar1.inputsUsed = ["inputxbar5Gpio","inputxbar6Gpio"];
inputxbar1.inputxbar5Gpio = "GPIO56";
inputxbar1.inputxbar6Gpio = "GPIO56";
@@ -0,0 +1,338 @@
//#############################################################################
//
// FILE: hrpwm_ex4_duty_updown_sfo.c
//
// TITLE: HRPWM Duty Control with UPDOWN Mode.
//
//! \addtogroup driver_example_list
//! <h1>HRPWM Duty Control with UPDOWN Mode</h1>
//!
//! This example calls the following TI's MEP Scale Factor Optimizer (SFO)
//! software library V8 functions:
//!
//! \b int \b SFO(); \n
//! - updates MEP_ScaleFactor dynamically when HRPWM is in use
//! - updates HRMSTEP register (exists only in EPwm1Regs register space)
//! with MEP_ScaleFactor value
//! - returns 2 if error: MEP_ScaleFactor is greater than maximum value of 255
//! (Auto-conversion may not function properly under this condition)
//! - returns 1 when complete for the specified channel
//! - returns 0 if not complete for the specified channel
//!
//! This example is intended to explain the HRPWM capabilities. The code can be
//! optimized for code efficiency. Refer to TI's Digital power application
//! examples and TI Digital Power Supply software libraries for details.
//!
//! \b External \b Connections \n
//! - Monitor ePWM1/2/3/4 A/B pins on an oscilloscope.
//
//#############################################################################
//
//
// 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"
#include "sfo_v8.h"
#define CHANNEL_B_AS_ZRO_PRD_REF 1
#define EPWM_TIMER_TBPRD 100UL
#define MIN_HRPWM_DUTY_PERCENT 4.0/((float32_t)EPWM_TIMER_TBPRD)*100.0
//
// Defines
//
#define LAST_EPWM_INDEX_FOR_EXAMPLE 5
//
// Globals
//
float32_t dutyFine = 50.0;
uint16_t status;
int MEP_ScaleFactor; // Global variable used by the SFO library
// Result can be used for all HRPWM channels
// This variable is also copied to HRMSTEP
// register by SFO() function.
volatile uint32_t ePWM[] =
{0, myEPWM1_BASE, myEPWM2_BASE, myEPWM3_BASE, myEPWM4_BASE};
//
// Function Prototypes
//
void initHRPWM_ChannelB(uint32_t period);
void error(void);
//__interrupt void epwm1ISR(void);
//__interrupt void epwm2ISR(void);
//__interrupt void epwm3ISR(void);
//__interrupt void epwm4ISR(void);
//
// Main
//
void main(void)
{
uint16_t i = 0;
//
// Initialize device clock and peripherals
//
Device_init();
//
// Disable pin locks and enable internal pull ups.
//
Device_initGPIO();
//
// Initialize PIE and clear PIE registers. Disables CPU interrupts.
//
Interrupt_initModule();
//
// Initialize the PIE vector table with pointers to the shell Interrupt
// Service Routines (ISR).
//
Interrupt_initVectorTable();
//
// Assign the interrupt service routines to ePWM interrupts
//
//Interrupt_register(INT_EPWM1, &epwm1ISR);
//Interrupt_register(INT_EPWM2, &epwm2ISR);
//Interrupt_register(INT_EPWM3, &epwm3ISR);
//Interrupt_register(INT_EPWM4, &epwm4ISR);
//
// Calling SFO() updates the HRMSTEP register with calibrated MEP_ScaleFactor.
// HRMSTEP must be populated with a scale factor value prior to enabling
// high resolution period control.
//
while(status == SFO_INCOMPLETE)
{
status = SFO();
if(status == SFO_ERROR)
{
error(); // SFO function returns 2 if an error occurs & # of MEP
} // steps/coarse step exceeds maximum of 255.
}
//
// Disable sync(Freeze clock to PWM as well)
//
SysCtl_disablePeripheral(SYSCTL_PERIPH_CLK_TBCLKSYNC);
//
// Initialize the EPWM GPIOs and change XBAR inputs from using GPIO0
//
Board_init();
initHRPWM_ChannelB(EPWM_TIMER_TBPRD);
//
// Enable sync and clock to PWM
//
SysCtl_enablePeripheral(SYSCTL_PERIPH_CLK_TBCLKSYNC);
// Enable ePWM interrupts
//
//Interrupt_enable(INT_EPWM1);
//Interrupt_enable(INT_EPWM2);
//Interrupt_enable(INT_EPWM3);
//Interrupt_enable(INT_EPWM4);
//
// Enable Global Interrupt (INTM) and realtime interrupt (DBGM)
//
EINT;
ERTM;
for(;;)
{
//
// Sweep DutyFine
//
for(dutyFine = MIN_HRPWM_DUTY_PERCENT; dutyFine < (100.0-MIN_HRPWM_DUTY_PERCENT); dutyFine += 0.01)
{
DEVICE_DELAY_US(1000);
for(i=1; i<LAST_EPWM_INDEX_FOR_EXAMPLE; i++)
{
float32_t count = ((100.0 - dutyFine) * (float32_t)(EPWM_TIMER_TBPRD << 8))/100.0;
uint32_t compCount = (count);
uint32_t hrCompCount = (compCount & (0x000000FF));
if (hrCompCount == 0)
{
//
// Add 1 to not have CMPxHR = 0
//
compCount |= 0x00000001;
}
HRPWM_setCounterCompareValue(ePWM[i], HRPWM_COUNTER_COMPARE_A, compCount);
#if CHANNEL_B_AS_ZRO_PRD_REF == 0
HRPWM_setCounterCompareValue(ePWM[i], HRPWM_COUNTER_COMPARE_B, compCount);
#endif
}
//
// Call the scale factor optimizer lib function SFO()
// periodically to track for any change due to temp/voltage.
// This function generates MEP_ScaleFactor by running the
// MEP calibration module in the HRPWM logic. This scale
// factor can be used for all HRPWM channels. The SFO()
// function also updates the HRMSTEP register with the
// scale factor value.
//
status = SFO(); // in background, MEP calibration module
// continuously updates MEP_ScaleFactor
if (status == SFO_ERROR)
{
error(); // SFO function returns 2 if an error occurs & #
// of MEP steps/coarse step
} // exceeds maximum of 255.
}
}
}
//
// epwm1ISR - ePWM 1 ISR
//
//__interrupt void epwm1ISR(void)
//{
// EPWM_clearEventTriggerInterruptFlag(EPWM1_BASE);
// Interrupt_clearACKGroup(INTERRUPT_ACK_GROUP3);
//}
//
// epwm2ISR - ePWM 2 ISR
//
//__interrupt void epwm2ISR(void)
//{
// EPWM_clearEventTriggerInterruptFlag(EPWM2_BASE);
// Interrupt_clearACKGroup(INTERRUPT_ACK_GROUP3);
//}
//
// epwm3ISR - ePWM 3 ISR
//
//__interrupt void epwm3ISR(void)
//{
// EPWM_clearEventTriggerInterruptFlag(EPWM3_BASE);
// Interrupt_clearACKGroup(INTERRUPT_ACK_GROUP3);
//}
//
// epwm4ISR - ePWM 4 ISR
//
//__interrupt void epwm4ISR(void)
//{
// EPWM_clearEventTriggerInterruptFlag(EPWM4_BASE);
// Interrupt_clearACKGroup(INTERRUPT_ACK_GROUP3);
//}
void initHRPWM_ChannelB(uint32_t period)
{
uint16_t j;
//
// ePWM channel register configuration with HRPWM
// ePWMxA / ePWMxB toggle low/high with MEP control on Rising and Falling edges
//
for (j=1;j<LAST_EPWM_INDEX_FOR_EXAMPLE;j++)
{
#if CHANNEL_B_AS_ZRO_PRD_REF == 1
//
// Use B channel as the ZERO and PRD reference
//
EPWM_setActionQualifierAction(ePWM[j],
EPWM_AQ_OUTPUT_B,
EPWM_AQ_OUTPUT_HIGH,
EPWM_AQ_OUTPUT_ON_TIMEBASE_ZERO);
EPWM_setActionQualifierAction(ePWM[j],
EPWM_AQ_OUTPUT_B,
EPWM_AQ_OUTPUT_LOW,
EPWM_AQ_OUTPUT_ON_TIMEBASE_PERIOD);
#else
EPWM_setActionQualifierAction(ePWM[j],
EPWM_AQ_OUTPUT_B,
EPWM_AQ_OUTPUT_HIGH,
EPWM_AQ_OUTPUT_ON_TIMEBASE_UP_CMPB);
EPWM_setActionQualifierAction(ePWM[j],
EPWM_AQ_OUTPUT_B,
EPWM_AQ_OUTPUT_LOW,
EPWM_AQ_OUTPUT_ON_TIMEBASE_DOWN_CMPB);
#endif
#if CHANNEL_B_AS_ZRO_PRD_REF == 0
HRPWM_setMEPEdgeSelect(ePWM[j], HRPWM_CHANNEL_B, HRPWM_MEP_CTRL_RISING_AND_FALLING_EDGE);
HRPWM_setMEPControlMode(ePWM[j], HRPWM_CHANNEL_B, HRPWM_MEP_DUTY_PERIOD_CTRL);
//
// Set up shadowing
// MUST BE CTR=(ZER & PRD)
//
HRPWM_setCounterCompareShadowLoadEvent(ePWM[j], HRPWM_CHANNEL_B, HRPWM_LOAD_ON_CNTR_ZERO_PERIOD);
#endif
//
// Interrupt where we will change the Compare Values
// Select INT on Time base counter zero event,
// Enable INT, generate INT on 1st event
//
//EPWM_setInterruptSource(ePWM[j], EPWM_INT_TBCTR_ZERO);
//EPWM_enableInterrupt(ePWM[j]);
//EPWM_setInterruptEventCount(ePWM[j], 1U);
}
}
//
// error - Halt debugger when called
//
void error (void)
{
ESTOP0; // Stop here and handle error
}
@@ -0,0 +1,100 @@
/**
* Import the modules used in this configuration.
*/
const epwm = scripting.addModule("/driverlib/epwm.js", {}, false);
const epwm1 = epwm.addInstance();
const epwm2 = epwm.addInstance();
const epwm3 = epwm.addInstance();
const epwm4 = epwm.addInstance();
const inputxbar = scripting.addModule("/driverlib/inputxbar.js", {}, false);
const inputxbar1 = inputxbar.addInstance();
/**
* Write custom configuration values to the imported modules.
*/
epwm1.$name = "myEPWM1";
epwm1.epwmTimebase_emulationMode = "EPWM_EMULATION_FREE_RUN";
epwm1.epwmCounterCompare_cmpA = 50;
epwm1.epwmCounterCompare_cmpB = 50;
epwm1.epwmTimebase_counterMode = "EPWM_COUNTER_MODE_UP_DOWN";
epwm1.epwmCounterCompare_shadowLoadModeCMPA = "EPWM_COMP_LOAD_ON_CNTR_ZERO_PERIOD";
epwm1.epwmCounterCompare_shadowLoadModeCMPB = "EPWM_COMP_LOAD_ON_CNTR_ZERO_PERIOD";
epwm1.epwmActionQualifier_EPWM_AQ_OUTPUT_A_ON_TIMEBASE_UP_CMPA = "EPWM_AQ_OUTPUT_HIGH";
epwm1.epwmActionQualifier_EPWM_AQ_OUTPUT_A_ON_TIMEBASE_DOWN_CMPA = "EPWM_AQ_OUTPUT_LOW";
epwm1.hrpwm_enable = true;
epwm1.hrpwm_edgeModeA = "HRPWM_MEP_CTRL_RISING_AND_FALLING_EDGE";
epwm1.hrpwm_HRLoadA = "HRPWM_LOAD_ON_CNTR_ZERO_PERIOD";
epwm1.hrpwm_autoConv = true;
epwm1.hrpwm_periodEnable = true;
epwm1.epwmTimebase_period = 99;
epwm1.epwmTimebase_hsClockDiv = "EPWM_HSCLOCK_DIVIDER_1";
epwm1.epwm.$assign = "EPWM1";
epwm1.epwm.epwmaPin.$assign = "GPIO0";
epwm1.epwm.epwmbPin.$assign = "GPIO1";
epwm2.$name = "myEPWM2";
epwm2.epwmTimebase_emulationMode = "EPWM_EMULATION_FREE_RUN";
epwm2.epwmCounterCompare_cmpA = 50;
epwm2.epwmCounterCompare_cmpB = 50;
epwm2.epwmTimebase_counterMode = "EPWM_COUNTER_MODE_UP_DOWN";
epwm2.epwmCounterCompare_shadowLoadModeCMPA = "EPWM_COMP_LOAD_ON_CNTR_ZERO_PERIOD";
epwm2.epwmCounterCompare_shadowLoadModeCMPB = "EPWM_COMP_LOAD_ON_CNTR_ZERO_PERIOD";
epwm2.epwmActionQualifier_EPWM_AQ_OUTPUT_A_ON_TIMEBASE_UP_CMPA = "EPWM_AQ_OUTPUT_HIGH";
epwm2.epwmActionQualifier_EPWM_AQ_OUTPUT_A_ON_TIMEBASE_DOWN_CMPA = "EPWM_AQ_OUTPUT_LOW";
epwm2.hrpwm_enable = true;
epwm2.hrpwm_edgeModeA = "HRPWM_MEP_CTRL_RISING_AND_FALLING_EDGE";
epwm2.hrpwm_HRLoadA = "HRPWM_LOAD_ON_CNTR_ZERO_PERIOD";
epwm2.hrpwm_autoConv = true;
epwm2.hrpwm_periodEnable = true;
epwm2.epwmTimebase_period = 99;
epwm2.epwmTimebase_hsClockDiv = "EPWM_HSCLOCK_DIVIDER_1";
epwm2.epwm.$assign = "EPWM2";
epwm2.epwm.epwmaPin.$assign = "GPIO2";
epwm2.epwm.epwmbPin.$assign = "GPIO3";
epwm3.$name = "myEPWM3";
epwm3.epwmTimebase_emulationMode = "EPWM_EMULATION_FREE_RUN";
epwm3.epwmCounterCompare_cmpA = 50;
epwm3.epwmCounterCompare_cmpB = 50;
epwm3.epwmTimebase_counterMode = "EPWM_COUNTER_MODE_UP_DOWN";
epwm3.epwmCounterCompare_shadowLoadModeCMPA = "EPWM_COMP_LOAD_ON_CNTR_ZERO_PERIOD";
epwm3.epwmCounterCompare_shadowLoadModeCMPB = "EPWM_COMP_LOAD_ON_CNTR_ZERO_PERIOD";
epwm3.epwmActionQualifier_EPWM_AQ_OUTPUT_A_ON_TIMEBASE_UP_CMPA = "EPWM_AQ_OUTPUT_HIGH";
epwm3.epwmActionQualifier_EPWM_AQ_OUTPUT_A_ON_TIMEBASE_DOWN_CMPA = "EPWM_AQ_OUTPUT_LOW";
epwm3.hrpwm_enable = true;
epwm3.hrpwm_edgeModeA = "HRPWM_MEP_CTRL_RISING_AND_FALLING_EDGE";
epwm3.hrpwm_HRLoadA = "HRPWM_LOAD_ON_CNTR_ZERO_PERIOD";
epwm3.hrpwm_autoConv = true;
epwm3.hrpwm_periodEnable = true;
epwm3.epwmTimebase_period = 99;
epwm3.epwmTimebase_hsClockDiv = "EPWM_HSCLOCK_DIVIDER_1";
epwm3.epwm.$assign = "EPWM3";
epwm3.epwm.epwmaPin.$assign = "GPIO4";
epwm3.epwm.epwmbPin.$assign = "GPIO5";
epwm4.$name = "myEPWM4";
epwm4.epwmTimebase_emulationMode = "EPWM_EMULATION_FREE_RUN";
epwm4.epwmCounterCompare_cmpA = 50;
epwm4.epwmCounterCompare_cmpB = 50;
epwm4.epwmTimebase_counterMode = "EPWM_COUNTER_MODE_UP_DOWN";
epwm4.epwmCounterCompare_shadowLoadModeCMPA = "EPWM_COMP_LOAD_ON_CNTR_ZERO_PERIOD";
epwm4.epwmCounterCompare_shadowLoadModeCMPB = "EPWM_COMP_LOAD_ON_CNTR_ZERO_PERIOD";
epwm4.epwmActionQualifier_EPWM_AQ_OUTPUT_A_ON_TIMEBASE_UP_CMPA = "EPWM_AQ_OUTPUT_HIGH";
epwm4.epwmActionQualifier_EPWM_AQ_OUTPUT_A_ON_TIMEBASE_DOWN_CMPA = "EPWM_AQ_OUTPUT_LOW";
epwm4.hrpwm_enable = true;
epwm4.hrpwm_edgeModeA = "HRPWM_MEP_CTRL_RISING_AND_FALLING_EDGE";
epwm4.hrpwm_HRLoadA = "HRPWM_LOAD_ON_CNTR_ZERO_PERIOD";
epwm4.hrpwm_autoConv = true;
epwm4.hrpwm_periodEnable = true;
epwm4.epwmTimebase_period = 99;
epwm4.epwmTimebase_hsClockDiv = "EPWM_HSCLOCK_DIVIDER_1";
epwm4.epwm.$assign = "EPWM4";
epwm4.epwm.epwmaPin.$assign = "GPIO6";
epwm4.epwm.epwmbPin.$assign = "GPIO7";
inputxbar1.$name = "myINPUTXBAR5";
inputxbar1.inputsUsed = ["inputxbar5Gpio","inputxbar6Gpio"];
inputxbar1.inputxbar5Gpio = "GPIO56";
inputxbar1.inputxbar6Gpio = "GPIO56";
@@ -0,0 +1,147 @@
//#############################################################################
//
// FILE: hrpwm_ex5_slider_qformat.c
//
// TITLE: HRPWM MEP Slider example
//
//! \addtogroup driver_example_list
//! <h1>HRPWM Slider Test</h1>
//!
//! This example modifies the MEP control registers to show edge displacement
//! due to HRPWM. Control blocks of the respective ePWM module channel A and B
//! will have fine edge movement due to HRPWM logic. Load the
//! hrpwm_slider.gel file. Select the HRPWM_eval from the GEL menu.
//! A FineDuty slider graphics will show up in CCS. Load the program and run.
//! Use the Slider to and observe the EPWM edge displacement for each slider
//! step change. This explains the MEP control on the EPwmxA channels.
//!
//! Monitor ePWM1 & ePWM2 A/B pins on an oscilloscope.
//
//
//
//#############################################################################
//
//
//
// 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 "board.h"
//
// Globals
//
uint32_t dutySliderVal, update, i, j, n;
void main(void)
{
//
// Initialize device clock and peripherals
//
Device_init();
//
// Disable pin locks and enable internal pull-ups.
//
Device_initGPIO();
//
// Initialize PIE and clear PIE registers. Disables CPU interrupts.
//
Interrupt_initModule();
//
// Initialize the PIE vector table with pointers to the shell Interrupt
// Service Routines (ISR).
//
Interrupt_initVectorTable();
//
// user specific code
//
update = 1;
dutySliderVal = 0;
//
// Disable sync(Freeze clock to PWM as well)
//
SysCtl_disablePeripheral(SYSCTL_PERIPH_CLK_TBCLKSYNC);
//
// Configure ePWM module/s and GPIOs
//
Board_init();
//
// Enable sync and clock to PWM
//
SysCtl_enablePeripheral(SYSCTL_PERIPH_CLK_TBCLKSYNC);
//
// Enable Global Interrupt (INTM) and real time interrupt (DBGM)
//
EINT;
ERTM;
while(update == 1U)
{
//
// Write to HRPWM extension of CMPA/ CMPB
//
HWREGH(myEPWM1_BASE + HRPWM_O_CMPA) =
(HWREGH(myEPWM1_BASE + HRPWM_O_CMPA) & ~(0xFF00)) |
(dutySliderVal << 8U);
HWREGH(myEPWM1_BASE + HRPWM_O_CMPB) =
(HWREGH(myEPWM1_BASE + HRPWM_O_CMPB) & ~(0xFF00)) |
(dutySliderVal << 8U);
//
// Write to HRPWM extension of CMPA/ CMPB
//
HWREGH(myEPWM2_BASE + HRPWM_O_CMPA) =
(HWREGH(EPWM2_BASE + HRPWM_O_CMPA) & ~(0xFF00)) |
(dutySliderVal << 8U);
HWREGH(myEPWM2_BASE + HRPWM_O_CMPB) =
(HWREGH(myEPWM2_BASE + HRPWM_O_CMPB) & ~(0xFF00)) |
(dutySliderVal << 8U);
}
while(1)
{
}
}
@@ -0,0 +1,45 @@
/**
* Import the modules used in this configuration.
*/
const epwm = scripting.addModule("/driverlib/epwm.js", {}, false);
const epwm1 = epwm.addInstance();
const epwm2 = epwm.addInstance();
/**
* Write custom configuration values to the imported modules.
*/
epwm1.$name = "myEPWM1";
epwm1.epwmTimebase_hsClockDiv = "EPWM_HSCLOCK_DIVIDER_1";
epwm1.epwmTimebase_periodLoadMode = "EPWM_PERIOD_DIRECT_LOAD";
epwm1.epwmTimebase_counterMode = "EPWM_COUNTER_MODE_UP";
epwm1.epwmTimebase_period = 29;
epwm1.epwmCounterCompare_cmpA = 15;
epwm1.epwmCounterCompare_cmpB = 15;
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.epwmActionQualifier_EPWM_AQ_OUTPUT_B_ON_TIMEBASE_ZERO = "EPWM_AQ_OUTPUT_HIGH";
epwm1.epwmActionQualifier_EPWM_AQ_OUTPUT_B_ON_TIMEBASE_UP_CMPB = "EPWM_AQ_OUTPUT_LOW";
epwm1.hrpwm_enable = true;
epwm1.hrpwm_edgeModeA = "HRPWM_MEP_CTRL_FALLING_EDGE";
epwm1.hrpwm_edgeModeB = "HRPWM_MEP_CTRL_FALLING_EDGE";
epwm1.epwm.$assign = "EPWM1";
epwm1.epwm.epwmaPin.$assign = "GPIO0";
epwm1.epwm.epwmbPin.$assign = "GPIO1";
epwm2.$name = "myEPWM2";
epwm2.epwmTimebase_hsClockDiv = "EPWM_HSCLOCK_DIVIDER_1";
epwm2.epwmTimebase_periodLoadMode = "EPWM_PERIOD_DIRECT_LOAD";
epwm2.epwmTimebase_counterMode = "EPWM_COUNTER_MODE_UP";
epwm2.epwmTimebase_period = 19;
epwm2.epwmCounterCompare_cmpA = 10;
epwm2.epwmCounterCompare_cmpB = 10;
epwm2.epwmActionQualifier_EPWM_AQ_OUTPUT_A_ON_TIMEBASE_ZERO = "EPWM_AQ_OUTPUT_HIGH";
epwm2.epwmActionQualifier_EPWM_AQ_OUTPUT_A_ON_TIMEBASE_UP_CMPA = "EPWM_AQ_OUTPUT_LOW";
epwm2.epwmActionQualifier_EPWM_AQ_OUTPUT_B_ON_TIMEBASE_ZERO = "EPWM_AQ_OUTPUT_HIGH";
epwm2.epwmActionQualifier_EPWM_AQ_OUTPUT_B_ON_TIMEBASE_UP_CMPB = "EPWM_AQ_OUTPUT_LOW";
epwm2.hrpwm_enable = true;
epwm2.hrpwm_edgeModeA = "HRPWM_MEP_CTRL_FALLING_EDGE";
epwm2.hrpwm_edgeModeB = "HRPWM_MEP_CTRL_FALLING_EDGE";
epwm2.epwm.$assign = "EPWM2";
epwm2.epwm.epwmaPin.$assign = "GPIO2";
epwm2.epwm.epwmbPin.$assign = "GPIO3";
@@ -0,0 +1,350 @@
//#############################################################################
//
// FILE: hrpwm_ex6_duty_sfo_qformat.c
//
// TITLE: HRPWM SFO V8 High-Resolution Period
// (Up Count) example
//
//! \addtogroup driver_example_list
//! <h1>HRPWM Duty Up Count</h1>
//!
//! This example modifies the MEP control registers to show edge displacement
//! for high-resolution period with ePWM in Up count mode
//! due to the HRPWM control extension of the respective ePWM module.
//!
//! This example calls the following TI's MEP Scale Factor Optimizer (SFO)
//! software library V8 functions:
//!
//! \b int \b SFO(); \n
//! - updates MEP_ScaleFactor dynamically when HRPWM is in use
//! - updates HRMSTEP register (exists only in EPwm1Regs register space)
//! with MEP_ScaleFactor value
//! - returns 2 if error: MEP_ScaleFactor is greater than maximum value of 255
//! (Auto-conversion may not function properly under this condition)
//! - returns 1 when complete for the specified channel
//! - returns 0 if not complete for the specified channel
//!
//! This example is intended to explain the HRPWM capabilities. The code can be
//! optimized for code efficiency. Refer to TI's Digital power application
//! examples and TI Digital Power Supply software libraries for details.
//!
//! To run this example:
//! -# Run this example at maximum SYSCLKOUT
//! -# Activate Real time mode
//! -# Run the code
//!
//! \b External \b Connections \n
//! - Monitor ePWM1/2 A/B pins on an oscilloscope.
//!
//! \b Watch \b Variables \n
//! - status - Example run status
//! - updateFine - Set to 1 use HRPWM capabilities and observe in fine MEP
//! steps(default)
//! Set to 0 to disable HRPWM capabilities and observe in
//! coarse SYSCLKOUT cycle steps
//!
//
//#############################################################################
//
//
//
// 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 "sfo_v8.h"
#include "board.h"
//
// Defines
//
//
// # of PWM channels
//
#define PWM_CH 2
#define STATUS_SUCCESS 1
#define STATUS_FAIL 0
//
// 1 = Turn auto-conversion ON
// 0 = Turn auto-conversion OFF
//
#define AUTOCONVERT 1
//
// Globals
//
uint16_t updateFine;
uint16_t dutyFine;
uint16_t status;
uint16_t regValCMPA;
uint16_t regValCMPAHR;
uint16_t regValCMPB;
uint16_t regValCMPBHR;
//
// Global variable used by the SFO library
// Result can be used for all HRPWM channels
// This variable is also copied to HRMSTEP
// register by SFO() function.
//
int MEP_ScaleFactor;
//
// Used by SFO library (ePWM[0] is a dummy value that isn't used)
//
volatile uint32_t ePWM[PWM_CH + 1] = {0, EPWM1_BASE, EPWM2_BASE};
//
// Function Prototypes
//
void error(void);
//
// Main
//
void main(void)
{
uint16_t i;
uint32_t temp, temp1, base;
uint16_t periodVal;
//
// Initialize device clock and peripherals
//
Device_init();
//
// Disable pin locks and enable internal pull-ups.
//
Device_initGPIO();
//
// Initialize PIE and clear PIE registers.
//
Interrupt_initModule();
//
// Initialize the PIE vector table with pointers to the shell Interrupt
// Service Routines (ISR).
//
Interrupt_initVectorTable();
//
// Setup example variables
//
updateFine = 1;
dutyFine = 0;
status = SFO_INCOMPLETE;
//
// Calling SFO() updates the HRMSTEP register with calibrated
// MEP_ScaleFactor. HRMSTEP must be populated with a scale factor value
// prior to enabling high resolution period control.
//
while(status == SFO_INCOMPLETE)
{
status = SFO();
if(status == SFO_ERROR)
{
error(); // SFO function returns 2 if an error occurs & # of MEP
} // steps/coarse step exceeds maximum of 255.
}
//
// Configure ePWM1 and ePWM2
//
Board_init();
//
// Enable Global Interrupt (INTM) and realtime interrupt (DBGM)
//
EINT;
ERTM;
while(1)
{
//
// Sweep dutyFine as a Q15 number from 0.2 - 0.999
//
for(dutyFine = 0x199AU; dutyFine < 0x7FDFU; dutyFine++)
{
if(updateFine)
{
/*
// All below calculation apply for CMPB as well
// regValCMPA , regValCMPAHR are calculated as Q0.
// Since dutyFine is a Q15 number, and the period is Q0
// the product is Q15. So to store as a Q0, we shift right
// 15 bits.
regValCMPA = ((long)dutyFine * periodVal) >> 15U;
// This next step is to obtain the remainder which was
// truncated during our 15 bit shift above.
// Compute the whole value, and then subtract regValCMPA
// shifted LEFT 15 bits:
temp = ((long)dutyFine * periodVal) ;
temp = temp - ((long)regValCMPA << 15);
// If auto-conversion is disabled, the following step can be
// skipped. If autoconversion is enabled, the SFO function will
// write the MEP_ScaleFactor to the HRMSTEP register and the
// hardware will automatically scale the remainder in the
// CMPAHR register by the MEP_ScaleFactor.
// Because the remainder calculated above (temp) is in Q15
// format, it must be shifted left by 1 to convert to Q16
// format for the hardware to properly convert.
regValCMPAHR = temp << 1;
// If auto-conversion is enabled, the following step is
// performed automatically in hardware and can be skipped
// This obtains the MEP count in digits, from
// 0,1, .... MEP_Scalefactor.
// 0x0080 (0.5 in Q8) is converted to 0.5 in Q15 by shifting
// left 7. This is added to fractional duty*MEP_SF product in
// order to round the decimal portion of the product up to the
// next integer if the decimal portion is >=0.5.
//
// Once again since this is Q15
// convert to Q0 by shifting:
regValCMPAHR = (temp * MEP_ScaleFactor + (0x0080 << 7)) >> 15;
// Write the values to the registers as one 32-bit
// or two 16-bits
HWREG(base + HRPWM_O_CMPA) = ((long)regValCMPA) << 16U |
regValCMPAHR;
HWREG(base + HRPWM_O_CMPB) = ((long)regValCMPA) << 16U |
regValCMPBHR;
*/
//
// All the above operations may be condensed into
// the following form:
// EPWM1 calculations
//
for(i = 0; i < PWM_CH; i++)
{
base = ePWM[i+1];
periodVal = EPWM_getTimeBasePeriod(base) + 1U;
regValCMPA = ((long)dutyFine * periodVal) >> 15U;
regValCMPB = ((long)dutyFine * periodVal) >> 15U;
temp = ((long)dutyFine * periodVal) ;
temp1 = ((long)dutyFine * periodVal) ;
temp = temp - ((long)regValCMPA << 15U);
temp1 = temp1 - ((long)regValCMPB << 15U);
#if(AUTOCONVERT)
regValCMPAHR = temp << 1U; // convert to Q16
regValCMPBHR = temp << 1U; // convert to Q16
#else
regValCMPAHR = ((temp * MEP_ScaleFactor) +
(0x0080U << 7U)) >> 15U;
regValCMPAHR = regValCMPAHR << 8;
regValCMPBHR = ((temp1 * MEP_ScaleFactor) +
(0x0080U << 7U)) >> 15U;
regValCMPBHR = regValCMPBHR << 8U;
#endif
//
// Example for a 32 bit write to CMPA:CMPAHR
//
HWREG(base + HRPWM_O_CMPA) = (((long)regValCMPA) << 16U) |
regValCMPAHR;
//
// Example for a 32 bit write to CMPB:CMPBHR
//
HWREG(base + HRPWM_O_CMPB) = (((long)regValCMPB) << 16U) |
regValCMPBHR;
}
}
else
{
//
// regValCMPA is calculated as a Q0.
// Since dutyFine is a Q15 number, and the period is Q0
// the product is Q15. So to store as a Q0, we shift right
// 15 bits.
//
for(i = 0; i < PWM_CH; i++)
{
base = ePWM[i+1];
periodVal = EPWM_getTimeBasePeriod(base) + 1U;
regValCMPA = ((long)dutyFine * periodVal) >> 15U;
EPWM_setCounterCompareValue(base, EPWM_COUNTER_COMPARE_A,
regValCMPA);
regValCMPB = ((long)dutyFine * periodVal) >> 15U;
EPWM_setCounterCompareValue(base, EPWM_COUNTER_COMPARE_B,
regValCMPB);
}
}
//
// Call the scale factor optimizer lib function SFO()
// periodically to track for any change due to temp/voltage.
// This function generates MEP_ScaleFactor by running the
// MEP calibration module in the HRPWM logic. This scale
// factor can be used for all HRPWM channels. The SFO()
// function also updates the HRMSTEP register with the
// scale factor value.
//
status = SFO(); // in background, MEP calibration module
// continuously updates MEP_ScaleFactor
if(status == SFO_ERROR)
{
error(); // SFO function returns 2 if an error occurs & #
// of MEP steps/coarse step exceeds maximum of 255.
}
} // end dutyFine for loop
} // end infinite for loop
}
//
// error - Halt debugger when called
//
void error(void)
{
ESTOP0; // Stop here and handle error
}
//
// End of file
//
@@ -0,0 +1,53 @@
/**
* Import the modules used in this configuration.
*/
const epwm = scripting.addModule("/driverlib/epwm.js", {}, false);
const epwm1 = epwm.addInstance();
const epwm2 = epwm.addInstance();
/**
* Write custom configuration values to the imported modules.
*/
epwm1.$name = "myEPWM1";
epwm1.epwmTimebase_emulationMode = "EPWM_EMULATION_FREE_RUN";
epwm1.epwmTimebase_hsClockDiv = "EPWM_HSCLOCK_DIVIDER_1";
epwm1.epwmTimebase_period = 9;
epwm1.epwmTimebase_counterMode = "EPWM_COUNTER_MODE_UP";
epwm1.epwmCounterCompare_cmpA = 4;
epwm1.epwmCounterCompare_cmpB = 4;
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.epwmActionQualifier_EPWM_AQ_OUTPUT_B_ON_TIMEBASE_ZERO = "EPWM_AQ_OUTPUT_HIGH";
epwm1.epwmActionQualifier_EPWM_AQ_OUTPUT_B_ON_TIMEBASE_UP_CMPB = "EPWM_AQ_OUTPUT_LOW";
epwm1.hrpwm_enable = true;
epwm1.hrpwm_periodEnable = true;
epwm1.hrpwm_autoConv = true;
epwm1.hrpwm_edgeModeA = "HRPWM_MEP_CTRL_FALLING_EDGE";
epwm1.hrpwm_edgeModeB = "HRPWM_MEP_CTRL_FALLING_EDGE";
epwm1.epwmCounterCompare_shadowLoadModeCMPA = "EPWM_COMP_LOAD_ON_CNTR_PERIOD";
epwm1.epwmCounterCompare_shadowLoadModeCMPB = "EPWM_COMP_LOAD_ON_CNTR_PERIOD";
epwm1.epwm.$assign = "EPWM1";
epwm1.epwm.epwmaPin.$assign = "GPIO0";
epwm1.epwm.epwmbPin.$assign = "GPIO1";
epwm2.$name = "myEPWM2";
epwm2.epwmTimebase_emulationMode = "EPWM_EMULATION_FREE_RUN";
epwm2.epwmTimebase_hsClockDiv = "EPWM_HSCLOCK_DIVIDER_1";
epwm2.epwmTimebase_period = 9;
epwm2.epwmTimebase_counterMode = "EPWM_COUNTER_MODE_UP";
epwm2.epwmCounterCompare_cmpA = 4;
epwm2.epwmCounterCompare_cmpB = 4;
epwm2.epwmActionQualifier_EPWM_AQ_OUTPUT_A_ON_TIMEBASE_ZERO = "EPWM_AQ_OUTPUT_HIGH";
epwm2.epwmActionQualifier_EPWM_AQ_OUTPUT_A_ON_TIMEBASE_UP_CMPA = "EPWM_AQ_OUTPUT_LOW";
epwm2.epwmActionQualifier_EPWM_AQ_OUTPUT_B_ON_TIMEBASE_ZERO = "EPWM_AQ_OUTPUT_HIGH";
epwm2.epwmActionQualifier_EPWM_AQ_OUTPUT_B_ON_TIMEBASE_UP_CMPB = "EPWM_AQ_OUTPUT_LOW";
epwm2.hrpwm_enable = true;
epwm2.hrpwm_periodEnable = true;
epwm2.hrpwm_autoConv = true;
epwm2.hrpwm_edgeModeA = "HRPWM_MEP_CTRL_FALLING_EDGE";
epwm2.hrpwm_edgeModeB = "HRPWM_MEP_CTRL_FALLING_EDGE";
epwm2.epwmCounterCompare_shadowLoadModeCMPA = "EPWM_COMP_LOAD_ON_CNTR_PERIOD";
epwm2.epwmCounterCompare_shadowLoadModeCMPB = "EPWM_COMP_LOAD_ON_CNTR_PERIOD";
epwm2.epwm.$assign = "EPWM2";
epwm2.epwm.epwmaPin.$assign = "GPIO2";
epwm2.epwm.epwmbPin.$assign = "GPIO3";
@@ -0,0 +1,276 @@
//#############################################################################
//
// FILE: hrpwm_ex7_prd_updown_sfo_qformat.c
//
// TITLE: HRPWM SFO V8 High-Resolution Period (Up-Down Count) example
//
//! \addtogroup driver_example_list
//! <h1>HRPWM Period Up-Down Count</h1>
//!
//! This example modifies the MEP control registers to show edge displacement
//! for high-resolution period with ePWM in Up-Down count mode
//! due to the HRPWM control extension of the respective ePWM module.
//!
//! This example calls the following TI's MEP Scale Factor Optimizer (SFO)
//! software library V8 functions:
//!
//! \b int \b SFO(); \n
//! - updates MEP_ScaleFactor dynamically when HRPWM is in use
//! - updates HRMSTEP register (exists only in EPwm1Regs register space)
//! with MEP_ScaleFactor value
//! - returns 2 if error: MEP_ScaleFactor is greater than maximum value of 255
//! (Auto-conversion may not function properly under this condition)
//! - returns 1 when complete for the specified channel
//! - returns 0 if not complete for the specified channel
//!
//! This example is intended to explain the HRPWM capabilities. The code can be
//! optimized for code efficiency. Refer to TI's Digital power application
//! examples and TI Digital Power Supply software libraries for details.
//!
//! To run this example:
//! -# Run this example at maximum SYSCLKOUT
//! -# Activate Real time mode
//! -# Run the code
//!
//! \b External \b Connections \n
//! - Monitor ePWM1/2 A/B pins on an oscilloscope.
//!
//! \b Watch \b Variables \n
//! - updateFine - Set to 1 use HRPWM capabilities and observe in fine MEP
//! steps(default)
//! Set to 0 to disable HRPWM capabilities and observe in
//! coarse SYSCLKOUT cycle steps
//!
//
//#############################################################################
//
//
//
// 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 "sfo_v8.h"
#include "driverlib.h"
#include "device.h"
#include "board.h"
//
// Defines
//
// # of PWM channels
#define PWM_CH 2
#define STATUS_SUCCESS 1
#define STATUS_FAIL 0
//
// Globals
//
uint16_t updateFine, periodFine, status;
//
// Global variable used by the SFO library
// Result can be used for all HRPWM channels
// This variable is also copied to HRMSTEP
// register by SFO(0) function.
//
int MEP_ScaleFactor = 0;
//
// Used by SFO library (ePWM[0] is a dummy value that isn't used)
//
volatile uint32_t ePWM[PWM_CH + 1] = {0, EPWM1_BASE, EPWM2_BASE};
//
// Function Prototypes
//
void error(void);
//
// Main
//
void main(void)
{
uint16_t i;
uint32_t base;
//
// Initialize device clock and peripherals
//
Device_init();
//
// Disable pin locks and enable internal pull-ups.
//
Device_initGPIO();
//
// Initialize PIE and clear PIE registers.
//
Interrupt_initModule();
//
// Initialize the PIE vector table with pointers to the shell Interrupt
// Service Routines (ISR).
//
Interrupt_initVectorTable();
//
// Setup example variables
//
updateFine = 1;
periodFine = 0;
status = SFO_INCOMPLETE;
//
// Calling SFO() updates the HRMSTEP register with calibrated
// MEP_ScaleFactor. HRMSTEP must be populated with a scale factor
// value prior to enabling high resolution period control.
//
while(status == SFO_INCOMPLETE)
{
status = SFO();
if(status == SFO_ERROR)
{
//
// SFO function returns 2 if an error occurs & # of MEP
// steps/coarse step exceeds maximum of 255.
//
error();
}
}
//
// Configure ePWM1 and ePWM2 GPIOs
//
Board_init();
//
// Enable TBCLK within EPWM.
//
SysCtl_enablePeripheral(SYSCTL_PERIPH_CLK_TBCLKSYNC);
//
// Enable Global Interrupt (INTM) and realtime interrupt (DBGM)
//
EINT;
ERTM;
for(;;)
{
//
// Sweep periodFine as a Q16 number from 0.2 - 0.999
//
for(periodFine = 0x3333; periodFine < 0xFFBF; periodFine++)
{
if(updateFine)
{
//
// Because auto-conversion is enabled, the desired
// fractional period must be written directly to the
// TBPRDHR (or TBPRDHRM) register in Q16 format
// (lower 8-bits are ignored)
//
// EPwm1Regs.TBPRDHR = periodFine;
//
// The hardware will automatically scale
// the fractional period by the MEP_ScaleFactor
// in the HRMSTEP register (which is updated
// by the SFO calibration software).
//
// Hardware conversion:
// MEP delay movement = ((TBPRDHR(15:0) >> 8) * HRMSTEP(7:0) +
// 0x80) >> 8
//
for(i = 0; i < PWM_CH; i++)
{
base = EPWM1_BASE + (i * 0x100U);
//
// Write fractional period value in Q16 format
//
HWREGH(base + HRPWM_O_TBPRDHR) = periodFine;
}
}
else
{
//
// No high-resolution movement on TBPRDHR.
//
for(i = 0; i < PWM_CH; i++)
{
HWREGH(base + HRPWM_O_TBPRDHR) = 0U;
}
}
//
// Call the scale factor optimizer lib function SFO(0)
// periodically to track for any change due to temp/voltage.
// This function generates MEP_ScaleFactor by running the
// MEP calibration module in the HRPWM logic. This scale
// factor can be used for all HRPWM channels. HRMSTEP
// register is automatically updated by the SFO function.
// In background, MEP calibration module continuously updates
// MEP_ScaleFactor
//
status = SFO();
if(status == SFO_ERROR)
{
//
// SFO function returns 2 if an error occurs & # of
// MEP steps/coarse step exceeds maximum of 255.
//
error();
}
}
}
}
// error - Halt debugger when error occurs
//
void error (void)
{
//
// Stop here and handle error
//
ESTOP0;
}
//
// End of file
//
@@ -0,0 +1,55 @@
/**
* Import the modules used in this configuration.
*/
const epwm = scripting.addModule("/driverlib/epwm.js", {}, false);
const epwm1 = epwm.addInstance();
const epwm2 = epwm.addInstance();
/**
* Write custom configuration values to the imported modules.
*/
epwm1.$name = "myEPWM1";
epwm1.epwmTimebase_counterMode = "EPWM_COUNTER_MODE_UP_DOWN";
epwm1.epwmTimebase_period = 20;
epwm1.epwmCounterCompare_cmpA = 10;
epwm1.epwmCounterCompare_cmpB = 10;
epwm1.epwmTimebase_hsClockDiv = "EPWM_HSCLOCK_DIVIDER_1";
epwm1.epwmTimebase_emulationMode = "EPWM_EMULATION_FREE_RUN";
epwm1.epwmActionQualifier_EPWM_AQ_OUTPUT_A_ON_TIMEBASE_UP_CMPA = "EPWM_AQ_OUTPUT_HIGH";
epwm1.epwmActionQualifier_EPWM_AQ_OUTPUT_A_ON_TIMEBASE_DOWN_CMPA = "EPWM_AQ_OUTPUT_LOW";
epwm1.epwmActionQualifier_EPWM_AQ_OUTPUT_B_ON_TIMEBASE_UP_CMPA = "EPWM_AQ_OUTPUT_HIGH";
epwm1.epwmActionQualifier_EPWM_AQ_OUTPUT_B_ON_TIMEBASE_DOWN_CMPA = "EPWM_AQ_OUTPUT_LOW";
epwm1.hrpwm_enable = true;
epwm1.hrpwm_autoConv = true;
epwm1.hrpwm_periodEnable = true;
epwm1.hrpwm_edgeModeA = "HRPWM_MEP_CTRL_FALLING_EDGE";
epwm1.hrpwm_edgeModeB = "HRPWM_MEP_CTRL_FALLING_EDGE";
epwm1.epwmCounterCompare_shadowLoadModeCMPA = "EPWM_COMP_LOAD_ON_CNTR_ZERO_PERIOD";
epwm1.epwmCounterCompare_shadowLoadModeCMPB = "EPWM_COMP_LOAD_ON_CNTR_ZERO_PERIOD";
epwm1.epwmTimebase_forceSyncPulse = true;
epwm1.epwm.$assign = "EPWM1";
epwm1.epwm.epwmaPin.$assign = "GPIO0";
epwm1.epwm.epwmbPin.$assign = "GPIO1";
epwm2.$name = "myEPWM2";
epwm2.epwmTimebase_counterMode = "EPWM_COUNTER_MODE_UP_DOWN";
epwm2.epwmTimebase_period = 20;
epwm2.epwmCounterCompare_cmpA = 10;
epwm2.epwmCounterCompare_cmpB = 10;
epwm2.epwmTimebase_hsClockDiv = "EPWM_HSCLOCK_DIVIDER_1";
epwm2.epwmTimebase_emulationMode = "EPWM_EMULATION_FREE_RUN";
epwm2.epwmActionQualifier_EPWM_AQ_OUTPUT_A_ON_TIMEBASE_UP_CMPA = "EPWM_AQ_OUTPUT_HIGH";
epwm2.epwmActionQualifier_EPWM_AQ_OUTPUT_A_ON_TIMEBASE_DOWN_CMPA = "EPWM_AQ_OUTPUT_LOW";
epwm2.epwmActionQualifier_EPWM_AQ_OUTPUT_B_ON_TIMEBASE_UP_CMPA = "EPWM_AQ_OUTPUT_HIGH";
epwm2.epwmActionQualifier_EPWM_AQ_OUTPUT_B_ON_TIMEBASE_DOWN_CMPA = "EPWM_AQ_OUTPUT_LOW";
epwm2.hrpwm_enable = true;
epwm2.hrpwm_autoConv = true;
epwm2.hrpwm_periodEnable = true;
epwm2.hrpwm_edgeModeA = "HRPWM_MEP_CTRL_FALLING_EDGE";
epwm2.hrpwm_edgeModeB = "HRPWM_MEP_CTRL_FALLING_EDGE";
epwm2.epwmCounterCompare_shadowLoadModeCMPA = "EPWM_COMP_LOAD_ON_CNTR_ZERO_PERIOD";
epwm2.epwmCounterCompare_shadowLoadModeCMPB = "EPWM_COMP_LOAD_ON_CNTR_ZERO_PERIOD";
epwm2.epwmTimebase_forceSyncPulse = true;
epwm2.epwm.$assign = "EPWM2";
epwm2.epwm.epwmaPin.$assign = "GPIO2";
epwm2.epwm.epwmbPin.$assign = "GPIO3";
@@ -0,0 +1,307 @@
//#############################################################################
//
// FILE: hrpwm_dutyhr_updown_deadband.c
//
// TITLE: HRPWM Duty Control with Up-Down, Active High Complementary Deadband.
//
//! \addtogroup driver_example_list
//! <h1>HRPWM Duty Control with AHC Deadband</h1>
//!
//! This example implements High-Resolution EPWM duty control capability. The
//! example begins with a basic Active-High Complementary (AHC) output
//! on channels A and B of the EPWM module(s) by using the Dead Band submodule
//! to apply rising and falling edge delays on channel A and B respectively.
//! High-Resolution duty control is then applied on both A/B channels of the
//! EPWM module(s). HR duty control is implemented by applying the CMPAHR
//! (for channel A) and CMPBHR (for channel B) values to control both edges of
//! both EPWM channel outputs with finer granularity. The duty cycle of the
//! EPWM module(s) are updated with calculations performed in main().
//! This example also calls the following TI's MEP Scale Factor Optimizer (SFO)
//! software library V8 functions:
//!
//! \b int \b SFO(); \n
//! - Updates MEP_ScaleFactor dynamically when HRPWM is in use
//! - Updates HRMSTEP register (exists only in EPwm1Regs register space)
//! with MEP_ScaleFactor value
//! - Returns 2 if error: MEP_ScaleFactor is greater than maximum value of 255
//! (Auto-conversion may not function properly under this condition)
//! - Returns 1 when complete for the specified channel
//! - Returns 0 if not complete for the specified channel
//!
//! This example is intended to explain the HRPWM capabilities. The code can be
//! optimized for code efficiency. Refer to TI's Digital power application
//! examples and TI Digital Power Supply software libraries for details.
//!
//! \b External \b Connections \n
//! - Monitor ePWM1/2/3/4 A/B pins on an oscilloscope.
//
//#############################################################################
//
//
//
// 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"
#include "sfo_v8.h"
//
// Defines
//
// The below TBPRD, RED, and FED values are programmed in SysConfig. Note
// that the HRPWM edges must be placed outside of the 3-clock-cycle restricted
// areas. Please see your device technical reference manual for details on this
// HRPWM duty cycle range limitation.
//
#define EPWM_TIMER_TBPRD 100UL // Time-Base Period
#define EPWM_RED 10UL // Rising Edge Delay
#define EPWM_FED 10UL // Falling Edge Delay
//
// In this example, we want to increment the CMPx values to update the HRPWM
// duty cycle during run-time. While varying CMPx, TBPRD should remain
// greater than or equal to CMPx + RED/2 and TBPRD should remain greater
// than or equal to CMPx + FED/2, otherwise one of the channels will be
// demanded low for longer than the full EPWM period. In this PWM
// configuration, the desired CMPx range is:
// - The minimum CMPx value should be larger than the FED/2.
// - The maximum CMPx value should be smaller than (TBPRD - (RED/2)).
// These min and max values are converted to percentages to be used in main().
//
#define MIN_HRPWM_DUTY_PERCENT ((float32_t)EPWM_FED/2)/((float32_t)EPWM_TIMER_TBPRD)*100.0
#define MAX_HRPWM_DUTY_PERCENT ((float32_t)EPWM_TIMER_TBPRD - EPWM_RED/2)/((float32_t)EPWM_TIMER_TBPRD)*100.0
#define LAST_EPWM_INDEX_FOR_EXAMPLE 5
//
// Globals
//
float32_t dutyFine = 50.0; // Start the duty cycle at 50%
uint16_t status;
int MEP_ScaleFactor; // Global variable used by the SFO library
// Result can be used for all HRPWM channels
// This variable is also copied to HRMSTEP
// register by SFO() function.
volatile uint32_t ePWM[] =
{0, myEPWM1_BASE, myEPWM2_BASE, myEPWM3_BASE, myEPWM4_BASE};
//
// Function Prototypes
//
void error(void);
//__interrupt void epwm1ISR(void);
//__interrupt void epwm2ISR(void);
//__interrupt void epwm3ISR(void);
//__interrupt void epwm4ISR(void);
//
// Main
//
void main(void)
{
uint16_t i = 0;
//
// Initialize device clock and peripherals.
//
Device_init();
//
// Disable pin locks and enable internal pull ups.
//
Device_initGPIO();
//
// Initialize PIE and clear PIE registers. Disables CPU interrupts.
//
Interrupt_initModule();
//
// Initialize the PIE vector table with pointers to the shell Interrupt
// Service Routines (ISR).
//
Interrupt_initVectorTable();
//
// Assign the interrupt service routines to ePWM interrupts.
//
//Interrupt_register(INT_EPWM1, &epwm1ISR);
//Interrupt_register(INT_EPWM2, &epwm2ISR);
//Interrupt_register(INT_EPWM3, &epwm3ISR);
//Interrupt_register(INT_EPWM4, &epwm4ISR);
//
// Disable sync (Freeze clock to PWM as well)
//
SysCtl_disablePeripheral(SYSCTL_PERIPH_CLK_TBCLKSYNC);
//
// Initialize EPWM modules and change EXTSYNCIN XBAR Inputs from GPIO0.
//
Board_init();
//
// Calling SFO() updates the HRMSTEP register with calibrated MEP_ScaleFactor.
// HRMSTEP must be populated with a scale factor value prior to enabling
// high resolution period control.
//
while(status == SFO_INCOMPLETE)
{
status = SFO();
if(status == SFO_ERROR)
{
error(); // SFO function returns 2 if an error occurs & # of MEP
} // steps/coarse step exceeds maximum of 255.
}
//
// Enable sync and clock to PWM
//
SysCtl_enablePeripheral(SYSCTL_PERIPH_CLK_TBCLKSYNC);
// Enable ePWM interrupts
//
//Interrupt_enable(INT_EPWM1);
//Interrupt_enable(INT_EPWM2);
//Interrupt_enable(INT_EPWM3);
//Interrupt_enable(INT_EPWM4);
//
// Enable Global Interrupt (INTM) and real-time interrupt (DBGM)
//
EINT;
ERTM;
for(;;)
{
//
// Sweep dutyFine from the minimum to maximum duty percentages.
//
for(dutyFine = MIN_HRPWM_DUTY_PERCENT; dutyFine < MAX_HRPWM_DUTY_PERCENT; dutyFine += 0.01)
{
DEVICE_DELAY_US(1000);
for(i=1; i<LAST_EPWM_INDEX_FOR_EXAMPLE; i++)
{
float32_t count = ((100.0 - dutyFine) * (float32_t)(EPWM_TIMER_TBPRD << 8))/100.0;
uint32_t compCount = (count);
uint32_t hrCompCount = (compCount & (0x000000FF));
if (hrCompCount == 0)
{
//
// Add 1 so that CMPxHR is never equal to 0.
//
compCount |= 0x00000001;
}
//
// Update CMPA/B and their HR components.
//
HRPWM_setCounterCompareValue(ePWM[i], HRPWM_COUNTER_COMPARE_A, compCount);
HRPWM_setCounterCompareValue(ePWM[i], HRPWM_COUNTER_COMPARE_B, compCount);
}
//
// Call the scale factor optimizer lib function SFO()
// periodically to track for any change due to temp/voltage.
// This function generates MEP_ScaleFactor by running the
// MEP calibration module in the HRPWM logic. This scale
// factor can be used for all HRPWM channels. The SFO()
// function also updates the HRMSTEP register with the
// scale factor value.
//
status = SFO(); // In the background, the MEP calibration module
// continuously updates MEP_ScaleFactor.
if (status == SFO_ERROR)
{
error(); // SFO function returns 2 if an error occurs & #
// of MEP steps/coarse step exceeds the maximum
} // of 255.
}
}
}
//
// epwm1ISR - ePWM 1 ISR
//
//__interrupt void epwm1ISR(void)
//{
// EPWM_clearEventTriggerInterruptFlag(EPWM1_BASE);
// Interrupt_clearACKGroup(INTERRUPT_ACK_GROUP3);
//}
//
// epwm2ISR - ePWM 2 ISR
//
//__interrupt void epwm2ISR(void)
//{
// EPWM_clearEventTriggerInterruptFlag(EPWM2_BASE);
// Interrupt_clearACKGroup(INTERRUPT_ACK_GROUP3);
//}
//
// epwm3ISR - ePWM 3 ISR
//
//__interrupt void epwm3ISR(void)
//{
// EPWM_clearEventTriggerInterruptFlag(EPWM3_BASE);
// Interrupt_clearACKGroup(INTERRUPT_ACK_GROUP3);
//}
//
// epwm4ISR - ePWM 4 ISR
//
//__interrupt void epwm4ISR(void)
//{
// EPWM_clearEventTriggerInterruptFlag(EPWM4_BASE);
// Interrupt_clearACKGroup(INTERRUPT_ACK_GROUP3);
//}
//
// Error - Halt debugger when called
//
void error (void)
{
ESTOP0; // Stop here and handle error
}
@@ -0,0 +1,138 @@
/**
* Import the modules used in this configuration.
*/
const epwm = scripting.addModule("/driverlib/epwm.js", {}, false);
const epwm1 = epwm.addInstance();
const epwm2 = epwm.addInstance();
const epwm3 = epwm.addInstance();
const epwm4 = epwm.addInstance();
const inputxbar = scripting.addModule("/driverlib/inputxbar.js", {}, false);
const inputxbar1 = inputxbar.addInstance();
const inputxbar_input = scripting.addModule("/driverlib/inputxbar_input.js");
const inputxbar_input1 = inputxbar_input.addInstance();
const inputxbar_input2 = inputxbar_input.addInstance();
/**
* Write custom configuration values to the imported modules.
*/
epwm1.$name = "myEPWM1";
epwm1.epwmTimebase_period = 100;
epwm1.epwmTimebase_counterMode = "EPWM_COUNTER_MODE_UP_DOWN";
epwm1.epwmTimebase_hsClockDiv = "EPWM_HSCLOCK_DIVIDER_1";
epwm1.epwmCounterCompare_cmpA = 50;
epwm1.epwmCounterCompare_shadowLoadModeCMPA = "EPWM_COMP_LOAD_ON_CNTR_ZERO_PERIOD";
epwm1.epwmCounterCompare_cmpB = 50;
epwm1.epwmCounterCompare_shadowLoadModeCMPB = "EPWM_COMP_LOAD_ON_CNTR_ZERO_PERIOD";
epwm1.epwmActionQualifier_EPWM_AQ_OUTPUT_A_ON_TIMEBASE_UP_CMPA = "EPWM_AQ_OUTPUT_HIGH";
epwm1.epwmActionQualifier_EPWM_AQ_OUTPUT_A_ON_TIMEBASE_DOWN_CMPA = "EPWM_AQ_OUTPUT_LOW";
epwm1.epwmDeadband_polarityFED = "EPWM_DB_POLARITY_ACTIVE_LOW";
epwm1.epwmDeadband_enableRED = true;
epwm1.epwmDeadband_enableFED = true;
epwm1.hrpwm_enable = true;
epwm1.hrpwm_autoConv = true;
epwm1.hrpwm_edgeModeA = "HRPWM_MEP_CTRL_RISING_AND_FALLING_EDGE";
epwm1.hrpwm_edgeModeB = "HRPWM_MEP_CTRL_RISING_AND_FALLING_EDGE";
epwm1.hrpwm_periodEnable = true;
epwm1.hrpwm_HRLoadA = "HRPWM_LOAD_ON_CNTR_ZERO_PERIOD";
epwm1.hrpwm_HRLoadB = "HRPWM_LOAD_ON_CNTR_ZERO_PERIOD";
epwm1.epwmActionQualifier_EPWM_AQ_OUTPUT_B_ON_TIMEBASE_UP_CMPB = "EPWM_AQ_OUTPUT_HIGH";
epwm1.epwmActionQualifier_EPWM_AQ_OUTPUT_B_ON_TIMEBASE_DOWN_CMPB = "EPWM_AQ_OUTPUT_LOW";
epwm1.epwmDeadband_delayRED = 10;
epwm1.epwmDeadband_delayFED = 10;
epwm1.epwm.$assign = "EPWM1";
epwm1.epwm.epwmaPin.$assign = "GPIO0";
epwm1.epwm.epwmbPin.$assign = "GPIO1";
epwm2.$name = "myEPWM2";
epwm2.epwmTimebase_period = 100;
epwm2.epwmTimebase_counterMode = "EPWM_COUNTER_MODE_UP_DOWN";
epwm2.epwmTimebase_hsClockDiv = "EPWM_HSCLOCK_DIVIDER_1";
epwm2.epwmCounterCompare_cmpA = 50;
epwm2.epwmCounterCompare_shadowLoadModeCMPA = "EPWM_COMP_LOAD_ON_CNTR_ZERO_PERIOD";
epwm2.epwmCounterCompare_cmpB = 50;
epwm2.epwmCounterCompare_shadowLoadModeCMPB = "EPWM_COMP_LOAD_ON_CNTR_ZERO_PERIOD";
epwm2.epwmActionQualifier_EPWM_AQ_OUTPUT_A_ON_TIMEBASE_UP_CMPA = "EPWM_AQ_OUTPUT_HIGH";
epwm2.epwmActionQualifier_EPWM_AQ_OUTPUT_A_ON_TIMEBASE_DOWN_CMPA = "EPWM_AQ_OUTPUT_LOW";
epwm2.epwmDeadband_polarityFED = "EPWM_DB_POLARITY_ACTIVE_LOW";
epwm2.epwmDeadband_enableRED = true;
epwm2.epwmDeadband_enableFED = true;
epwm2.hrpwm_enable = true;
epwm2.hrpwm_autoConv = true;
epwm2.hrpwm_edgeModeA = "HRPWM_MEP_CTRL_RISING_AND_FALLING_EDGE";
epwm2.hrpwm_edgeModeB = "HRPWM_MEP_CTRL_RISING_AND_FALLING_EDGE";
epwm2.hrpwm_periodEnable = true;
epwm2.hrpwm_HRLoadA = "HRPWM_LOAD_ON_CNTR_ZERO_PERIOD";
epwm2.hrpwm_HRLoadB = "HRPWM_LOAD_ON_CNTR_ZERO_PERIOD";
epwm2.epwmActionQualifier_EPWM_AQ_OUTPUT_B_ON_TIMEBASE_UP_CMPB = "EPWM_AQ_OUTPUT_HIGH";
epwm2.epwmActionQualifier_EPWM_AQ_OUTPUT_B_ON_TIMEBASE_DOWN_CMPB = "EPWM_AQ_OUTPUT_LOW";
epwm2.epwmDeadband_delayRED = 10;
epwm2.epwmDeadband_delayFED = 10;
epwm2.epwm.$assign = "EPWM2";
epwm2.epwm.epwmaPin.$assign = "GPIO2";
epwm2.epwm.epwmbPin.$assign = "GPIO3";
epwm3.$name = "myEPWM3";
epwm3.epwmTimebase_period = 100;
epwm3.epwmTimebase_counterMode = "EPWM_COUNTER_MODE_UP_DOWN";
epwm3.epwmTimebase_hsClockDiv = "EPWM_HSCLOCK_DIVIDER_1";
epwm3.epwmCounterCompare_cmpA = 50;
epwm3.epwmCounterCompare_shadowLoadModeCMPA = "EPWM_COMP_LOAD_ON_CNTR_ZERO_PERIOD";
epwm3.epwmCounterCompare_cmpB = 50;
epwm3.epwmCounterCompare_shadowLoadModeCMPB = "EPWM_COMP_LOAD_ON_CNTR_ZERO_PERIOD";
epwm3.epwmActionQualifier_EPWM_AQ_OUTPUT_A_ON_TIMEBASE_UP_CMPA = "EPWM_AQ_OUTPUT_HIGH";
epwm3.epwmActionQualifier_EPWM_AQ_OUTPUT_A_ON_TIMEBASE_DOWN_CMPA = "EPWM_AQ_OUTPUT_LOW";
epwm3.epwmDeadband_polarityFED = "EPWM_DB_POLARITY_ACTIVE_LOW";
epwm3.epwmDeadband_enableRED = true;
epwm3.epwmDeadband_enableFED = true;
epwm3.hrpwm_enable = true;
epwm3.hrpwm_autoConv = true;
epwm3.hrpwm_edgeModeA = "HRPWM_MEP_CTRL_RISING_AND_FALLING_EDGE";
epwm3.hrpwm_edgeModeB = "HRPWM_MEP_CTRL_RISING_AND_FALLING_EDGE";
epwm3.hrpwm_periodEnable = true;
epwm3.hrpwm_HRLoadA = "HRPWM_LOAD_ON_CNTR_ZERO_PERIOD";
epwm3.hrpwm_HRLoadB = "HRPWM_LOAD_ON_CNTR_ZERO_PERIOD";
epwm3.epwmActionQualifier_EPWM_AQ_OUTPUT_B_ON_TIMEBASE_UP_CMPB = "EPWM_AQ_OUTPUT_HIGH";
epwm3.epwmActionQualifier_EPWM_AQ_OUTPUT_B_ON_TIMEBASE_DOWN_CMPB = "EPWM_AQ_OUTPUT_LOW";
epwm3.epwmDeadband_delayRED = 10;
epwm3.epwmDeadband_delayFED = 10;
epwm3.epwm.$assign = "EPWM3";
epwm3.epwm.epwmaPin.$assign = "GPIO4";
epwm3.epwm.epwmbPin.$assign = "GPIO5";
epwm4.$name = "myEPWM4";
epwm4.epwmTimebase_period = 100;
epwm4.epwmTimebase_counterMode = "EPWM_COUNTER_MODE_UP_DOWN";
epwm4.epwmTimebase_hsClockDiv = "EPWM_HSCLOCK_DIVIDER_1";
epwm4.epwmCounterCompare_cmpA = 50;
epwm4.epwmCounterCompare_shadowLoadModeCMPA = "EPWM_COMP_LOAD_ON_CNTR_ZERO_PERIOD";
epwm4.epwmCounterCompare_cmpB = 50;
epwm4.epwmCounterCompare_shadowLoadModeCMPB = "EPWM_COMP_LOAD_ON_CNTR_ZERO_PERIOD";
epwm4.epwmActionQualifier_EPWM_AQ_OUTPUT_A_ON_TIMEBASE_UP_CMPA = "EPWM_AQ_OUTPUT_HIGH";
epwm4.epwmActionQualifier_EPWM_AQ_OUTPUT_A_ON_TIMEBASE_DOWN_CMPA = "EPWM_AQ_OUTPUT_LOW";
epwm4.epwmDeadband_polarityFED = "EPWM_DB_POLARITY_ACTIVE_LOW";
epwm4.epwmDeadband_enableRED = true;
epwm4.epwmDeadband_enableFED = true;
epwm4.hrpwm_enable = true;
epwm4.hrpwm_autoConv = true;
epwm4.hrpwm_edgeModeA = "HRPWM_MEP_CTRL_RISING_AND_FALLING_EDGE";
epwm4.hrpwm_edgeModeB = "HRPWM_MEP_CTRL_RISING_AND_FALLING_EDGE";
epwm4.hrpwm_periodEnable = true;
epwm4.hrpwm_HRLoadA = "HRPWM_LOAD_ON_CNTR_ZERO_PERIOD";
epwm4.hrpwm_HRLoadB = "HRPWM_LOAD_ON_CNTR_ZERO_PERIOD";
epwm4.epwmActionQualifier_EPWM_AQ_OUTPUT_B_ON_TIMEBASE_UP_CMPB = "EPWM_AQ_OUTPUT_HIGH";
epwm4.epwmActionQualifier_EPWM_AQ_OUTPUT_B_ON_TIMEBASE_DOWN_CMPB = "EPWM_AQ_OUTPUT_LOW";
epwm4.epwmDeadband_delayRED = 10;
epwm4.epwmDeadband_delayFED = 10;
epwm4.epwm.$assign = "EPWM4";
epwm4.epwm.epwmaPin.$assign = "GPIO6";
epwm4.epwm.epwmbPin.$assign = "GPIO7";
inputxbar1.$name = "myINPUTXBAR5";
inputxbar_input1.inputxbarInput = "XBAR_INPUT5";
inputxbar_input1.inputxbarGpio = "GPIO56";
inputxbar_input1.$name = "myINPUTXBARINPUT5";
inputxbar_input2.inputxbarInput = "XBAR_INPUT6";
inputxbar_input2.inputxbarGpio = "GPIO56";
inputxbar_input2.$name = "myINPUTXBARINPUT6";
@@ -0,0 +1,50 @@
//###########################################################################
//
// This .gel file can be used to help demonstrate the example project.
//
//#############################################################################
//
//
//
// 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.
// $
//#############################################################################
menuitem "HRPWM FineDutySlider"
slider FineDutySlider(1, 255, 1, 1, finedutyvalue)
{
dutySliderVal = finedutyvalue;
}