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.

TMS320F280049C: AD采样结果在程序运行时和程序暂停时 结果不相同

Part Number: TMS320F280049C

60kHz  2.5Vpp  1.25V偏置 正弦信号 程序运行情况下

60kHz  2.5Vpp  1.25V偏置 正弦信号 程序暂停情况下

一样的输入源,一样的配置,可是程序运行过程中,graph输出的波形很不好,当暂停程序时,graph的波形瞬间变好。应该是数据的问题,两个波形的数据都导出后,使用matlab对数据进行波形绘制。

结果和graph相同,我想知道现在的问题出在了哪,ad采样后使用dma进行了数据搬运,dma的配置我认为也没有问题。

void ARC_HAL_setupIntADC(void)
{

//
// asysctl initialization
// Disables the temperature sensor output to the ADC.
//
ASysCtl_disableTemperatureSensor();

//
// Set the analog voltage reference selection to internal.
//
ASysCtl_setAnalogReferenceInternal( ASYSCTL_VREFHIA |
ASYSCTL_VREFHIB |
ASYSCTL_VREFHIC );

//
// Set the internal analog voltage reference selection to 1.65V.
//
ASysCtl_setAnalogReference1P65( ASYSCTL_VREFHIA |
ASYSCTL_VREFHIB |
ASYSCTL_VREFHIC );
//
//ADCA6 initialization
//
// ADC Initialization: Write ADC configurations and power up the ADC
// Configures the ADC module's offset trim
//
ADC_setOffsetTrimAll(ADC_REFERENCE_INTERNAL, ADC_REFERENCE_3_3V);//参考电压设置为3.3V

//
// Configures the analog-to-digital converter module prescaler.
//
ADC_setPrescaler(ARC_ADC_BASE, ADC_CLK_DIV_2_0);//ADC时钟二分频
// ADC_setPrescaler(ARC_ADC_BASE, ADC_CLK_DIV_1_0);//ADC时钟不分频
//
// Sets the timing of the end-of-conversion pulse
//
ADC_setInterruptPulseMode(ARC_ADC_BASE, ADC_PULSE_END_OF_CONV);//设置转化结束时触发中断

//
// Powers up the analog-to-digital converter core.
//
ADC_enableConverter(ARC_ADC_BASE);

//
// Delay for 1ms to allow ADC time to power up
//
DEVICE_DELAY_US(5000); //在ADC转换前延迟5ms
// DEVICE_DELAY_US(10000);
//ADC初始化,配置ADC偏移修剪、时钟预分频、中断脉冲模式和启动ADC

//
// SOC Configuration: Setup ADC EPWM channel and trigger settings
// Disables SOC burst mode.
//
ADC_disableBurstMode(ARC_ADC_BASE);

//
// Sets the priority mode of the SOCs.
//
ADC_setSOCPriority(ARC_ADC_BASE, ADC_PRI_ALL_ROUND_ROBIN);

//
// Start of Conversion 0 Configuration
// Configures a start-of-conversion (SOC) in the ADC and its
// interrupt SOC trigger.
// SOC number : 0
// Trigger : ARC_ADC_TRIG_SOURCE
// Channel : ARC_ADC_PIN
// Sample Window : ARC_ADC_ACQ_SYS_CLKS
// Interrupt Trigger: ADC_INT_SOC_TRIGGER_NONE
//
ADC_setupSOC(ARC_ADC_BASE, ARC_ADC_SOC,ARC_ADC_TRIG_SOURCE, ARC_ADC_PIN, ARC_ADC_ACQ_SYS_CLKS);//采样窗口持续8个系统时钟
ADC_setInterruptSOCTrigger(ARC_ADC_BASE, ARC_ADC_SOC,ADC_INT_SOC_TRIGGER_NONE);

//
// ADC Interrupt 1 Configuration
// SOC/EOC number : 0
// Interrupt Source: enabled
// Continuous Mode : enabled
//
// 设置中断为ADCINT1,并启用
ADC_setInterruptSource(ARC_ADC_BASE, ARC_ADC_INT1, ARC_ADC_SOC);
ADC_enableInterrupt(ARC_ADC_BASE, ARC_ADC_INT1);
ADC_clearInterruptStatus(ARC_ADC_BASE, ARC_ADC_INT1);
ADC_enableContinuousMode(ARC_ADC_BASE, ARC_ADC_INT1);

//
// ADC Interrupt 2 Configuration
// SOC/EOC number : 0
// Interrupt Source: enabled
// Continuous Mode : enabled
//
ADC_setInterruptSource(ARC_ADC_BASE, ARC_ADC_INT2, ARC_ADC_SOC);
ADC_enableInterrupt(ARC_ADC_BASE, ARC_ADC_INT2);
ADC_clearInterruptStatus(ARC_ADC_BASE, ARC_ADC_INT2);
ADC_enableContinuousMode(ARC_ADC_BASE, ARC_ADC_INT2); //配置两个中断源,包括中断的SOC/EOC编号、启用中断、清除状态和启用连续模式

//
//Clear interrupt flag
//
HWREGH(ARC_ADC_BASE + ADC_O_INTFLGCLR) = 0x3U; // ADCA 清除标志位


}


