我是新手...刚学DSP不久。。
我想用DMA模块将表中的数据不断的传输到ePWM模块的CMPA寄存器中,DMA的中断源信号用ePWM3SOCA。但是运行起来CMPA寄存器中的值一直不变,观察发现DmaRegs.CH1.SRC_ADDR_SHADOW中的值也是一直不变的 这是什么情况。。。
我写的程序如下:
/*
* main.c
*
* Created on: 2014-8-13
* Author: icecream
*/
#include "DSP28x_Project.h"
#define EPWM_TBPRD 50000
volatile Uint16 *DMADest3;
volatile Uint16 *DMASource3;
volatile Uint16 *DMADest4;
volatile Uint16 *DMASource4;
volatile Uint16 *DMADest5;
volatile Uint16 *DMASource5;
void InitEPwm3(void);
void InitEPwm4(void);
void InitEPwm5(void);
Uint16 sin_tab_3[100] =
{
25353,26765,28170,29562,30936,32287,33609,34897,36146,37351,
38508,39611,40656,41640,42558,43406,44182,44882,45504,46045,
46503,46876,47162,47361,47472,47494,47428,47273,47030,46700,
46284,45785,45203,44542,43803,42991,42107,41156,40141,39066,
37936,36755,35527,34258,32952,31615,30252,28868,27469,26060,
24647,23235,21830,20438,19064,17713,16391,15103,13854,12649,
11492,10389,9344,8360,7442,6594,5818,5118,4496,3955,
3497,3124,2838,2639,2528,2506,2572,2727,2970,3300,
3716,4215,4797,5458,6197,7009,7893,8844,9859,10934,
12064,13245,14473,15742,17048,18385,19748,21132,22531,23940
};
Uint16 sin_tab_4[100] =
{
44542,43803,42991,42107,41156,40141,39066,
37936,36755,35527,34258,32952,31615,30252,28868,27469,26060,
24647,23235,21830,20438,19064,17713,16391,15103,13854,12649,
11492,10389,9344,8360,7442,6594,5818,5118,4496,3955,
3497,3124,2838,2639,2528,2506,2572,2727,2970,3300,
3716,4215,4797,5458,6197,7009,7893,8844,9859,10934,
12064,13245,14473,15742,17048,18385,19748,21132,22531,23940,
25353,26765,28170,29562,30936,32287,33609,34897,36146,37351,
38508,39611,40656,41640,42558,43406,44182,44882,45504,46045,
46503,46876,47162,47361,47472,47494,47428,47273,47030,46700,
46284,45785,45203
};
Uint16 sin_tab_5[100] =
{
5818,5118,4496,3955,3497,3124,2838,2639,2528,2506,2572,2727,2970,3300,
3716,4215,4797,5458,6197,7009,7893,8844,9859,10934,
12064,13245,14473,15742,17048,18385,19748,21132,22531,23940,
25353,26765,28170,29562,30936,32287,33609,34897,36146,37351,
38508,39611,40656,41640,42558,43406,44182,44882,45504,46045,
46503,46876,47162,47361,47472,47494,47428,47273,47030,46700,
46284,45785,45203,44542,43803,42991,42107,41156,40141,39066,
37936,36755,35527,34258,32952,31615,30252,28868,27469,26060,
24647,23235,21830,20438,19064,17713,16391,15103,13854,12649,
11492,10389,9344,8360,7442,6594
};
void main(void)
{
InitSysCtrl();
InitEPwm3Gpio();
InitEPwm4Gpio();
InitEPwm5Gpio();
DINT;
InitPieCtrl();
IER = 0x0000;
IFR = 0x0000;
InitPieVectTable();
EALLOW;
SysCtrlRegs.PCLKCR0.bit.TBCLKSYNC = 0;
EDIS;
InitEPwm3();
InitEPwm4();
InitEPwm5();
EPwm1Regs.TBCTL.bit.SYNCOSEL =TB_CTR_ZERO;
EPwm2Regs.TBCTL.bit.SYNCOSEL =TB_SYNC_IN;
EALLOW;
SysCtrlRegs.PCLKCR0.bit.TBCLKSYNC = 1;
EDIS;
//IER |= M_INT3;
PieCtrlRegs.PIEIER3.bit.INTx3 = 1;
PieCtrlRegs.PIEIER3.bit.INTx4 = 1;
PieCtrlRegs.PIEIER3.bit.INTx5 = 1;
//EINT;
//ERTM;
DMAInitialize();
DMASource3 = &sin_tab_3[0];
DMASource4 = &sin_tab_4[0];
DMASource5 = &sin_tab_5[0];
DMADest3 = &EPwm3Regs.CMPA.half.CMPA;
DMADest4 = &EPwm4Regs.CMPA.half.CMPA;
DMADest5 = &EPwm5Regs.CMPA.half.CMPA;
DMACH1AddrConfig(DMADest3,DMASource3);
DMACH2AddrConfig(DMADest4,DMASource4);
DMACH3AddrConfig(DMADest5,DMASource5);
DMACH1BurstConfig(9,1,0);
DMACH2BurstConfig(9,1,0);
DMACH3BurstConfig(9,1,0);
DMACH1TransferConfig(9,1,0);
DMACH2TransferConfig(9,1,0);
DMACH3TransferConfig(9,1,0);
DMACH1WrapConfig(9,1,0,0);
DMACH2WrapConfig(9,0,0,0);
DMACH3WrapConfig(9,0,0,0);
DMACH1ModeConfig(22,PERINT_ENABLE,ONESHOT_DISABLE,CONT_ENABLE,SYNC_DISABLE,SYNC_SRC,OVRFLOW_DISABLE,SIXTEEN_BIT,CHINT_END,CHINT_ENABLE);
DMACH2ModeConfig(22,PERINT_ENABLE,ONESHOT_DISABLE,CONT_ENABLE,SYNC_DISABLE,SYNC_SRC,OVRFLOW_DISABLE,SIXTEEN_BIT,CHINT_END,CHINT_ENABLE);
DMACH3ModeConfig(22,PERINT_ENABLE,ONESHOT_DISABLE,CONT_ENABLE,SYNC_DISABLE,SYNC_SRC,OVRFLOW_DISABLE,SIXTEEN_BIT,CHINT_END,CHINT_ENABLE);
StartDMACH1();
StartDMACH2();
StartDMACH3();
EALLOW;
SysCtrlRegs.PCLKCR3.bit.DMAENCLK = 1;
EDIS;
for(;;);
}
void InitEPwm3(void)
{
EPwm3Regs.TBPRD = EPWM_TBPRD;
EPwm3Regs.TBPHS.half.TBPHS = 0x0000;
EPwm3Regs.TBCTR = 0x0000;
EPwm3Regs.TBCTL.bit.CTRMODE = TB_COUNT_UPDOWN;
EPwm3Regs.TBCTL.bit.PHSEN = TB_ENABLE;
EPwm3Regs.TBCTL.bit.HSPCLKDIV = 0x3;
EPwm3Regs.TBCTL.bit.CLKDIV = TB_DIV1;
EPwm3Regs.TBCTL.bit.SYNCOSEL = TB_SYNC_IN;
EPwm3Regs.CMPCTL.bit.SHDWAMODE = CC_SHADOW;
EPwm3Regs.CMPCTL.bit.SHDWBMODE = CC_SHADOW;
EPwm3Regs.CMPCTL.bit.LOADAMODE = CC_CTR_ZERO;
EPwm3Regs.CMPCTL.bit.LOADBMODE = CC_CTR_ZERO;
EPwm3Regs.CMPA.half.CMPA = 0;
EPwm3Regs.CMPB = 0;
EPwm3Regs.AQCTLA.bit.CAU = AQ_CLEAR;
EPwm3Regs.AQCTLA.bit.CAD = AQ_SET;
EPwm3Regs.AQCTLB.bit.CAU = AQ_SET;
EPwm3Regs.AQCTLB.bit.CAD = AQ_CLEAR;
EPwm3Regs.ETSEL.bit.INTSEL = ET_CTR_ZERO;
EPwm3Regs.ETSEL.bit.INTEN = 1;
EPwm3Regs.ETPS.bit.INTPRD = ET_1ST;
EPwm3Regs.ETSEL.bit.SOCASEL = ET_CTR_ZERO;
EPwm3Regs.ETSEL.bit.SOCAEN = 1;
EPwm3Regs.ETPS.bit.SOCAPRD = ET_1ST;
EPwm3Regs.DBCTL.bit.IN_MODE = DBA_ALL;
EPwm3Regs.DBCTL.bit.POLSEL = DB_ACTV_HIC;
EPwm3Regs.DBCTL.bit.OUT_MODE = DB_FULL_ENABLE;
EPwm3Regs.DBRED = 50;
EPwm3Regs.DBFED = 50;
}
void InitEPwm4(void)
{
EPwm4Regs.TBPRD = EPWM_TBPRD;
EPwm4Regs.TBPHS.half.TBPHS = 0x0000;
EPwm4Regs.TBCTR = 0x0000;
EPwm4Regs.TBCTL.bit.CTRMODE = TB_COUNT_UPDOWN;
EPwm4Regs.TBCTL.bit.PHSEN = TB_ENABLE;
EPwm4Regs.TBCTL.bit.HSPCLKDIV = 0x3;
EPwm4Regs.TBCTL.bit.CLKDIV = TB_DIV1;
EPwm4Regs.TBCTL.bit.SYNCOSEL = TB_SYNC_IN;
EPwm4Regs.CMPCTL.bit.SHDWAMODE = CC_SHADOW;
EPwm4Regs.CMPCTL.bit.SHDWBMODE = CC_SHADOW;
EPwm4Regs.CMPCTL.bit.LOADAMODE = CC_CTR_ZERO;
EPwm4Regs.CMPCTL.bit.LOADBMODE = CC_CTR_ZERO;
EPwm4Regs.CMPA.half.CMPA = 0;
EPwm4Regs.CMPB = 0;
EPwm4Regs.AQCTLA.bit.CAU = AQ_CLEAR;
EPwm4Regs.AQCTLA.bit.CAD = AQ_SET;
EPwm4Regs.AQCTLB.bit.CAU = AQ_SET;
EPwm4Regs.AQCTLB.bit.CAD = AQ_CLEAR;
EPwm4Regs.ETSEL.bit.INTSEL = ET_CTR_ZERO;
EPwm4Regs.ETSEL.bit.INTEN = 1;
EPwm4Regs.ETPS.bit.INTPRD = ET_1ST;
EPwm4Regs.ETSEL.bit.SOCASEL = ET_CTR_ZERO;
EPwm4Regs.ETSEL.bit.SOCAEN = 1;
EPwm4Regs.ETPS.bit.SOCAPRD = ET_1ST;
EPwm4Regs.DBCTL.bit.IN_MODE = DBA_ALL;
EPwm4Regs.DBCTL.bit.POLSEL = DB_ACTV_HIC;
EPwm4Regs.DBCTL.bit.OUT_MODE = DB_FULL_ENABLE;
EPwm4Regs.DBRED = 50;
EPwm4Regs.DBFED = 50;
}
void InitEPwm5(void)
{
EPwm5Regs.TBPRD = EPWM_TBPRD;
EPwm5Regs.TBPHS.half.TBPHS = 0x0000;
EPwm5Regs.TBCTR = 0x0000;
EPwm5Regs.TBCTL.bit.CTRMODE = TB_COUNT_UPDOWN;
EPwm5Regs.TBCTL.bit.PHSEN = TB_ENABLE;
EPwm5Regs.TBCTL.bit.HSPCLKDIV = 0x3;
EPwm5Regs.TBCTL.bit.CLKDIV = TB_DIV1;
EPwm5Regs.TBCTL.bit.SYNCOSEL = TB_SYNC_IN;
EPwm5Regs.CMPCTL.bit.SHDWAMODE = CC_SHADOW;
EPwm5Regs.CMPCTL.bit.SHDWBMODE = CC_SHADOW;
EPwm5Regs.CMPCTL.bit.LOADAMODE = CC_CTR_ZERO;
EPwm5Regs.CMPCTL.bit.LOADBMODE = CC_CTR_ZERO;
EPwm5Regs.CMPA.half.CMPA = 0;
EPwm5Regs.CMPB = 0;
EPwm5Regs.AQCTLA.bit.CAU = AQ_CLEAR;
EPwm5Regs.AQCTLA.bit.CAD = AQ_SET;
EPwm5Regs.AQCTLB.bit.CAU = AQ_SET;
EPwm5Regs.AQCTLB.bit.CAD = AQ_CLEAR;
EPwm5Regs.ETSEL.bit.INTSEL = ET_CTR_ZERO;
EPwm5Regs.ETSEL.bit.INTEN = 1;
EPwm5Regs.ETPS.bit.INTPRD = ET_1ST;
EPwm5Regs.ETSEL.bit.SOCASEL = ET_CTR_ZERO;
EPwm5Regs.ETSEL.bit.SOCAEN = 1;
EPwm5Regs.ETPS.bit.SOCAPRD = ET_1ST;
EPwm5Regs.DBCTL.bit.IN_MODE = DBA_ALL;
EPwm5Regs.DBCTL.bit.POLSEL = DB_ACTV_HIC;
EPwm5Regs.DBCTL.bit.OUT_MODE = DB_FULL_ENABLE;
EPwm5Regs.DBRED = 50;
EPwm5Regs.DBFED = 50;
}
还请各位大侠帮帮忙看看呀~ |