Other Parts Discussed in Thread: C2000WARE, CONTROLSUITE
我们使用附件程序,开发版调试可以正常读取AD数值,我们自设板子AD数值始终为0。
ADC程序如下所示
void DriverDspAdcInit(void)
{
EALLOW;
SysCtrlRegs.PCLKCR0.bit.ADCENCLK = 1; //使能ADC的时钟
ADC_cal(); //调用ADC_cal汇编语言,它是TI官方提供的。
EDIS;
AdcRegs.ADCREFSEL.bit.REF_SEL = 0x0; // 选择内部参考电压
AdcRegs.ADCTRL3.all = 0x00E0; // Power up bandgap/reference/ADC circuits
DELAY_US(50000L); // Delay before converting ADC channels
// AdcRegs.ADCTRL3.bit.SMODE_SEL=0;//
AdcRegs.ADCTRL3.bit.SMODE_SEL=1;// 1 同步采样模式
AdcRegs.ADCTRL1.bit.SEQ_CASC = 1; // 0x0 Dual Sequencer Mode, 0x1 Cascaded Mode
AdcRegs.ADCTRL3.bit.ADCCLKPS = 0x04; // Fclk = HSPCLK/2 = 37.5MHz
AdcRegs.ADCTRL1.bit.CPS = 1; // ADCCLK = Fclk/2 = 18.75MHz
AdcRegs.ADCTRL1.bit.CONT_RUN=0;//0 非连续
AdcRegs.ADCTRL1.bit.ACQ_PS = 0x01; // 设置启动脉冲的宽度
AdcRegs.ADCTRL2.bit.INT_ENA_SEQ1 = 0x0; // 使能INT_SEQ1中断
AdcRegs.ADCTRL2.bit.RST_SEQ1 = 0x1; // Reset SEQ/SEQ1
AdcRegs.ADCTRL2.bit.RST_SEQ2 = 0x1; // Reset SEQ/SEQ2
AdcRegs.ADCTRL2.bit.EPWM_SOCA_SEQ1=0x1; // 允许SEQ/SEQ1被EPWMA_SOCA信号触发启动
// AdcRegs.ADCCHSELSEQ1.bit.CONV00 = 6; // Dummy meas. avoid 1st sample issue Rev0 Picollo*/
// AdcRegs.ADCCHSELSEQ1.bit.CONV01 = 1; // A1-> Phase A Current
// AdcRegs.ADCCHSELSEQ1.bit.CONV02 = 2; // B1-> Phase B Current
// AdcRegs.ADCCHSELSEQ1.bit.CONV03 = 3; // A3-> Phase C Current
// AdcRegs.ADCCHSELSEQ2.bit.CONV04 = 4; // B7-> Phase A Voltage TEMP
// AdcRegs.ADCCHSELSEQ2.bit.CONV05 = 5; // B6-> Phase B Voltage TEMP MOTOR
// AdcRegs.ADCCHSELSEQ2.bit.CONV06 = 12; // B4-> Phase C Voltage
// AdcRegs.ADCCHSELSEQ2.bit.CONV07 = 6; // A7-> DC Bus Voltage
AdcRegs.ADCCHSELSEQ1.bit.CONV00 = 0; // Dummy meas. avoid 1st sample issue Rev0 Picollo*/
AdcRegs.ADCCHSELSEQ1.bit.CONV01 = 1; // A1-> Phase A Current
AdcRegs.ADCCHSELSEQ1.bit.CONV02 = 2; // B1-> Phase B Current
AdcRegs.ADCCHSELSEQ1.bit.CONV03 = 3; // A3-> Phase C Current
AdcRegs.ADCCHSELSEQ2.bit.CONV04 = 4; // B7-> Phase A Voltage TEMP
AdcRegs.ADCCHSELSEQ2.bit.CONV05 = 5; // B6-> Phase B Voltage TEMP MOTOR
AdcRegs.ADCCHSELSEQ2.bit.CONV06 = 6; // B4-> Phase C Voltage
AdcRegs.ADCCHSELSEQ2.bit.CONV07 = 7;
AdcRegs.ADCMAXCONV.bit.MAX_CONV1 = 7;
EDIS;
/* Set up Event Trigger with CNT_zero enable for Time-base of EPWM1 */
EPwm1Regs.ETSEL.bit.SOCAEN = 1; // 使能ADC启动脉冲ePWMxSOCA
EPwm1Regs.ETSEL.bit.SOCASEL = ET_CTR_PRD; // TBCTR = PEROID 时产生SOCA中断,因为IR2136反向的。
EPwm1Regs.ETPS.bit.SOCAPRD = ET_1ST; // 每发生一次事件,产生信号EPWM1SOCA
EPwm1Regs.ETCLR.bit.SOCA = 1; // Clear SOCA flag */
}
硬件设计如PDF所示5KW_Invertion.pdf