Update repo
This commit is contained in:
@@ -0,0 +1,43 @@
|
||||
<projectSpec>
|
||||
<project
|
||||
name="hrpwm_ex1_duty_sfo"
|
||||
device="TMS320F28377S"
|
||||
cgtVersion="22.6.0.LTS"
|
||||
products="sysconfig;C2000WARE"
|
||||
outputFormat="ELF"
|
||||
launchWizard="False"
|
||||
linkerCommandFile=""
|
||||
enableSysConfigTool="true"
|
||||
sysConfigBuildOptions="--product ${C2000WARE_ROOT}/.metadata/sdk.json --device F2837xS --package F2837xS_176PTP --part F2837xS_176PTP"
|
||||
>
|
||||
<configuration name="CPU1_RAM" compilerBuildOptions="--opt_level=off -I${PROJECT_ROOT}/device -I${C2000WARE_DLIB_ROOT} -I${C2000WARE_SFO_INCLUDE} --define=DEBUG -v28 -ml -mt --define=CPU1 --diag_warning=225 --diag_suppress=10063 --display_error_number" linkerBuildOptions="--entry_point code_start --stack_size=0x3F8 --heap_size=0x200 --define RAM" />
|
||||
<configuration name="CPU1_FLASH" compilerBuildOptions="--opt_level=off -I${PROJECT_ROOT}/device -I${C2000WARE_DLIB_ROOT} -I${C2000WARE_SFO_INCLUDE} --define=DEBUG -v28 -ml -mt --define=CPU1 --define=_FLASH --diag_warning=225 --diag_suppress=10063 --display_error_number" linkerBuildOptions="--entry_point code_start --stack_size=0x3F8 --heap_size=0x200 " />
|
||||
|
||||
<configuration name="CPU1_CLB" postBuildStep="mkdir "${BuildDirectory}/simulation"
|
||||
;${CLB_SIM_COMPILER}/g++ -c -DCLB_SIM -I${SYSTEMC_INSTALL}/src -I${C2000WARE_ROOT}/utilities/clb_tool/clb_syscfg/systemc/include -I${PROJECT_ROOT} -I${CLB_SIM_COMPILER}/include -Og -g -gdwarf-3 -gstrict-dwarf -Wall -MMD -MP -MF${BuildDirectory}/simulation/clb_sim.d -MT${BuildDirectory}/simulation/clb_sim.o -I${BuildDirectory}/syscfg -fno-threadsafe-statics -o${BuildDirectory}/simulation/clb_sim.o ${BuildDirectory}/syscfg/clb_sim.cpp
|
||||
;${CLB_SIM_COMPILER}/g++ -DCLB_SIM -Og -g -gdwarf-3 -gstrict-dwarf -Wall -Wl,-Map,${BuildDirectory}/simulation/simulation_output.map -L${SYSTEMC_INSTALL}/build/src -o${BuildDirectory}/simulation/simulation_output.exe ${BuildDirectory}/simulation/clb_sim.o ${C2000WARE_ROOT}/utilities/clb_tool/clb_syscfg/systemc/src/CLB_FSM_SC_model.o ${C2000WARE_ROOT}/utilities/clb_tool/clb_syscfg/systemc/src/CLB_HLC_SC_model.o ${C2000WARE_ROOT}/utilities/clb_tool/clb_syscfg/systemc/src/CLB_LUT4_SC_model.o ${C2000WARE_ROOT}/utilities/clb_tool/clb_syscfg/systemc/src/CLB_OutputLUT_SC_model.o ${C2000WARE_ROOT}/utilities/clb_tool/clb_syscfg/systemc/src/CLB_counter_SC_model.o -Wl,--start-group -lsystemc -Wl,--end-group;./simulation/simulation_output.exe
|
||||
;${NODE_TOOL} "${CLB_SYSCFG_ROOT}/dot_file_libraries/clbDotUtility.js" "${CLB_SYSCFG_ROOT}" "${BuildDirectory}/syscfg" "${BuildDirectory}/syscfg/clb.dot"" compilerBuildOptions="--opt_level=off -I${PROJECT_ROOT}/device -I${C2000WARE_DLIB_ROOT} -I${C2000WARE_SFO_INCLUDE} --define=DEBUG -v28 -ml -mt --define=CPU1 --diag_warning=225 --diag_suppress=10063 --display_error_number" linkerBuildOptions="--entry_point code_start --stack_size=0x3F8 --heap_size=0x200 --define RAM" />
|
||||
|
||||
<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" />
|
||||
|
||||
<pathVariable name="C2000WARE_DLIB_ROOT" path="../../../../driverlib/" scope="project" />
|
||||
<pathVariable name="C2000WARE_ROOT" path="../../../../../../" scope="project" />
|
||||
<pathVariable name="C2000WARE_SFO_INCLUDE" path="../../../../../../libraries/calibration/hrpwm/f2837xs/include/" scope="project" />
|
||||
|
||||
<file action="link" path="../../../../../../libraries/calibration/hrpwm/f2837xs/lib/SFO_v8_fpu_lib_build_c28_driverlib.lib" targetDirectory="" />
|
||||
<file action="copy" path="../../../../../../device_support/f2837xs/common/include/driverlib.h" targetDirectory="device" />
|
||||
<file action="copy" path="../../../../../../device_support/f2837xs/common/include/device.h" targetDirectory="device" />
|
||||
<file action="copy" path="../../../../../../device_support/f2837xs/common/source/device.c" targetDirectory="device" />
|
||||
<file action="copy" path="../../../../../../device_support/f2837xs/common/targetConfigs/TMS320F28377S.ccxml" targetDirectory="targetConfigs" />
|
||||
<file action="copy" path="../../../../../../device_support/f2837xs/common/cmd/2837xS_Generic_RAM_lnk.cmd" targetDirectory="" applicableConfigurations="CPU1_RAM,CPU1_CLB" />
|
||||
<file action="copy" path="../../../../../../device_support/f2837xs/common/cmd/2837xS_Generic_FLASH_lnk.cmd" targetDirectory="" applicableConfigurations="CPU1_FLASH" />
|
||||
<file action="copy" path="../../../../driverlib/" targetDirectory="device" excludeFromBuild="True" />
|
||||
<file action="copy" path="../../../../../../device_support/f2837xs/common/source/F2837xS_CodeStartBranch.asm" targetDirectory="device" />
|
||||
<file action="link" path="../../../../driverlib/ccs/Debug/driverlib.lib" targetDirectory="" />
|
||||
|
||||
<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="TMS320F28377S"
|
||||
cgtVersion="22.6.0.LTS"
|
||||
products="sysconfig;C2000WARE"
|
||||
outputFormat="ELF"
|
||||
launchWizard="False"
|
||||
linkerCommandFile=""
|
||||
enableSysConfigTool="true"
|
||||
sysConfigBuildOptions="--product ${C2000WARE_ROOT}/.metadata/sdk.json --device F2837xS --package F2837xS_176PTP --part F2837xS_176PTP"
|
||||
>
|
||||
<configuration name="CPU1_RAM" compilerBuildOptions="--opt_level=off -I${PROJECT_ROOT}/device -I${C2000WARE_DLIB_ROOT} -I${C2000WARE_SFO_INCLUDE} --define=DEBUG -v28 -ml -mt --define=CPU1 --diag_warning=225 --diag_suppress=10063 --display_error_number" linkerBuildOptions="--entry_point code_start --stack_size=0x3F8 --heap_size=0x200 --define RAM" />
|
||||
<configuration name="CPU1_FLASH" compilerBuildOptions="--opt_level=off -I${PROJECT_ROOT}/device -I${C2000WARE_DLIB_ROOT} -I${C2000WARE_SFO_INCLUDE} --define=DEBUG -v28 -ml -mt --define=CPU1 --define=_FLASH --diag_warning=225 --diag_suppress=10063 --display_error_number" linkerBuildOptions="--entry_point code_start --stack_size=0x3F8 --heap_size=0x200 " />
|
||||
|
||||
<configuration name="CPU1_CLB" postBuildStep="mkdir "${BuildDirectory}/simulation"
|
||||
;${CLB_SIM_COMPILER}/g++ -c -DCLB_SIM -I${SYSTEMC_INSTALL}/src -I${C2000WARE_ROOT}/utilities/clb_tool/clb_syscfg/systemc/include -I${PROJECT_ROOT} -I${CLB_SIM_COMPILER}/include -Og -g -gdwarf-3 -gstrict-dwarf -Wall -MMD -MP -MF${BuildDirectory}/simulation/clb_sim.d -MT${BuildDirectory}/simulation/clb_sim.o -I${BuildDirectory}/syscfg -fno-threadsafe-statics -o${BuildDirectory}/simulation/clb_sim.o ${BuildDirectory}/syscfg/clb_sim.cpp
|
||||
;${CLB_SIM_COMPILER}/g++ -DCLB_SIM -Og -g -gdwarf-3 -gstrict-dwarf -Wall -Wl,-Map,${BuildDirectory}/simulation/simulation_output.map -L${SYSTEMC_INSTALL}/build/src -o${BuildDirectory}/simulation/simulation_output.exe ${BuildDirectory}/simulation/clb_sim.o ${C2000WARE_ROOT}/utilities/clb_tool/clb_syscfg/systemc/src/CLB_FSM_SC_model.o ${C2000WARE_ROOT}/utilities/clb_tool/clb_syscfg/systemc/src/CLB_HLC_SC_model.o ${C2000WARE_ROOT}/utilities/clb_tool/clb_syscfg/systemc/src/CLB_LUT4_SC_model.o ${C2000WARE_ROOT}/utilities/clb_tool/clb_syscfg/systemc/src/CLB_OutputLUT_SC_model.o ${C2000WARE_ROOT}/utilities/clb_tool/clb_syscfg/systemc/src/CLB_counter_SC_model.o -Wl,--start-group -lsystemc -Wl,--end-group;./simulation/simulation_output.exe
|
||||
;${NODE_TOOL} "${CLB_SYSCFG_ROOT}/dot_file_libraries/clbDotUtility.js" "${CLB_SYSCFG_ROOT}" "${BuildDirectory}/syscfg" "${BuildDirectory}/syscfg/clb.dot"" compilerBuildOptions="--opt_level=off -I${PROJECT_ROOT}/device -I${C2000WARE_DLIB_ROOT} -I${C2000WARE_SFO_INCLUDE} --define=DEBUG -v28 -ml -mt --define=CPU1 --diag_warning=225 --diag_suppress=10063 --display_error_number" linkerBuildOptions="--entry_point code_start --stack_size=0x3F8 --heap_size=0x200 --define RAM" />
|
||||
|
||||
<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" />
|
||||
|
||||
<pathVariable name="C2000WARE_DLIB_ROOT" path="../../../../driverlib/" scope="project" />
|
||||
<pathVariable name="C2000WARE_ROOT" path="../../../../../../" scope="project" />
|
||||
<pathVariable name="C2000WARE_SFO_INCLUDE" path="../../../../../../libraries/calibration/hrpwm/f2837xs/include/" scope="project" />
|
||||
|
||||
<file action="link" path="../../../../../../libraries/calibration/hrpwm/f2837xs/lib/SFO_v8_fpu_lib_build_c28_driverlib.lib" targetDirectory="" />
|
||||
<file action="copy" path="../../../../../../device_support/f2837xs/common/include/driverlib.h" targetDirectory="device" />
|
||||
<file action="copy" path="../../../../../../device_support/f2837xs/common/include/device.h" targetDirectory="device" />
|
||||
<file action="copy" path="../../../../../../device_support/f2837xs/common/source/device.c" targetDirectory="device" />
|
||||
<file action="copy" path="../../../../../../device_support/f2837xs/common/targetConfigs/TMS320F28377S.ccxml" targetDirectory="targetConfigs" />
|
||||
<file action="copy" path="../../../../../../device_support/f2837xs/common/cmd/2837xS_Generic_RAM_lnk.cmd" targetDirectory="" applicableConfigurations="CPU1_RAM,CPU1_CLB" />
|
||||
<file action="copy" path="../../../../../../device_support/f2837xs/common/cmd/2837xS_Generic_FLASH_lnk.cmd" targetDirectory="" applicableConfigurations="CPU1_FLASH" />
|
||||
<file action="copy" path="../../../../driverlib/" targetDirectory="device" excludeFromBuild="True" />
|
||||
<file action="copy" path="../../../../../../device_support/f2837xs/common/source/F2837xS_CodeStartBranch.asm" targetDirectory="device" />
|
||||
<file action="link" path="../../../../driverlib/ccs/Debug/driverlib.lib" targetDirectory="" />
|
||||
|
||||
<file action="copy" path="../hrpwm_ex2_slider.c" targetDirectory="" />
|
||||
<file action="copy" path="../hrpwm_ex2_slider.syscfg" targetDirectory="" />
|
||||
</project>
|
||||
</projectSpec>
|
||||
+43
@@ -0,0 +1,43 @@
|
||||
<projectSpec>
|
||||
<project
|
||||
name="hrpwm_ex3_prd_updown_sfo"
|
||||
device="TMS320F28377S"
|
||||
cgtVersion="22.6.0.LTS"
|
||||
products="sysconfig;C2000WARE"
|
||||
outputFormat="ELF"
|
||||
launchWizard="False"
|
||||
linkerCommandFile=""
|
||||
enableSysConfigTool="true"
|
||||
sysConfigBuildOptions="--product ${C2000WARE_ROOT}/.metadata/sdk.json --device F2837xS --package F2837xS_176PTP --part F2837xS_176PTP"
|
||||
>
|
||||
<configuration name="CPU1_RAM" compilerBuildOptions="--opt_level=off -I${PROJECT_ROOT}/device -I${C2000WARE_DLIB_ROOT} -I${C2000WARE_SFO_INCLUDE} --define=DEBUG -v28 -ml -mt --define=CPU1 --diag_warning=225 --diag_suppress=10063 --display_error_number" linkerBuildOptions="--entry_point code_start --stack_size=0x3F8 --heap_size=0x200 --define RAM" />
|
||||
<configuration name="CPU1_FLASH" compilerBuildOptions="--opt_level=off -I${PROJECT_ROOT}/device -I${C2000WARE_DLIB_ROOT} -I${C2000WARE_SFO_INCLUDE} --define=DEBUG -v28 -ml -mt --define=CPU1 --define=_FLASH --diag_warning=225 --diag_suppress=10063 --display_error_number" linkerBuildOptions="--entry_point code_start --stack_size=0x3F8 --heap_size=0x200 " />
|
||||
|
||||
<configuration name="CPU1_CLB" postBuildStep="mkdir "${BuildDirectory}/simulation"
|
||||
;${CLB_SIM_COMPILER}/g++ -c -DCLB_SIM -I${SYSTEMC_INSTALL}/src -I${C2000WARE_ROOT}/utilities/clb_tool/clb_syscfg/systemc/include -I${PROJECT_ROOT} -I${CLB_SIM_COMPILER}/include -Og -g -gdwarf-3 -gstrict-dwarf -Wall -MMD -MP -MF${BuildDirectory}/simulation/clb_sim.d -MT${BuildDirectory}/simulation/clb_sim.o -I${BuildDirectory}/syscfg -fno-threadsafe-statics -o${BuildDirectory}/simulation/clb_sim.o ${BuildDirectory}/syscfg/clb_sim.cpp
|
||||
;${CLB_SIM_COMPILER}/g++ -DCLB_SIM -Og -g -gdwarf-3 -gstrict-dwarf -Wall -Wl,-Map,${BuildDirectory}/simulation/simulation_output.map -L${SYSTEMC_INSTALL}/build/src -o${BuildDirectory}/simulation/simulation_output.exe ${BuildDirectory}/simulation/clb_sim.o ${C2000WARE_ROOT}/utilities/clb_tool/clb_syscfg/systemc/src/CLB_FSM_SC_model.o ${C2000WARE_ROOT}/utilities/clb_tool/clb_syscfg/systemc/src/CLB_HLC_SC_model.o ${C2000WARE_ROOT}/utilities/clb_tool/clb_syscfg/systemc/src/CLB_LUT4_SC_model.o ${C2000WARE_ROOT}/utilities/clb_tool/clb_syscfg/systemc/src/CLB_OutputLUT_SC_model.o ${C2000WARE_ROOT}/utilities/clb_tool/clb_syscfg/systemc/src/CLB_counter_SC_model.o -Wl,--start-group -lsystemc -Wl,--end-group;./simulation/simulation_output.exe
|
||||
;${NODE_TOOL} "${CLB_SYSCFG_ROOT}/dot_file_libraries/clbDotUtility.js" "${CLB_SYSCFG_ROOT}" "${BuildDirectory}/syscfg" "${BuildDirectory}/syscfg/clb.dot"" compilerBuildOptions="--opt_level=off -I${PROJECT_ROOT}/device -I${C2000WARE_DLIB_ROOT} -I${C2000WARE_SFO_INCLUDE} --define=DEBUG -v28 -ml -mt --define=CPU1 --diag_warning=225 --diag_suppress=10063 --display_error_number" linkerBuildOptions="--entry_point code_start --stack_size=0x3F8 --heap_size=0x200 --define RAM" />
|
||||
|
||||
<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" />
|
||||
|
||||
<pathVariable name="C2000WARE_DLIB_ROOT" path="../../../../driverlib/" scope="project" />
|
||||
<pathVariable name="C2000WARE_ROOT" path="../../../../../../" scope="project" />
|
||||
<pathVariable name="C2000WARE_SFO_INCLUDE" path="../../../../../../libraries/calibration/hrpwm/f2837xs/include/" scope="project" />
|
||||
|
||||
<file action="link" path="../../../../../../libraries/calibration/hrpwm/f2837xs/lib/SFO_v8_fpu_lib_build_c28_driverlib.lib" targetDirectory="" />
|
||||
<file action="copy" path="../../../../../../device_support/f2837xs/common/include/driverlib.h" targetDirectory="device" />
|
||||
<file action="copy" path="../../../../../../device_support/f2837xs/common/include/device.h" targetDirectory="device" />
|
||||
<file action="copy" path="../../../../../../device_support/f2837xs/common/source/device.c" targetDirectory="device" />
|
||||
<file action="copy" path="../../../../../../device_support/f2837xs/common/targetConfigs/TMS320F28377S.ccxml" targetDirectory="targetConfigs" />
|
||||
<file action="copy" path="../../../../../../device_support/f2837xs/common/cmd/2837xS_Generic_RAM_lnk.cmd" targetDirectory="" applicableConfigurations="CPU1_RAM,CPU1_CLB" />
|
||||
<file action="copy" path="../../../../../../device_support/f2837xs/common/cmd/2837xS_Generic_FLASH_lnk.cmd" targetDirectory="" applicableConfigurations="CPU1_FLASH" />
|
||||
<file action="copy" path="../../../../driverlib/" targetDirectory="device" excludeFromBuild="True" />
|
||||
<file action="copy" path="../../../../../../device_support/f2837xs/common/source/F2837xS_CodeStartBranch.asm" targetDirectory="device" />
|
||||
<file action="link" path="../../../../driverlib/ccs/Debug/driverlib.lib" targetDirectory="" />
|
||||
|
||||
<file action="copy" path="../hrpwm_ex3_prd_updown_sfo.c" targetDirectory="" />
|
||||
<file action="copy" path="../hrpwm_ex3_prd_updown_sfo.syscfg" targetDirectory="" />
|
||||
</project>
|
||||
</projectSpec>
|
||||
+43
@@ -0,0 +1,43 @@
|
||||
<projectSpec>
|
||||
<project
|
||||
name="hrpwm_ex4_duty_updown_sfo"
|
||||
device="TMS320F28377S"
|
||||
cgtVersion="22.6.0.LTS"
|
||||
products="sysconfig;C2000WARE"
|
||||
outputFormat="ELF"
|
||||
launchWizard="False"
|
||||
linkerCommandFile=""
|
||||
enableSysConfigTool="true"
|
||||
sysConfigBuildOptions="--product ${C2000WARE_ROOT}/.metadata/sdk.json --device F2837xS --package F2837xS_176PTP --part F2837xS_176PTP"
|
||||
>
|
||||
<configuration name="CPU1_RAM" compilerBuildOptions="--opt_level=off -I${PROJECT_ROOT}/device -I${C2000WARE_DLIB_ROOT} -I${C2000WARE_SFO_INCLUDE} --define=DEBUG -v28 -ml -mt --define=CPU1 --diag_warning=225 --diag_suppress=10063 --display_error_number" linkerBuildOptions="--entry_point code_start --stack_size=0x3F8 --heap_size=0x200 --define RAM" />
|
||||
<configuration name="CPU1_FLASH" compilerBuildOptions="--opt_level=off -I${PROJECT_ROOT}/device -I${C2000WARE_DLIB_ROOT} -I${C2000WARE_SFO_INCLUDE} --define=DEBUG -v28 -ml -mt --define=CPU1 --define=_FLASH --diag_warning=225 --diag_suppress=10063 --display_error_number" linkerBuildOptions="--entry_point code_start --stack_size=0x3F8 --heap_size=0x200 " />
|
||||
|
||||
<configuration name="CPU1_CLB" postBuildStep="mkdir "${BuildDirectory}/simulation"
|
||||
;${CLB_SIM_COMPILER}/g++ -c -DCLB_SIM -I${SYSTEMC_INSTALL}/src -I${C2000WARE_ROOT}/utilities/clb_tool/clb_syscfg/systemc/include -I${PROJECT_ROOT} -I${CLB_SIM_COMPILER}/include -Og -g -gdwarf-3 -gstrict-dwarf -Wall -MMD -MP -MF${BuildDirectory}/simulation/clb_sim.d -MT${BuildDirectory}/simulation/clb_sim.o -I${BuildDirectory}/syscfg -fno-threadsafe-statics -o${BuildDirectory}/simulation/clb_sim.o ${BuildDirectory}/syscfg/clb_sim.cpp
|
||||
;${CLB_SIM_COMPILER}/g++ -DCLB_SIM -Og -g -gdwarf-3 -gstrict-dwarf -Wall -Wl,-Map,${BuildDirectory}/simulation/simulation_output.map -L${SYSTEMC_INSTALL}/build/src -o${BuildDirectory}/simulation/simulation_output.exe ${BuildDirectory}/simulation/clb_sim.o ${C2000WARE_ROOT}/utilities/clb_tool/clb_syscfg/systemc/src/CLB_FSM_SC_model.o ${C2000WARE_ROOT}/utilities/clb_tool/clb_syscfg/systemc/src/CLB_HLC_SC_model.o ${C2000WARE_ROOT}/utilities/clb_tool/clb_syscfg/systemc/src/CLB_LUT4_SC_model.o ${C2000WARE_ROOT}/utilities/clb_tool/clb_syscfg/systemc/src/CLB_OutputLUT_SC_model.o ${C2000WARE_ROOT}/utilities/clb_tool/clb_syscfg/systemc/src/CLB_counter_SC_model.o -Wl,--start-group -lsystemc -Wl,--end-group;./simulation/simulation_output.exe
|
||||
;${NODE_TOOL} "${CLB_SYSCFG_ROOT}/dot_file_libraries/clbDotUtility.js" "${CLB_SYSCFG_ROOT}" "${BuildDirectory}/syscfg" "${BuildDirectory}/syscfg/clb.dot"" compilerBuildOptions="--opt_level=off -I${PROJECT_ROOT}/device -I${C2000WARE_DLIB_ROOT} -I${C2000WARE_SFO_INCLUDE} --define=DEBUG -v28 -ml -mt --define=CPU1 --diag_warning=225 --diag_suppress=10063 --display_error_number" linkerBuildOptions="--entry_point code_start --stack_size=0x3F8 --heap_size=0x200 --define RAM" />
|
||||
|
||||
<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" />
|
||||
|
||||
<pathVariable name="C2000WARE_DLIB_ROOT" path="../../../../driverlib/" scope="project" />
|
||||
<pathVariable name="C2000WARE_ROOT" path="../../../../../../" scope="project" />
|
||||
<pathVariable name="C2000WARE_SFO_INCLUDE" path="../../../../../../libraries/calibration/hrpwm/f2837xs/include/" scope="project" />
|
||||
|
||||
<file action="link" path="../../../../../../libraries/calibration/hrpwm/f2837xs/lib/SFO_v8_fpu_lib_build_c28_driverlib.lib" targetDirectory="" />
|
||||
<file action="copy" path="../../../../../../device_support/f2837xs/common/include/driverlib.h" targetDirectory="device" />
|
||||
<file action="copy" path="../../../../../../device_support/f2837xs/common/include/device.h" targetDirectory="device" />
|
||||
<file action="copy" path="../../../../../../device_support/f2837xs/common/source/device.c" targetDirectory="device" />
|
||||
<file action="copy" path="../../../../../../device_support/f2837xs/common/targetConfigs/TMS320F28377S.ccxml" targetDirectory="targetConfigs" />
|
||||
<file action="copy" path="../../../../../../device_support/f2837xs/common/cmd/2837xS_Generic_RAM_lnk.cmd" targetDirectory="" applicableConfigurations="CPU1_RAM,CPU1_CLB" />
|
||||
<file action="copy" path="../../../../../../device_support/f2837xs/common/cmd/2837xS_Generic_FLASH_lnk.cmd" targetDirectory="" applicableConfigurations="CPU1_FLASH" />
|
||||
<file action="copy" path="../../../../driverlib/" targetDirectory="device" excludeFromBuild="True" />
|
||||
<file action="copy" path="../../../../../../device_support/f2837xs/common/source/F2837xS_CodeStartBranch.asm" targetDirectory="device" />
|
||||
<file action="link" path="../../../../driverlib/ccs/Debug/driverlib.lib" targetDirectory="" />
|
||||
|
||||
<file action="copy" path="../hrpwm_ex4_duty_updown_sfo.c" targetDirectory="" />
|
||||
<file action="copy" path="../hrpwm_ex4_duty_updown_sfo.syscfg" targetDirectory="" />
|
||||
</project>
|
||||
</projectSpec>
|
||||
+43
@@ -0,0 +1,43 @@
|
||||
<projectSpec>
|
||||
<project
|
||||
name="hrpwm_ex9_dutyhr_updown_deadband_sfo"
|
||||
device="TMS320F28377S"
|
||||
cgtVersion="22.6.0.LTS"
|
||||
products="sysconfig;C2000WARE"
|
||||
outputFormat="ELF"
|
||||
launchWizard="False"
|
||||
linkerCommandFile=""
|
||||
enableSysConfigTool="true"
|
||||
sysConfigBuildOptions="--product ${C2000WARE_ROOT}/.metadata/sdk.json --device F2837xS --package F2837xS_176PTP --part F2837xS_176PTP"
|
||||
>
|
||||
<configuration name="CPU1_RAM" compilerBuildOptions="--opt_level=off -I${PROJECT_ROOT}/device -I${C2000WARE_DLIB_ROOT} -I${C2000WARE_SFO_INCLUDE} --define=DEBUG -v28 -ml -mt --define=CPU1 --diag_warning=225 --diag_suppress=10063 --display_error_number" linkerBuildOptions="--entry_point code_start --stack_size=0x3F8 --heap_size=0x200 --define RAM" />
|
||||
<configuration name="CPU1_FLASH" compilerBuildOptions="--opt_level=off -I${PROJECT_ROOT}/device -I${C2000WARE_DLIB_ROOT} -I${C2000WARE_SFO_INCLUDE} --define=DEBUG -v28 -ml -mt --define=CPU1 --define=_FLASH --diag_warning=225 --diag_suppress=10063 --display_error_number" linkerBuildOptions="--entry_point code_start --stack_size=0x3F8 --heap_size=0x200 " />
|
||||
|
||||
<configuration name="CPU1_CLB" postBuildStep="mkdir "${BuildDirectory}/simulation"
|
||||
;${CLB_SIM_COMPILER}/g++ -c -DCLB_SIM -I${SYSTEMC_INSTALL}/src -I${C2000WARE_ROOT}/utilities/clb_tool/clb_syscfg/systemc/include -I${PROJECT_ROOT} -I${CLB_SIM_COMPILER}/include -Og -g -gdwarf-3 -gstrict-dwarf -Wall -MMD -MP -MF${BuildDirectory}/simulation/clb_sim.d -MT${BuildDirectory}/simulation/clb_sim.o -I${BuildDirectory}/syscfg -fno-threadsafe-statics -o${BuildDirectory}/simulation/clb_sim.o ${BuildDirectory}/syscfg/clb_sim.cpp
|
||||
;${CLB_SIM_COMPILER}/g++ -DCLB_SIM -Og -g -gdwarf-3 -gstrict-dwarf -Wall -Wl,-Map,${BuildDirectory}/simulation/simulation_output.map -L${SYSTEMC_INSTALL}/build/src -o${BuildDirectory}/simulation/simulation_output.exe ${BuildDirectory}/simulation/clb_sim.o ${C2000WARE_ROOT}/utilities/clb_tool/clb_syscfg/systemc/src/CLB_FSM_SC_model.o ${C2000WARE_ROOT}/utilities/clb_tool/clb_syscfg/systemc/src/CLB_HLC_SC_model.o ${C2000WARE_ROOT}/utilities/clb_tool/clb_syscfg/systemc/src/CLB_LUT4_SC_model.o ${C2000WARE_ROOT}/utilities/clb_tool/clb_syscfg/systemc/src/CLB_OutputLUT_SC_model.o ${C2000WARE_ROOT}/utilities/clb_tool/clb_syscfg/systemc/src/CLB_counter_SC_model.o -Wl,--start-group -lsystemc -Wl,--end-group;./simulation/simulation_output.exe
|
||||
;${NODE_TOOL} "${CLB_SYSCFG_ROOT}/dot_file_libraries/clbDotUtility.js" "${CLB_SYSCFG_ROOT}" "${BuildDirectory}/syscfg" "${BuildDirectory}/syscfg/clb.dot"" compilerBuildOptions="--opt_level=off -I${PROJECT_ROOT}/device -I${C2000WARE_DLIB_ROOT} -I${C2000WARE_SFO_INCLUDE} --define=DEBUG -v28 -ml -mt --define=CPU1 --diag_warning=225 --diag_suppress=10063 --display_error_number" linkerBuildOptions="--entry_point code_start --stack_size=0x3F8 --heap_size=0x200 --define RAM" />
|
||||
|
||||
<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" />
|
||||
|
||||
<pathVariable name="C2000WARE_DLIB_ROOT" path="../../../../driverlib/" scope="project" />
|
||||
<pathVariable name="C2000WARE_ROOT" path="../../../../../../" scope="project" />
|
||||
<pathVariable name="C2000WARE_SFO_INCLUDE" path="../../../../../../libraries/calibration/hrpwm/f2837xs/include/" scope="project" />
|
||||
|
||||
<file action="link" path="../../../../../../libraries/calibration/hrpwm/f2837xs/lib/SFO_v8_fpu_lib_build_c28_driverlib.lib" targetDirectory="" />
|
||||
<file action="copy" path="../../../../../../device_support/f2837xs/common/include/driverlib.h" targetDirectory="device" />
|
||||
<file action="copy" path="../../../../../../device_support/f2837xs/common/include/device.h" targetDirectory="device" />
|
||||
<file action="copy" path="../../../../../../device_support/f2837xs/common/source/device.c" targetDirectory="device" />
|
||||
<file action="copy" path="../../../../../../device_support/f2837xs/common/targetConfigs/TMS320F28377S.ccxml" targetDirectory="targetConfigs" />
|
||||
<file action="copy" path="../../../../../../device_support/f2837xs/common/cmd/2837xS_Generic_RAM_lnk.cmd" targetDirectory="" applicableConfigurations="CPU1_RAM,CPU1_CLB" />
|
||||
<file action="copy" path="../../../../../../device_support/f2837xs/common/cmd/2837xS_Generic_FLASH_lnk.cmd" targetDirectory="" applicableConfigurations="CPU1_FLASH" />
|
||||
<file action="copy" path="../../../../driverlib/" targetDirectory="device" excludeFromBuild="True" />
|
||||
<file action="copy" path="../../../../../../device_support/f2837xs/common/source/F2837xS_CodeStartBranch.asm" targetDirectory="device" />
|
||||
<file action="link" path="../../../../driverlib/ccs/Debug/driverlib.lib" targetDirectory="" />
|
||||
|
||||
<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,48 @@
|
||||
//###########################################################################
|
||||
//
|
||||
// This .gel file can be used to help demonstrate the example project.
|
||||
//
|
||||
//#############################################################################
|
||||
//
|
||||
// $Release Date: Sun Oct 4 15:50:18 IST 2020 $
|
||||
// $Copyright:
|
||||
// Copyright (C) 2020 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;
|
||||
}
|
||||
|
||||
@@ -0,0 +1,48 @@
|
||||
//###########################################################################
|
||||
//
|
||||
// This .gel file can be used to help demonstrate the example project.
|
||||
//
|
||||
//#############################################################################
|
||||
//
|
||||
// $Release Date: Sun Oct 4 16:00:36 IST 2020 $
|
||||
// $Copyright:
|
||||
// Copyright (C) 2020 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;
|
||||
}
|
||||
|
||||
@@ -0,0 +1,377 @@
|
||||
//#############################################################################
|
||||
//
|
||||
// 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.
|
||||
//
|
||||
//#############################################################################
|
||||
//
|
||||
//
|
||||
// $Copyright:
|
||||
// Copyright (C) 2014-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 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 initHRPWM(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);
|
||||
|
||||
//
|
||||
// Initialize the EPWM GPIO Pins and change the XBAR inputs from using 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.
|
||||
}
|
||||
|
||||
|
||||
|
||||
//
|
||||
// Disable sync(Freeze clock to PWM as well)
|
||||
//
|
||||
SysCtl_disablePeripheral(SYSCTL_PERIPH_CLK_TBCLKSYNC);
|
||||
|
||||
initHRPWM(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 < 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);
|
||||
//}
|
||||
|
||||
|
||||
|
||||
void initHRPWM(uint32_t period)
|
||||
{
|
||||
|
||||
uint16_t j;
|
||||
|
||||
//
|
||||
// ePWM channel register configuration with HRPWM
|
||||
// ePWMxA / ePWMxB toggle low/high with MEP control on Rising edge
|
||||
//
|
||||
for (j=1;j<LAST_EPWM_INDEX_FOR_EXAMPLE;j++)
|
||||
{
|
||||
EPWM_setEmulationMode(ePWM[j], EPWM_EMULATION_FREE_RUN);
|
||||
|
||||
//
|
||||
// Set-up TBCLK
|
||||
//
|
||||
EPWM_setTimeBasePeriod(ePWM[j], period-1);
|
||||
EPWM_setPhaseShift(ePWM[j], 0U);
|
||||
EPWM_setTimeBaseCounter(ePWM[j], 0U);
|
||||
|
||||
//
|
||||
// set duty 50% initially
|
||||
//
|
||||
HRPWM_setCounterCompareValue(ePWM[j], HRPWM_COUNTER_COMPARE_A, (period/2 << 8));
|
||||
HRPWM_setCounterCompareValue(ePWM[j], HRPWM_COUNTER_COMPARE_B, (period/2 << 8));
|
||||
|
||||
|
||||
//
|
||||
// Set up counter mode
|
||||
//
|
||||
EPWM_setTimeBaseCounterMode(ePWM[j], EPWM_COUNTER_MODE_UP);
|
||||
EPWM_disablePhaseShiftLoad(ePWM[j]);
|
||||
EPWM_setClockPrescaler(ePWM[j],
|
||||
EPWM_CLOCK_DIVIDER_1,
|
||||
EPWM_HSCLOCK_DIVIDER_1);
|
||||
EPWM_setSyncOutPulseMode(ePWM[j], EPWM_SYNC_OUT_PULSE_DISABLED);
|
||||
|
||||
//
|
||||
// Set up shadowing
|
||||
//
|
||||
EPWM_setCounterCompareShadowLoadMode(ePWM[j],
|
||||
EPWM_COUNTER_COMPARE_A,
|
||||
EPWM_COMP_LOAD_ON_CNTR_ZERO);
|
||||
EPWM_setCounterCompareShadowLoadMode(ePWM[j],
|
||||
EPWM_COUNTER_COMPARE_B,
|
||||
EPWM_COMP_LOAD_ON_CNTR_ZERO);
|
||||
|
||||
//
|
||||
// Set actions
|
||||
//
|
||||
|
||||
EPWM_setActionQualifierAction(ePWM[j],
|
||||
EPWM_AQ_OUTPUT_A,
|
||||
EPWM_AQ_OUTPUT_HIGH,
|
||||
EPWM_AQ_OUTPUT_ON_TIMEBASE_ZERO);
|
||||
|
||||
|
||||
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_A,
|
||||
EPWM_AQ_OUTPUT_LOW,
|
||||
EPWM_AQ_OUTPUT_ON_TIMEBASE_UP_CMPA);
|
||||
EPWM_setActionQualifierAction(ePWM[j],
|
||||
EPWM_AQ_OUTPUT_B,
|
||||
EPWM_AQ_OUTPUT_LOW,
|
||||
EPWM_AQ_OUTPUT_ON_TIMEBASE_UP_CMPB);
|
||||
|
||||
|
||||
HRPWM_setMEPEdgeSelect(ePWM[j], HRPWM_CHANNEL_A, HRPWM_MEP_CTRL_FALLING_EDGE);
|
||||
HRPWM_setMEPControlMode(ePWM[j], HRPWM_CHANNEL_A, HRPWM_MEP_DUTY_PERIOD_CTRL);
|
||||
HRPWM_setCounterCompareShadowLoadEvent(ePWM[j], HRPWM_CHANNEL_A, HRPWM_LOAD_ON_CNTR_ZERO);
|
||||
|
||||
HRPWM_setMEPEdgeSelect(ePWM[j], HRPWM_CHANNEL_B, HRPWM_MEP_CTRL_FALLING_EDGE);
|
||||
HRPWM_setMEPControlMode(ePWM[j], HRPWM_CHANNEL_B, HRPWM_MEP_DUTY_PERIOD_CTRL);
|
||||
HRPWM_setCounterCompareShadowLoadEvent(ePWM[j], HRPWM_CHANNEL_B, HRPWM_LOAD_ON_CNTR_ZERO);
|
||||
|
||||
HRPWM_enableAutoConversion(ePWM[j]);
|
||||
|
||||
//
|
||||
// Turn off high-resolution period control.
|
||||
//
|
||||
|
||||
HRPWM_disablePeriodControl(ePWM[j]);
|
||||
HRPWM_disablePhaseShiftLoad(ePWM[j]);
|
||||
|
||||
|
||||
//
|
||||
// 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,42 @@
|
||||
/**
|
||||
* 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.epwm.$assign = "EPWM1";
|
||||
epwm1.epwm.epwmaPin.$assign = "GPIO0";
|
||||
epwm1.epwm.epwmbPin.$assign = "GPIO1";
|
||||
|
||||
epwm2.$name = "myEPWM2";
|
||||
epwm2.epwm.$assign = "EPWM2";
|
||||
epwm2.epwm.epwmaPin.$assign = "GPIO2";
|
||||
epwm2.epwm.epwmbPin.$assign = "GPIO3";
|
||||
|
||||
epwm3.$name = "myEPWM3";
|
||||
epwm3.epwm.$assign = "EPWM3";
|
||||
epwm3.epwm.epwmaPin.$assign = "GPIO4";
|
||||
epwm3.epwm.epwmbPin.$assign = "GPIO5";
|
||||
|
||||
epwm4.$name = "myEPWM4";
|
||||
epwm4.epwm.$assign = "EPWM4";
|
||||
epwm4.epwm.epwmaPin.$assign = "GPIO6";
|
||||
epwm4.epwm.epwmbPin.$assign = "GPIO7";
|
||||
|
||||
inputxbar1.inputxbar1Gpio = "GPIO25";
|
||||
inputxbar1.$name = "myINPUTXBAR5";
|
||||
inputxbar1.inputsUsed = ["inputxbar5Gpio","inputxbar6Gpio"];
|
||||
inputxbar1.inputxbar5Gpio = "GPIO56";
|
||||
inputxbar1.inputxbar6Gpio = "GPIO56";
|
||||
@@ -0,0 +1,237 @@
|
||||
//#############################################################################
|
||||
//
|
||||
// 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.
|
||||
//
|
||||
//
|
||||
//#############################################################################
|
||||
//
|
||||
//
|
||||
// $Copyright:
|
||||
// Copyright (C) 2014-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"
|
||||
|
||||
#define EPWM_TIMER_TBPRD 100UL
|
||||
|
||||
//
|
||||
// Globals
|
||||
//
|
||||
|
||||
uint16_t dutyFine = 1;
|
||||
uint16_t previousDutyFine = 1;
|
||||
uint16_t status;
|
||||
|
||||
//
|
||||
// Function Prototypes
|
||||
//
|
||||
void initHRPWM(uint32_t period);
|
||||
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();
|
||||
|
||||
//
|
||||
// Initialize the EPWM GPIOs and CHANGE XBAR inputs from using GPIO0
|
||||
//
|
||||
Board_init();
|
||||
|
||||
//
|
||||
// Disable sync(Freeze clock to PWM as well)
|
||||
//
|
||||
SysCtl_disablePeripheral(SYSCTL_PERIPH_CLK_TBCLKSYNC);
|
||||
|
||||
initHRPWM(EPWM_TIMER_TBPRD);
|
||||
|
||||
//
|
||||
// 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;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
void initHRPWM(uint32_t period)
|
||||
{
|
||||
EPWM_setEmulationMode(myEPWM1_BASE, EPWM_EMULATION_FREE_RUN);
|
||||
|
||||
//
|
||||
// Set-up TBCLK
|
||||
//
|
||||
EPWM_setTimeBasePeriod(myEPWM1_BASE, period-1);
|
||||
EPWM_setPhaseShift(myEPWM1_BASE, 0U);
|
||||
EPWM_setTimeBaseCounter(myEPWM1_BASE, 0U);
|
||||
|
||||
//
|
||||
// set duty 50% initially
|
||||
//
|
||||
HRPWM_setCounterCompareValue(myEPWM1_BASE, HRPWM_COUNTER_COMPARE_A, (period/2 << 8));
|
||||
HRPWM_setCounterCompareValue(myEPWM1_BASE, HRPWM_COUNTER_COMPARE_B, (period/2 << 8));
|
||||
|
||||
|
||||
//
|
||||
// Set up counter mode
|
||||
//
|
||||
EPWM_setTimeBaseCounterMode(myEPWM1_BASE, EPWM_COUNTER_MODE_UP);
|
||||
EPWM_disablePhaseShiftLoad(myEPWM1_BASE);
|
||||
EPWM_setClockPrescaler(myEPWM1_BASE,
|
||||
EPWM_CLOCK_DIVIDER_1,
|
||||
EPWM_HSCLOCK_DIVIDER_1);
|
||||
EPWM_setSyncOutPulseMode(myEPWM1_BASE, EPWM_SYNC_OUT_PULSE_DISABLED);
|
||||
|
||||
|
||||
//
|
||||
// Set up shadowing
|
||||
//
|
||||
EPWM_setCounterCompareShadowLoadMode(myEPWM1_BASE,
|
||||
EPWM_COUNTER_COMPARE_A,
|
||||
EPWM_COMP_LOAD_ON_CNTR_ZERO);
|
||||
EPWM_setCounterCompareShadowLoadMode(myEPWM1_BASE,
|
||||
EPWM_COUNTER_COMPARE_B,
|
||||
EPWM_COMP_LOAD_ON_CNTR_ZERO);
|
||||
|
||||
//
|
||||
// Set actions
|
||||
//
|
||||
|
||||
EPWM_setActionQualifierAction(myEPWM1_BASE,
|
||||
EPWM_AQ_OUTPUT_A,
|
||||
EPWM_AQ_OUTPUT_LOW,
|
||||
EPWM_AQ_OUTPUT_ON_TIMEBASE_ZERO);
|
||||
|
||||
|
||||
EPWM_setActionQualifierAction(myEPWM1_BASE,
|
||||
EPWM_AQ_OUTPUT_B,
|
||||
EPWM_AQ_OUTPUT_LOW,
|
||||
EPWM_AQ_OUTPUT_ON_TIMEBASE_ZERO);
|
||||
|
||||
EPWM_setActionQualifierAction(myEPWM1_BASE,
|
||||
EPWM_AQ_OUTPUT_A,
|
||||
EPWM_AQ_OUTPUT_HIGH,
|
||||
EPWM_AQ_OUTPUT_ON_TIMEBASE_UP_CMPA);
|
||||
EPWM_setActionQualifierAction(myEPWM1_BASE,
|
||||
EPWM_AQ_OUTPUT_B,
|
||||
EPWM_AQ_OUTPUT_HIGH,
|
||||
EPWM_AQ_OUTPUT_ON_TIMEBASE_UP_CMPB);
|
||||
|
||||
|
||||
HRPWM_setMEPEdgeSelect(myEPWM1_BASE, HRPWM_CHANNEL_A, HRPWM_MEP_CTRL_RISING_EDGE);
|
||||
HRPWM_setMEPControlMode(myEPWM1_BASE, HRPWM_CHANNEL_A, HRPWM_MEP_DUTY_PERIOD_CTRL);
|
||||
HRPWM_setCounterCompareShadowLoadEvent(myEPWM1_BASE, HRPWM_CHANNEL_A, HRPWM_LOAD_ON_CNTR_ZERO);
|
||||
|
||||
HRPWM_setMEPEdgeSelect(myEPWM1_BASE, HRPWM_CHANNEL_B, HRPWM_MEP_CTRL_RISING_EDGE);
|
||||
HRPWM_setMEPControlMode(myEPWM1_BASE, HRPWM_CHANNEL_B, HRPWM_MEP_DUTY_PERIOD_CTRL);
|
||||
HRPWM_setCounterCompareShadowLoadEvent(myEPWM1_BASE, HRPWM_CHANNEL_B, HRPWM_LOAD_ON_CNTR_ZERO);
|
||||
|
||||
//
|
||||
// Since we are not using the SFO the Auto Conversion
|
||||
// ***MUST*** be DISABLED .
|
||||
//
|
||||
HRPWM_disableAutoConversion(myEPWM1_BASE);
|
||||
|
||||
//
|
||||
// Turn off high-resolution period control.
|
||||
//
|
||||
|
||||
HRPWM_disablePeriodControl(myEPWM1_BASE);
|
||||
HRPWM_disablePhaseShiftLoad(myEPWM1_BASE);
|
||||
|
||||
}
|
||||
|
||||
//
|
||||
// error - Halt debugger when called
|
||||
//
|
||||
void error (void)
|
||||
{
|
||||
ESTOP0; // Stop here and handle error
|
||||
}
|
||||
|
||||
@@ -0,0 +1,24 @@
|
||||
/**
|
||||
* 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.epwm.$assign = "EPWM1";
|
||||
epwm1.epwm.epwmaPin.$assign = "GPIO0";
|
||||
epwm1.epwm.epwmbPin.$assign = "GPIO1";
|
||||
|
||||
inputxbar1.inputxbar1Gpio = "GPIO25";
|
||||
inputxbar1.$name = "myINPUTXBAR5";
|
||||
inputxbar1.inputsUsed = ["inputxbar5Gpio","inputxbar6Gpio"];
|
||||
inputxbar1.inputxbar5Gpio = "GPIO56";
|
||||
inputxbar1.inputxbar6Gpio = "GPIO56";
|
||||
@@ -0,0 +1,310 @@
|
||||
//#############################################################################
|
||||
//
|
||||
// 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.
|
||||
//
|
||||
//#############################################################################
|
||||
//
|
||||
//
|
||||
// $Copyright:
|
||||
// Copyright (C) 2014-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
|
||||
//
|
||||
#define EPWM_TIMER_TBPRD 20UL
|
||||
#define LAST_EPWM_INDEX_FOR_EXAMPLE 5
|
||||
#define MIN_HRPWM_PRD_PERCENT 0.2
|
||||
|
||||
//
|
||||
// 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 initHRPWM(uint32_t period);
|
||||
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();
|
||||
|
||||
//
|
||||
// Initialize EPWM GPIOs and change XBAR inputs from using 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.
|
||||
}
|
||||
|
||||
|
||||
|
||||
//
|
||||
// Disable sync(Freeze clock to PWM as well)
|
||||
//
|
||||
SysCtl_disablePeripheral(SYSCTL_PERIPH_CLK_TBCLKSYNC);
|
||||
|
||||
initHRPWM(EPWM_TIMER_TBPRD);
|
||||
|
||||
//
|
||||
// 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.
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
void initHRPWM(uint32_t period)
|
||||
{
|
||||
|
||||
uint16_t j;
|
||||
|
||||
//
|
||||
// ePWM channel register configuration with HRPWM
|
||||
//
|
||||
for (j=1;j<LAST_EPWM_INDEX_FOR_EXAMPLE;j++)
|
||||
{
|
||||
EPWM_setEmulationMode(ePWM[j], EPWM_EMULATION_FREE_RUN);
|
||||
|
||||
//
|
||||
// Set-up TBCLK
|
||||
//
|
||||
EPWM_setPeriodLoadMode(ePWM[j], EPWM_PERIOD_SHADOW_LOAD);
|
||||
EPWM_setTimeBasePeriod(ePWM[j], period-1);
|
||||
EPWM_setPhaseShift(ePWM[j], 0U);
|
||||
EPWM_setTimeBaseCounter(ePWM[j], 0U);
|
||||
|
||||
//
|
||||
// set duty 50% initially
|
||||
//
|
||||
HRPWM_setCounterCompareValue(ePWM[j], HRPWM_COUNTER_COMPARE_A, (period/2 << 8));
|
||||
HRPWM_setCounterCompareValue(ePWM[j], HRPWM_COUNTER_COMPARE_B, (period/2 << 8));
|
||||
|
||||
|
||||
//
|
||||
// Set up counter mode
|
||||
//
|
||||
EPWM_setTimeBaseCounterMode(ePWM[j], EPWM_COUNTER_MODE_UP_DOWN);
|
||||
EPWM_disablePhaseShiftLoad(ePWM[j]);
|
||||
EPWM_setClockPrescaler(ePWM[j],
|
||||
EPWM_CLOCK_DIVIDER_1,
|
||||
EPWM_HSCLOCK_DIVIDER_1);
|
||||
EPWM_setSyncOutPulseMode(ePWM[j], EPWM_SYNC_OUT_PULSE_DISABLED);
|
||||
|
||||
//
|
||||
// Set up shadowing
|
||||
//
|
||||
EPWM_setCounterCompareShadowLoadMode(ePWM[j],
|
||||
EPWM_COUNTER_COMPARE_A,
|
||||
EPWM_COMP_LOAD_ON_CNTR_ZERO);
|
||||
EPWM_setCounterCompareShadowLoadMode(ePWM[j],
|
||||
EPWM_COUNTER_COMPARE_B,
|
||||
EPWM_COMP_LOAD_ON_CNTR_ZERO);
|
||||
|
||||
//
|
||||
// Set actions
|
||||
//
|
||||
|
||||
EPWM_setActionQualifierAction(ePWM[j],
|
||||
EPWM_AQ_OUTPUT_A,
|
||||
EPWM_AQ_OUTPUT_HIGH,
|
||||
EPWM_AQ_OUTPUT_ON_TIMEBASE_UP_CMPA);
|
||||
|
||||
|
||||
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_A,
|
||||
EPWM_AQ_OUTPUT_LOW,
|
||||
EPWM_AQ_OUTPUT_ON_TIMEBASE_DOWN_CMPA);
|
||||
EPWM_setActionQualifierAction(ePWM[j],
|
||||
EPWM_AQ_OUTPUT_B,
|
||||
EPWM_AQ_OUTPUT_LOW,
|
||||
EPWM_AQ_OUTPUT_ON_TIMEBASE_DOWN_CMPB);
|
||||
|
||||
|
||||
HRPWM_setMEPEdgeSelect(ePWM[j], HRPWM_CHANNEL_A, HRPWM_MEP_CTRL_RISING_AND_FALLING_EDGE);
|
||||
HRPWM_setMEPControlMode(ePWM[j], HRPWM_CHANNEL_A, HRPWM_MEP_DUTY_PERIOD_CTRL);
|
||||
HRPWM_setCounterCompareShadowLoadEvent(ePWM[j], HRPWM_CHANNEL_A, HRPWM_LOAD_ON_CNTR_ZERO_PERIOD);
|
||||
|
||||
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);
|
||||
HRPWM_setCounterCompareShadowLoadEvent(ePWM[j], HRPWM_CHANNEL_B, HRPWM_LOAD_ON_CNTR_ZERO_PERIOD);
|
||||
|
||||
HRPWM_enableAutoConversion(ePWM[j]);
|
||||
|
||||
//
|
||||
// Turn on high-resolution period control.
|
||||
//
|
||||
|
||||
HRPWM_enablePeriodControl(ePWM[j]);
|
||||
HRPWM_enablePhaseShiftLoad(ePWM[j]);
|
||||
|
||||
EPWM_forceSyncPulse(ePWM[j]);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
//
|
||||
// error - Halt debugger when called
|
||||
//
|
||||
void error (void)
|
||||
{
|
||||
ESTOP0; // Stop here and handle error
|
||||
}
|
||||
|
||||
@@ -0,0 +1,42 @@
|
||||
/**
|
||||
* 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.epwm.$assign = "EPWM1";
|
||||
epwm1.epwm.epwmaPin.$assign = "GPIO0";
|
||||
epwm1.epwm.epwmbPin.$assign = "GPIO1";
|
||||
|
||||
epwm2.$name = "myEPWM2";
|
||||
epwm2.epwm.$assign = "EPWM2";
|
||||
epwm2.epwm.epwmaPin.$assign = "GPIO2";
|
||||
epwm2.epwm.epwmbPin.$assign = "GPIO3";
|
||||
|
||||
epwm3.$name = "myEPWM3";
|
||||
epwm3.epwm.$assign = "EPWM3";
|
||||
epwm3.epwm.epwmaPin.$assign = "GPIO4";
|
||||
epwm3.epwm.epwmbPin.$assign = "GPIO5";
|
||||
|
||||
epwm4.$name = "myEPWM4";
|
||||
epwm4.epwm.$assign = "EPWM4";
|
||||
epwm4.epwm.epwmaPin.$assign = "GPIO6";
|
||||
epwm4.epwm.epwmbPin.$assign = "GPIO7";
|
||||
|
||||
inputxbar1.inputxbar1Gpio = "GPIO25";
|
||||
inputxbar1.$name = "myINPUTXBAR5";
|
||||
inputxbar1.inputsUsed = ["inputxbar5Gpio","inputxbar6Gpio"];
|
||||
inputxbar1.inputxbar5Gpio = "GPIO56";
|
||||
inputxbar1.inputxbar6Gpio = "GPIO56";
|
||||
@@ -0,0 +1,411 @@
|
||||
//#############################################################################
|
||||
//
|
||||
// FILE: hrpwm_ex3_prdupdown_sfo.c
|
||||
//
|
||||
// TITLE: HRPWM Period Control.
|
||||
//
|
||||
//#############################################################################
|
||||
//
|
||||
// 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.
|
||||
//
|
||||
//#############################################################################
|
||||
//
|
||||
//
|
||||
// $Copyright:
|
||||
// Copyright (C) 2014-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 0
|
||||
#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(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);
|
||||
|
||||
//
|
||||
// Initialize the EPWM GPIOs and change XBAR inputs from using 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.
|
||||
}
|
||||
|
||||
|
||||
|
||||
//
|
||||
// Disable sync(Freeze clock to PWM as well)
|
||||
//
|
||||
SysCtl_disablePeripheral(SYSCTL_PERIPH_CLK_TBCLKSYNC);
|
||||
|
||||
initHRPWM(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(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++)
|
||||
{
|
||||
EPWM_setEmulationMode(ePWM[j], EPWM_EMULATION_FREE_RUN);
|
||||
|
||||
//
|
||||
// Set-up TBCLK
|
||||
//
|
||||
EPWM_setTimeBasePeriod(ePWM[j], period-1);
|
||||
EPWM_setPhaseShift(ePWM[j], 0U);
|
||||
EPWM_setTimeBaseCounter(ePWM[j], 0U);
|
||||
|
||||
//
|
||||
// set duty 50% initially
|
||||
//
|
||||
HRPWM_setCounterCompareValue(ePWM[j], HRPWM_COUNTER_COMPARE_A, (period/2 << 8) + 1);
|
||||
HRPWM_setCounterCompareValue(ePWM[j], HRPWM_COUNTER_COMPARE_B, (period/2 << 8) + 1);
|
||||
|
||||
|
||||
//
|
||||
// Set up counter mode
|
||||
//
|
||||
EPWM_setTimeBaseCounterMode(ePWM[j], EPWM_COUNTER_MODE_UP_DOWN);
|
||||
EPWM_disablePhaseShiftLoad(ePWM[j]);
|
||||
EPWM_setClockPrescaler(ePWM[j],
|
||||
EPWM_CLOCK_DIVIDER_1,
|
||||
EPWM_HSCLOCK_DIVIDER_1);
|
||||
EPWM_setSyncOutPulseMode(ePWM[j], EPWM_SYNC_OUT_PULSE_DISABLED);
|
||||
|
||||
//
|
||||
// Set up shadowing
|
||||
// MUST BE CTR=(ZER & PRD)
|
||||
//
|
||||
EPWM_setCounterCompareShadowLoadMode(ePWM[j],
|
||||
EPWM_COUNTER_COMPARE_A,
|
||||
EPWM_COMP_LOAD_ON_CNTR_ZERO_PERIOD);
|
||||
EPWM_setCounterCompareShadowLoadMode(ePWM[j],
|
||||
EPWM_COUNTER_COMPARE_B,
|
||||
EPWM_COMP_LOAD_ON_CNTR_ZERO_PERIOD);
|
||||
|
||||
//
|
||||
// Set actions
|
||||
//
|
||||
|
||||
EPWM_setActionQualifierAction(ePWM[j],
|
||||
EPWM_AQ_OUTPUT_A,
|
||||
EPWM_AQ_OUTPUT_HIGH,
|
||||
EPWM_AQ_OUTPUT_ON_TIMEBASE_UP_CMPA);
|
||||
EPWM_setActionQualifierAction(ePWM[j],
|
||||
EPWM_AQ_OUTPUT_A,
|
||||
EPWM_AQ_OUTPUT_LOW,
|
||||
EPWM_AQ_OUTPUT_ON_TIMEBASE_DOWN_CMPA);
|
||||
|
||||
#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
|
||||
|
||||
|
||||
HRPWM_setMEPEdgeSelect(ePWM[j], HRPWM_CHANNEL_A, HRPWM_MEP_CTRL_RISING_AND_FALLING_EDGE);
|
||||
HRPWM_setMEPControlMode(ePWM[j], HRPWM_CHANNEL_A, HRPWM_MEP_DUTY_PERIOD_CTRL);
|
||||
|
||||
//
|
||||
// Set up shadowing
|
||||
// MUST BE CTR=(ZER & PRD)
|
||||
//
|
||||
HRPWM_setCounterCompareShadowLoadEvent(ePWM[j], HRPWM_CHANNEL_A, HRPWM_LOAD_ON_CNTR_ZERO_PERIOD);
|
||||
|
||||
#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
|
||||
|
||||
HRPWM_enableAutoConversion(ePWM[j]);
|
||||
|
||||
//
|
||||
// Turn on high-resolution period control for DUTY to take HR on BOTH EDGEs.
|
||||
//
|
||||
|
||||
HRPWM_enablePeriodControl(ePWM[j]);
|
||||
HRPWM_disablePhaseShiftLoad(ePWM[j]);
|
||||
|
||||
|
||||
//
|
||||
// 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,43 @@
|
||||
/**
|
||||
* 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.epwm.$assign = "EPWM1";
|
||||
epwm1.epwm.epwmaPin.$assign = "GPIO0";
|
||||
epwm1.epwm.epwmbPin.$assign = "GPIO1";
|
||||
|
||||
epwm2.$name = "myEPWM2";
|
||||
epwm2.epwm.$assign = "EPWM2";
|
||||
epwm2.epwm.epwmaPin.$assign = "GPIO2";
|
||||
epwm2.epwm.epwmbPin.$assign = "GPIO3";
|
||||
|
||||
epwm3.$name = "myEPWM3";
|
||||
epwm3.epwm.$assign = "EPWM3";
|
||||
epwm3.epwm.epwmaPin.$assign = "GPIO4";
|
||||
epwm3.epwm.epwmbPin.$assign = "GPIO5";
|
||||
|
||||
epwm4.$name = "myEPWM4";
|
||||
epwm4.epwm.$assign = "EPWM4";
|
||||
epwm4.epwm.epwmaPin.$assign = "GPIO6";
|
||||
epwm4.epwm.epwmbPin.$assign = "GPIO7";
|
||||
|
||||
inputxbar1.inputxbar1Gpio = "GPIO25";
|
||||
inputxbar1.$name = "myINPUTXBAR5";
|
||||
inputxbar1.inputsUsed = ["inputxbar5Gpio","inputxbar6Gpio"];
|
||||
inputxbar1.inputxbar5Gpio = "GPIO56";
|
||||
inputxbar1.inputxbar6Gpio = "GPIO56";
|
||||
+305
@@ -0,0 +1,305 @@
|
||||
//#############################################################################
|
||||
//
|
||||
// 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.
|
||||
//
|
||||
//#############################################################################
|
||||
//
|
||||
//
|
||||
// $Copyright:
|
||||
// Copyright (C) 2014-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
|
||||
}
|
||||
+142
@@ -0,0 +1,142 @@
|
||||
/**
|
||||
* 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.epwmTimebase_syncOutPulseMode = "EPWM_SYNC_OUT_PULSE_DISABLED";
|
||||
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.epwm_aPin.$assign = "GPIO0";
|
||||
epwm1.epwm.epwm_bPin.$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.epwmTimebase_syncOutPulseMode = "EPWM_SYNC_OUT_PULSE_DISABLED";
|
||||
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.epwm_aPin.$assign = "GPIO2";
|
||||
epwm2.epwm.epwm_bPin.$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.epwmTimebase_syncOutPulseMode = "EPWM_SYNC_OUT_PULSE_DISABLED";
|
||||
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.epwm_aPin.$assign = "GPIO4";
|
||||
epwm3.epwm.epwm_bPin.$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.epwmTimebase_syncOutPulseMode = "EPWM_SYNC_OUT_PULSE_DISABLED";
|
||||
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.epwm_aPin.$assign = "GPIO6";
|
||||
epwm4.epwm.epwm_bPin.$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";
|
||||
Reference in New Issue
Block a user