Update repo
This commit is contained in:
1 parent
749dab5721
commit
ce65a0f59a
14950 files changed
+4408250
-1
No files matched your search
@@ -0,0 +1,40 @@
|
||||
<projectSpec>
|
||||
<project
|
||||
name="ecap_ex1_apwm"
|
||||
device="TMS320F28388D"
|
||||
cgtVersion="22.6.1.LTS"
|
||||
products="sysconfig;C2000WARE"
|
||||
outputFormat="ELF"
|
||||
launchWizard="False"
|
||||
linkerCommandFile=""
|
||||
enableSysConfigTool="true"
|
||||
sysConfigBuildOptions="--product ${C2000WARE_ROOT}/.metadata/sdk.json --device F2838x --package 337bga --part F2838x_337bga"
|
||||
postBuildStep="
|
||||
echo "========= Build of the CLB simulation has moved to the CLB Tool. Click the '?' icon by the _Generate CLB Simulation File_ enable for more details (located in the Global Parameters of the Tile Design SysConfig module) ============="
|
||||
;if ${GENERATE_DIAGRAM} == 1 ${NODE_TOOL} "${C2000WARE_ROOT}/utilities/clb_tool/clb_syscfg/dot_file_libraries/clbDotUtility.js" "${C2000WARE_ROOT}/utilities/clb_tool/clb_syscfg/" "${BuildDirectory}/syscfg" "${BuildDirectory}/syscfg/clb.dot"
|
||||
;if ${GENERATE_DIAGRAM} == 1 mkdir "${BuildDirectory}/diagrams"
|
||||
;if ${GENERATE_DIAGRAM} == 1 ${NODE_TOOL} "${C2000WARE_ROOT}/driverlib/.meta/generate_diagrams.js" "${C2000WARE_ROOT}" "${BuildDirectory}/diagrams" "${BuildDirectory}/syscfg"
|
||||
"
|
||||
>
|
||||
<configuration name="CPU1_RAM" compilerBuildOptions= "--opt_level=off -I${C2000WARE_ROOT} -I${PROJECT_ROOT}/device -I${C2000WARE_DLIB_ROOT} -v28 -ml -mt --cla_support=cla2 --define=RAM --float_support=fpu64 --tmu_support=tmu0 --define=DEBUG --define=CPU1 --gen_func_subsections=on --diag_warning=225 --diag_suppress=10063" linkerBuildOptions="--entry_point code_start --stack_size=0x3F8 --heap_size=0x200 --define=RAM -i${C2000WARE_ROOT} -i${PROJECT_BUILD_DIR}/syscfg -lc2000ware_libraries.cmd.genlibs " />
|
||||
<configuration name="CPU1_FLASH" compilerBuildOptions="--opt_level=off -I${C2000WARE_ROOT} -I${PROJECT_ROOT}/device -I${C2000WARE_DLIB_ROOT} --define=_FLASH -v28 -ml -mt --cla_support=cla2 --float_support=fpu64 --tmu_support=tmu0 --define=DEBUG --define=CPU1 --gen_func_subsections=on --diag_warning=225 --diag_suppress=10063" linkerBuildOptions="--entry_point code_start --stack_size=0x3F8 --heap_size=0x200 --define=_FLASH -i${C2000WARE_ROOT} -i${PROJECT_BUILD_DIR}/syscfg -lc2000ware_libraries.cmd.genlibs " />
|
||||
|
||||
<pathVariable name="C2000WARE_DLIB_ROOT" path="../../../../../../driverlib/f2838x/driverlib/" scope="project" />
|
||||
<pathVariable name="C2000WARE_ROOT" path="../../../../../../" scope="project" />
|
||||
<pathVariable name="CLB_SYSCFG_ROOT" path="../../../../../../utilities/clb_tool/clb_syscfg/" scope="project" />
|
||||
<pathVariable name="SYSTEMC_INSTALL" path="../../../../../../utilities/clb_tool/clb_syscfg/systemc-2.3.3" scope="project" />
|
||||
<pathVariable name="CLB_SIM_COMPILER" path="C:/TDM-GCC-64/bin" scope="project" />
|
||||
<buildVariable name="GENERATE_DIAGRAM" value="0" scope="project" />
|
||||
<file action="copy" path="../../../../../../device_support/f2838x/common/include/driverlib.h" targetDirectory="device" />
|
||||
<file action="copy" path="../../../../../../device_support/f2838x/common/include/device.h" targetDirectory="device" />
|
||||
<file action="copy" path="../../../../../../device_support/f2838x/common/source/device.c" targetDirectory="device" />
|
||||
<file action="copy" path="../../../../../../device_support/f2838x/common/targetConfigs/TMS320F28388D.ccxml" targetDirectory="targetConfigs" />
|
||||
<file action="copy" path="../../../../../../device_support/f2838x/common/cmd/2838x_RAM_lnk_cpu1.cmd" targetDirectory="" applicableConfigurations="CPU1_RAM" />
|
||||
<file action="copy" path="../../../../../../device_support/f2838x/common/cmd/2838x_FLASH_lnk_cpu1.cmd" targetDirectory="" applicableConfigurations="CPU1_FLASH" />
|
||||
<file action="copy" path="../../../../../../device_support/f2838x/common/source/f2838x_codestartbranch.asm" targetDirectory="device" />
|
||||
<file action="link" path="../../../../../../driverlib/f2838x/driverlib/ccs/Debug/driverlib.lib" targetDirectory="" />
|
||||
<file action="copy" path="../../../../../../driverlib/f2838x/driverlib/" targetDirectory="device" excludeFromBuild="True" />
|
||||
<file action="copy" path="../ecap_ex1_apwm.c" targetDirectory=""/>
|
||||
<file action="copy" path="../ecap_ex1_apwm.syscfg" targetDirectory=""/>
|
||||
</project>
|
||||
</projectSpec>
|
||||
@@ -0,0 +1,40 @@
|
||||
<projectSpec>
|
||||
<project
|
||||
name="ecap_ex2_capture_pwm"
|
||||
device="TMS320F28388D"
|
||||
cgtVersion="22.6.1.LTS"
|
||||
products="sysconfig;C2000WARE"
|
||||
outputFormat="ELF"
|
||||
launchWizard="False"
|
||||
linkerCommandFile=""
|
||||
enableSysConfigTool="true"
|
||||
sysConfigBuildOptions="--product ${C2000WARE_ROOT}/.metadata/sdk.json --device F2838x --package 337bga --part F2838x_337bga"
|
||||
postBuildStep="
|
||||
echo "========= Build of the CLB simulation has moved to the CLB Tool. Click the '?' icon by the _Generate CLB Simulation File_ enable for more details (located in the Global Parameters of the Tile Design SysConfig module) ============="
|
||||
;if ${GENERATE_DIAGRAM} == 1 ${NODE_TOOL} "${C2000WARE_ROOT}/utilities/clb_tool/clb_syscfg/dot_file_libraries/clbDotUtility.js" "${C2000WARE_ROOT}/utilities/clb_tool/clb_syscfg/" "${BuildDirectory}/syscfg" "${BuildDirectory}/syscfg/clb.dot"
|
||||
;if ${GENERATE_DIAGRAM} == 1 mkdir "${BuildDirectory}/diagrams"
|
||||
;if ${GENERATE_DIAGRAM} == 1 ${NODE_TOOL} "${C2000WARE_ROOT}/driverlib/.meta/generate_diagrams.js" "${C2000WARE_ROOT}" "${BuildDirectory}/diagrams" "${BuildDirectory}/syscfg"
|
||||
"
|
||||
>
|
||||
<configuration name="CPU1_RAM" compilerBuildOptions= "--opt_level=off -I${C2000WARE_ROOT} -I${PROJECT_ROOT}/device -I${C2000WARE_DLIB_ROOT} -v28 -ml -mt --cla_support=cla2 --define=RAM --float_support=fpu64 --tmu_support=tmu0 --define=DEBUG --define=CPU1 --gen_func_subsections=on --diag_warning=225 --diag_suppress=10063" linkerBuildOptions="--entry_point code_start --stack_size=0x3F8 --heap_size=0x200 --define=RAM -i${C2000WARE_ROOT} -i${PROJECT_BUILD_DIR}/syscfg -lc2000ware_libraries.cmd.genlibs " />
|
||||
<configuration name="CPU1_FLASH" compilerBuildOptions="--opt_level=off -I${C2000WARE_ROOT} -I${PROJECT_ROOT}/device -I${C2000WARE_DLIB_ROOT} --define=_FLASH -v28 -ml -mt --cla_support=cla2 --float_support=fpu64 --tmu_support=tmu0 --define=DEBUG --define=CPU1 --gen_func_subsections=on --diag_warning=225 --diag_suppress=10063" linkerBuildOptions="--entry_point code_start --stack_size=0x3F8 --heap_size=0x200 --define=_FLASH -i${C2000WARE_ROOT} -i${PROJECT_BUILD_DIR}/syscfg -lc2000ware_libraries.cmd.genlibs " />
|
||||
|
||||
<pathVariable name="C2000WARE_DLIB_ROOT" path="../../../../../../driverlib/f2838x/driverlib/" scope="project" />
|
||||
<pathVariable name="C2000WARE_ROOT" path="../../../../../../" scope="project" />
|
||||
<pathVariable name="CLB_SYSCFG_ROOT" path="../../../../../../utilities/clb_tool/clb_syscfg/" scope="project" />
|
||||
<pathVariable name="SYSTEMC_INSTALL" path="../../../../../../utilities/clb_tool/clb_syscfg/systemc-2.3.3" scope="project" />
|
||||
<pathVariable name="CLB_SIM_COMPILER" path="C:/TDM-GCC-64/bin" scope="project" />
|
||||
<buildVariable name="GENERATE_DIAGRAM" value="0" scope="project" />
|
||||
<file action="copy" path="../../../../../../device_support/f2838x/common/include/driverlib.h" targetDirectory="device" />
|
||||
<file action="copy" path="../../../../../../device_support/f2838x/common/include/device.h" targetDirectory="device" />
|
||||
<file action="copy" path="../../../../../../device_support/f2838x/common/source/device.c" targetDirectory="device" />
|
||||
<file action="copy" path="../../../../../../device_support/f2838x/common/targetConfigs/TMS320F28388D.ccxml" targetDirectory="targetConfigs" />
|
||||
<file action="copy" path="../../../../../../device_support/f2838x/common/cmd/2838x_RAM_lnk_cpu1.cmd" targetDirectory="" applicableConfigurations="CPU1_RAM" />
|
||||
<file action="copy" path="../../../../../../device_support/f2838x/common/cmd/2838x_FLASH_lnk_cpu1.cmd" targetDirectory="" applicableConfigurations="CPU1_FLASH" />
|
||||
<file action="copy" path="../../../../../../device_support/f2838x/common/source/f2838x_codestartbranch.asm" targetDirectory="device" />
|
||||
<file action="link" path="../../../../../../driverlib/f2838x/driverlib/ccs/Debug/driverlib.lib" targetDirectory="" />
|
||||
<file action="copy" path="../../../../../../driverlib/f2838x/driverlib/" targetDirectory="device" excludeFromBuild="True" />
|
||||
<file action="copy" path="../ecap_ex2_capture_pwm.c" targetDirectory=""/>
|
||||
<file action="copy" path="../ecap_ex2_capture_pwm.syscfg" targetDirectory=""/>
|
||||
</project>
|
||||
</projectSpec>
|
||||
+40
@@ -0,0 +1,40 @@
|
||||
<projectSpec>
|
||||
<project
|
||||
name="ecap_ex3_apwm_phase_shift"
|
||||
device="TMS320F28388D"
|
||||
cgtVersion="22.6.1.LTS"
|
||||
products="sysconfig;C2000WARE"
|
||||
outputFormat="ELF"
|
||||
launchWizard="False"
|
||||
linkerCommandFile=""
|
||||
enableSysConfigTool="true"
|
||||
sysConfigBuildOptions="--product ${C2000WARE_ROOT}/.metadata/sdk.json --device F2838x --package 337bga --part F2838x_337bga"
|
||||
postBuildStep="
|
||||
echo "========= Build of the CLB simulation has moved to the CLB Tool. Click the '?' icon by the _Generate CLB Simulation File_ enable for more details (located in the Global Parameters of the Tile Design SysConfig module) ============="
|
||||
;if ${GENERATE_DIAGRAM} == 1 ${NODE_TOOL} "${C2000WARE_ROOT}/utilities/clb_tool/clb_syscfg/dot_file_libraries/clbDotUtility.js" "${C2000WARE_ROOT}/utilities/clb_tool/clb_syscfg/" "${BuildDirectory}/syscfg" "${BuildDirectory}/syscfg/clb.dot"
|
||||
;if ${GENERATE_DIAGRAM} == 1 mkdir "${BuildDirectory}/diagrams"
|
||||
;if ${GENERATE_DIAGRAM} == 1 ${NODE_TOOL} "${C2000WARE_ROOT}/driverlib/.meta/generate_diagrams.js" "${C2000WARE_ROOT}" "${BuildDirectory}/diagrams" "${BuildDirectory}/syscfg"
|
||||
"
|
||||
>
|
||||
<configuration name="CPU1_RAM" compilerBuildOptions= "--opt_level=off -I${C2000WARE_ROOT} -I${PROJECT_ROOT}/device -I${C2000WARE_DLIB_ROOT} -v28 -ml -mt --cla_support=cla2 --define=RAM --float_support=fpu64 --tmu_support=tmu0 --define=DEBUG --define=CPU1 --gen_func_subsections=on --diag_warning=225 --diag_suppress=10063" linkerBuildOptions="--entry_point code_start --stack_size=0x3F8 --heap_size=0x200 --define=RAM -i${C2000WARE_ROOT} -i${PROJECT_BUILD_DIR}/syscfg -lc2000ware_libraries.cmd.genlibs " />
|
||||
<configuration name="CPU1_FLASH" compilerBuildOptions="--opt_level=off -I${C2000WARE_ROOT} -I${PROJECT_ROOT}/device -I${C2000WARE_DLIB_ROOT} --define=_FLASH -v28 -ml -mt --cla_support=cla2 --float_support=fpu64 --tmu_support=tmu0 --define=DEBUG --define=CPU1 --gen_func_subsections=on --diag_warning=225 --diag_suppress=10063" linkerBuildOptions="--entry_point code_start --stack_size=0x3F8 --heap_size=0x200 --define=_FLASH -i${C2000WARE_ROOT} -i${PROJECT_BUILD_DIR}/syscfg -lc2000ware_libraries.cmd.genlibs " />
|
||||
|
||||
<pathVariable name="C2000WARE_DLIB_ROOT" path="../../../../../../driverlib/f2838x/driverlib/" scope="project" />
|
||||
<pathVariable name="C2000WARE_ROOT" path="../../../../../../" scope="project" />
|
||||
<pathVariable name="CLB_SYSCFG_ROOT" path="../../../../../../utilities/clb_tool/clb_syscfg/" scope="project" />
|
||||
<pathVariable name="SYSTEMC_INSTALL" path="../../../../../../utilities/clb_tool/clb_syscfg/systemc-2.3.3" scope="project" />
|
||||
<pathVariable name="CLB_SIM_COMPILER" path="C:/TDM-GCC-64/bin" scope="project" />
|
||||
<buildVariable name="GENERATE_DIAGRAM" value="0" scope="project" />
|
||||
<file action="copy" path="../../../../../../device_support/f2838x/common/include/driverlib.h" targetDirectory="device" />
|
||||
<file action="copy" path="../../../../../../device_support/f2838x/common/include/device.h" targetDirectory="device" />
|
||||
<file action="copy" path="../../../../../../device_support/f2838x/common/source/device.c" targetDirectory="device" />
|
||||
<file action="copy" path="../../../../../../device_support/f2838x/common/targetConfigs/TMS320F28388D.ccxml" targetDirectory="targetConfigs" />
|
||||
<file action="copy" path="../../../../../../device_support/f2838x/common/cmd/2838x_RAM_lnk_cpu1.cmd" targetDirectory="" applicableConfigurations="CPU1_RAM" />
|
||||
<file action="copy" path="../../../../../../device_support/f2838x/common/cmd/2838x_FLASH_lnk_cpu1.cmd" targetDirectory="" applicableConfigurations="CPU1_FLASH" />
|
||||
<file action="copy" path="../../../../../../device_support/f2838x/common/source/f2838x_codestartbranch.asm" targetDirectory="device" />
|
||||
<file action="link" path="../../../../../../driverlib/f2838x/driverlib/ccs/Debug/driverlib.lib" targetDirectory="" />
|
||||
<file action="copy" path="../../../../../../driverlib/f2838x/driverlib/" targetDirectory="device" excludeFromBuild="True" />
|
||||
<file action="copy" path="../ecap_ex3_apwm_phase_shift.c" targetDirectory=""/>
|
||||
<file action="copy" path="../ecap_ex3_apwm_phase_shift.syscfg" targetDirectory=""/>
|
||||
</project>
|
||||
</projectSpec>
|
||||
@@ -0,0 +1,40 @@
|
||||
<projectSpec>
|
||||
<project
|
||||
name="ecap_ex4_sw_sync"
|
||||
device="TMS320F28388D"
|
||||
cgtVersion="22.6.1.LTS"
|
||||
products="sysconfig;C2000WARE"
|
||||
outputFormat="ELF"
|
||||
launchWizard="False"
|
||||
linkerCommandFile=""
|
||||
enableSysConfigTool="true"
|
||||
sysConfigBuildOptions="--product ${C2000WARE_ROOT}/.metadata/sdk.json --device F2838x --package 337bga --part F2838x_337bga"
|
||||
postBuildStep="
|
||||
echo "========= Build of the CLB simulation has moved to the CLB Tool. Click the '?' icon by the _Generate CLB Simulation File_ enable for more details (located in the Global Parameters of the Tile Design SysConfig module) ============="
|
||||
;if ${GENERATE_DIAGRAM} == 1 ${NODE_TOOL} "${C2000WARE_ROOT}/utilities/clb_tool/clb_syscfg/dot_file_libraries/clbDotUtility.js" "${C2000WARE_ROOT}/utilities/clb_tool/clb_syscfg/" "${BuildDirectory}/syscfg" "${BuildDirectory}/syscfg/clb.dot"
|
||||
;if ${GENERATE_DIAGRAM} == 1 mkdir "${BuildDirectory}/diagrams"
|
||||
;if ${GENERATE_DIAGRAM} == 1 ${NODE_TOOL} "${C2000WARE_ROOT}/driverlib/.meta/generate_diagrams.js" "${C2000WARE_ROOT}" "${BuildDirectory}/diagrams" "${BuildDirectory}/syscfg"
|
||||
"
|
||||
>
|
||||
<configuration name="CPU1_RAM" compilerBuildOptions= "--opt_level=off -I${C2000WARE_ROOT} -I${PROJECT_ROOT}/device -I${C2000WARE_DLIB_ROOT} -v28 -ml -mt --cla_support=cla2 --define=RAM --float_support=fpu64 --tmu_support=tmu0 --define=DEBUG --define=CPU1 --gen_func_subsections=on --diag_warning=225 --diag_suppress=10063" linkerBuildOptions="--entry_point code_start --stack_size=0x3F8 --heap_size=0x200 --define=RAM -i${C2000WARE_ROOT} -i${PROJECT_BUILD_DIR}/syscfg -lc2000ware_libraries.cmd.genlibs " />
|
||||
<configuration name="CPU1_FLASH" compilerBuildOptions="--opt_level=off -I${C2000WARE_ROOT} -I${PROJECT_ROOT}/device -I${C2000WARE_DLIB_ROOT} --define=_FLASH -v28 -ml -mt --cla_support=cla2 --float_support=fpu64 --tmu_support=tmu0 --define=DEBUG --define=CPU1 --gen_func_subsections=on --diag_warning=225 --diag_suppress=10063" linkerBuildOptions="--entry_point code_start --stack_size=0x3F8 --heap_size=0x200 --define=_FLASH -i${C2000WARE_ROOT} -i${PROJECT_BUILD_DIR}/syscfg -lc2000ware_libraries.cmd.genlibs " />
|
||||
|
||||
<pathVariable name="C2000WARE_DLIB_ROOT" path="../../../../../../driverlib/f2838x/driverlib/" scope="project" />
|
||||
<pathVariable name="C2000WARE_ROOT" path="../../../../../../" scope="project" />
|
||||
<pathVariable name="CLB_SYSCFG_ROOT" path="../../../../../../utilities/clb_tool/clb_syscfg/" scope="project" />
|
||||
<pathVariable name="SYSTEMC_INSTALL" path="../../../../../../utilities/clb_tool/clb_syscfg/systemc-2.3.3" scope="project" />
|
||||
<pathVariable name="CLB_SIM_COMPILER" path="C:/TDM-GCC-64/bin" scope="project" />
|
||||
<buildVariable name="GENERATE_DIAGRAM" value="0" scope="project" />
|
||||
<file action="copy" path="../../../../../../device_support/f2838x/common/include/driverlib.h" targetDirectory="device" />
|
||||
<file action="copy" path="../../../../../../device_support/f2838x/common/include/device.h" targetDirectory="device" />
|
||||
<file action="copy" path="../../../../../../device_support/f2838x/common/source/device.c" targetDirectory="device" />
|
||||
<file action="copy" path="../../../../../../device_support/f2838x/common/targetConfigs/TMS320F28388D.ccxml" targetDirectory="targetConfigs" />
|
||||
<file action="copy" path="../../../../../../device_support/f2838x/common/cmd/2838x_RAM_lnk_cpu1.cmd" targetDirectory="" applicableConfigurations="CPU1_RAM" />
|
||||
<file action="copy" path="../../../../../../device_support/f2838x/common/cmd/2838x_FLASH_lnk_cpu1.cmd" targetDirectory="" applicableConfigurations="CPU1_FLASH" />
|
||||
<file action="copy" path="../../../../../../device_support/f2838x/common/source/f2838x_codestartbranch.asm" targetDirectory="device" />
|
||||
<file action="link" path="../../../../../../driverlib/f2838x/driverlib/ccs/Debug/driverlib.lib" targetDirectory="" />
|
||||
<file action="copy" path="../../../../../../driverlib/f2838x/driverlib/" targetDirectory="device" excludeFromBuild="True" />
|
||||
<file action="copy" path="../ecap_ex4_sw_sync.c" targetDirectory=""/>
|
||||
<file action="copy" path="../ecap_ex4_sw_sync.syscfg" targetDirectory=""/>
|
||||
</project>
|
||||
</projectSpec>
|
||||
@@ -0,0 +1,137 @@
|
||||
//#############################################################################
|
||||
//
|
||||
// FILE: ecap_ex1_apwm.c
|
||||
//
|
||||
// TITLE: eCAP APWM Example.
|
||||
//
|
||||
//! \addtogroup driver_example_list
|
||||
//! <h1>eCAP APWM Example</h1>
|
||||
//!
|
||||
//! This program sets up the eCAP module in APWM mode. The PWM waveform will
|
||||
//! come out on GPIO5. The frequency of PWM is configured to vary between 10Hz
|
||||
//! and 20Hz using the shadow registers to load the next period/compare values.
|
||||
//!
|
||||
//
|
||||
//#############################################################################
|
||||
//
|
||||
//
|
||||
//
|
||||
// C2000Ware v5.04.00.00
|
||||
//
|
||||
// Copyright (C) 2024 Texas Instruments Incorporated - http://www.ti.com
|
||||
//
|
||||
// Redistribution and use in source and binary forms, with or without
|
||||
// modification, are permitted provided that the following conditions
|
||||
// are met:
|
||||
//
|
||||
// Redistributions of source code must retain the above copyright
|
||||
// notice, this list of conditions and the following disclaimer.
|
||||
//
|
||||
// Redistributions in binary form must reproduce the above copyright
|
||||
// notice, this list of conditions and the following disclaimer in the
|
||||
// documentation and/or other materials provided with the
|
||||
// distribution.
|
||||
//
|
||||
// Neither the name of Texas Instruments Incorporated nor the names of
|
||||
// its contributors may be used to endorse or promote products derived
|
||||
// from this software without specific prior written permission.
|
||||
//
|
||||
// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
|
||||
// "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
|
||||
// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
|
||||
// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
|
||||
// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
|
||||
// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
|
||||
// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
|
||||
// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
|
||||
// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
||||
// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
|
||||
// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
// $
|
||||
//#############################################################################
|
||||
|
||||
//
|
||||
// Included Files
|
||||
//
|
||||
#include "driverlib.h"
|
||||
#include "device.h"
|
||||
#include "board.h"
|
||||
|
||||
//
|
||||
// Defines
|
||||
//
|
||||
#define DECREASE_FREQUENCY 0
|
||||
#define INCREASE_FREQUENCY 1
|
||||
|
||||
//
|
||||
// Globals
|
||||
//
|
||||
uint16_t direction;
|
||||
volatile uint32_t cap1Count;
|
||||
|
||||
//
|
||||
// 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();
|
||||
|
||||
//
|
||||
// Board initialization
|
||||
// Select eCAP1OUT on MUX 0. Make GPIO5 eCAP1OUT for PWM output
|
||||
// Configure eCAP in APWM mode
|
||||
//
|
||||
Board_init();
|
||||
|
||||
for(;;)
|
||||
{
|
||||
//
|
||||
// Set the duty cycle to 50%
|
||||
//
|
||||
ECAP_setAPWMShadowCompare(myECAP0_BASE,
|
||||
(ECAP_getEventTimeStamp(myECAP0_BASE, ECAP_EVENT_1) >> 1U));
|
||||
|
||||
cap1Count = ECAP_getEventTimeStamp(myECAP0_BASE, ECAP_EVENT_1);
|
||||
|
||||
//
|
||||
// Vary frequency
|
||||
//
|
||||
if(cap1Count >= 20000000U)
|
||||
{
|
||||
direction = INCREASE_FREQUENCY;
|
||||
}
|
||||
else if (cap1Count <= 10000000U)
|
||||
{
|
||||
direction = DECREASE_FREQUENCY;
|
||||
}
|
||||
|
||||
if(direction == INCREASE_FREQUENCY)
|
||||
{
|
||||
ECAP_setAPWMShadowPeriod(myECAP0_BASE, (cap1Count - 500000U));
|
||||
}
|
||||
else
|
||||
{
|
||||
ECAP_setAPWMShadowPeriod(myECAP0_BASE, (cap1Count + 500000U));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -0,0 +1,22 @@
|
||||
|
||||
/**
|
||||
* Import the modules used in this configuration.
|
||||
*/
|
||||
const ecap = scripting.addModule("/driverlib/ecap.js", {}, false);
|
||||
const ecap1 = ecap.addInstance();
|
||||
const outputxbar = scripting.addModule("/driverlib/outputxbar.js", {}, false);
|
||||
const outputxbar1 = outputxbar.addInstance();
|
||||
|
||||
/**
|
||||
* Write custom configuration values to the imported modules.
|
||||
*/
|
||||
ecap1.$name = "myECAP0";
|
||||
ecap1.ecapMode = "APWM";
|
||||
ecap1.apwmPeriod = 20000000;
|
||||
ecap1.apwmCompare = 10000000;
|
||||
|
||||
outputxbar1.$name = "myOUTPUTXBAR0";
|
||||
outputxbar1.muxesUsed = ["XBAR_MUX00"];
|
||||
outputxbar1.mux0Config = "XBAR_OUT_MUX00_ECAP1_OUT";
|
||||
outputxbar1.outputxbar.$assign = "OUTPUTXBAR3";
|
||||
outputxbar1.outputxbar.outputxbarPin.$assign = "GPIO5";
|
||||
@@ -0,0 +1,298 @@
|
||||
//#############################################################################
|
||||
//
|
||||
// FILE: ecap_capture_pwm.c
|
||||
//
|
||||
// TITLE: Capture ePWM3.
|
||||
//
|
||||
//! \addtogroup driver_example_list
|
||||
//! <h1>eCAP Capture PWM Example</h1>
|
||||
//!
|
||||
//! This example configures ePWM3A for:
|
||||
//! - Up count mode
|
||||
//! - Period starts at 500 and goes up to 8000
|
||||
//! - Toggle output on PRD
|
||||
//!
|
||||
//! eCAP1 is configured to capture the time between rising
|
||||
//! and falling edge of the ePWM3A output.
|
||||
//!
|
||||
//! \b External \b Connections \n
|
||||
//! - eCAP1 is on GPIO16
|
||||
//! - ePWM3A is on GPIO4
|
||||
//! - Connect GPIO4 to GPIO16.
|
||||
//!
|
||||
//! \b Watch \b Variables \n
|
||||
//! - \b ecap1PassCount - Successful captures.
|
||||
//! - \b ecap1IntCount - Interrupt counts.
|
||||
//
|
||||
//#############################################################################
|
||||
//
|
||||
//
|
||||
//
|
||||
// C2000Ware v5.04.00.00
|
||||
//
|
||||
// Copyright (C) 2024 Texas Instruments Incorporated - http://www.ti.com
|
||||
//
|
||||
// Redistribution and use in source and binary forms, with or without
|
||||
// modification, are permitted provided that the following conditions
|
||||
// are met:
|
||||
//
|
||||
// Redistributions of source code must retain the above copyright
|
||||
// notice, this list of conditions and the following disclaimer.
|
||||
//
|
||||
// Redistributions in binary form must reproduce the above copyright
|
||||
// notice, this list of conditions and the following disclaimer in the
|
||||
// documentation and/or other materials provided with the
|
||||
// distribution.
|
||||
//
|
||||
// Neither the name of Texas Instruments Incorporated nor the names of
|
||||
// its contributors may be used to endorse or promote products derived
|
||||
// from this software without specific prior written permission.
|
||||
//
|
||||
// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
|
||||
// "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
|
||||
// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
|
||||
// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
|
||||
// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
|
||||
// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
|
||||
// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
|
||||
// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
|
||||
// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
||||
// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
|
||||
// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
// $
|
||||
//#############################################################################
|
||||
|
||||
//
|
||||
// Included Files
|
||||
//
|
||||
#include "driverlib.h"
|
||||
#include "device.h"
|
||||
#include "board.h"
|
||||
|
||||
//
|
||||
// Defines
|
||||
//
|
||||
#define PWM3_TIMER_MIN 500U
|
||||
#define PWM3_TIMER_MAX 8000U
|
||||
#define EPWM_TIMER_UP 1U
|
||||
#define EPWM_TIMER_DOWN 0U
|
||||
|
||||
//
|
||||
// Globals
|
||||
//
|
||||
uint32_t ecap1IntCount;
|
||||
uint32_t ecap1PassCount;
|
||||
uint32_t epwm3TimerDirection;
|
||||
volatile uint32_t cap2Count;
|
||||
volatile uint32_t cap3Count;
|
||||
volatile uint32_t cap4Count;
|
||||
volatile uint16_t epwm3PeriodCount;
|
||||
|
||||
//
|
||||
// Function Prototypes
|
||||
//
|
||||
void error(void);
|
||||
void initECAP(void);
|
||||
void initEPWM(void);
|
||||
|
||||
//
|
||||
// Main
|
||||
//
|
||||
void main(void)
|
||||
{
|
||||
//
|
||||
// Initialize device clock and peripherals
|
||||
//
|
||||
Device_init();
|
||||
|
||||
//
|
||||
// Disable pin locks and enable internal pullups.
|
||||
//
|
||||
Device_initGPIO();
|
||||
|
||||
//
|
||||
// Initialize PIE and clear PIE registers. Disables CPU interrupts.
|
||||
//
|
||||
Interrupt_initModule();
|
||||
|
||||
//
|
||||
// Initialize the PIE vector table with pointers to the shell Interrupt
|
||||
// Service Routines (ISR).
|
||||
//
|
||||
Interrupt_initVectorTable();
|
||||
|
||||
//
|
||||
// Configure GPIO4/5 as ePWM3A/3B
|
||||
//
|
||||
GPIO_setPadConfig(4,GPIO_PIN_TYPE_STD);
|
||||
GPIO_setPinConfig(GPIO_4_EPWM3A);
|
||||
GPIO_setPadConfig(5,GPIO_PIN_TYPE_STD);
|
||||
GPIO_setPinConfig(GPIO_5_EPWM3B);
|
||||
|
||||
//
|
||||
// Board initialization
|
||||
// Configure GPIO 16 as eCAP input
|
||||
// Enable interrupts required for this example
|
||||
//
|
||||
Board_init();
|
||||
|
||||
//
|
||||
// Configure ePWM
|
||||
//
|
||||
initEPWM();
|
||||
|
||||
//
|
||||
// Initialize counters:
|
||||
//
|
||||
cap2Count = 0U;
|
||||
cap3Count = 0U;
|
||||
cap4Count = 0U;
|
||||
ecap1IntCount = 0U;
|
||||
ecap1PassCount = 0U;
|
||||
epwm3PeriodCount = 0U;
|
||||
|
||||
//
|
||||
// Enable Global Interrupt (INTM) and Real time interrupt (DBGM)
|
||||
//
|
||||
EINT;
|
||||
ERTM;
|
||||
|
||||
//
|
||||
// Loop forever. Suspend or place breakpoints to observe the buffers.
|
||||
//
|
||||
for(;;)
|
||||
{
|
||||
NOP;
|
||||
}
|
||||
}
|
||||
|
||||
//
|
||||
// initEPWM - Configure ePWM
|
||||
//
|
||||
void initEPWM()
|
||||
{
|
||||
//
|
||||
// Disable sync(Freeze clock to PWM as well)
|
||||
//
|
||||
SysCtl_disablePeripheral(SYSCTL_PERIPH_CLK_TBCLKSYNC);
|
||||
|
||||
//
|
||||
// Configure ePWM
|
||||
// Counter runs in up-count mode.
|
||||
// Action qualifier will toggle output on period match
|
||||
//
|
||||
EPWM_setTimeBaseCounterMode(EPWM3_BASE, EPWM_COUNTER_MODE_UP);
|
||||
EPWM_setTimeBasePeriod(EPWM3_BASE, PWM3_TIMER_MIN);
|
||||
EPWM_setPhaseShift(EPWM3_BASE, 0U);
|
||||
EPWM_setActionQualifierAction(EPWM3_BASE,
|
||||
EPWM_AQ_OUTPUT_A,
|
||||
EPWM_AQ_OUTPUT_TOGGLE,
|
||||
EPWM_AQ_OUTPUT_ON_TIMEBASE_PERIOD);
|
||||
EPWM_setClockPrescaler(EPWM3_BASE,
|
||||
EPWM_CLOCK_DIVIDER_1,
|
||||
EPWM_HSCLOCK_DIVIDER_2);
|
||||
|
||||
epwm3TimerDirection = EPWM_TIMER_UP;
|
||||
|
||||
//
|
||||
// Enable sync and clock to PWM
|
||||
//
|
||||
SysCtl_enablePeripheral(SYSCTL_PERIPH_CLK_TBCLKSYNC);
|
||||
}
|
||||
|
||||
//
|
||||
// myECAP0 ISR
|
||||
//
|
||||
__interrupt void INT_myECAP0_ISR(void)
|
||||
{
|
||||
//
|
||||
// Get the capture counts. Each capture should be 4x the ePWM count
|
||||
// because of the ePWM clock divider.
|
||||
//
|
||||
cap2Count = ECAP_getEventTimeStamp(myECAP0_BASE, ECAP_EVENT_2);
|
||||
cap3Count = ECAP_getEventTimeStamp(myECAP0_BASE, ECAP_EVENT_3);
|
||||
cap4Count = ECAP_getEventTimeStamp(myECAP0_BASE, ECAP_EVENT_4);
|
||||
|
||||
//
|
||||
// Compare the period value with the captured count
|
||||
//
|
||||
epwm3PeriodCount = EPWM_getTimeBasePeriod(EPWM3_BASE);
|
||||
|
||||
if(cap2Count > ((epwm3PeriodCount *4) + 4) ||
|
||||
cap2Count < ((epwm3PeriodCount *4) - 4))
|
||||
{
|
||||
error();
|
||||
}
|
||||
|
||||
if(cap3Count > ((epwm3PeriodCount *4) + 4) ||
|
||||
cap3Count < ((epwm3PeriodCount *4) - 4))
|
||||
{
|
||||
error();
|
||||
}
|
||||
|
||||
if(cap4Count > ((epwm3PeriodCount *4) + 4) ||
|
||||
cap4Count < ((epwm3PeriodCount *4) - 4))
|
||||
{
|
||||
error();
|
||||
}
|
||||
|
||||
ecap1IntCount++;
|
||||
|
||||
//
|
||||
// Keep track of the ePWM direction and adjust period accordingly to
|
||||
// generate a variable frequency PWM.
|
||||
//
|
||||
if(epwm3TimerDirection == EPWM_TIMER_UP)
|
||||
{
|
||||
if(epwm3PeriodCount < PWM3_TIMER_MAX)
|
||||
{
|
||||
EPWM_setTimeBasePeriod(EPWM3_BASE, ++epwm3PeriodCount);
|
||||
}
|
||||
else
|
||||
{
|
||||
epwm3TimerDirection = EPWM_TIMER_DOWN;
|
||||
EPWM_setTimeBasePeriod(EPWM3_BASE, ++epwm3PeriodCount);
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
if(epwm3PeriodCount > PWM3_TIMER_MIN)
|
||||
{
|
||||
EPWM_setTimeBasePeriod(EPWM3_BASE, --epwm3PeriodCount);
|
||||
}
|
||||
else
|
||||
{
|
||||
epwm3TimerDirection = EPWM_TIMER_UP;
|
||||
EPWM_setTimeBasePeriod(EPWM3_BASE, ++epwm3PeriodCount);
|
||||
}
|
||||
}
|
||||
|
||||
//
|
||||
// Count correct captures
|
||||
//
|
||||
ecap1PassCount++;
|
||||
|
||||
//
|
||||
// Clear interrupt flags for more interrupts.
|
||||
//
|
||||
ECAP_clearInterrupt(myECAP0_BASE,ECAP_ISR_SOURCE_CAPTURE_EVENT_4);
|
||||
ECAP_clearGlobalInterrupt(myECAP0_BASE);
|
||||
|
||||
//
|
||||
// Start eCAP
|
||||
//
|
||||
ECAP_reArm(myECAP0_BASE);
|
||||
|
||||
//
|
||||
// Acknowledge the group interrupt for more interrupts.
|
||||
//
|
||||
Interrupt_clearACKGroup(INT_myECAP0_INTERRUPT_ACK_GROUP);
|
||||
}
|
||||
|
||||
//
|
||||
// error - Error function
|
||||
//
|
||||
void error()
|
||||
{
|
||||
ESTOP0;
|
||||
}
|
||||
@@ -0,0 +1,37 @@
|
||||
|
||||
/**
|
||||
* Import the modules used in this configuration.
|
||||
*/
|
||||
const ecap = scripting.addModule("/driverlib/ecap.js", {}, false);
|
||||
const ecap1 = ecap.addInstance();
|
||||
const gpio = scripting.addModule("/driverlib/gpio.js", {}, false);
|
||||
const gpio1 = gpio.addInstance();
|
||||
const inputxbar = scripting.addModule("/driverlib/inputxbar.js", {}, false);
|
||||
const inputxbar1 = inputxbar.addInstance();
|
||||
|
||||
/**
|
||||
* Write custom configuration values to the imported modules.
|
||||
*/
|
||||
ecap1.$name = "myECAP0";
|
||||
ecap1.enableInterrupt = true;
|
||||
ecap1.captureMode = "ECAP_ONE_SHOT_CAPTURE_MODE";
|
||||
ecap1.eventStop = "ECAP_EVENT_4";
|
||||
ecap1.eventOnePolarity = "ECAP_EVNT_FALLING_EDGE";
|
||||
ecap1.eventThreePolarity = "ECAP_EVNT_FALLING_EDGE";
|
||||
ecap1.interruptSourceCapture = ["ECAP_ISR_SOURCE_CAPTURE_EVENT_4"];
|
||||
ecap1.counterResetOnEvent = ["ECAP_EVENT_1","ECAP_EVENT_2","ECAP_EVENT_3","ECAP_EVENT_4"];
|
||||
ecap1.enableLoadCounter = true;
|
||||
ecap1.reArm = true;
|
||||
ecap1.ecapInput = "ECAP_INPUT_INPUTXBAR7";
|
||||
ecap1.registerInterrupts = true;
|
||||
ecap1.ecapInt.enableInterrupt = true;
|
||||
|
||||
gpio1.$name = "myGPIO0";
|
||||
gpio1.qualMode = "GPIO_QUAL_ASYNC";
|
||||
gpio1.gpioPin.$assign = "GPIO16";
|
||||
|
||||
|
||||
inputxbar1.$name = "myINPUTXBAR0";
|
||||
inputxbar1.inputsUsed = ["inputxbar7Gpio"];
|
||||
inputxbar1.inputxbar7Gpio = "GPIO16";
|
||||
|
||||
@@ -0,0 +1,118 @@
|
||||
//#############################################################################
|
||||
//
|
||||
// FILE: ecap_ex3_apwm_phase_shift.c
|
||||
//
|
||||
// TITLE: eCAP APWM Phase-shift Example.
|
||||
//
|
||||
//! \addtogroup driver_example_list
|
||||
//! <h1>eCAP APWM Phase-shift Example</h1>
|
||||
//!
|
||||
//! This program sets up the eCAP1 and eCAP2 modules in APWM mode to generate
|
||||
//! the two phase-shifted PWM outputs of same duty and frequency value
|
||||
//! The frequency, duty and phase values can be programmed of choice by updating
|
||||
//! the defined macros. By default 10 Khz frequency, 50% duty and 30% phase
|
||||
//! shift values are used. eCAP2 output leads the eCAP1 output by 30%
|
||||
//! GPIO5 and GPIO6 are used as eCAP1/2 outputs and can be probed using
|
||||
//! analyzer/CRO to observe the waveforms.
|
||||
//!
|
||||
//
|
||||
//#############################################################################
|
||||
//
|
||||
//
|
||||
//
|
||||
// C2000Ware v5.04.00.00
|
||||
//
|
||||
// Copyright (C) 2024 Texas Instruments Incorporated - http://www.ti.com
|
||||
//
|
||||
// Redistribution and use in source and binary forms, with or without
|
||||
// modification, are permitted provided that the following conditions
|
||||
// are met:
|
||||
//
|
||||
// Redistributions of source code must retain the above copyright
|
||||
// notice, this list of conditions and the following disclaimer.
|
||||
//
|
||||
// Redistributions in binary form must reproduce the above copyright
|
||||
// notice, this list of conditions and the following disclaimer in the
|
||||
// documentation and/or other materials provided with the
|
||||
// distribution.
|
||||
//
|
||||
// Neither the name of Texas Instruments Incorporated nor the names of
|
||||
// its contributors may be used to endorse or promote products derived
|
||||
// from this software without specific prior written permission.
|
||||
//
|
||||
// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
|
||||
// "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
|
||||
// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
|
||||
// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
|
||||
// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
|
||||
// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
|
||||
// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
|
||||
// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
|
||||
// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
||||
// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
|
||||
// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
// $
|
||||
//#############################################################################
|
||||
|
||||
//
|
||||
// Included Files
|
||||
//
|
||||
#include "driverlib.h"
|
||||
#include "device.h"
|
||||
#include "board.h"
|
||||
|
||||
//
|
||||
// Defines
|
||||
//
|
||||
#define PWM_FREQUENCY 10000U // 10 Khz
|
||||
#define PWM_DUTY 0.5f // 50% duty
|
||||
#define PWM_PHASE_SHIFT 0.3f // 30% Phase shift
|
||||
#define PWM_PRD_VAL DEVICE_SYSCLK_FREQ / PWM_FREQUENCY
|
||||
#define PWM_CMP_VAL (uint32_t)(PWM_DUTY * PWM_PRD_VAL)
|
||||
#define PWM_PHASE_VAL (uint32_t)(PWM_PHASE_SHIFT * PWM_PRD_VAL)
|
||||
|
||||
//
|
||||
// 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();
|
||||
|
||||
//
|
||||
// Board initialization
|
||||
// Select eCAP1OUT on MUX 0. Make GPIO5 as eCAP1OUT for PWM output
|
||||
// Select eCAP2OUT on MUX 2. Make GPIO6 as eCAP2OUT for PWM output
|
||||
// Configure eCAP1 in APWM mode with defined period and duty values
|
||||
// Polarity as low and configure SYNCOUT at CTR=PRD
|
||||
//
|
||||
Board_init();
|
||||
|
||||
while(1)
|
||||
{
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
//
|
||||
// End of File
|
||||
//
|
||||
|
||||
@@ -0,0 +1,42 @@
|
||||
|
||||
/**
|
||||
* Import the modules used in this configuration.
|
||||
*/
|
||||
const ecap = scripting.addModule("/driverlib/ecap.js", {}, false);
|
||||
const ecap1 = ecap.addInstance();
|
||||
const ecap2 = ecap.addInstance();
|
||||
const outputxbar = scripting.addModule("/driverlib/outputxbar.js", {}, false);
|
||||
const outputxbar1 = outputxbar.addInstance();
|
||||
const outputxbar2 = outputxbar.addInstance();
|
||||
|
||||
/**
|
||||
* Write custom configuration values to the imported modules.
|
||||
*/
|
||||
ecap1.$name = "myECAP0";
|
||||
ecap1.ecapMode = "APWM";
|
||||
ecap1.syncOutMode = "ECAP_SYNC_OUT_COUNTER_PRD";
|
||||
ecap1.apwmPolarity = "ECAP_APWM_ACTIVE_LOW";
|
||||
ecap1.apwmPeriod = 20000;
|
||||
ecap1.apwmCompare = 10000;
|
||||
|
||||
ecap2.$name = "myECAP1";
|
||||
ecap2.ecapBase = "ECAP2_BASE";
|
||||
ecap2.ecapMode = "APWM";
|
||||
ecap2.enableLoadCounter = true;
|
||||
ecap2.apwmPeriod = 20000;
|
||||
ecap2.apwmCompare = 10000;
|
||||
ecap2.apwmPolarity = "ECAP_APWM_ACTIVE_LOW";
|
||||
ecap2.phaseShiftCount = 6000;
|
||||
ecap2.syncInPulseSource = "ECAP_SYNC_IN_PULSE_SRC_SYNCOUT_ECAP1";
|
||||
|
||||
outputxbar1.$name = "myOUTPUTXBAR0";
|
||||
outputxbar1.muxesUsed = ["XBAR_MUX00"];
|
||||
outputxbar1.mux0Config = "XBAR_OUT_MUX00_ECAP1_OUT";
|
||||
outputxbar1.outputxbar.$assign = "OUTPUTXBAR3";
|
||||
outputxbar1.outputxbar.outputxbarPin.$assign = "GPIO5";
|
||||
|
||||
outputxbar2.$name = "myOUTPUTXBAR1";
|
||||
outputxbar2.muxesUsed = ["XBAR_MUX02"];
|
||||
outputxbar2.mux2Config = "XBAR_OUT_MUX02_ECAP2_OUT";
|
||||
outputxbar2.outputxbar.$assign = "OUTPUTXBAR4";
|
||||
outputxbar2.outputxbar.outputxbarPin.$assign = "GPIO6";
|
||||
@@ -0,0 +1,335 @@
|
||||
//#############################################################################
|
||||
//
|
||||
// FILE: ecap_sw_sync.c
|
||||
//
|
||||
// TITLE: Software Sync.
|
||||
//
|
||||
//! \addtogroup driver_example_list
|
||||
//! <h1>eCAP Software Sync Example</h1>
|
||||
//!
|
||||
//! This example configures ePWM3A for:
|
||||
//! - Up count mode
|
||||
//! - Period starts at 500 and goes up to 8000
|
||||
//! - Toggle output on PRD
|
||||
//!
|
||||
//! eCAP1, eCAP2 and eCAP3 are configured to capture the time between rising
|
||||
//! and falling edge of the ePWM3A output.
|
||||
//!
|
||||
//! \b External \b Connections \n
|
||||
//! - eCAP1, eCAP2, eCAP3 are on GPIO16
|
||||
//! - ePWM3A is on GPIO4
|
||||
//! - Connect GPIO4 to GPIO16.
|
||||
//!
|
||||
//! \b Watch \b Variables \n
|
||||
//! - \b ecapPassCount - Successful captures.
|
||||
//! - \b ecap3IntCount - Interrupt counts.
|
||||
//
|
||||
//#############################################################################
|
||||
//
|
||||
//
|
||||
//
|
||||
// C2000Ware v5.04.00.00
|
||||
//
|
||||
// Copyright (C) 2024 Texas Instruments Incorporated - http://www.ti.com
|
||||
//
|
||||
// Redistribution and use in source and binary forms, with or without
|
||||
// modification, are permitted provided that the following conditions
|
||||
// are met:
|
||||
//
|
||||
// Redistributions of source code must retain the above copyright
|
||||
// notice, this list of conditions and the following disclaimer.
|
||||
//
|
||||
// Redistributions in binary form must reproduce the above copyright
|
||||
// notice, this list of conditions and the following disclaimer in the
|
||||
// documentation and/or other materials provided with the
|
||||
// distribution.
|
||||
//
|
||||
// Neither the name of Texas Instruments Incorporated nor the names of
|
||||
// its contributors may be used to endorse or promote products derived
|
||||
// from this software without specific prior written permission.
|
||||
//
|
||||
// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
|
||||
// "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
|
||||
// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
|
||||
// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
|
||||
// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
|
||||
// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
|
||||
// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
|
||||
// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
|
||||
// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
||||
// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
|
||||
// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
// $
|
||||
//#############################################################################
|
||||
|
||||
//
|
||||
// Included Files
|
||||
//
|
||||
#include "driverlib.h"
|
||||
#include "device.h"
|
||||
#include "board.h"
|
||||
|
||||
//
|
||||
// Defines
|
||||
//
|
||||
#define PWM3_TIMER_MIN 500U
|
||||
#define PWM3_TIMER_MAX 8000U
|
||||
#define EPWM_TIMER_UP 1U
|
||||
#define EPWM_TIMER_DOWN 0U
|
||||
|
||||
//
|
||||
// Globals
|
||||
//
|
||||
bool firstInterrupt;
|
||||
uint32_t ecap3IntCount;
|
||||
uint32_t ecapPassCount;
|
||||
uint32_t epwm3TimerDirection;
|
||||
volatile uint16_t epwm3PeriodCount;
|
||||
volatile uint16_t ecap1Cap1Count;
|
||||
volatile uint16_t ecap1Cap2Count;
|
||||
volatile uint16_t ecap1Cap3Count;
|
||||
volatile uint16_t ecap1Cap4Count;
|
||||
volatile uint16_t ecap2Cap1Count;
|
||||
volatile uint16_t ecap2Cap2Count;
|
||||
volatile uint16_t ecap2Cap3Count;
|
||||
volatile uint16_t ecap2Cap4Count;
|
||||
volatile uint16_t ecap3Cap1Count;
|
||||
volatile uint16_t ecap3Cap2Count;
|
||||
volatile uint16_t ecap3Cap3Count;
|
||||
volatile uint16_t ecap3Cap4Count;
|
||||
|
||||
//
|
||||
// Function Prototypes
|
||||
//
|
||||
void error(void);
|
||||
void initECAP(void);
|
||||
void initEPWM(void);
|
||||
|
||||
//
|
||||
// Main
|
||||
//
|
||||
void main(void)
|
||||
{
|
||||
//
|
||||
// Initialize device clock and peripherals
|
||||
//
|
||||
Device_init();
|
||||
|
||||
//
|
||||
// Disable pin locks and enable internal pullups.
|
||||
//
|
||||
Device_initGPIO();
|
||||
|
||||
//
|
||||
// Initialize PIE and clear PIE registers. Disables CPU interrupts.
|
||||
//
|
||||
Interrupt_initModule();
|
||||
|
||||
//
|
||||
// Initialize the PIE vector table with pointers to the shell Interrupt
|
||||
// Service Routines (ISR).
|
||||
//
|
||||
Interrupt_initVectorTable();
|
||||
|
||||
//
|
||||
// Configure GPIO4/5 as ePWM3A/3B
|
||||
//
|
||||
GPIO_setPadConfig(4,GPIO_PIN_TYPE_STD);
|
||||
GPIO_setPinConfig(GPIO_4_EPWM3A);
|
||||
GPIO_setPadConfig(5,GPIO_PIN_TYPE_STD);
|
||||
GPIO_setPinConfig(GPIO_5_EPWM3B);
|
||||
|
||||
//
|
||||
// Board initialization
|
||||
// Configure GPIO 16 as eCAP input
|
||||
// Enable interrupts required for this example
|
||||
//
|
||||
Board_init();
|
||||
|
||||
//
|
||||
// Configure ePWM
|
||||
//
|
||||
initEPWM();
|
||||
|
||||
//
|
||||
// Initialize counters: and values
|
||||
//
|
||||
firstInterrupt = true;
|
||||
ecap3IntCount = 0U;
|
||||
ecapPassCount = 0U;
|
||||
epwm3PeriodCount = 0U;
|
||||
ecap1Cap1Count = 0U;
|
||||
ecap1Cap2Count = 0U;
|
||||
ecap1Cap3Count = 0U;
|
||||
ecap1Cap4Count = 0U;
|
||||
ecap2Cap1Count = 0U;
|
||||
ecap2Cap2Count = 0U;
|
||||
ecap2Cap3Count = 0U;
|
||||
ecap2Cap4Count = 0U;
|
||||
ecap3Cap1Count = 0U;
|
||||
ecap3Cap2Count = 0U;
|
||||
ecap3Cap3Count = 0U;
|
||||
ecap3Cap4Count = 0U;
|
||||
|
||||
//
|
||||
// Enable Global Interrupt (INTM) and Real time interrupt (DBGM)
|
||||
//
|
||||
EINT;
|
||||
ERTM;
|
||||
|
||||
//
|
||||
// Loop forever. Suspend or place breakpoints to observe the buffers.
|
||||
//
|
||||
for(;;)
|
||||
{
|
||||
NOP;
|
||||
}
|
||||
}
|
||||
|
||||
//
|
||||
// initEPWM - Configure ePWM
|
||||
//
|
||||
void initEPWM()
|
||||
{
|
||||
//
|
||||
// Disable sync(Freeze clock to PWM as well)
|
||||
//
|
||||
SysCtl_disablePeripheral(SYSCTL_PERIPH_CLK_TBCLKSYNC);
|
||||
|
||||
//
|
||||
// Configure ePWM
|
||||
// Counter runs in up-count mode.
|
||||
// Action qualifier will toggle output on period match
|
||||
//
|
||||
EPWM_setTimeBaseCounterMode(EPWM3_BASE, EPWM_COUNTER_MODE_UP);
|
||||
EPWM_setTimeBasePeriod(EPWM3_BASE, PWM3_TIMER_MIN);
|
||||
EPWM_setPhaseShift(EPWM3_BASE, 0U);
|
||||
EPWM_setActionQualifierAction(EPWM3_BASE,
|
||||
EPWM_AQ_OUTPUT_A,
|
||||
EPWM_AQ_OUTPUT_TOGGLE,
|
||||
EPWM_AQ_OUTPUT_ON_TIMEBASE_PERIOD);
|
||||
EPWM_setClockPrescaler(EPWM3_BASE,
|
||||
EPWM_CLOCK_DIVIDER_1,
|
||||
EPWM_HSCLOCK_DIVIDER_2);
|
||||
|
||||
epwm3TimerDirection = EPWM_TIMER_UP;
|
||||
|
||||
//
|
||||
// Enable sync and clock to PWM
|
||||
//
|
||||
SysCtl_enablePeripheral(SYSCTL_PERIPH_CLK_TBCLKSYNC);
|
||||
}
|
||||
|
||||
//
|
||||
// myECAP3 ISR
|
||||
//
|
||||
__interrupt void INT_myECAP3_ISR(void)
|
||||
{
|
||||
//
|
||||
// Get the capture counts. Each capture should match for all the eCAPs.
|
||||
//
|
||||
ecap1Cap1Count = ECAP_getEventTimeStamp(myECAP1_BASE, ECAP_EVENT_1);
|
||||
ecap1Cap2Count = ECAP_getEventTimeStamp(myECAP1_BASE, ECAP_EVENT_2);
|
||||
ecap1Cap3Count = ECAP_getEventTimeStamp(myECAP1_BASE, ECAP_EVENT_3);
|
||||
ecap1Cap4Count = ECAP_getEventTimeStamp(myECAP1_BASE, ECAP_EVENT_4);
|
||||
ecap2Cap1Count = ECAP_getEventTimeStamp(myECAP2_BASE, ECAP_EVENT_1);
|
||||
ecap2Cap2Count = ECAP_getEventTimeStamp(myECAP2_BASE, ECAP_EVENT_2);
|
||||
ecap2Cap3Count = ECAP_getEventTimeStamp(myECAP2_BASE, ECAP_EVENT_3);
|
||||
ecap2Cap4Count = ECAP_getEventTimeStamp(myECAP2_BASE, ECAP_EVENT_4);
|
||||
ecap3Cap1Count = ECAP_getEventTimeStamp(myECAP3_BASE, ECAP_EVENT_1);
|
||||
ecap3Cap2Count = ECAP_getEventTimeStamp(myECAP3_BASE, ECAP_EVENT_2);
|
||||
ecap3Cap3Count = ECAP_getEventTimeStamp(myECAP3_BASE, ECAP_EVENT_3);
|
||||
ecap3Cap4Count = ECAP_getEventTimeStamp(myECAP3_BASE, ECAP_EVENT_4);
|
||||
|
||||
//
|
||||
// Compare the period value with the captured count
|
||||
//
|
||||
epwm3PeriodCount = EPWM_getTimeBasePeriod(EPWM3_BASE);
|
||||
|
||||
//
|
||||
// Validate synchronization.
|
||||
//
|
||||
if(firstInterrupt){
|
||||
firstInterrupt = false;
|
||||
}
|
||||
else{
|
||||
if (!((ecap1Cap1Count == ecap2Cap1Count)&&(ecap2Cap1Count == ecap3Cap1Count)))
|
||||
{
|
||||
error();
|
||||
}
|
||||
}
|
||||
if (!((ecap1Cap2Count == ecap2Cap2Count)&&(ecap2Cap2Count == ecap3Cap2Count)))
|
||||
{
|
||||
error();
|
||||
}
|
||||
if (!((ecap1Cap3Count == ecap2Cap3Count)&&(ecap2Cap3Count == ecap3Cap3Count)))
|
||||
{
|
||||
error();
|
||||
}
|
||||
if (!((ecap1Cap4Count == ecap2Cap4Count)&&(ecap2Cap4Count == ecap3Cap4Count)))
|
||||
{
|
||||
error();
|
||||
}
|
||||
|
||||
ecap3IntCount++;
|
||||
|
||||
//
|
||||
// Keep track of the ePWM direction and adjust period accordingly to
|
||||
// generate a variable frequency PWM.
|
||||
//
|
||||
if(epwm3TimerDirection == EPWM_TIMER_UP)
|
||||
{
|
||||
if(epwm3PeriodCount < PWM3_TIMER_MAX)
|
||||
{
|
||||
EPWM_setTimeBasePeriod(EPWM3_BASE, ++epwm3PeriodCount);
|
||||
}
|
||||
else
|
||||
{
|
||||
epwm3TimerDirection = EPWM_TIMER_DOWN;
|
||||
EPWM_setTimeBasePeriod(EPWM3_BASE, ++epwm3PeriodCount);
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
if(epwm3PeriodCount > PWM3_TIMER_MIN)
|
||||
{
|
||||
EPWM_setTimeBasePeriod(EPWM3_BASE, --epwm3PeriodCount);
|
||||
}
|
||||
else
|
||||
{
|
||||
epwm3TimerDirection = EPWM_TIMER_UP;
|
||||
EPWM_setTimeBasePeriod(EPWM3_BASE, ++epwm3PeriodCount);
|
||||
}
|
||||
}
|
||||
|
||||
//
|
||||
// Count correct captures
|
||||
//
|
||||
ecapPassCount++;
|
||||
|
||||
//
|
||||
// Clear interrupt flags for more interrupts.
|
||||
//
|
||||
ECAP_clearInterrupt(myECAP3_BASE,ECAP_ISR_SOURCE_CAPTURE_EVENT_4);
|
||||
ECAP_clearGlobalInterrupt(myECAP3_BASE);
|
||||
|
||||
//
|
||||
// Start eCAP
|
||||
//
|
||||
ECAP_reArm(myECAP1_BASE);
|
||||
ECAP_reArm(myECAP2_BASE);
|
||||
ECAP_reArm(myECAP3_BASE);
|
||||
|
||||
//
|
||||
// Acknowledge the group interrupt for more interrupts.
|
||||
//
|
||||
Interrupt_clearACKGroup(INT_myECAP3_INTERRUPT_ACK_GROUP);
|
||||
}
|
||||
|
||||
//
|
||||
// error - Error function
|
||||
//
|
||||
void error()
|
||||
{
|
||||
ESTOP0;
|
||||
}
|
||||
@@ -0,0 +1,60 @@
|
||||
|
||||
/**
|
||||
* Import the modules used in this configuration.
|
||||
*/
|
||||
const ecap = scripting.addModule("/driverlib/ecap.js", {}, false);
|
||||
const ecap1 = ecap.addInstance();
|
||||
const ecap2 = ecap.addInstance();
|
||||
const ecap3 = ecap.addInstance();
|
||||
const gpio = scripting.addModule("/driverlib/gpio.js", {}, false);
|
||||
const gpio1 = gpio.addInstance();
|
||||
const inputxbar = scripting.addModule("/driverlib/inputxbar.js", {}, false);
|
||||
const inputxbar1 = inputxbar.addInstance();
|
||||
|
||||
/**
|
||||
* Write custom configuration values to the imported modules.
|
||||
*/
|
||||
ecap1.$name = "myECAP1";
|
||||
ecap1.ecapInput = "ECAP_INPUT_INPUTXBAR7";
|
||||
ecap1.captureMode = "ECAP_ONE_SHOT_CAPTURE_MODE";
|
||||
ecap1.eventOnePolarity = "ECAP_EVNT_FALLING_EDGE";
|
||||
ecap1.eventThreePolarity = "ECAP_EVNT_FALLING_EDGE";
|
||||
ecap1.enableLoadCounter = true;
|
||||
ecap1.loadCounter = true;
|
||||
ecap1.eventStop = "ECAP_EVENT_4";
|
||||
ecap1.counterResetOnEvent = ["ECAP_EVENT_1","ECAP_EVENT_2","ECAP_EVENT_3","ECAP_EVENT_4"];
|
||||
ecap1.reArm = true;
|
||||
|
||||
ecap2.$name = "myECAP2";
|
||||
ecap2.ecapBase = "ECAP2_BASE";
|
||||
ecap2.ecapInput = "ECAP_INPUT_INPUTXBAR7";
|
||||
ecap2.captureMode = "ECAP_ONE_SHOT_CAPTURE_MODE";
|
||||
ecap2.eventOnePolarity = "ECAP_EVNT_FALLING_EDGE";
|
||||
ecap2.eventThreePolarity = "ECAP_EVNT_FALLING_EDGE";
|
||||
ecap2.enableLoadCounter = true;
|
||||
ecap2.eventStop = "ECAP_EVENT_4";
|
||||
ecap2.counterResetOnEvent = ["ECAP_EVENT_1","ECAP_EVENT_2","ECAP_EVENT_3","ECAP_EVENT_4"];
|
||||
ecap2.reArm = true;
|
||||
|
||||
ecap3.$name = "myECAP3";
|
||||
ecap3.ecapBase = "ECAP3_BASE";
|
||||
ecap3.ecapInput = "ECAP_INPUT_INPUTXBAR7";
|
||||
ecap3.captureMode = "ECAP_ONE_SHOT_CAPTURE_MODE";
|
||||
ecap3.eventOnePolarity = "ECAP_EVNT_FALLING_EDGE";
|
||||
ecap3.eventThreePolarity = "ECAP_EVNT_FALLING_EDGE";
|
||||
ecap3.enableLoadCounter = true;
|
||||
ecap3.enableInterrupt = true;
|
||||
ecap3.interruptSourceCapture = ["ECAP_ISR_SOURCE_CAPTURE_EVENT_4"];
|
||||
ecap3.eventStop = "ECAP_EVENT_4";
|
||||
ecap3.counterResetOnEvent = ["ECAP_EVENT_1","ECAP_EVENT_2","ECAP_EVENT_3","ECAP_EVENT_4"];
|
||||
ecap3.reArm = true;
|
||||
ecap3.registerInterrupts = true;
|
||||
ecap3.ecapInt.enableInterrupt = true;
|
||||
|
||||
gpio1.$name = "myGPIO0";
|
||||
gpio1.qualMode = "GPIO_QUAL_ASYNC";
|
||||
gpio1.gpioPin.$assign = "GPIO16";
|
||||
|
||||
inputxbar1.$name = "myINPUTXBAR0";
|
||||
inputxbar1.inputxbar7Gpio = "GPIO16";
|
||||
inputxbar1.inputsUsed = ["inputxbar7Gpio"];
|
||||
Reference in new issue
Block a user