TI中文支持网
TI专业的中文技术问题搜集分享网站

TMS320F28388D: PWM触发ADC采样问题

Part Number:TMS320F28388D

ADC_setupSOC(ADCA_BASE, ADC_SOC_NUMBER0, ADC_TRIGGER_EPWM1_SOCA,ADC_CH_ADCIN0, 63);
ADC_setupSOC(ADCA_BASE, ADC_SOC_NUMBER1, ADC_TRIGGER_EPWM1_SOCA,ADC_CH_ADCIN1, 63);
ADC_setupSOC(ADCA_BASE, ADC_SOC_NUMBER2, ADC_TRIGGER_EPWM1_SOCA,ADC_CH_ADCIN2, 63);
ADC_setupSOC(ADCA_BASE, ADC_SOC_NUMBER3, ADC_TRIGGER_EPWM1_SOCA,ADC_CH_ADCIN3, 63);
ADC_setupSOC(ADCA_BASE, ADC_SOC_NUMBER4, ADC_TRIGGER_EPWM1_SOCA,ADC_CH_ADCIN4, 63);
ADC_setupSOC(ADCA_BASE, ADC_SOC_NUMBER5, ADC_TRIGGER_EPWM1_SOCA,ADC_CH_ADCIN5, 63);
ADC_setupSOC(ADCA_BASE, ADC_SOC_NUMBER6, ADC_TRIGGER_EPWM1_SOCA,ADC_CH_ADCIN14, 63);
ADC_setupSOC(ADCA_BASE, ADC_SOC_NUMBER7, ADC_TRIGGER_EPWM1_SOCA,ADC_CH_ADCIN15, 63);

设置PWM 增计数,在计数等于period时触发ADC采样,    ADC_setInterruptPulseMode(ADCA_BASE, ADC_PULSE_END_OF_CONV);

采样完成后触发中断,ADC_setInterruptSource(ADCA_BASE, ADC_INT_NUMBER1, ADC_SOC_NUMBER7);实际测试PWM触发ADC采样到进入中断需要7us

ADC_setInterruptSource(ADCA_BASE, ADC_INT_NUMBER1, ADC_SOC_NUMBER0);实际测试PWM触发ADC采样到进入中断需要1us

我的理解是,SOC0-15顺序刷新,所以以ADC_SOC_NUMBER7去触发中断采样的数据时0-7都采集完的,如果是ADC_SOC_NUMBER1去触发,ADC_SOC_NUMBER7可能还没完成数据读取的是上一次的

这样就有个问题就是,pwm触发ADC中断时间超过7us,当开关频率120K以上实际测试pwm开关频率和进入中断频率对不上了,进入中断频率被7us限制了,请问该如何解决

ADC_setInterruptSource(ADCA_BASE, ADC_INT_NUMBER1, ADC_SOC_NUMBER7);
ADC_enableInterrupt(ADCA_BASE, ADC_INT_NUMBER1);
ADC_clearInterruptStatus(ADCA_BASE, ADC_INT_NUMBER1);

Susan Yang:

DSP应用 说:当开关频率120K以上实际测试pwm开关频率和进入中断频率对不上了,进入中断频率被7us限制了,请问该如何解决

若是可以的话请给出您的完整PWM ADC配置代码,谢谢

,

DSP应用:

