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,48 @@
<projectSpec>
<project
name="dma_ex1_shared_periph_cpu1"
device="TMS320F28377D"
cgtVersion="22.6.0.LTS"
products="C2000WARE"
outputFormat="ELF"
launchWizard="False"
linkerCommandFile=""
>
<configuration name="CPU1_RAM" compilerBuildOptions="--opt_level=off -I${PROJECT_ROOT}/device -I${C2000WARE_DLIB_ROOT} --define=CPU1 -v28 -ml -mt --cla_support=cla1 --float_support=fpu32 --tmu_support=tmu0 --vcu_support=vcu2 --diag_warning=225 --diag_suppress=10063 --display_error_number" linkerBuildOptions="--entry_point code_start --stack_size=0x100" />
<configuration name="CPU1_FLASH" compilerBuildOptions="--opt_level=off -I${PROJECT_ROOT}/device -I${C2000WARE_DLIB_ROOT} --define=_FLASH --define=CPU1 -v28 -ml -mt --cla_support=cla1 --float_support=fpu32 --tmu_support=tmu0 --vcu_support=vcu2 --diag_warning=225 --diag_suppress=10063 --display_error_number" linkerBuildOptions="--entry_point code_start --stack_size=0x100" />
<pathVariable name="C2000WARE_DLIB_ROOT" path="../../../../driverlib" scope="project" />
<file action="copy" path="../../../../../../device_support/f2837xd/common/include/driverlib.h" targetDirectory="device" />
<file action="copy" path="../../../../../../device_support/f2837xd/common/include/device.h" targetDirectory="device" />
<file action="copy" path="../../../../../../device_support/f2837xd/common/source/device.c" targetDirectory="device" />
<file action="copy" path="../../../../../../device_support/f2837xd/common/targetConfigs/TMS320F28377D.ccxml" targetDirectory="targetConfigs" />
<file action="copy" path="../../../../../../device_support/f2837xd/common/cmd/2837xD_RAM_lnk_shared_cpu1.cmd" targetDirectory="" applicableConfigurations="CPU1_RAM" />
<file action="copy" path="../../../../../../device_support/f2837xd/common/cmd/2837xD_FLASH_lnk_cpu1.cmd" targetDirectory="" applicableConfigurations="CPU1_FLASH" />
<file action="copy" path="../../../../driverlib/" targetDirectory="device" excludeFromBuild="True" />
<file action="copy" path="../../../../../../device_support/f2837xd/common/source/F2837xD_CodeStartBranch.asm" targetDirectory="device" />
<file action="link" path="../../../../driverlib/ccs/Debug/driverlib.lib" targetDirectory="" />
<file action="copy" path="../dma_ex1_shared_periph_cpu1.c" targetDirectory="" />
</project>
<project
name="dma_ex1_shared_periph_cpu2"
device="TMS320F28377D"
cgtVersion="22.6.0.LTS"
products="C2000WARE"
outputFormat="ELF"
launchWizard="False"
linkerCommandFile=""
>
<configuration name="CPU2_RAM" compilerBuildOptions="--opt_level=off -I${PROJECT_ROOT}/device -I${C2000WARE_DLIB_ROOT} --define=CPU2 -v28 -ml -mt --cla_support=cla1 --float_support=fpu32 --tmu_support=tmu0 --vcu_support=vcu2 --diag_warning=225 --diag_suppress=10063 --display_error_number" linkerBuildOptions="--entry_point code_start --stack_size=0x100" />
<configuration name="CPU2_FLASH" compilerBuildOptions="--opt_level=off -I${PROJECT_ROOT}/device -I${C2000WARE_DLIB_ROOT} --define=_FLASH --define=CPU2 -v28 -ml -mt --cla_support=cla1 --float_support=fpu32 --tmu_support=tmu0 --vcu_support=vcu2 --diag_warning=225 --diag_suppress=10063 --display_error_number" linkerBuildOptions="--entry_point code_start --stack_size=0x100" />
<pathVariable name="C2000WARE_DLIB_ROOT" path="../../../../driverlib" scope="project" />
<file action="copy" path="../../../../../../device_support/f2837xd/common/include/driverlib.h" targetDirectory="device" />
<file action="copy" path="../../../../../../device_support/f2837xd/common/include/device.h" targetDirectory="device" />
<file action="copy" path="../../../../../../device_support/f2837xd/common/source/device.c" targetDirectory="device" />
<file action="copy" path="../../../../../../device_support/f2837xd/common/targetConfigs/TMS320F28377D.ccxml" targetDirectory="targetConfigs" />
<file action="copy" path="../../../../../../device_support/f2837xd/common/cmd/2837xD_RAM_lnk_shared_cpu2.cmd" targetDirectory="" applicableConfigurations="CPU2_RAM" />
<file action="copy" path="../../../../../../device_support/f2837xd/common/cmd/2837xD_FLASH_lnk_cpu2.cmd" targetDirectory="" applicableConfigurations="CPU2_FLASH" />
<file action="copy" path="../../../../driverlib/" targetDirectory="device" excludeFromBuild="True" />
<file action="copy" path="../../../../../../device_support/f2837xd/common/source/F2837xD_CodeStartBranch.asm" targetDirectory="device" />
<file action="link" path="../../../../driverlib/ccs/Debug/driverlib.lib" targetDirectory="" />
<file action="copy" path="../dma_ex1_shared_periph_cpu2.c" targetDirectory="" />
</project>
</projectSpec>
@@ -0,0 +1,71 @@
<projectSpec>
<project
name="dma_ex2_sysconfig_multi"
configurations="
FLASH,
RAM,
"
device="TMS320F28377D"
outputType="system"
cgtVersion="20.2.1.LTS"
>
<pathVariable name="C2000WARE_ROOT" path="../../../../../../" scope="project" />
<file path="../system.xml" action="copy" openOnCreation="true"/>
<configuration name="FLASH"
></configuration>
<configuration name="RAM"
></configuration>
</project>
<project
name="dma_ex2_sysconfig_cpu1"
device="TMS320F28377D"
cgtVersion="20.2.1.LTS"
outputFormat="ELF"
launchWizard="False"
linkerCommandFile=""
enableSysConfigTool="true"
sysConfigBuildOptions="--product ${C2000WARE_ROOT}/.metadata/sdk.json"
>
<configuration name="FLASH" compilerBuildOptions="--opt_level=off -I${C2000WARE_ROOT} -I${PROJECT_ROOT}/device -I${C2000WARE_DLIB_ROOT} --define=_FLASH --define=CPU1 -v28 -ml -mt --cla_support=cla1 --float_support=fpu32 --tmu_support=tmu0 --vcu_support=vcu2 --diag_warning=225 --diag_suppress=10063 --display_error_number" linkerBuildOptions="--entry_point code_start --stack_size=0x100" />
<configuration name="RAM" compilerBuildOptions="--opt_level=off -I${C2000WARE_ROOT} -I${PROJECT_ROOT}/device -I${C2000WARE_DLIB_ROOT} --define=CPU1 -v28 -ml -mt --cla_support=cla1 --float_support=fpu32 --tmu_support=tmu0 --vcu_support=vcu2 --diag_warning=225 --diag_suppress=10063 --display_error_number" linkerBuildOptions="--entry_point code_start --stack_size=0x100" />
<pathVariable name="C2000WARE_ROOT" path="../../../../../../" scope="project" />
<pathVariable name="C2000WARE_DLIB_ROOT" path="../../../../driverlib" scope="project" />
<file action="copy" path="../../../../../../device_support/F2837xD/common/include/driverlib.h" targetDirectory="device" />
<file action="copy" path="../../../../../../device_support/F2837xD/common/include/device.h" targetDirectory="device" />
<file action="copy" path="../../../../../../device_support/F2837xD/common/source/device.c" targetDirectory="device" />
<file action="copy" path="../../../../../../device_support/F2837xD/common/targetConfigs/TMS320F28377D.ccxml" targetDirectory="targetConfigs" />
<file action="copy" path="../../../../../../device_support/F2837xD/common/cmd/2837xD_FLASH_lnk_cpu1.cmd" targetDirectory="" applicableConfigurations="FLASH" />
<file action="copy" path="../../../../../../device_support/F2837xD/common/cmd/2837xD_RAM_lnk_cpu1.cmd" targetDirectory="" applicableConfigurations="RAM" />
<file action="copy" path="../../../../../../device_support/F2837xD/common/source/F2837xD_CodeStartBranch.asm" targetDirectory="device" />
<file action="link" path="../../../../driverlib/ccs/Debug/driverlib.lib" targetDirectory="" />
<file action="copy" path="../../../../driverlib/" targetDirectory="device" excludeFromBuild="True" />
<file action="copy" path="../dma_ex2_sysconfig_cpu1.c" targetDirectory="" />
<file action="copy" path="../dma_ex2_sysconfig_cpu1.syscfg" targetDirectory="" />
</project>
<project
name="dma_ex2_sysconfig_cpu2"
device="TMS320F28377D"
cgtVersion="20.2.1.LTS"
outputFormat="ELF"
launchWizard="False"
linkerCommandFile=""
enableSysConfigTool="true"
sysConfigBuildOptions="--product ${C2000WARE_ROOT}/.metadata/sdk.json"
>
<configuration name="FLASH" compilerBuildOptions="--opt_level=off -I${C2000WARE_ROOT} -I${PROJECT_ROOT}/device -I${C2000WARE_DLIB_ROOT} --define=_FLASH --define=CPU2 -v28 -ml -mt --cla_support=cla1 --float_support=fpu32 --tmu_support=tmu0 --vcu_support=vcu2 --diag_warning=225 --diag_suppress=10063 --display_error_number" linkerBuildOptions="--entry_point code_start --stack_size=0x100" />
<configuration name="RAM" compilerBuildOptions="--opt_level=off -I${C2000WARE_ROOT} -I${PROJECT_ROOT}/device -I${C2000WARE_DLIB_ROOT} --define=CPU2 -v28 -ml -mt --cla_support=cla1 --float_support=fpu32 --tmu_support=tmu0 --vcu_support=vcu2 --diag_warning=225 --diag_suppress=10063 --display_error_number" linkerBuildOptions="--entry_point code_start --stack_size=0x100" />
<pathVariable name="C2000WARE_ROOT" path="../../../../../../" scope="project" />
<pathVariable name="C2000WARE_DLIB_ROOT" path="../../../../driverlib" scope="project" />
<file action="copy" path="../../../../../../device_support/F2837xD/common/include/driverlib.h" targetDirectory="device" />
<file action="copy" path="../../../../../../device_support/F2837xD/common/include/device.h" targetDirectory="device" />
<file action="copy" path="../../../../../../device_support/F2837xD/common/source/device.c" targetDirectory="device" />
<file action="copy" path="../../../../../../device_support/F2837xD/common/targetConfigs/TMS320F28377D.ccxml" targetDirectory="targetConfigs" />
<file action="copy" path="../../../../../../device_support/F2837xD/common/cmd/2837xD_FLASH_lnk_cpu2.cmd" targetDirectory="" applicableConfigurations="FLASH" />
<file action="copy" path="../../../../../../device_support/F2837xD/common/cmd/2837xD_RAM_lnk_cpu2.cmd" targetDirectory="" applicableConfigurations="RAM" />
<file action="copy" path="../../../../../../device_support/F2837xD/common/source/F2837xD_CodeStartBranch.asm" targetDirectory="device" />
<file action="link" path="../../../../driverlib/ccs/Debug/driverlib.lib" targetDirectory="" />
<file action="copy" path="../../../../driverlib/" targetDirectory="device" excludeFromBuild="True" />
<file action="copy" path="../dma_ex2_sysconfig_cpu2.c" targetDirectory="" />
<file action="copy" path="../dma_ex2_sysconfig_cpu2.syscfg" targetDirectory="" />
</project>
</projectSpec>
@@ -0,0 +1,332 @@
//#############################################################################
//
// FILE: dma_ex1_shared_periph_cpu1.c
//
// TITLE: DMA Transfer for Shared Peripheral Example
//
//! \addtogroup driver_dual_example_list
//! <h1> DMA Transfer Shared Peripheral </h1>
//!
//! This example shows how to initiate a DMA transfer on CPU1 from a shared
//! peripheral which is owned by CPU2. In this specific example, a timer ISR
//! is used on CPU2 to initiate a SPI transfer which will trigger the CPU1 DMA.
//! CPU1's DMA will then in turn update the ePWM1 CMPA value for the PWM which
//! it owns. The PWM output can be observed on the GPIO pins.
//!
//! \b Watch \b Pins
//! - GPIO0 and GPIO1 - ePWM output can be viewed with oscilloscope
//!
//
//#############################################################################
//
//
// $Copyright:
// Copyright (C) 2013-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 "inc/hw_ipc.h"
//
// Defines
//
//#define USE_DMA_INTERRUPT
//
// Globals
//
uint16_t newCMPValue;
#pragma DATA_SECTION(newCMPValue, "SHARERAMGS2");
//
// Function Prototypes
//
void Example_deviceInit(void);
void initEPWM1(void);
void setupDMA(void);
#ifdef USE_DMA_INTERRUPT
__interrupt void dmaISR(void);
#endif
//
// Main
//
void main(void)
{
//
// Initialize device clock and peripherals
//
Example_deviceInit();
//
// Initialize GPIO and configure the GPIOs 0 and 1 as ePWM outputs
//
Device_initGPIO();
GPIO_setPadConfig(0, GPIO_PIN_TYPE_STD);
GPIO_setPinConfig(GPIO_0_EPWM1A);
GPIO_setPadConfig(1, GPIO_PIN_TYPE_STD);
GPIO_setPinConfig(GPIO_1_EPWM1B);
//
// 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 ePWM1 and the DMA
//
initEPWM1();
setupDMA();
//
// Send IPC to CPU2 telling it to proceed with configuring the SPI
//
HWREG(IPC_BASE + IPC_O_SET) = IPC_SET_IPC1;
//
// Enable DMA interrupt
//
#ifdef USE_DMA_INTERRUPT
Interrupt_enable(INT_DMA_CH5);
Interrupt_register(INT_DMA_CH5, &dmaISR);
#endif
//
// Enable Global Interrupt (INTM) and realtime interrupt (DBGM)
//
EINT;
ERTM;
//
// Loop indefinitely
//
for(;;)
{
NOP;
}
}
//
// Example_deviceInit function
// This example uses custom Device_init function since CPU2 owns some of the
// peripherals
//
void Example_deviceInit(void)
{
//
// Disable the watchdog
//
SysCtl_disableWatchdog();
#ifdef _FLASH
//
// Copy time critical code and flash setup code to RAM. This includes the
// following functions: InitFlash();
//
// The RamfuncsLoadStart, RamfuncsLoadSize, and RamfuncsRunStart symbols
// are created by the linker. Refer to the device .cmd file.
//
memcpy(&RamfuncsRunStart, &RamfuncsLoadStart, (size_t)&RamfuncsLoadSize);
//
// Call Flash Initialization to setup flash waitstates. This function must
// reside in RAM.
//
Flash_initModule(FLASH0CTRL_BASE, FLASH0ECC_BASE, DEVICE_FLASH_WAITSTATES);
#endif
//
// Set up PLL control and clock dividers
//
SysCtl_setClock(DEVICE_SETCLOCK_CFG);
//
// Make sure the LSPCLK divider is set to the default (divide by 4)
//
SysCtl_setLowSpeedClock(SYSCTL_LSPCLK_PRESCALE_4);
//
// These asserts will check that the #defines for the clock rates in
// device.h match the actual rates that have been configured. If they do
// not match, check that the calculations of DEVICE_SYSCLK_FREQ and
// DEVICE_LSPCLK_FREQ are accurate. Some examples will not perform as
// expected if these are not correct.
//
ASSERT(SysCtl_getClock(DEVICE_OSCSRC_FREQ) == DEVICE_SYSCLK_FREQ);
ASSERT(SysCtl_getLowSpeedClock(DEVICE_OSCSRC_FREQ) == DEVICE_LSPCLK_FREQ);
//
// Give control of SPIA and GS2 to CPU2, and ePWM a secondary master to DMA
//
SysCtl_selectCPUForPeripheral(SYSCTL_CPUSEL6_SPI, 1, SYSCTL_CPUSEL_CPU2);
SysCtl_selectSecMaster(SYSCTL_SEC_MASTER_DMA, SYSCTL_SEC_MASTER_DMA);
MemCfg_setGSRAMMasterSel(MEMCFG_SECT_GS2, MEMCFG_GSRAMMASTER_CPU2);
//
// Send IPC flag to CPU2 signaling the completion of system initialization
//
HWREG(IPC_BASE + IPC_O_SET) = IPC_SET_IPC0;
//
// Turn on the required peripherals
//
SysCtl_enablePeripheral(SYSCTL_PERIPH_CLK_DMA);
SysCtl_enablePeripheral(SYSCTL_PERIPH_CLK_EPWM1);
SysCtl_enablePeripheral(SYSCTL_PERIPH_CLK_TBCLKSYNC);
}
//
// initEPWM1 - Function to Initialize ePWM1
//
void initEPWM1(void)
{
//
// Disable sync (freeze clock to PWM as well)
//
SysCtl_disablePeripheral(SYSCTL_PERIPH_CLK_TBCLKSYNC);
//
// Set-up TBCLK
//
EPWM_setTimeBasePeriod(EPWM1_BASE, 6000);
EPWM_setPhaseShift(EPWM1_BASE, 0U);
EPWM_setTimeBaseCounter(EPWM1_BASE, 0U);
EPWM_setTimeBaseCounterMode(EPWM1_BASE, EPWM_COUNTER_MODE_UP_DOWN);
EPWM_disablePhaseShiftLoad(EPWM1_BASE);
//
// Set ePWM clock pre-scaler
//
EPWM_setClockPrescaler(EPWM1_BASE,
EPWM_CLOCK_DIVIDER_4,
EPWM_HSCLOCK_DIVIDER_4);
//
// Set up shadowing
//
EPWM_setCounterCompareShadowLoadMode(EPWM1_BASE,
EPWM_COUNTER_COMPARE_A,
EPWM_COMP_LOAD_ON_CNTR_ZERO);
EPWM_setCounterCompareShadowLoadMode(EPWM1_BASE,
EPWM_COUNTER_COMPARE_B,
EPWM_COMP_LOAD_ON_CNTR_ZERO);
//
// Setup compare
//
EPWM_setCounterCompareValue(EPWM1_BASE, EPWM_COUNTER_COMPARE_A, 3000U);
//
// Set actions
//
EPWM_setActionQualifierAction(EPWM1_BASE,
EPWM_AQ_OUTPUT_A,
EPWM_AQ_OUTPUT_HIGH,
EPWM_AQ_OUTPUT_ON_TIMEBASE_UP_CMPA);
EPWM_setActionQualifierAction(EPWM1_BASE,
EPWM_AQ_OUTPUT_A,
EPWM_AQ_OUTPUT_LOW,
EPWM_AQ_OUTPUT_ON_TIMEBASE_DOWN_CMPA);
EPWM_setActionQualifierAction(EPWM1_BASE,
EPWM_AQ_OUTPUT_B,
EPWM_AQ_OUTPUT_LOW,
EPWM_AQ_OUTPUT_ON_TIMEBASE_UP_CMPA);
EPWM_setActionQualifierAction(EPWM1_BASE,
EPWM_AQ_OUTPUT_B,
EPWM_AQ_OUTPUT_HIGH,
EPWM_AQ_OUTPUT_ON_TIMEBASE_DOWN_CMPA);
//
// Enable sync and clock to PWM
//
SysCtl_enablePeripheral(SYSCTL_PERIPH_CLK_TBCLKSYNC);
}
//
// setupDMA - Function to Setup DMA
//
void setupDMA(void)
{
const void *destAddr, *srcAddr;
//
// Initialize DMA
//
DMA_initController();
destAddr = (const void *)(EPWM1_BASE + EPWM_O_CMPA + 1);
srcAddr = (const void *)&newCMPValue;
//
// Setup DMA to transfer a single 16-bit word. The DMA is setup to run
// continuously so that an interrupt is not required to restart the RUN
// bit. The DMA trigger is SPIA-FFTX.
//
DMA_configAddresses(DMA_CH5_BASE, destAddr, srcAddr);
DMA_configBurst(DMA_CH5_BASE, 1, 1, 1);
DMA_configTransfer(DMA_CH5_BASE, 1, 1, 1);
DMA_configWrap(DMA_CH5_BASE, 0xFFFF, 0, 0xFFFF, 0);
DMA_configMode(DMA_CH5_BASE, DMA_TRIGGER_SPIATX, DMA_CFG_ONESHOT_ENABLE |
DMA_CFG_CONTINUOUS_ENABLE |
DMA_CFG_SIZE_16BIT);
DMA_setInterruptMode(DMA_CH5_BASE, DMA_INT_AT_END);
DMA_enableTrigger(DMA_CH5_BASE);
DMA_enableInterrupt(DMA_CH5_BASE);
DMA_startChannel(DMA_CH5_BASE);
}
//
// dmaISR - DMA Interrupt Service Routine (uncomment to enable DMA ISR)
//
#ifdef USE_DMA_INTERRUPT
__interrupt void dmaISR(void)
{
Interrupt_clearACKGroup(INTERRUPT_ACK_GROUP7);
}
#endif
//
// End of File
//
@@ -0,0 +1,371 @@
//#############################################################################
//
// FILE: dma_ex1_shared_periph_cpu2.c
//
// TITLE: DMA Transfer for Shared Peripheral Example (CPU2)
//
// This example shows how to initiate a DMA transfer on CPU1 from a shared
// peripheral which is owned by CPU2. In this specific example, a timer ISR
// is used on CPU2 to initiate a SPI transfer which will trigger the CPU1 DMA.
// CPU1's DMA will then in turn update the ePWM1 CMPA value for the PWM which
// it owns. The PWM output can be observed on the GPIO pins.
//
//#############################################################################
//
// $Release Date: $
// $Copyright:
// Copyright (C) 2013-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 "inc/hw_ipc.h"
//
// Globals
//
uint16_t newCMPValue;
#pragma DATA_SECTION(newCMPValue, "SHARERAMGS2");
uint16_t direction = 1;
//
// Function Prototypes
//
void Example_deviceInit(void);
void initSpi(void);
void loadBuffer(void);
void initCPUTimer(uint32_t);
void configCPUTimer(uint32_t, float, float);
__interrupt void cpuTimer1ISR(void);
//
// Main
//
void main(void)
{
//
// Initialize device clock and peripherals
//
Example_deviceInit();
newCMPValue = 3000; // Set CMP value
//
// 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();
//
// Wait for IPC from CPU1 confirming DMA is configured before initializing
// SPI. Note that because of the way the TXFIFO interrupt is configured a
// DMA transfer will be triggered immediately after the SPI is released
// from reset.
//
while((HWREG(IPC_BASE + IPC_O_STS) & IPC_STS_IPC1) == 0U)
{
}
//
// Configure the SPI
//
initSpi();
//
// Setup CPU Timer 1 to interrupt every 10 ms
//
initCPUTimer(CPUTIMER1_BASE);
configCPUTimer(CPUTIMER1_BASE, DEVICE_SYSCLK_FREQ, 10000);
CPUTimer_startTimer(CPUTIMER1_BASE);
//
// Interrupts that are used in this example are re-mapped to ISR functions
// found within this file.
//
Interrupt_register(INT_TIMER1, &cpuTimer1ISR);
//
// Enable CPU Timer 1 interrupt
//
Interrupt_enable(INT_TIMER1);
//
// Enable Global Interrupt (INTM) and realtime interrupt (DBGM)
//
EINT;
ERTM;
//
// Loop indefinitely
//
for(;;)
{
NOP;
}
}
//
// Example_deviceInit function
// This example uses custom Device_init function since CPU2 owns some of the
// peripherals
//
void Example_deviceInit(void)
{
//
// Disable the watchdog
//
SysCtl_disableWatchdog();
#ifdef _FLASH
//
// Copy time critical code and flash setup code to RAM. This includes the
// following functions: InitFlash();
//
// The RamfuncsLoadStart, RamfuncsLoadSize, and RamfuncsRunStart symbols
// are created by the linker. Refer to the device .cmd file.
//
memcpy(&RamfuncsRunStart, &RamfuncsLoadStart, (size_t)&RamfuncsLoadSize);
//
// Call Flash Initialization to setup flash waitstates. This function must
// reside in RAM.
//
Flash_initModule(FLASH0CTRL_BASE, FLASH0ECC_BASE, DEVICE_FLASH_WAITSTATES);
#endif
//
// Wait for IPC flag from CPU1
//
while((HWREG(IPC_BASE + IPC_O_STS) & IPC_STS_IPC0) == 0U)
{
}
HWREG(IPC_BASE + IPC_O_ACK) = IPC_ACK_IPC0;
//
// Turn on required peripherals
//
SysCtl_enablePeripheral(SYSCTL_PERIPH_CLK_SPIA);
}
//
// initSpi - Function to Setup SPI for FIFO mode
//
void initSpi(void)
{
//
// Must put SPI into reset before configuring it
//
SPI_disableModule(SPIA_BASE);
//
// SPI configuration. Use a 500kHz SPICLK and 16-bit word size.
//
SPI_setConfig(SPIA_BASE, DEVICE_LSPCLK_FREQ, SPI_PROT_POL0PHA0,
SPI_MODE_MASTER, 500000, 16);
SPI_enableLoopback(SPIA_BASE);
SPI_enableModule(SPIA_BASE);
//
// FIFO configuration
//
SPI_enableFIFO(SPIA_BASE);
SPI_clearInterruptStatus(SPIA_BASE, SPI_INT_RXFF | SPI_INT_TXFF);
SPI_setFIFOInterruptLevel(SPIA_BASE, SPI_FIFO_TX2, SPI_FIFO_RX2);
//
// A DMA transfer will be triggered here!
//
//
// Load the SPI FIFO Tx Buffer
//
loadBuffer();
//
// Disable the clock to prevent continuous transfer/DMA triggers. Note that
// this method of disabling the clock should not be used if actual data is
// being transmitted.
//
SysCtl_disablePeripheral(SYSCTL_PERIPH_CLK_SPIA);
}
//
// loadBuffer - Function to load SPI Tx FIFO Buffer
//
void loadBuffer(void)
{
//
// Fill up the FIFO buffer
//
HWREGH(SPIA_BASE + SPI_O_TXBUF) = 0xAAAA;
HWREGH(SPIA_BASE + SPI_O_TXBUF) = 0xAAAA;
HWREGH(SPIA_BASE + SPI_O_TXBUF) = 0xAAAA;
HWREGH(SPIA_BASE + SPI_O_TXBUF) = 0xAAAA;
HWREGH(SPIA_BASE + SPI_O_TXBUF) = 0xAAAA;
HWREGH(SPIA_BASE + SPI_O_TXBUF) = 0xAAAA;
HWREGH(SPIA_BASE + SPI_O_TXBUF) = 0xAAAA;
HWREGH(SPIA_BASE + SPI_O_TXBUF) = 0xAAAA;
HWREGH(SPIA_BASE + SPI_O_TXBUF) = 0xAAAA;
HWREGH(SPIA_BASE + SPI_O_TXBUF) = 0xAAAA;
HWREGH(SPIA_BASE + SPI_O_TXBUF) = 0xAAAA;
HWREGH(SPIA_BASE + SPI_O_TXBUF) = 0xAAAA;
HWREGH(SPIA_BASE + SPI_O_TXBUF) = 0xAAAA;
HWREGH(SPIA_BASE + SPI_O_TXBUF) = 0xAAAA;
HWREGH(SPIA_BASE + SPI_O_TXBUF) = 0xAAAA;
HWREGH(SPIA_BASE + SPI_O_TXBUF) = 0xAAAA;
}
//
// initCPUTimer - This function initializes a CPU Timer to a known state.
//
void
initCPUTimer(uint32_t cpuTimer)
{
//
// Initialize timer period to maximum
//
CPUTimer_setPeriod(cpuTimer, 0xFFFFFFFF);
//
// Initialize pre-scale counter to divide by 1 (SYSCLKOUT)
//
CPUTimer_setPreScaler(cpuTimer, 0);
//
// Make sure timer is stopped
//
CPUTimer_stopTimer(cpuTimer);
//
// Reload all counter registers with period value
//
CPUTimer_reloadTimerCounter(cpuTimer);
}
//
// configCPUTimer - This function initializes the selected timer to the
// period specified by the "freq" and "period" parameters. The "freq" is
// entered as Hz and the period in microseconds. The timer is held in the
// stopped state after configuration.
//
void
configCPUTimer(uint32_t cpuTimer, float freq, float period)
{
uint32_t temp;
//
// Initialize timer period:
//
temp = (uint32_t)(freq / 1000000 * period);
CPUTimer_setPeriod(cpuTimer, temp);
//
// Set pre-scale counter to divide by 1 (SYSCLKOUT):
//
CPUTimer_setPreScaler(cpuTimer, 0);
//
// Initializes timer control register. The timer is stopped, reloaded,
// free run disabled, and interrupt enabled.
//
CPUTimer_stopTimer(cpuTimer);
CPUTimer_reloadTimerCounter(cpuTimer);
CPUTimer_setEmulationMode(cpuTimer,
CPUTIMER_EMULATIONMODE_STOPAFTERNEXTDECREMENT);
CPUTimer_enableInterrupt(cpuTimer);
}
//
// cpuTimer1ISR - CPU Timer 1 ISR
//
__interrupt void cpuTimer1ISR(void)
{
//
// Re-enable SPI clock to allow DMA trigger
//
SysCtl_enablePeripheral(SYSCTL_PERIPH_CLK_SPIA);
//
// Wait for interrupt flag. This is when the DMA trigger will occur.
//
while((SPI_getInterruptStatus(SPIA_BASE) & SPI_INT_TXFF) == 0)
{
}
//
// Reload the SPI TX buffer and clear interrupt flag
//
loadBuffer();
SPI_clearInterruptStatus(SPIA_BASE, SPI_INT_TXFF);
//
// Disable the clock to prevent continuous transfer/DMA triggers. Note that
// this method of disabling the clock should not be used if actual data is
// being transmitted.
//
SysCtl_disablePeripheral(SYSCTL_PERIPH_CLK_SPIA);
//
// Update next value to be transferred to the ePWM
//
if(newCMPValue >= 4500)
{
direction = 0;
}
else if(newCMPValue <= 1500)
{
direction = 1;
}
if(!direction)
{
newCMPValue -= 50;
}
else
{
newCMPValue += 50;
}
}
//
// End of File
//
@@ -0,0 +1,191 @@
//#############################################################################
//
// FILE: dma_ex2_sysconfig_cpu1.c
//
// TITLE: SysConfig DMA Transfer for Shared Peripheral Example
//
//! \addtogroup driver_dual_example_list
//! <h1> DMA Transfer Shared Peripheral </h1>
//!
//! This example shows how to initiate a DMA transfer on CPU1 from a shared
//! peripheral which is owned by CPU2. In this specific example, a timer ISR
//! is used on CPU2 to initiate a SPI transfer which will trigger the CPU1 DMA.
//! CPU1's DMA will then in turn update the ePWM1 CMPA value for the PWM which
//! it owns. The PWM output can be observed on the GPIO pins.
//!
//! \b Watch \b Pins
//! - GPIO0 and GPIO1 - ePWM output can be viewed with oscilloscope
//!
//
//#############################################################################
//
//
// $Copyright:
// Copyright (C) 2013-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 "inc/hw_ipc.h"
#include "board.h"
//
// Defines
//
//#define USE_DMA_INTERRUPT
//
// Globals
//
uint16_t newCMPValue;
#pragma DATA_SECTION(newCMPValue, "SHARERAMGS2");
//
// Function Prototypes
//
void Example_deviceInit(void);
void initEPWM1(void);
void setupDMA(void);
#ifdef USE_DMA_INTERRUPT
__interrupt void dmaISR(void);
#endif
//
// Main
//
void main(void)
{
//
// Initialize device clock and peripherals
//
Device_init();
//
// Initialize PIE and clear PIE registers. Disables CPU interrupts.
//
Interrupt_initModule();
//
// Initialize the PIE vector table with pointers to the shell Interrupt
// Service Routines (ISR).
//
Interrupt_initVectorTable();
//
// Initialize SysConfig Settings
//
Board_init();
//
// Send IPC_FLAG0 from CPU1 to CPU2 to let CPU2 continue initialization
//
HWREG(IPC_BASE + IPC_O_SET) = IPC_SET_IPC0;
//
// Finish Configuring the DMA, mostly done in SysConfig
//
setupDMA();
//
// Send IPC to CPU2 telling it to proceed with configuring the SPI
//
HWREG(IPC_BASE + IPC_O_SET) = IPC_SET_IPC1;
//
// Enable DMA interrupt
//
#ifdef USE_DMA_INTERRUPT
Interrupt_enable(INT_DMA_CH5);
Interrupt_register(INT_DMA_CH5, &dmaISR);
#endif
//
// Enable Global Interrupt (INTM) and realtime interrupt (DBGM)
//
EINT;
ERTM;
uint16_t full_cycles = 0;
//
// Loop indefinitely
//
for(;;)
{
if(newCMPValue == 4500){
if(full_cycles++ > 20){
GPIO_togglePin(CPU1_LED1);
GPIO_togglePin(CPU1_LED2);
full_cycles = 0;
}
}
}
}
//
// setupDMA - Function to Setup DMA, most of DMA setup done in SysConfig
//
void setupDMA(void)
{
//
// Setup DMA to transfer a single 16-bit word. The DMA is setup to run
// continuously so that an interrupt is not required to restart the RUN
// bit. The DMA trigger is SPIA-FFTX.
//
//
// Set the source and destination addresses for the DMA transfers
//
const void *destAddr, *srcAddr;
destAddr = (const void *)(EPWM1_BASE + EPWM_O_CMPA + 1);
srcAddr = (const void *)&newCMPValue;
DMA_configAddresses(DMA_CH5_BASE, destAddr, srcAddr);
}
//
// dmaISR - DMA Interrupt Service Routine (uncomment to enable DMA ISR)
//
#ifdef USE_DMA_INTERRUPT
__interrupt void dmaISR(void)
{
Interrupt_clearACKGroup(INTERRUPT_ACK_GROUP7);
}
#endif
//
// End of File
//
@@ -0,0 +1,75 @@
/**
* These arguments were used when this file was generated. They will be automatically applied on subsequent loads
* via the GUI or CLI. Run CLI with '--help' for additional information on how to override these arguments.
* @cliArgs --device "F2837xD" --package "F2837xD_337ZWT" --part "F2837xD_337ZWT" --context "CPU1" --product "C2000WARE@4.03.00.00"
* @versions {"tool":"1.15.999+71"}
*/
/**
* Import the modules used in this configuration.
*/
const dma = scripting.addModule("/driverlib/dma.js", {}, false);
const dma1 = dma.addInstance();
const epwm = scripting.addModule("/driverlib/epwm.js", {}, false);
const epwm1 = epwm.addInstance();
const gpio = scripting.addModule("/driverlib/gpio.js", {}, false);
const gpio1 = gpio.addInstance();
const gpio2 = gpio.addInstance();
const ipc = scripting.addModule("/driverlib/ipc.js");
const memcfg = scripting.addModule("/driverlib/memcfg.js");
const sysctl = scripting.addModule("/driverlib/sysctl.js");
/**
* Write custom configuration values to the imported modules.
*/
dma1.$name = "myDMA5";
dma1.dmaBase = "DMA_CH5_BASE";
dma1.enableTriggers = true;
dma1.triggerSource = "DMA_TRIGGER_SPIATX";
dma1.useInterrupts = true;
dma1.enableInterrupts = true;
dma1.interruptMode = "DMA_INT_AT_END";
dma1.oneShotConfig = "DMA_CFG_ONESHOT_ENABLE";
dma1.continuousModeConfig = "DMA_CFG_CONTINUOUS_ENABLE";
dma1.startChannel = true;
dma1.srcBurstStep = 1;
dma1.srcTransferStep = 1;
dma1.destBurstStep = 1;
dma1.destTransferStep = 1;
epwm1.$name = "myEPWM0";
epwm1.epwmTimebase_clockDiv = "EPWM_CLOCK_DIVIDER_4";
epwm1.epwmTimebase_hsClockDiv = "EPWM_HSCLOCK_DIVIDER_4";
epwm1.epwmTimebase_period = 6000;
epwm1.epwmTimebase_counterMode = "EPWM_COUNTER_MODE_UP_DOWN";
epwm1.epwmTimebase_syncOutPulseMode = "EPWM_SYNC_OUT_PULSE_DISABLED";
epwm1.epwmCounterCompare_cmpA = 3000;
epwm1.epwmActionQualifier_EPWM_AQ_OUTPUT_A_ON_TIMEBASE_UP_CMPA = "EPWM_AQ_OUTPUT_HIGH";
epwm1.epwmActionQualifier_EPWM_AQ_OUTPUT_A_ON_TIMEBASE_DOWN_CMPA = "EPWM_AQ_OUTPUT_LOW";
epwm1.epwmActionQualifier_EPWM_AQ_OUTPUT_B_ON_TIMEBASE_UP_CMPA = "EPWM_AQ_OUTPUT_LOW";
epwm1.epwmActionQualifier_EPWM_AQ_OUTPUT_B_ON_TIMEBASE_DOWN_CMPA = "EPWM_AQ_OUTPUT_HIGH";
epwm1.epwm.$assign = "EPWM1";
gpio1.direction = "GPIO_DIR_MODE_OUT";
gpio1.$name = "CPU1_LED1";
gpio1.gpioPin.$assign = "GPIO31";
gpio2.$name = "CPU1_LED2";
gpio2.direction = "GPIO_DIR_MODE_OUT";
gpio2.gpioPin.$assign = "GPIO34";
memcfg.config_MEMCFG_SECT_GS2 = "MEMCFG_GSRAMCONTROLLER_CPU2";
sysctl.enable_SYSCTL_PERIPH_CLK_TBCLKSYNC = true;
sysctl.cpuSel_SPIC = "SYSCTL_CPUSEL_CPU2";
sysctl.secMasterFrame1 = "SYSCTL_SEC_CONTROLLER_DMA";
sysctl.cpuSel_SPIA = "SYSCTL_CPUSEL_CPU2";
sysctl.secMasterFrame2 = "SYSCTL_SEC_CONTROLLER_DMA";
/**
* 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.
*/
epwm1.epwm.epwm_aPin.$suggestSolution = "GPIO0";
epwm1.epwm.epwm_bPin.$suggestSolution = "GPIO1";
@@ -0,0 +1,273 @@
//#############################################################################
//
// FILE: dma_ex2_sysconfig_cpu2.c
//
// TITLE: SysConfig DMA Transfer for Shared Peripheral Example (CPU2)
//
// This example shows how to initiate a DMA transfer on CPU1 from a shared
// peripheral which is owned by CPU2. In this specific example, a timer ISR
// is used on CPU2 to initiate a SPI transfer which will trigger the CPU1 DMA.
// CPU1's DMA will then in turn update the ePWM1 CMPA value for the PWM which
// it owns. The PWM output can be observed on the GPIO pins.
//
//#############################################################################
//
// $Release Date: $
// $Copyright:
// Copyright (C) 2013-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 "inc/hw_ipc.h"
#include "board.h"
//
// Globals
//
uint16_t newCMPValue;
#pragma DATA_SECTION(newCMPValue, "SHARERAMGS2");
uint16_t direction = 1;
//
// Function Prototypes
//
void Example_deviceInit(void);
void initSpi(void);
void loadBuffer(void);
void initCPUTimer(uint32_t);
void configCPUTimer(uint32_t, float, float);
__interrupt void cpuTimer1ISR(void);
//
// Main
//
void main(void)
{
//
// Initialize device clock and peripherals
//
Device_init();
//
// Wait for IPC flag from CPU1
//
while((HWREG(IPC_BASE + IPC_O_STS) & IPC_STS_IPC0) == 0U)
{
}
HWREG(IPC_BASE + IPC_O_ACK) = IPC_ACK_IPC0;
newCMPValue = 3000; // Set CMP value
//
// 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 settings from SysConfig
//
Board_init();
//
// Wait for IPC from CPU1 confirming DMA is configured before initializing
// SPI. Note that because of the way the TXFIFO interrupt is configured a
// DMA transfer will be triggered immediately after the SPI is released
// from reset.
//
while((HWREG(IPC_BASE + IPC_O_STS) & IPC_STS_IPC1) == 0U)
{
}
//
// Fill up SPI buffer
//
loadBuffer();
//
// Setup CPU Timer 1 to interrupt every 10 ms
//
configCPUTimer(CPUTIMER1_BASE, DEVICE_SYSCLK_FREQ, 10000);
CPUTimer_startTimer(CPUTIMER1_BASE);
//
// Interrupts that are used in this example are re-mapped to ISR functions
// found within this file.
//
Interrupt_register(INT_TIMER1, &cpuTimer1ISR);
//
// Enable CPU Timer 1 interrupt
//
Interrupt_enable(INT_TIMER1);
//
// Enable Global Interrupt (INTM) and realtime interrupt (DBGM)
//
EINT;
ERTM;
//
// Loop indefinitely
//
for(;;)
{
NOP;
}
}
//
// loadBuffer - Function to load SPI Tx FIFO Buffer
//
void loadBuffer(void)
{
//
// Fill up the FIFO buffer
//
HWREGH(SPIA_BASE + SPI_O_TXBUF) = 0xAAAA;
HWREGH(SPIA_BASE + SPI_O_TXBUF) = 0xAAAA;
HWREGH(SPIA_BASE + SPI_O_TXBUF) = 0xAAAA;
HWREGH(SPIA_BASE + SPI_O_TXBUF) = 0xAAAA;
HWREGH(SPIA_BASE + SPI_O_TXBUF) = 0xAAAA;
HWREGH(SPIA_BASE + SPI_O_TXBUF) = 0xAAAA;
HWREGH(SPIA_BASE + SPI_O_TXBUF) = 0xAAAA;
HWREGH(SPIA_BASE + SPI_O_TXBUF) = 0xAAAA;
HWREGH(SPIA_BASE + SPI_O_TXBUF) = 0xAAAA;
HWREGH(SPIA_BASE + SPI_O_TXBUF) = 0xAAAA;
HWREGH(SPIA_BASE + SPI_O_TXBUF) = 0xAAAA;
HWREGH(SPIA_BASE + SPI_O_TXBUF) = 0xAAAA;
HWREGH(SPIA_BASE + SPI_O_TXBUF) = 0xAAAA;
HWREGH(SPIA_BASE + SPI_O_TXBUF) = 0xAAAA;
HWREGH(SPIA_BASE + SPI_O_TXBUF) = 0xAAAA;
HWREGH(SPIA_BASE + SPI_O_TXBUF) = 0xAAAA;
}
//
// configCPUTimer - This function initializes the selected timer to the
// period specified by the "freq" and "period" parameters. The "freq" is
// entered as Hz and the period in microseconds. The timer is held in the
// stopped state after configuration.
//
void
configCPUTimer(uint32_t cpuTimer, float freq, float period)
{
uint32_t temp;
//
// Initialize timer period:
//
temp = (uint32_t)(freq / 1000000 * period);
CPUTimer_setPeriod(cpuTimer, temp);
//
// Set pre-scale counter to divide by 1 (SYSCLKOUT):
//
CPUTimer_setPreScaler(cpuTimer, 0);
//
// Initializes timer control register. The timer is stopped, reloaded,
// free run disabled, and interrupt enabled.
//
CPUTimer_stopTimer(cpuTimer);
CPUTimer_reloadTimerCounter(cpuTimer);
CPUTimer_setEmulationMode(cpuTimer,
CPUTIMER_EMULATIONMODE_STOPAFTERNEXTDECREMENT);
CPUTimer_enableInterrupt(cpuTimer);
}
//
// cpuTimer1ISR - CPU Timer 1 ISR
//
__interrupt void cpuTimer1ISR(void)
{
//
// Re-enable SPI clock to allow DMA trigger
//
SysCtl_enablePeripheral(SYSCTL_PERIPH_CLK_SPIA);
//
// Wait for interrupt flag. This is when the DMA trigger will occur.
//
while((SPI_getInterruptStatus(SPIA_BASE) & SPI_INT_TXFF) == 0)
{
}
//
// Reload the SPI TX buffer and clear interrupt flag
//
loadBuffer();
SPI_clearInterruptStatus(SPIA_BASE, SPI_INT_TXFF);
//
// Disable the clock to prevent continuous transfer/DMA triggers. Note that
// this method of disabling the clock should not be used if actual data is
// being transmitted.
//
SysCtl_disablePeripheral(SYSCTL_PERIPH_CLK_SPIA);
//
// Update next value to be transferred to the ePWM
//
if(newCMPValue >= 4500)
{
direction = 0;
}
else if(newCMPValue <= 1500)
{
direction = 1;
}
if(!direction)
{
newCMPValue -= 50;
}
else
{
newCMPValue += 50;
}
}
//
// End of File
//
@@ -0,0 +1,43 @@
/**
* These arguments were used when this file was generated. They will be automatically applied on subsequent loads
* via the GUI or CLI. Run CLI with '--help' for additional information on how to override these arguments.
* @cliArgs --device "F2837xD" --package "F2837xD_337ZWT" --part "F2837xD_337ZWT" --context "CPU2" --product "C2000WARE@4.03.00.00"
* @versions {"tool":"1.15.999+71"}
*/
/**
* Import the modules used in this configuration.
*/
const cputimer = scripting.addModule("/driverlib/cputimer.js", {}, false);
const cputimer1 = cputimer.addInstance();
const ipc = scripting.addModule("/driverlib/ipc.js");
const spi = scripting.addModule("/driverlib/spi.js", {}, false);
const spi1 = spi.addInstance();
/**
* Write custom configuration values to the imported modules.
*/
cputimer1.timerPeriod = 4294967295;
cputimer1.enableInterrupt = true;
cputimer1.cputimerBase = "CPUTIMER1_BASE";
cputimer1.$name = "myCPUTIMER1";
spi1.$name = "mySPI0";
spi1.mode = "SPI_MODE_CONTROLLER";
spi1.emulationMode = "SPI_EMULATION_STOP_AFTER_TRANSMIT";
spi1.bitRate = 500000;
spi1.txFifo = "SPI_FIFO_TX2";
spi1.rxFifo = "SPI_FIFO_RX2";
spi1.loopback = true;
spi1.enabledFIFOInterrupts = ["SPI_INT_RXFF","SPI_INT_TXFF"];
/**
* 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.
*/
spi1.spi.$suggestSolution = "SPIA";
spi1.spi.spi_picoPin.$suggestSolution = "GPIO16";
spi1.spi.spi_pociPin.$suggestSolution = "GPIO17";
spi1.spi.spi_clkPin.$suggestSolution = "GPIO18";
spi1.spi.spi_ptePin.$suggestSolution = "GPIO19";
@@ -0,0 +1,14 @@
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
<system>
<project configuration="@match" id="project_0" name="dma_ex2_sysconfig_cpu1">
</project>
<core id="C28xx_CPU1" project="project_0"/>
<project configuration="@match" id="project_1" name="dma_ex2_sysconfig_cpu2">
</project>
<core id="C28xx_CPU2" project="project_1"/>
<preBuildSteps>
</preBuildSteps>
<postBuildSteps>
</postBuildSteps>
</system>