Update repo

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

No files matched your search

@@ -0,0 +1,42 @@
<projectSpec>
<project
name="hrcap_ex1_capture"
device="TMS320F28388D"
cgtVersion="22.6.1.LTS"
products="sysconfig;C2000WARE"
outputFormat="ELF"
launchWizard="False"
linkerCommandFile=""
enableSysConfigTool="true"
sysConfigBuildOptions="--product ${C2000WARE_ROOT}/.metadata/sdk.json --device F2838x --package 337bga --part F2838x_337bga"
postBuildStep="
echo &quot;========= Build of the CLB simulation has moved to the CLB Tool. Click the '?' icon by the _Generate CLB Simulation File_ enable for more details (located in the Global Parameters of the Tile Design SysConfig module) =============&quot;
;if ${GENERATE_DIAGRAM} == 1 ${NODE_TOOL} &quot;${C2000WARE_ROOT}/utilities/clb_tool/clb_syscfg/dot_file_libraries/clbDotUtility.js&quot; &quot;${C2000WARE_ROOT}/utilities/clb_tool/clb_syscfg/&quot; &quot;${BuildDirectory}/syscfg&quot; &quot;${BuildDirectory}/syscfg/clb.dot&quot;
;if ${GENERATE_DIAGRAM} == 1 mkdir &quot;${BuildDirectory}/diagrams&quot;
;if ${GENERATE_DIAGRAM} == 1 ${NODE_TOOL} &quot;${C2000WARE_ROOT}/driverlib/.meta/generate_diagrams.js&quot; &quot;${C2000WARE_ROOT}&quot; &quot;${BuildDirectory}/diagrams&quot; &quot;${BuildDirectory}/syscfg&quot;
"
>
<configuration name="CPU1_RAM" compilerBuildOptions= "--opt_level=off -I${C2000WARE_ROOT} -I${PROJECT_ROOT}/device -I${C2000WARE_DLIB_ROOT} -v28 -ml -mt --cla_support=cla2 --define=RAM --float_support=fpu64 --tmu_support=tmu0 --define=DEBUG --define=CPU1 --gen_func_subsections=on --diag_warning=225 --diag_suppress=10063" linkerBuildOptions="--entry_point code_start --stack_size=0x3F8 --heap_size=0x200 --define=RAM -i${C2000WARE_ROOT} -i${PROJECT_BUILD_DIR}/syscfg -lc2000ware_libraries.cmd.genlibs " />
<configuration name="CPU1_FLASH" compilerBuildOptions="--opt_level=off -I${C2000WARE_ROOT} -I${PROJECT_ROOT}/device -I${C2000WARE_DLIB_ROOT} --define=_FLASH -v28 -ml -mt --cla_support=cla2 --float_support=fpu64 --tmu_support=tmu0 --define=DEBUG --define=CPU1 --gen_func_subsections=on --diag_warning=225 --diag_suppress=10063" linkerBuildOptions="--entry_point code_start --stack_size=0x3F8 --heap_size=0x200 --define=_FLASH -i${C2000WARE_ROOT} -i${PROJECT_BUILD_DIR}/syscfg -lc2000ware_libraries.cmd.genlibs " />
<pathVariable name="C2000WARE_DLIB_ROOT" path="../../../../../../driverlib/f2838x/driverlib/" scope="project" />
<pathVariable name="C2000WARE_ROOT" path="../../../../../../" scope="project" />
<pathVariable name="CLB_SYSCFG_ROOT" path="../../../../../../utilities/clb_tool/clb_syscfg/" scope="project" />
<pathVariable name="SYSTEMC_INSTALL" path="../../../../../../utilities/clb_tool/clb_syscfg/systemc-2.3.3" scope="project" />
<pathVariable name="CLB_SIM_COMPILER" path="C:/TDM-GCC-64/bin" scope="project" />
<buildVariable name="GENERATE_DIAGRAM" value="0" scope="project" />
<file action="copy" path="../../../../../../device_support/f2838x/common/include/driverlib.h" targetDirectory="device" />
<file action="copy" path="../../../../../../device_support/f2838x/common/include/device.h" targetDirectory="device" />
<file action="copy" path="../../../../../../device_support/f2838x/common/source/device.c" targetDirectory="device" />
<file action="copy" path="../../../../../../device_support/f2838x/common/targetConfigs/TMS320F28388D.ccxml" targetDirectory="targetConfigs" />
<file action="copy" path="../../../../../../device_support/f2838x/common/cmd/2838x_RAM_lnk_cpu1.cmd" targetDirectory="" applicableConfigurations="CPU1_RAM" />
<file action="copy" path="../../../../../../device_support/f2838x/common/cmd/2838x_FLASH_lnk_cpu1.cmd" targetDirectory="" applicableConfigurations="CPU1_FLASH" />
<file action="copy" path="../../../../../../device_support/f2838x/common/source/f2838x_codestartbranch.asm" targetDirectory="device" />
<file action="link" path="../../../../../../driverlib/f2838x/driverlib/ccs/Debug/driverlib.lib" targetDirectory="" />
<file action="copy" path="../../../../../../driverlib/f2838x/driverlib/" targetDirectory="device" excludeFromBuild="True" />
<file action="copy" path="../hrcap_ex1_capture.c" targetDirectory="" />
<file action="copy" path="../hrcap_ex1_capture.syscfg" targetDirectory="" />
<file action="copy" path="../hrcap_ex1_capture.h" targetDirectory="" />
</project>
</projectSpec>
@@ -0,0 +1,333 @@
//#############################################################################
//
// FILE: hrcap_ex1_capture.c
//
// TITLE: HRCAP Capture and Calibration Example
//
//! \addtogroup driver_example_list
//! <h1>HRCAP Capture and Calibration Example</h1>
//!
//! This example configures an ECAP to use HRCAP functionality to capture time
//! between edges on input GPIO2.
//!
//! \b External \b Connections \n
//! The user must provide a signal to GPIO2. XCLKOUT has been configured to
//! an output GPIO and can be externally jumped to serve this purpose. See
//! Sysconfig file for XCLKOUT GPIO selected.
//!
//! \b Watch \b Variables \n
//! - onTime1, onTime2
//! - offTime1, offTime2
//! - period1, period2
//
//#############################################################################
//
//
//
// 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 "hrcap_ex1_capture.h"
#include "board.h"
//
// Globals
//
volatile uint32_t cap1Count;
volatile uint32_t cap2Count;
volatile uint32_t cap3Count;
volatile uint32_t cap4Count;
uint32_t absCountOn1, absCountOn2;
uint32_t absCountOff1, absCountOff2;
uint32_t absCountPeriod1, absCountPeriod2;
float32_t onTime1 = 0, onTime2 = 0;
float32_t offTime1 = 0, offTime2 = 0;
float32_t period1 = 0, period2 = 0;
uint32_t ecapIntCount;
uint16_t hrcapIntCount = 0;
uint16_t ecapIntCalCount = 0;
uint16_t calStatus = 0;
HRCAPCAL_CalResultObj hrcapCalResult;
uint64_t totalCount = 0;
float32_t inputFreqMHz = 0;
//
// Function Prototypes
//
void initXCLKOUT(void);
//
// Main
//
void main(void)
{
//
// Initialize device clock and peripherals
//
Device_init();
//
// Disable pin locks and enable internal pullups.
//
Device_initGPIO();
//
// Initialize PIE and clear PIE registers. Disables CPU interrupts.
//
Interrupt_initModule();
//
// Initialize the PIE vector table with pointers to the shell Interrupt
// Service Routines (ISR).
//
Interrupt_initVectorTable();
//
// Board Initialization
//
Board_init();
//
// Initialize XCLKOUT
//
initXCLKOUT();
SysCtl_disablePeripheral(SYSCTL_PERIPH_CLK_TBCLKSYNC);
//
// Enable interrupts required for this example
//
Interrupt_enable(INT_myECAP0);
Interrupt_enable(INT_myECAP0_HR);
//
// Initialize counters
//
ecapIntCount = 0;
cap2Count = 0U;
cap3Count = 0U;
cap4Count = 0U;
SysCtl_enablePeripheral(SYSCTL_PERIPH_CLK_TBCLKSYNC);
//
// Enable Global Interrupt (INTM) and Real time interrupt (DBGM)
//
EINT;
ERTM;
//
// Loop indefinitely
//
while(1)
{
//
// Wait for a value to be captured by the HRCAP
//
if (period1 != 0)
{
//
// Convert from nS to MHz
//
inputFreqMHz = 1 / (period1 / 1000);
}
}
}
//
// initXCLKOUT - Configure XCLKOUT
//
void initXCLKOUT(void)
{
//
// Clock source is SYSCLK
//
SysCtl_selectClockOutSource(SYSCTL_CLOCKOUT_XTALOSC);
//
// XCLKOUT = Clock Source / 8
//
EALLOW;
SysCtl_setXClk(SYSCTL_XCLKOUT_DIV_8);
EDIS;
}
//
// INT_myECAP0_ISR - eCAP ISR
//
__interrupt void INT_myECAP0_ISR(void)
{
ecapIntCalCount++;
if(ecapIntCount++ > 10)
{
ecapIntCount = 0;
//
// Get the raw time stamps
//
cap1Count = ECAP_getEventTimeStamp(myECAP0_BASE, ECAP_EVENT_1);
cap2Count = ECAP_getEventTimeStamp(myECAP0_BASE, ECAP_EVENT_2);
cap3Count = ECAP_getEventTimeStamp(myECAP0_BASE, ECAP_EVENT_3);
cap4Count = ECAP_getEventTimeStamp(myECAP0_BASE, ECAP_EVENT_4);
absCountOn1 = cap2Count - cap1Count;
absCountOff1 = cap3Count - cap2Count;
absCountPeriod1 = cap3Count - cap1Count;
absCountOn2 = cap4Count - cap3Count;
absCountOff2 = cap3Count - cap2Count;
absCountPeriod2 = cap4Count - cap2Count;
//
// Convert counts to nanoseconds using the scale factor
//
onTime1 = HRCAP_convertEventTimeStampNanoseconds(absCountOn1,
hrcapCalResult.scaleFactor);
offTime1 = HRCAP_convertEventTimeStampNanoseconds(absCountOff1,
hrcapCalResult.scaleFactor);
period1 = HRCAP_convertEventTimeStampNanoseconds(absCountPeriod1,
hrcapCalResult.scaleFactor);
onTime2 = HRCAP_convertEventTimeStampNanoseconds(absCountOn2,
hrcapCalResult.scaleFactor);
offTime2 = HRCAP_convertEventTimeStampNanoseconds(absCountOff2,
hrcapCalResult.scaleFactor);
period2 = HRCAP_convertEventTimeStampNanoseconds(absCountPeriod2,
hrcapCalResult.scaleFactor);
totalCount++;
}
ECAP_clearInterrupt(myECAP0_BASE, ECAP_ISR_SOURCE_CAPTURE_EVENT_4);
ECAP_clearGlobalInterrupt(myECAP0_BASE);
ECAP_reArm(myECAP0_BASE);
ECAP_resetCounters(myECAP0_BASE);
//
// Acknowledge the PIE interrupt group
//
Interrupt_clearACKGroup(INT_myECAP0_INTERRUPT_ACK_GROUP);
}
//
// INT_myECAP0_HR_ISR - HRCAP Calibration ISR
//
__interrupt void INT_myECAP0_HR_ISR(void)
{
hrcapIntCount++;
//
// Get calibration interrupt sources
//
calStatus = HRCAP_getCalibrationFlags(myECAP0_HR_BASE);
//
// Get calibration clock counts
//
hrcapCalResult.hrclkCount = HRCAP_getCalibrationClockPeriod(myECAP0_HR_BASE,
HRCAP_CALIBRATION_CLOCK_HRCLK);
hrcapCalResult.sysclkcount = HRCAP_getCalibrationClockPeriod(myECAP0_HR_BASE,
HRCAP_CALIBRATION_CLOCK_SYSCLK);
//
// The following options are possible
// - HRCALCAL_STATUS_DONE_ISR
// - HRCALCAL_STATUS_DONE_PERIOD_OVERFLOW_ISR
// - Software forced generated interrupt
//
if(HRCALCAL_STATUS_DONE_ISR == calStatus)
{
//
// Calculate scale factor
//
hrcapCalResult.scaleFactor = HRCAP_getScaleFactor(myECAP0_HR_BASE);
}
else if (HRCALCAL_STATUS_DONE_PERIOD_OVERFLOW_ISR == calStatus)
{
//
// Calibration done with an overflow. Determine which counter has
// overflowed
//
if(hrcapCalResult.hrclkCount > hrcapCalResult.sysclkcount)
{
//
// HRCLK has overflowed
//
hrcapCalResult.scaleFactor = hrcapCalResult.sysclkcount *
HRCAPCAL_INV_OVERFLOW;
}
else if(hrcapCalResult.hrclkCount < hrcapCalResult.sysclkcount)
{
//
// SYSCLK has overflowed
//
hrcapCalResult.scaleFactor = HRCAPCAL_OVERFLOW /
hrcapCalResult.hrclkCount;
}
else
{
//
// Both SYSCLK and HRCLK have overflowed
//
hrcapCalResult.scaleFactor = 1.0f;
}
}
else
{
//
// Software generated interrupt
//
}
//
// Clear the interrupts
//
HRCAP_clearCalibrationFlags(myECAP0_HR_BASE, calStatus);
//
// Acknowledge the PIE interrupt group
//
Interrupt_clearACKGroup(INT_myECAP0_HR_INTERRUPT_ACK_GROUP);
}
@@ -0,0 +1,76 @@
//#############################################################################
//
// FILE: hrcap_ex1_capture.h
//
// TITLE: HRCAP Calibration Header
//
//#############################################################################
//
//
//
// 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 "hrcap.h"
//
// Defines
//
#define HRCALCAL_STATUS_DONE_ISR (HRCAP_CALIBRATION_DONE | \
HRCAP_GLOBAL_CALIBRATION_INTERRUPT )
#define HRCALCAL_STATUS_DONE_PERIOD_OVERFLOW_ISR \
(HRCAP_CALIBRATION_DONE | \
HRCAP_GLOBAL_CALIBRATION_INTERRUPT | \
HRCAP_CALIBRATION_PERIOD_OVERFLOW)
#define HRCALCAL_CALIBRATION_FLAGS (HRCAP_CALIBRATION_DONE | \
HRCAP_CALIBRATION_PERIOD_OVERFLOW)
#define HRCAPCAL_OVERFLOW 4294967295.0f
#define HRCAPCAL_INV_OVERFLOW (float32_t)(1.0f / HRCAPCAL_OVERFLOW)
//
// Typedefs
//
typedef struct
{
uint32_t hrclkCount; // High resolution clock count
uint32_t sysclkcount; // System clock count
float32_t scaleFactor; // Scale factor
bool calDone; // Calibration done flag
} HRCAPCAL_CalResultObj;
@@ -0,0 +1,51 @@
/**
* 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();
const other = scripting.addModule("/driverlib/other.js", {}, false);
const other1 = other.addInstance();
/**
* Write custom configuration values to the imported modules.
*/
ecap1.$name = "myECAP0";
ecap1.registerInterrupts = true;
ecap1.enableInterrupt = true;
ecap1.captureMode = "ECAP_ONE_SHOT_CAPTURE_MODE";
ecap1.eventStop = "ECAP_EVENT_4";
ecap1.eventTwoPolarity = "ECAP_EVNT_FALLING_EDGE";
ecap1.eventFourPolarity = "ECAP_EVNT_FALLING_EDGE";
ecap1.ecapInput = "ECAP_INPUT_INPUTXBAR7";
ecap1.enableLoadCounter = true;
ecap1.resetCounters = true;
ecap1.interruptSourceCapture = ["ECAP_ISR_SOURCE_CAPTURE_EVENT_4"];
ecap1.hrcapEnable = true;
ecap1.ecapBase = "ECAP7_BASE";
ecap1.hrcapCalibrationEnable = true;
ecap1.enabledCalibrationInterrupts = ["HRCAP_CALIBRATION_DONE","HRCAP_CALIBRATION_PERIOD_OVERFLOW"];
ecap1.ecapInt.enableInterrupt = true;
ecap1.hrcapCalibrationInt.enableInterrupt = true;
gpio1.$name = "myGPIO0";
gpio1.qualMode = "GPIO_QUAL_ASYNC";
gpio1.gpioPin.$assign = "GPIO2";
inputxbar1.$name = "myINPUTXBAR0";
inputxbar1.inputsUsed = ["inputxbar7Gpio"];
inputxbar1.inputxbar7Gpio = "GPIO2";
other1.$name = "myOTHER0";
other1.useCase = "CUSTOM";
other1.useInterfacePins = ["XCLKOUT"];
other1.other.$assign = "OTHER";
/**
* Pinmux solution for unlocked pins/peripherals. This ensures that minor changes to the automatic solver in a future
* version of the tool will not impact the pinmux you originally saw. These lines can be completely deleted in order to
* re-solve from scratch.
*/