有个问题!
关于28335ADC的 Sequencer Start/Stop模式,在TI28335 ADC 参考手册第22页,如下图:
代码初始化:
1. eWPM1计数器工作在up-down模式;
2. CTR=0时,产生ePWM1SOCA触发AD排序器1采样转换I1,I2,I3这三个通道;
3. CTR=PRD时,产生ePWM1SOCB触发AD排序器2采样转换V1,V2,V3这三个通道;
但为什么转换的结果只有I1,I2,I3这三个通道转换成功了,而V1,V2,V3折三个通道始终值为0。
请问大家使用过这种模式吗?
麻烦大家给指导指导吧!!
测试代码如下:
附件中是源文件!
#include "DSP2833x_Device.h" // DSP2833x Headerfile Include File
#include "DSP2833x_Examples.h" // DSP2833x Examples Include File
// Prototype statements for functions found within this file.
interrupt void adc_isr(void);
Uint16 VoltageA[3];
Uint16 VoltageB[3];
Uint16 upDownFlag = 0;
Uint16 PWMDuty = 0;
void main(void)
{
InitSysCtrl();
DINT;
InitPieCtrl();
IER = 0x0000;
IFR = 0x0000;
InitPieVectTable();
InitEPwm1Gpio(); //PWM outPin≥ı ºªØ
EALLOW;
GpioCtrlRegs.GPAMUX1.bit.GPIO7 = 0; // GPIO0∏¥”√Œ™GPIO𶃋
GpioCtrlRegs.GPADIR.bit.GPIO7 = 1; // GPIO0…Ë÷√Œ™ ‰≥ˆ
PieVectTable.ADCINT = &adc_isr;//ADC interrupt
PieVectTable.EPWM1_INT = &EPWM1_INT_ISR; //ePWM1 zero interrupt
EDIS;
AdcRegs.ADCTRL1.all = 0;
AdcRegs.ADCTRL2.all = 0;
AdcRegs.ADCTRL3.all = 0;
//config ADC
AdcRegs.ADCTRL2.bit.RST_SEQ1 = 1;
AdcRegs.ADCTRL2.bit.RST_SEQ2 = 1;
AdcRegs.ADCTRL1.bit.ACQ_PS = 3;
AdcRegs.ADCTRL1.bit.SEQ_CASC = 0;//0:À´≈≈–Ú∆˜ƒ£ Ω£ª1£∫º∂¡™≈≈–Úƒ£ Ω
AdcRegs.ADCTRL3.bit.SMODE_SEL = 0;//0:¡¨–¯≤…—˘£ª1£∫Õ¨≤Ω≤…—˘ƒ£ Ω
AdcRegs.ADCTRL1.bit.CONT_RUN = 0;//0£∫∆Ù∂Ø/Õ£÷πƒ£ Ω£ª1:¡¨–¯ƒ£ Ω
AdcRegs.ADCTRL1.bit.SEQ_OVRD = 0;
//config SEQ1
AdcRegs.ADCTRL2.bit.SOC_SEQ1 = 1;
AdcRegs.ADCTRL2.bit.EPWM_SOCA_SEQ1 = 1;
AdcRegs.ADCTRL2.bit.INT_ENA_SEQ1 = 1;
AdcRegs.ADCCHSELSEQ1.bit.CONV00 = 0x00;
AdcRegs.ADCCHSELSEQ1.bit.CONV01 = 0x01;
AdcRegs.ADCCHSELSEQ1.bit.CONV02 = 0x02;
AdcRegs.ADCMAXCONV.all = 0x22;
//config SEQ2
AdcRegs.ADCTRL2.bit.SOC_SEQ2 = 1;
AdcRegs.ADCTRL2.bit.EPWM_SOCB_SEQ2 = 1;
AdcRegs.ADCTRL2.bit.INT_ENA_SEQ2 = 1;
AdcRegs.ADCCHSELSEQ3.bit.CONV08 = 0x08;
AdcRegs.ADCCHSELSEQ3.bit.CONV09 = 0x09;
AdcRegs.ADCCHSELSEQ3.bit.CONV10 = 0x0A;
// AdcRegs.ADCMAXCONV.bit.MAX_CONV2 = 0x2;
extern void DSP28x_usDelay(Uint32 Count);
AdcRegs.ADCTRL3.all |= 0x00E0; // Power up bandgap/reference/ADC circuits
DELAY_US(5000L); // Delay before converting ADC channels
/*ePWM config*/
EPwm1Regs.TBPRD = 6000; // ±ª˘º∆ ˝÷‹∆⁄
EPwm1Regs.CMPA.half.CMPA = 1500; //º∆ ˝±»Ωœºƒ¥Ê∆˜A
EPwm1Regs.TBPHS.all = 0;// ±ª˘Õ¨≤Ωœ‡Œª
EPwm1Regs.TBCTR = 0;// ±ª˘º∆ ˝∆˜≥ı º÷µ
EPwm1Regs.TBCTL.bit.PHSDIR = TB_UP;//œ‡Œª∑ΩœÚøÿ÷∆ºƒ¥Ê∆˜£¨µ±Õ¨≤Ω–≈∫≈¿¥ ±£¨◊∞‘ÿ¡Àœ‡Œªºƒ¥Ê∆˜µƒ÷µ∫Û «œÚ…œº∆ ˝ªπ «œÚœ¬º∆ ˝
EPwm1Regs.TBCTL.bit.SYNCOSEL = TB_CTR_ZERO; //œ‡ŒªÕ¨≤Ω–≈∫≈‘¥—°‘Ò£¨µ±CTR=ZERO ± ‰≥ˆÕ¨≤Ω–≈∫≈
EPwm1Regs.TBCTL.bit.PHSEN = TB_ENABLE;//µ±Õ¨≤Ω–≈∫≈¿¥ ±£¨øÿ÷∆ «∑Ò◊∞‘ÿœ‡Œªºƒ¥Ê∆˜µƒ÷µ–µ±Õ¨≤Ω–≈∫≈¿¥ ±£¨º∆ ˝ºƒ¥Ê∆˜◊∞‘ÿœ‡Œªºƒ¥Ê∆˜µƒ÷µ
EPwm1Regs.TBCTL.bit.PRDLD = TB_IMMEDIATE; //Ω˚÷π π”√”∞◊”ºƒ¥Ê∆˜
EPwm1Regs.TBCTL.bit.CTRMODE = TB_COUNT_UPDOWN; //º∆ ˝ƒ£ Ωøÿ÷∆ºƒ¥Ê∆˜:up; down; up-down;stop
EPwm1Regs.TBCTL.bit.HSPCLKDIV = TB_DIV1; //∏flÀŸ ±ª˘ ±÷”∑÷∆µ
EPwm1Regs.TBCTL.bit.CLKDIV = TB_DIV1;// ±ª˘ ±÷”∑÷∆µ
EPwm1Regs.DBCTL.bit.IN_MODE = DBA_ALL;//À¿«¯ƒ£øÈ ‰»Î‘¥øÿ÷∆£¨Ω´ePWM3A◊˜Œ™À´±fl—ÿ—” ± ‰»Î‘¥
EPwm1Regs.DBCTL.bit.POLSEL = DB_ACTV_HIC; //À¿«¯º´–‘—°‘Òøÿ÷∆£¨ePWM3A≤ª∑≠◊™£¨ePWM3B∑≠◊™
EPwm1Regs.DBCTL.bit.OUT_MODE = DB_FULL_ENABLE;
EPwm1Regs.DBRED = 100;//À¿«¯…œ…˝—ÿ—” ±ºƒ¥Ê∆˜
EPwm1Regs.DBFED = 100;//À¿«¯œ¬Ωµ—ÿ—” ±ºƒ¥Ê∆˜
EPwm1Regs.AQCTLA.bit.ZRO = AQ_CLEAR; //µ± ±ª˘º∆ ˝∆˜µƒ÷µµ»”⁄0 ±£¨ePWM3A ‰≥ˆµÕ
EPwm1Regs.AQCTLA.bit.CAU = AQ_SET;//µ± ±ª˘º∆ ˝∆˜œÚ…œº∆ ˝£¨≤¢«“ ±ª˘º∆ ˝∆˜µƒ÷µ”ÎCMPAºƒ¥Ê∆˜µƒ÷µœ‡µ» ±£¨ePWMA ‰≥ˆ∏fl
EPwm1Regs.AQCTLA.bit.CAD = AQ_CLEAR;//µ± ±ª˘º∆ ˝∆˜œÚœ¬º∆ ˝£¨≤¢«“ ±ª˘º∆ ˝∆˜µƒ÷µ”ÎCMPAºƒ¥Ê∆˜µƒ÷µœ‡µ» ±£¨eWPMA ‰≥ˆµÕ
EPwm1Regs.ETSEL.bit.SOCASEL = ET_CTR_PRD; //ePWMxSOCA¥•∑¢–≈∫≈≤˙…˙Ãıº˛£¨µ±CTR=0 ±≤˙…˙÷–∂œ¥•∑¢
EPwm1Regs.ETSEL.bit.SOCAEN = 0x1;// πƒ‹ePWMxSOCA–≈∫≈≤˙…˙
EPwm1Regs.ETSEL.bit.SOCBEN = 0x1;// πƒ‹ePWMxSOCB–≈∫≈≤˙…˙
EPwm1Regs.ETSEL.bit.SOCBSEL = ET_CTR_ZERO; //ePWMxSOCB¥•∑¢–≈∫≈≤˙…˙Ãıº˛£¨µ±CTR=PRD ±≤˙…˙÷–∂œ¥•∑¢
EPwm1Regs.ETSEL.bit.INTSEL = ET_CTR_ZERO; //ePWM÷–∂œÃıº˛—°‘Ò
EPwm1Regs.ETSEL.bit.INTEN = 0x1;// πƒ‹ePWM÷–∂œ
EPwm1Regs.ETPS.bit.SOCACNT = 0x1;//∂‘≤˙…˙ePWMxSOCAÃıº˛ ¬º˛º∆ ˝£¨”–1¥Œ ¬º˛∑¢…˙ ±
EPwm1Regs.ETPS.bit.SOCAPRD = 0x1;//ePWMxSOCA–≈∫≈≤˙…˙Ãıº˛£¨‘⁄µ⁄1∏ˆ ¬º˛ ±£¨≤˙…˙SOC–≈∫≈
EPwm1Regs.ETPS.bit.SOCBCNT = 0x1;//∂‘≤˙…˙ePWMxSOCBÃıº˛ ¬º˛º∆ ˝£¨”–1¥Œ ¬º˛∑¢…˙ ±
EPwm1Regs.ETPS.bit.SOCBPRD = 0x1;//ePWMxSOCB–≈∫≈≤˙…˙Ãıº˛£¨‘⁄µ⁄1∏ˆ ¬º˛ ±£¨≤˙…˙SOC–≈∫≈
EPwm1Regs.ETPS.bit.INTCNT = 0x1;//∂‘ePWM÷–∂œ ¬º˛º∆ ˝
EPwm1Regs.ETPS.bit.INTPRD = 0x1;//÷–∂œ≤˙…˙Ãıº˛…Ë÷√£¨µ±INTCNT º∆ ˝µ»”⁄1 ±£¨≤˙…˙÷–∂œ
EPwm1Regs.ETCLR.bit.INT = 0x1;//«Â≥˝÷–∂œ±Í÷挪
EPwm1Regs.ETCLR.bit.SOCA = 0x1;//«Â≥˝SOCA±Í÷挪
EPwm1Regs.ETCLR.bit.SOCB = 0x1;
//enable Interrupt
PieCtrlRegs.PIECTRL.bit.ENPIE = 1; //vector enable
PieCtrlRegs.PIEIER1.bit.INTx6 = 1; //enable adc
PieCtrlRegs.PIEIER3.bit.INTx1 = 1; //enable ePWM1 zero interrupt
IER |= M_INT1;
IER |= M_INT3;
EINT; // ◊‹÷–∂œ INTM πƒ‹
ERTM; // πƒ‹◊‹ µ ±÷–∂œ DBGM
while(1)
{
DELAY_US(1000);
}
}
interrupt void adc_isr(void)
{
GpioDataRegs.GPADAT.bit.GPIO7 = 1;
// Insert ISR Code here
VoltageA[0] = AdcRegs.ADCRESULT0 >>4;
VoltageA[1] = AdcRegs.ADCRESULT1 >>4;
VoltageA[2] = AdcRegs.ADCRESULT2 >>4;
VoltageB[0] = AdcRegs.ADCRESULT3 >>4;
VoltageB[1] = AdcRegs.ADCRESULT4 >>4;
VoltageB[2] = AdcRegs.ADCRESULT5 >>4;
AdcRegs.ADCTRL2.bit.RST_SEQ1 = 1; // Reset SEQ1
AdcRegs.ADCTRL2.bit.RST_SEQ2 = 1; // Reset SEQ1
AdcRegs.ADCST.bit.INT_SEQ1_CLR = 1; // Clear INT SEQ1 bit
AdcRegs.ADCST.bit.INT_SEQ2_CLR = 1; // Clear INT SEQ1 bit
PieCtrlRegs.PIEACK.all = PIEACK_GROUP1; // Acknowledge interrupt to PIE
GpioDataRegs.GPADAT.bit.GPIO7 = 0;
}
Linda:
您好!
请到以下网址下载controlSUITE:
www.ti.com/controlsuite
(选择offline ZIP installer)
安装后可以在以下目录下找到F28335的例程:
C:\ti\controlSUITE\device_support\f2833x\v142\DSP2833x_examples_ccsv5
可以参考其中adc_开头的例程中的设置.
有个问题!
关于28335ADC的 Sequencer Start/Stop模式,在TI28335 ADC 参考手册第22页,如下图:
代码初始化:
1. eWPM1计数器工作在up-down模式;
2. CTR=0时,产生ePWM1SOCA触发AD排序器1采样转换I1,I2,I3这三个通道;
3. CTR=PRD时,产生ePWM1SOCB触发AD排序器2采样转换V1,V2,V3这三个通道;
但为什么转换的结果只有I1,I2,I3这三个通道转换成功了,而V1,V2,V3折三个通道始终值为0。
请问大家使用过这种模式吗?
麻烦大家给指导指导吧!!
测试代码如下:
附件中是源文件!
#include "DSP2833x_Device.h" // DSP2833x Headerfile Include File
#include "DSP2833x_Examples.h" // DSP2833x Examples Include File
// Prototype statements for functions found within this file.
interrupt void adc_isr(void);
Uint16 VoltageA[3];
Uint16 VoltageB[3];
Uint16 upDownFlag = 0;
Uint16 PWMDuty = 0;
void main(void)
{
InitSysCtrl();
DINT;
InitPieCtrl();
IER = 0x0000;
IFR = 0x0000;
InitPieVectTable();
InitEPwm1Gpio(); //PWM outPin≥ı ºªØ
EALLOW;
GpioCtrlRegs.GPAMUX1.bit.GPIO7 = 0; // GPIO0∏¥”√Œ™GPIO𶃋
GpioCtrlRegs.GPADIR.bit.GPIO7 = 1; // GPIO0…Ë÷√Œ™ ‰≥ˆ
PieVectTable.ADCINT = &adc_isr;//ADC interrupt
PieVectTable.EPWM1_INT = &EPWM1_INT_ISR; //ePWM1 zero interrupt
EDIS;
AdcRegs.ADCTRL1.all = 0;
AdcRegs.ADCTRL2.all = 0;
AdcRegs.ADCTRL3.all = 0;
//config ADC
AdcRegs.ADCTRL2.bit.RST_SEQ1 = 1;
AdcRegs.ADCTRL2.bit.RST_SEQ2 = 1;
AdcRegs.ADCTRL1.bit.ACQ_PS = 3;
AdcRegs.ADCTRL1.bit.SEQ_CASC = 0;//0:À´≈≈–Ú∆˜ƒ£ Ω£ª1£∫º∂¡™≈≈–Úƒ£ Ω
AdcRegs.ADCTRL3.bit.SMODE_SEL = 0;//0:¡¨–¯≤…—˘£ª1£∫Õ¨≤Ω≤…—˘ƒ£ Ω
AdcRegs.ADCTRL1.bit.CONT_RUN = 0;//0£∫∆Ù∂Ø/Õ£÷πƒ£ Ω£ª1:¡¨–¯ƒ£ Ω
AdcRegs.ADCTRL1.bit.SEQ_OVRD = 0;
//config SEQ1
AdcRegs.ADCTRL2.bit.SOC_SEQ1 = 1;
AdcRegs.ADCTRL2.bit.EPWM_SOCA_SEQ1 = 1;
AdcRegs.ADCTRL2.bit.INT_ENA_SEQ1 = 1;
AdcRegs.ADCCHSELSEQ1.bit.CONV00 = 0x00;
AdcRegs.ADCCHSELSEQ1.bit.CONV01 = 0x01;
AdcRegs.ADCCHSELSEQ1.bit.CONV02 = 0x02;
AdcRegs.ADCMAXCONV.all = 0x22;
//config SEQ2
AdcRegs.ADCTRL2.bit.SOC_SEQ2 = 1;
AdcRegs.ADCTRL2.bit.EPWM_SOCB_SEQ2 = 1;
AdcRegs.ADCTRL2.bit.INT_ENA_SEQ2 = 1;
AdcRegs.ADCCHSELSEQ3.bit.CONV08 = 0x08;
AdcRegs.ADCCHSELSEQ3.bit.CONV09 = 0x09;
AdcRegs.ADCCHSELSEQ3.bit.CONV10 = 0x0A;
// AdcRegs.ADCMAXCONV.bit.MAX_CONV2 = 0x2;
extern void DSP28x_usDelay(Uint32 Count);
AdcRegs.ADCTRL3.all |= 0x00E0; // Power up bandgap/reference/ADC circuits
DELAY_US(5000L); // Delay before converting ADC channels
/*ePWM config*/
EPwm1Regs.TBPRD = 6000; // ±ª˘º∆ ˝÷‹∆⁄
EPwm1Regs.CMPA.half.CMPA = 1500; //º∆ ˝±»Ωœºƒ¥Ê∆˜A
EPwm1Regs.TBPHS.all = 0;// ±ª˘Õ¨≤Ωœ‡Œª
EPwm1Regs.TBCTR = 0;// ±ª˘º∆ ˝∆˜≥ı º÷µ
EPwm1Regs.TBCTL.bit.PHSDIR = TB_UP;//œ‡Œª∑ΩœÚøÿ÷∆ºƒ¥Ê∆˜£¨µ±Õ¨≤Ω–≈∫≈¿¥ ±£¨◊∞‘ÿ¡Àœ‡Œªºƒ¥Ê∆˜µƒ÷µ∫Û «œÚ…œº∆ ˝ªπ «œÚœ¬º∆ ˝
EPwm1Regs.TBCTL.bit.SYNCOSEL = TB_CTR_ZERO; //œ‡ŒªÕ¨≤Ω–≈∫≈‘¥—°‘Ò£¨µ±CTR=ZERO ± ‰≥ˆÕ¨≤Ω–≈∫≈
EPwm1Regs.TBCTL.bit.PHSEN = TB_ENABLE;//µ±Õ¨≤Ω–≈∫≈¿¥ ±£¨øÿ÷∆ «∑Ò◊∞‘ÿœ‡Œªºƒ¥Ê∆˜µƒ÷µ–µ±Õ¨≤Ω–≈∫≈¿¥ ±£¨º∆ ˝ºƒ¥Ê∆˜◊∞‘ÿœ‡Œªºƒ¥Ê∆˜µƒ÷µ
EPwm1Regs.TBCTL.bit.PRDLD = TB_IMMEDIATE; //Ω˚÷π π”√”∞◊”ºƒ¥Ê∆˜
EPwm1Regs.TBCTL.bit.CTRMODE = TB_COUNT_UPDOWN; //º∆ ˝ƒ£ Ωøÿ÷∆ºƒ¥Ê∆˜:up; down; up-down;stop
EPwm1Regs.TBCTL.bit.HSPCLKDIV = TB_DIV1; //∏flÀŸ ±ª˘ ±÷”∑÷∆µ
EPwm1Regs.TBCTL.bit.CLKDIV = TB_DIV1;// ±ª˘ ±÷”∑÷∆µ
EPwm1Regs.DBCTL.bit.IN_MODE = DBA_ALL;//À¿«¯ƒ£øÈ ‰»Î‘¥øÿ÷∆£¨Ω´ePWM3A◊˜Œ™À´±fl—ÿ—” ± ‰»Î‘¥
EPwm1Regs.DBCTL.bit.POLSEL = DB_ACTV_HIC; //À¿«¯º´–‘—°‘Òøÿ÷∆£¨ePWM3A≤ª∑≠◊™£¨ePWM3B∑≠◊™
EPwm1Regs.DBCTL.bit.OUT_MODE = DB_FULL_ENABLE;
EPwm1Regs.DBRED = 100;//À¿«¯…œ…˝—ÿ—” ±ºƒ¥Ê∆˜
EPwm1Regs.DBFED = 100;//À¿«¯œ¬Ωµ—ÿ—” ±ºƒ¥Ê∆˜
EPwm1Regs.AQCTLA.bit.ZRO = AQ_CLEAR; //µ± ±ª˘º∆ ˝∆˜µƒ÷µµ»”⁄0 ±£¨ePWM3A ‰≥ˆµÕ
EPwm1Regs.AQCTLA.bit.CAU = AQ_SET;//µ± ±ª˘º∆ ˝∆˜œÚ…œº∆ ˝£¨≤¢«“ ±ª˘º∆ ˝∆˜µƒ÷µ”ÎCMPAºƒ¥Ê∆˜µƒ÷µœ‡µ» ±£¨ePWMA ‰≥ˆ∏fl
EPwm1Regs.AQCTLA.bit.CAD = AQ_CLEAR;//µ± ±ª˘º∆ ˝∆˜œÚœ¬º∆ ˝£¨≤¢«“ ±ª˘º∆ ˝∆˜µƒ÷µ”ÎCMPAºƒ¥Ê∆˜µƒ÷µœ‡µ» ±£¨eWPMA ‰≥ˆµÕ
EPwm1Regs.ETSEL.bit.SOCASEL = ET_CTR_PRD; //ePWMxSOCA¥•∑¢–≈∫≈≤˙…˙Ãıº˛£¨µ±CTR=0 ±≤˙…˙÷–∂œ¥•∑¢
EPwm1Regs.ETSEL.bit.SOCAEN = 0x1;// πƒ‹ePWMxSOCA–≈∫≈≤˙…˙
EPwm1Regs.ETSEL.bit.SOCBEN = 0x1;// πƒ‹ePWMxSOCB–≈∫≈≤˙…˙
EPwm1Regs.ETSEL.bit.SOCBSEL = ET_CTR_ZERO; //ePWMxSOCB¥•∑¢–≈∫≈≤˙…˙Ãıº˛£¨µ±CTR=PRD ±≤˙…˙÷–∂œ¥•∑¢
EPwm1Regs.ETSEL.bit.INTSEL = ET_CTR_ZERO; //ePWM÷–∂œÃıº˛—°‘Ò
EPwm1Regs.ETSEL.bit.INTEN = 0x1;// πƒ‹ePWM÷–∂œ
EPwm1Regs.ETPS.bit.SOCACNT = 0x1;//∂‘≤˙…˙ePWMxSOCAÃıº˛ ¬º˛º∆ ˝£¨”–1¥Œ ¬º˛∑¢…˙ ±
EPwm1Regs.ETPS.bit.SOCAPRD = 0x1;//ePWMxSOCA–≈∫≈≤˙…˙Ãıº˛£¨‘⁄µ⁄1∏ˆ ¬º˛ ±£¨≤˙…˙SOC–≈∫≈
EPwm1Regs.ETPS.bit.SOCBCNT = 0x1;//∂‘≤˙…˙ePWMxSOCBÃıº˛ ¬º˛º∆ ˝£¨”–1¥Œ ¬º˛∑¢…˙ ±
EPwm1Regs.ETPS.bit.SOCBPRD = 0x1;//ePWMxSOCB–≈∫≈≤˙…˙Ãıº˛£¨‘⁄µ⁄1∏ˆ ¬º˛ ±£¨≤˙…˙SOC–≈∫≈
EPwm1Regs.ETPS.bit.INTCNT = 0x1;//∂‘ePWM÷–∂œ ¬º˛º∆ ˝
EPwm1Regs.ETPS.bit.INTPRD = 0x1;//÷–∂œ≤˙…˙Ãıº˛…Ë÷√£¨µ±INTCNT º∆ ˝µ»”⁄1 ±£¨≤˙…˙÷–∂œ
EPwm1Regs.ETCLR.bit.INT = 0x1;//«Â≥˝÷–∂œ±Í÷挪
EPwm1Regs.ETCLR.bit.SOCA = 0x1;//«Â≥˝SOCA±Í÷挪
EPwm1Regs.ETCLR.bit.SOCB = 0x1;
//enable Interrupt
PieCtrlRegs.PIECTRL.bit.ENPIE = 1; //vector enable
PieCtrlRegs.PIEIER1.bit.INTx6 = 1; //enable adc
PieCtrlRegs.PIEIER3.bit.INTx1 = 1; //enable ePWM1 zero interrupt
IER |= M_INT1;
IER |= M_INT3;
EINT; // ◊‹÷–∂œ INTM πƒ‹
ERTM; // πƒ‹◊‹ µ ±÷–∂œ DBGM
while(1)
{
DELAY_US(1000);
}
}
interrupt void adc_isr(void)
{
GpioDataRegs.GPADAT.bit.GPIO7 = 1;
// Insert ISR Code here
VoltageA[0] = AdcRegs.ADCRESULT0 >>4;
VoltageA[1] = AdcRegs.ADCRESULT1 >>4;
VoltageA[2] = AdcRegs.ADCRESULT2 >>4;
VoltageB[0] = AdcRegs.ADCRESULT3 >>4;
VoltageB[1] = AdcRegs.ADCRESULT4 >>4;
VoltageB[2] = AdcRegs.ADCRESULT5 >>4;
AdcRegs.ADCTRL2.bit.RST_SEQ1 = 1; // Reset SEQ1
AdcRegs.ADCTRL2.bit.RST_SEQ2 = 1; // Reset SEQ1
AdcRegs.ADCST.bit.INT_SEQ1_CLR = 1; // Clear INT SEQ1 bit
AdcRegs.ADCST.bit.INT_SEQ2_CLR = 1; // Clear INT SEQ1 bit
PieCtrlRegs.PIEACK.all = PIEACK_GROUP1; // Acknowledge interrupt to PIE
GpioDataRegs.GPADAT.bit.GPIO7 = 0;
}
z fang:
回复 Linda:
Hi Linda
谢谢你的回复
controlSUITE里关于ADC的部分我都看过,里面没有和我需求类似的应用,他们提供的模式和我的需求有很大的不同,比如“Example_2833xAdcSoc.c”的ePWM工作在Up-count 模式,每个PWM周期只产生了一个SOCA作为ADC SEQ1的触发信号。
而我需要用到的是ePWM工作在Up-down-count模式,在一个PWM周期里会产生SOCA和SOCB两个触发信号触发两次AD转换,且ADC排序器工作在Start/Stop模式,如《TMS320x2833x Analog-to-Digital Converter (ADC) Module》Reference Guide中Example 1-4中的描述,但TI没有提供相关的样例代码,而我自己配置的调试了很久了都不能达到预期的效果,这种模式在电机控制应用中应该是很常用的方式吧,能不能帮我提供一个可参考的样例呢
谢谢