ADC_setPrescaler(ADCA_BASE, ADC_CLK_DIV_4_0);ADC_setPrescaler(ADCB_BASE, ADC_CLK_DIV_4_0);ADC_setPrescaler(ADCC_BASE, ADC_CLK_DIV_4_0);ADC_setPrescaler(ADCD_BASE, ADC_CLK_DIV_4_0);
#if(EX_ADC_RESOLUTION == 12)ADC_setMode(ADCA_BASE, ADC_RESOLUTION_12BIT, ADC_MODE_SINGLE_ENDED);ADC_setMode(ADCB_BASE, ADC_RESOLUTION_12BIT, ADC_MODE_SINGLE_ENDED);ADC_setMode(ADCC_BASE, ADC_RESOLUTION_12BIT, ADC_MODE_SINGLE_ENDED);ADC_setMode(ADCD_BASE, ADC_RESOLUTION_12BIT, ADC_MODE_SINGLE_ENDED);
#elif(EX_ADC_RESOLUTION == 16)ADC_setMode(ADCA_BASE, ADC_RESOLUTION_16BIT, ADC_MODE_DIFFERENTIAL);//ADCA、B、C 差分采样ADC_setMode(ADCB_BASE, ADC_RESOLUTION_16BIT, ADC_MODE_DIFFERENTIAL);ADC_setMode(ADCC_BASE, ADC_RESOLUTION_16BIT, ADC_MODE_DIFFERENTIAL);ADC_setMode(ADCD_BASE, ADC_RESOLUTION_16BIT, ADC_MODE_SINGLE_ENDED);//ADCD 单端采样
#endif// Set pulse positions to lateADC_setInterruptPulseMode(ADCA_BASE, ADC_PULSE_END_OF_CONV);ADC_setInterruptPulseMode(ADCB_BASE, ADC_PULSE_END_OF_CONV);ADC_setInterruptPulseMode(ADCC_BASE, ADC_PULSE_END_OF_CONV);ADC_setInterruptPulseMode(ADCD_BASE, ADC_PULSE_END_OF_CONV);ADC_enableConverter(ADCA_BASE);ADC_enableConverter(ADCB_BASE);ADC_enableConverter(ADCC_BASE);ADC_enableConverter(ADCD_BASE);DEVICE_DELAY_US(1000);ADC_setupSOC(ADCA_BASE, ADC_SOC_NUMBER0, ADC_TRIGGER_EPWM1_SOCA,ADC_CH_ADCIN0, SAMPLEWINDOWS);ADC_setupSOC(ADCA_BASE, ADC_SOC_NUMBER1, ADC_TRIGGER_EPWM1_SOCA,ADC_CH_ADCIN1, SAMPLEWINDOWS);ADC_setupSOC(ADCA_BASE, ADC_SOC_NUMBER2, ADC_TRIGGER_EPWM1_SOCA,ADC_CH_ADCIN2, SAMPLEWINDOWS);ADC_setupSOC(ADCA_BASE, ADC_SOC_NUMBER3, ADC_TRIGGER_EPWM1_SOCA,ADC_CH_ADCIN3, SAMPLEWINDOWS);ADC_setupSOC(ADCA_BASE, ADC_SOC_NUMBER4, ADC_TRIGGER_EPWM1_SOCA,ADC_CH_ADCIN4, SAMPLEWINDOWS);ADC_setupSOC(ADCA_BASE, ADC_SOC_NUMBER5, ADC_TRIGGER_EPWM1_SOCA,ADC_CH_ADCIN5, SAMPLEWINDOWS);ADC_setupSOC(ADCA_BASE, ADC_SOC_NUMBER6, ADC_TRIGGER_EPWM1_SOCA,ADC_CH_ADCIN14, SAMPLEWINDOWS);ADC_setupSOC(ADCA_BASE, ADC_SOC_NUMBER7, ADC_TRIGGER_EPWM1_SOCA,ADC_CH_ADCIN15, SAMPLEWINDOWS);ADC_setupSOC(ADCB_BASE, ADC_SOC_NUMBER0, ADC_TRIGGER_EPWM1_SOCA,ADC_CH_ADCIN0, SAMPLEWINDOWS);ADC_setupSOC(ADCB_BASE, ADC_SOC_NUMBER1, ADC_TRIGGER_EPWM1_SOCA,ADC_CH_ADCIN1, SAMPLEWINDOWS);ADC_setupSOC(ADCB_BASE, ADC_SOC_NUMBER2, ADC_TRIGGER_EPWM1_SOCA,ADC_CH_ADCIN2, SAMPLEWINDOWS);ADC_setupSOC(ADCB_BASE, ADC_SOC_NUMBER3, ADC_TRIGGER_EPWM1_SOCA,ADC_CH_ADCIN3, SAMPLEWINDOWS);ADC_setupSOC(ADCB_BASE, ADC_SOC_NUMBER4, ADC_TRIGGER_EPWM1_SOCA,ADC_CH_ADCIN4, SAMPLEWINDOWS);ADC_setupSOC(ADCB_BASE, ADC_SOC_NUMBER5, ADC_TRIGGER_EPWM1_SOCA,ADC_CH_ADCIN5, SAMPLEWINDOWS);ADC_setupSOC(ADCC_BASE, ADC_SOC_NUMBER0, ADC_TRIGGER_EPWM1_SOCA,ADC_CH_ADCIN2, SAMPLEWINDOWS);ADC_setupSOC(ADCC_BASE, ADC_SOC_NUMBER1, ADC_TRIGGER_EPWM1_SOCA,ADC_CH_ADCIN3, SAMPLEWINDOWS);ADC_setupSOC(ADCC_BASE, ADC_SOC_NUMBER2, ADC_TRIGGER_EPWM1_SOCA,ADC_CH_ADCIN4, SAMPLEWINDOWS);ADC_setupSOC(ADCC_BASE, ADC_SOC_NUMBER3, ADC_TRIGGER_EPWM1_SOCA,ADC_CH_ADCIN5, SAMPLEWINDOWS);ADC_setupSOC(ADCD_BASE, ADC_SOC_NUMBER0, ADC_TRIGGER_EPWM1_SOCA,ADC_CH_ADCIN0, 14);ADC_setupSOC(ADCD_BASE, ADC_SOC_NUMBER1, ADC_TRIGGER_EPWM1_SOCA,ADC_CH_ADCIN1, 14);ADC_setupSOC(ADCD_BASE, ADC_SOC_NUMBER2, ADC_TRIGGER_EPWM1_SOCA,ADC_CH_ADCIN2, 14);ADC_setupSOC(ADCD_BASE, ADC_SOC_NUMBER3, ADC_TRIGGER_EPWM1_SOCA,ADC_CH_ADCIN3, 14);ADC_setupSOC(ADCD_BASE, ADC_SOC_NUMBER4, ADC_TRIGGER_EPWM1_SOCA,ADC_CH_ADCIN4, 14);ADC_setupSOC(ADCD_BASE, ADC_SOC_NUMBER5, ADC_TRIGGER_EPWM1_SOCA,ADC_CH_ADCIN5, 14);ADC_setInterruptSource(ADCA_BASE, ADC_INT_NUMBER1, ADC_SOC_NUMBER7);// ADC_SOC_NUMBER77us后ADC_SOC_NUMBER1 1.7us后ADC_enableInterrupt(ADCA_BASE, ADC_INT_NUMBER1);ADC_clearInterruptStatus(ADCA_BASE, ADC_INT_NUMBER1);
// AD触发设置Interrupt_register(INT_ADCA1, &PWM_Sample_Int_Hook);EPWM_disableADCTrigger(EPWM1_BASE, EPWM_SOC_A);EPWM_setADCTriggerSource(EPWM1_BASE, EPWM_SOC_A, EPWM_SOC_TBCTR_PERIOD);EPWM_enableADCTrigger(EPWM1_BASE, EPWM_SOC_A);EPWM_setADCTriggerEventPrescale(EPWM1_BASE, EPWM_SOC_A,1);Interrupt_enable(INT_ADCA1);