void ARC_HAL_setupDMA(void)
{
//
// Perform a hard reset on DMA
//
DMA_initController();
//
// Allow DMA to run free on emulation suspend
//
DMA_setEmulationMode(DMA_EMULATION_FREE_RUN);

//
// DMA channel 1 set up for ADCA first 512 Samples
//
DMA_configAddresses(ARC_DMA1_BASE, &ARC_ADCResults1,
(uint16_t *)ARC_ADC_RESULTS_BASE);

//
//Transfer 1 Word (16-Bit) per burst
//
DMA_configBurst(ARC_DMA1_BASE, 1, 0, 1);
//
//Do SAMPLES amount of burst per transfer
//
DMA_configTransfer(ARC_DMA1_BASE, ARC_SAMPLES / 2, 0, 1);
DMA_configMode(ARC_DMA1_BASE, DMA_TRIGGER_ADCA1,
(DMA_CFG_ONESHOT_DISABLE | DMA_CFG_CONTINUOUS_DISABLE |
DMA_CFG_SIZE_16BIT));

DMA_enableTrigger(ARC_DMA1_BASE);
DMA_disableOverrunInterrupt(ARC_DMA1_BASE);
DMA_setInterruptMode(ARC_DMA1_BASE, DMA_INT_AT_END);
DMA_enableInterrupt(ARC_DMA1_BASE);

//
// DMA channel 2 set up for ADCA second 512 Samples
//
DMA_configAddresses(ARC_DMA2_BASE, &ARC_ADCResults2,
(uint16_t *)ARC_ADC_RESULTS_BASE);

//
//Transfer 1 Word (16-Bit) per burst
//
DMA_configBurst(ARC_DMA2_BASE, 1, 0, 1);
//
//Do SAMPLES amount of burst per transfer
//
DMA_configTransfer(ARC_DMA2_BASE, ARC_SAMPLES / 2, 0, 1);
DMA_configMode(ARC_DMA2_BASE, DMA_TRIGGER_ADCA1,
(DMA_CFG_ONESHOT_DISABLE | DMA_CFG_CONTINUOUS_DISABLE |
DMA_CFG_SIZE_16BIT));

DMA_enableTrigger(ARC_DMA2_BASE);
DMA_disableOverrunInterrupt(ARC_DMA2_BASE);
DMA_setInterruptMode(ARC_DMA2_BASE, DMA_INT_AT_END);
DMA_enableInterrupt(ARC_DMA2_BASE);

//
// DMA channel 3 set up for copying from ADCResult1 or ADCResults to CH1Data
//
DMA_configAddresses(ARC_DMA3_BASE, &ARC_CH1Data,
&ARC_ADCResults1);

//
//Transfer 1 Word (16-Bit) per burst
//
DMA_configBurst(ARC_DMA3_BASE, 1, 1, 1);
//
//Do SAMPLES amount of burst per transfer
//
DMA_configTransfer(ARC_DMA3_BASE, ARC_SAMPLES / 2, 1, 1);
DMA_configMode(ARC_DMA3_BASE, DMA_TRIGGER_SOFTWARE,
(DMA_CFG_ONESHOT_ENABLE | DMA_CFG_CONTINUOUS_DISABLE |
DMA_CFG_SIZE_16BIT));

DMA_enableTrigger(ARC_DMA3_BASE);
DMA_disableOverrunInterrupt(ARC_DMA3_BASE);
DMA_setInterruptMode(ARC_DMA3_BASE, DMA_INT_AT_END);
DMA_enableInterrupt(ARC_DMA3_BASE);

DMA_clearTriggerFlag(ARC_DMA1_BASE); // DMA channel 1
DMA_clearTriggerFlag(ARC_DMA2_BASE); // DMA channel 2
DMA_clearTriggerFlag(ARC_DMA3_BASE); // DMA channel 3

//
// Start DMA 1
//
DMA_startChannel(ARC_DMA1_BASE);

}