我是通过epwm来触发内部ADC转换,再触发DMA传输到内存中,是每给一个epwm信号,就进行一次突发传输,我设置一次突发传输为一个字(我只用了通道A0),当epwm给的信号数为1024个时候,也就是说传了1024个burst到内存后,就触发DMA通道1中断。。。。采集停止。。。整个过程就是这样的。。。但现在我调试的时候发现进来的数据都是对的,就是没有进DMA中断,是不是采样窗和采样速率的原因导致ADC一直运行不能进中断。。。。真的希望有懂的人能够指点下,谢谢了。。。。我的程序是这样的。
#include "DSP2833x_Device.h" // DSP2833x Headerfile Include File
#include "DSP2833x_Examples.h" // DSP2833x Examples Include File
#define ADC_SHCLK 0xf // S/H width in ADC module periods
#define ADC_CKPS 0x1 // ADC module clock = HSPCLK/1
// Prototype statements for functions found within this file.
interrupt void local_DINTCH1_ISR(void);
#pragma DATA_SECTION(DMABuf1,"DMARAML4");
// Global variables used in this example:
volatile Uint16 *DMADest;
volatile Uint16 *DMASource;
volatile Uint16 DMABuf1[1024];
Uint16 flag=0;
main()
{
Uint16 i=0;
// Step 1. Initialize System Control:
// PLL, WatchDog, enable Peripheral Clocks
// This example function is found in the DSP2833x_SysCtrl.c file.
InitSysCtrl();
EALLOW;
#if (CPU_FRQ_150MHZ) // Default - 150 MHz SYSCLKOUT
#define ADC_MODCLK 0x3 // HSPCLK = SYSCLKOUT/2*ADC_MODCLK2 = 150/(2*3) = 25.0 MHz
#endif
#if (CPU_FRQ_100MHZ)
#define ADC_MODCLK 0x2 // HSPCLK = SYSCLKOUT/2*ADC_MODCLK2 = 100/(2*2) = 25.0 MHz
#endif
SysCtrlRegs.HISPCP.all = ADC_MODCLK;// HSPCLK = SYSCLKOUT/2*ADC_MODCLK2 = 150/(2*3) = 25.0 MHz
EDIS;
DINT;
// Initialize the PIE control registers to their default state.
// The default state is all PIE interrupts disabled and flags
// are cleared.
// This function is found in the DSP2833x_PieCtrl.c file.
InitPieCtrl();
// Clear Table
for (i=0; i<1024; i++)
{
DMABuf1[i] = 1;
}
// Disable CPU interrupts and clear all CPU interrupt flags:
IER = 0x0000;
IFR = 0x0000;
InitPieVectTable();
// Interrupts that are used in this example are re-mapped to
// ISR functions found within this file.
EALLOW; // This is needed to write to EALLOW protected register
PieVectTable.DINTCH1= &local_DINTCH1_ISR;
EDIS; // This is needed to disable write to EALLOW protected registers
IER = M_INT7 ; //Enable INT7 (7.1 DMA Ch1)
EnableInterrupts();
// Initialize all the Device Peripherals:
// This function is found in DSP2833x_InitPeripherals.c
// InitPeripherals(); // Not required for this example
InitAdc(); // For this example, init the ADC
// Configure ADC
AdcRegs.ADCTRL1.bit.ACQ_PS = ADC_SHCLK; //采样窗设置,尽量大点
AdcRegs.ADCTRL3.bit.ADCCLKPS = ADC_CKPS; //分频
AdcRegs.ADCTRL1.bit.SEQ_CASC = 1; //级联模式 1 Cascaded mode
AdcRegs.ADCMAXCONV.all = 0x0000; // 通道数为1个 Setup 1 conv's on SEQ1
AdcRegs.ADCTRL2.bit.RST_SEQ1 = 0x1; //初始化SEQ1
AdcRegs.ADCCHSELSEQ1.bit.CONV00 = 0x0; // 设置ADCINA0为第一采集通道 Setup ADCINA0 as 1st SEQ1 conv.
AdcRegs.ADCTRL2.bit.EPWM_SOCA_SEQ1 = 1; // 允许epwm为触发SEQ1 Enable SOCA from ePWM to start SEQ1
AdcRegs.ADCTRL2.bit.INT_ENA_SEQ1 = 1; //允许INT_SEQ1向CPU发出中断申请 Enable SEQ1 interrupt (every EOS)
// Configure ePWM1 设置1k的采样频率
EPwm1Regs.ETSEL.bit.SOCAEN = 1; // Enable SOC on A group
EPwm1Regs.ETSEL.bit.SOCASEL = 2; // 当TBCTR=TBPRD时产生epwm1soca信号
EPwm1Regs.ETPS.bit.SOCAPRD = 1; //在第一个事件时,产生SOC信号 Generate pulse on 1st event
EPwm1Regs.TBCTR=0; //对时基计数器清0
EPwm1Regs.TBPRD = 0x61A7; // Set period for ePWM1
EPwm1Regs.TBCTL.bit.HSPCLKDIV=3; //TBCLK=25Mhz
EPwm1Regs.TBCTL.bit.CTRMODE = 0; // count up and start
// Initialize DMA
DMAInitialize();
// Configure DMA Channel
DMADest = &DMABuf1[0]; //Point DMA destination to the beginning of the array
DMASource = &AdcMirror.ADCRESULT0; //Point DMA source to ADC result register base
DMACH1AddrConfig(DMADest,DMASource);
DMACH1BurstConfig(0,0,1);
DMACH1TransferConfig(1023,0,1);
DMACH1WrapConfig(0,0,0xFFFF,0);
DMACH1ModeConfig(DMA_SEQ1INT,PERINT_ENABLE,ONESHOT_DISABLE,CONT_ENABLE,SYNC_DISABLE,SYNC_SRC,
OVRFLOW_DISABLE,SIXTEEN_BIT,CHINT_END,CHINT_ENABLE);
StartDMACH1();
for(;;)
{
}
}
interrupt void local_DINTCH1_ISR(void)
{
// Acknowledge this interrupt to receive more interrupts from group 1
PieCtrlRegs.PIEACK.all = PIEACK_GROUP1; //0x0001赋给12组中断ACKnowledge寄存器,对其全部清除,不接受其他中断
// asm (" ESTOP0");
flag++;
}
|