,

Susan Yang:

我对您的代码有些疑惑

您现在是  EX_ADC_RESOLUTION == 16 且ADC_setMode(ADCA_BASE, ADC_RESOLUTION_16BIT, ADC_MODE_DIFFERENTIAL); //ADCA、B、C 差分采样

也就是目前是16bit ADCA的差分采样?

能否以附件形式上传一下您的c文件?

,

DSP应用:

就是实际测试例程把例程改成16bit模式,ADCA一共8通道单端采样,PWM触发ADC采样ADC_SOC_NUMBER0-ADC_SOC_NUMBER7采样完成后会触发ADC中断,这个过程要7.5us,按我的理解采样窗最小设置的63,8通道就是504个slck周期,这就5us了,不知道这样理解对不对

,

Susan Yang:

如果 ADC 在 16 位模式下运行,最大采样率约为 1MSPS,因此转换时间约为 1us(您可以从数据表中的时序信息中获得准确的时间 – 请参阅“ADC 时序图”部分)。 

如果SOC0到SOC7都按顺序触发,ADC使用16位模式,那么SOC0大约1us后完成,SOC7大约8us后完成
这个时间会限制触发 ISR 的速度(8us 周期确实是大约 125 kHz 的频率)
但是,请注意,该设备有 4 个旨在并行使用的 ADC,因此,如果您总共需要 8 个 16 位分辨率转换,您应该并行使用 4 个 ADC 以在大约 2 微秒内产生结果,这将给出更快的最大 ePWM 触发率。  

赞(0)
未经允许不得转载:TI中文支持网 » TMS320F28388D: PWM触发ADC采样问题
分享到: 更多 (0)