This thread has been locked.

If you have a related question, please click the "Ask a related question" button in the top right corner. The newly created question will be automatically linked to this question.

TMS320F280039C: 使用CPUTIME 触发ADC 采集信号,并且用DMA将数值搬运,遇到了数据并没有搬运的问题!

Part Number: TMS320F280039C

使用CPUTIME 触发ADC 采集信号,并且用DMA 搬运数据。具体具体实现是这样的,cputime 以1MHZ 的速率触发ADC采集数据,ADC只是采集一路,使用的是A0,采集完成使用DMA将数据搬运,程序运行的情况是DMA end int 能正常触发,但是adc buff 里面没有数值!

//#############################################################################
//
// FILE:   empty_driverlib_main.c
//
//! \addtogroup driver_example_list
//! <h1>Empty Project Example</h1> 
//!
//! This example is an empty project setup for Driverlib development.
//!
//
//#############################################################################
//
//
// $Copyright:
// Copyright (C) 2024 Texas Instruments Incorporated - http://www.ti.com/
//
// Redistribution and use in source and binary forms, with or without 
// modification, are permitted provided that the following conditions 
// are met:
// 
//   Redistributions of source code must retain the above copyright 
//   notice, this list of conditions and the following disclaimer.
// 
//   Redistributions in binary form must reproduce the above copyright
//   notice, this list of conditions and the following disclaimer in the 
//   documentation and/or other materials provided with the   
//   distribution.
// 
//   Neither the name of Texas Instruments Incorporated nor the names of
//   its contributors may be used to endorse or promote products derived
//   from this software without specific prior written permission.
// 
// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS 
// "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT 
// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT 
// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, 
// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT 
// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 
// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE 
// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
// $
//#############################################################################

//
// Included Files
//
#include "driverlib.h"
#include "device.h"
#include "board.h"
#include "c2000ware_libraries.h"


uint16_t adc_global_buf[myDMA0_TRANSFERSIZE];


const void *adc_result_reg = (uint16_t*)(myADC0_RESULT_BASE + (uint32_t)ADC_RESULTx_OFFSET_BASE + (uint32_t)myADC0_SOC0);
const void *adc_cap_buf    = adc_global_buf;


uint16_t sample_done = 0;

__interrupt void INT_myDMA0_ISR(void)
{
    DMA_stopChannel(myDMA0_BASE);
    EALLOW;
    Interrupt_clearACKGroup(INT_myDMA0_INTERRUPT_ACK_GROUP);
    EDIS;
    sample_done = 1;
//    ADC_readResult

}

////#define INT_myADC0_1 INT_ADCA1
////#define INT_myADC0_1_INTERRUPT_ACK_GROUP INTERRUPT_ACK_GROUP1

//volatile uint16_t adc_val;
//__interrupt void INT_myADC0_1_ISR(void)
//{
//    adc_val = ADC_readResult(myADC0_RESULT_BASE,myADC0_SOC0);
//    Interrupt_clearACKGroup(INT_myADC0_1_INTERRUPT_ACK_GROUP);
//}



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();

    //
    // PinMux and Peripheral Initialization
    //
    Board_init();

    //
    // C2000Ware Library initialization
    //
    C2000Ware_libraries_init();

    //
    // Enable Global Interrupt (INTM) and real time interrupt (DBGM)
    //
    EINT;
    ERTM;

    int i;
    for( i = 0; i < myDMA0_TRANSFERSIZE; ++i){
        adc_global_buf[i] = i;
    }

    DMA_clearTriggerFlag(myDMA0_BASE);
    ADC_clearInterruptStatus(myADC0_BASE,ADC_INT_NUMBER1);

    DMA_startChannel(myDMA0_BASE);
    CPUTimer_startTimer(myCPUTIMER0_BASE);

    while(1)
    {
        if(sample_done == 1){
            ESTOP0;
        }
    }
}

//
// End of File
//
/**
 * 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 "F28003x" --package "100PZ" --part "F28003x_100PZ" --context "system" --product "C2000WARE@5.02.00.00"
 * @versions {"tool":"1.20.0+3587"}
 */

/**
 * Import the modules used in this configuration.
 */
const adc       = scripting.addModule("/driverlib/adc.js", {}, false);
const adc1      = adc.addInstance();
const analog    = scripting.addModule("/driverlib/analog.js", {}, false);
const analog1   = analog.addInstance();
const asysctl   = scripting.addModule("/driverlib/asysctl.js");
const cputimer  = scripting.addModule("/driverlib/cputimer.js", {}, false);
const cputimer1 = cputimer.addInstance();
const dma       = scripting.addModule("/driverlib/dma.js", {}, false);
const dma1      = dma.addInstance();

/**
 * Write custom configuration values to the imported modules.
 */
adc1.$name                          = "myADC0";
adc1.adcClockPrescaler              = "ADC_CLK_DIV_2_0";
adc1.soc0Trigger                    = "ADC_TRIGGER_CPU1_TINT0";
adc1.soc0SampleWindow               = 9;
adc1.soc1Channel                    = "ADC_CH_ADCIN1";
adc1.enabledSOCs                    = ["ADC_SOC_NUMBER0"];
adc1.interruptPulseMode             = "ADC_PULSE_END_OF_CONV";
adc1.enableInterrupt1               = true;
adc1.enableInterrupt1ContinuousMode = true;
adc1.registerInterrupts             = ["1"];
adc1.soc0InterruptTrigger           = "ADC_INT_SOC_TRIGGER_ADCINT1";
adc1.enableInterrupt2               = true;
adc1.enableInterrupt2ContinuousMode = true;
adc1.enableInterrupt3               = true;
adc1.enableInterrupt3ContinuousMode = true;
adc1.enableInterrupt4               = true;
adc1.enableInterrupt4ContinuousMode = true;
adc1.enabledInts                    = ["ADC_INT_NUMBER1"];
adc1.useInterrupts                  = false;

analog1.$name                                    = "myANALOGPinMux0";
adc1.analog                                      = analog1;
analog1.useCase                                  = "CUSTOM";
analog1.useInterfacePins                         = ["A0/B15/C15/DACA_OUT"];
analog1.analog.$assign                           = "ANALOG";
analog1.analog["a0/b15/c15/daca_outPin"].$assign = "A0/B15/C15/DACA_OUT";

asysctl.analogReference        = "INTERNAL";
asysctl.analogReferenceVoltage = "1P65";

cputimer1.$name           = "myCPUTIMER0";
cputimer1.enableInterrupt = true;
cputimer1.timerPeriod     = 120;
cputimer1.emulationMode   = "CPUTIMER_EMULATIONMODE_RUNFREE";

dma1.$name                  = "myDMA0";
dma1.enableTriggers         = true;
dma1.useInterrupts          = true;
dma1.registerInterrupts     = true;
dma1.enableInterrupts       = true;
dma1.transferSize           = 512;
dma1.destAddressInputMode   = "VARIABLE";
dma1.destAddressVariable    = "adc_cap_buf";
dma1.srcAddressVariable     = "adc_result_reg";
dma1.interruptMode          = "DMA_INT_AT_END";
dma1.destTransferStep       = 1;
dma1.destBurstStep          = 1;
dma1.emulationMode          = "DMA_EMULATION_FREE_RUN";
dma1.srcAddressInputMode    = "VARIABLE";
dma1.triggerSource          = "DMA_TRIGGER_ADCA1";
dma1.dmaInt.enableInterrupt = true;