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

TMS320F280049 ADC采样配置

我想在运行过程中反复切换ADC采样的触发源,配置的原理是这样的:

SOCA和AOCB分别用EPWM1的COMPB减计数和增计数相等时触发,COPMB配置为影子模式,周期和下溢点更新,在增计数时用SOCB触发ADCA,ADCB和ADCC三个模块采样,减计数时用SOCA触发ADCA,ADCB和ADCC三个模块采样,在周期和下溢都执行的PWM中断中改变COMPB的值和触发方式。PWM模块增减计数,使能周期和下溢中断.

现在问题是,ADCC模块一直在采样,ADCA和ADCB模块不采样。下面是我的配置,请帮忙查看。谢谢。


配置代码// Disable SOCAEPWM_disableADCTrigger(EPWM1_BASE, EPWM_SOC_A);EPWM_setADCTriggerSource(EPWM1_BASE,EPWM_SOC_A,EPWM_SOC_TBCTR_D_CMPB);EPWM_setADCTriggerEventPrescale(EPWM1_BASE,EPWM_SOC_A,1);EPWM_enableADCTrigger(EPWM1_BASE,EPWM_SOC_A);// Disable SOCBEPWM_disableADCTrigger(EPWM1_BASE, EPWM_SOC_B);EPWM_setADCTriggerSource(EPWM1_BASE,EPWM_SOC_B,EPWM_SOC_TBCTR_U_CMPB);EPWM_setADCTriggerEventPrescale(EPWM1_BASE,EPWM_SOC_B,1);EPWM_enableADCTrigger(EPWM1_BASE,EPWM_SOC_B);

void InitADCSOC(void)
{// Configure SOC of ADCA/ADCB/ADCC, The EPWM1SOCA signal will be the trigger.ADC_setupSOC(ADCA_BASE, ADC_SOC_NUMBER0, ADC_TRIGGER_EPWM1_SOCA,ADC_CH_ADCIN10, 10U);ADC_setupSOC(ADCA_BASE, ADC_SOC_NUMBER1, ADC_TRIGGER_EPWM1_SOCA,ADC_CH_ADCIN3, 10U);ADC_setupSOC(ADCA_BASE, ADC_SOC_NUMBER2, ADC_TRIGGER_EPWM1_SOCA,ADC_CH_ADCIN0, 10U);ADC_setupSOC(ADCA_BASE, ADC_SOC_NUMBER3, ADC_TRIGGER_EPWM1_SOCA,ADC_CH_ADCIN6, 10U);ADC_setupSOC(ADCA_BASE, ADC_SOC_NUMBER4, ADC_TRIGGER_EPWM1_SOCA,ADC_CH_ADCIN8, 10U);ADC_setupSOC(ADCB_BASE, ADC_SOC_NUMBER0, ADC_TRIGGER_EPWM1_SOCA,ADC_CH_ADCIN0, 10U);ADC_setupSOC(ADCC_BASE, ADC_SOC_NUMBER0, ADC_TRIGGER_EPWM1_SOCA,ADC_CH_ADCIN14, 10U);ADC_setupSOC(ADCC_BASE, ADC_SOC_NUMBER1, ADC_TRIGGER_EPWM1_SOCA,ADC_CH_ADCIN0, 10U);ADC_setupSOC(ADCC_BASE, ADC_SOC_NUMBER2, ADC_TRIGGER_EPWM1_SOCA,ADC_CH_ADCIN1, 10U);ADC_setupSOC(ADCC_BASE, ADC_SOC_NUMBER3, ADC_TRIGGER_EPWM1_SOCA,ADC_CH_ADCIN2, 10U);ADC_setupSOC(ADCC_BASE, ADC_SOC_NUMBER4, ADC_TRIGGER_EPWM1_SOCA,ADC_CH_ADCIN3, 10U);ADC_setupSOC(ADCC_BASE, ADC_SOC_NUMBER5, ADC_TRIGGER_EPWM1_SOCA,ADC_CH_ADCIN5, 10U);// Set SOC5 to set the interrupt 1 flag. Enable the interrupt and make sure its flag is cleared.ADC_setInterruptSource(ADCC_BASE, ADC_INT_NUMBER1, ADC_SOC_NUMBER5);ADC_enableInterrupt(ADCC_BASE, ADC_INT_NUMBER1);ADC_clearInterruptStatus(ADCC_BASE, ADC_INT_NUMBER1);
}


interrupt void EPWM1TBIsr(void)
{
if((*gEPwmURegs).TBSTS.bit.CTRDIR == 1)
{EALLOW;
(*gEPwmURegs).CMPB.bit.CMPB = (*gEPwmURegs).TBPRD - ADC_SAMP_DELAY;EDIS;ADC_setupSOC(ADCA_BASE, ADC_SOC_NUMBER0, ADC_TRIGGER_EPWM1_SOCA,ADC_CH_ADCIN10, 10U);ADC_setupSOC(ADCA_BASE, ADC_SOC_NUMBER1, ADC_TRIGGER_EPWM1_SOCA,ADC_CH_ADCIN3, 10U);ADC_setupSOC(ADCA_BASE, ADC_SOC_NUMBER2, ADC_TRIGGER_EPWM1_SOCA,ADC_CH_ADCIN0, 10U);ADC_setupSOC(ADCA_BASE, ADC_SOC_NUMBER3, ADC_TRIGGER_EPWM1_SOCA,ADC_CH_ADCIN6, 10U);ADC_setupSOC(ADCA_BASE, ADC_SOC_NUMBER4, ADC_TRIGGER_EPWM1_SOCA,ADC_CH_ADCIN8, 10U);ADC_setupSOC(ADCB_BASE, ADC_SOC_NUMBER0, ADC_TRIGGER_EPWM1_SOCA,ADC_CH_ADCIN0, 10U);ADC_setupSOC(ADCC_BASE, ADC_SOC_NUMBER0, ADC_TRIGGER_EPWM1_SOCA,ADC_CH_ADCIN14, 10U);ADC_setupSOC(ADCC_BASE, ADC_SOC_NUMBER1, ADC_TRIGGER_EPWM1_SOCA,ADC_CH_ADCIN0, 10U);ADC_setupSOC(ADCC_BASE, ADC_SOC_NUMBER2, ADC_TRIGGER_EPWM1_SOCA,ADC_CH_ADCIN1, 10U);ADC_setupSOC(ADCC_BASE, ADC_SOC_NUMBER3, ADC_TRIGGER_EPWM1_SOCA,ADC_CH_ADCIN2, 10U);ADC_setupSOC(ADCC_BASE, ADC_SOC_NUMBER4, ADC_TRIGGER_EPWM1_SOCA,ADC_CH_ADCIN3, 10U);ADC_setupSOC(ADCC_BASE, ADC_SOC_NUMBER5, ADC_TRIGGER_EPWM1_SOCA,ADC_CH_ADCIN5, 10U);}else{EALLOW;
(*gEPwmURegs).CMPB.bit.CMPB = ADC_SAMP_DELAY;EDIS;ADC_setupSOC(ADCA_BASE, ADC_SOC_NUMBER0, ADC_TRIGGER_EPWM1_SOCB,ADC_CH_ADCIN10, 10U);ADC_setupSOC(ADCA_BASE, ADC_SOC_NUMBER1, ADC_TRIGGER_EPWM1_SOCB,ADC_CH_ADCIN3, 10U);ADC_setupSOC(ADCA_BASE, ADC_SOC_NUMBER2, ADC_TRIGGER_EPWM1_SOCB,ADC_CH_ADCIN0, 10U);ADC_setupSOC(ADCA_BASE, ADC_SOC_NUMBER3, ADC_TRIGGER_EPWM1_SOCB,ADC_CH_ADCIN6, 10U);ADC_setupSOC(ADCA_BASE, ADC_SOC_NUMBER4, ADC_TRIGGER_EPWM1_SOCB,ADC_CH_ADCIN8, 10U);ADC_setupSOC(ADCB_BASE, ADC_SOC_NUMBER0, ADC_TRIGGER_EPWM1_SOCB,ADC_CH_ADCIN0, 10U);ADC_setupSOC(ADCC_BASE, ADC_SOC_NUMBER0, ADC_TRIGGER_EPWM1_SOCB,ADC_CH_ADCIN14, 10U);ADC_setupSOC(ADCC_BASE, ADC_SOC_NUMBER1, ADC_TRIGGER_EPWM1_SOCB,ADC_CH_ADCIN0, 10U);ADC_setupSOC(ADCC_BASE, ADC_SOC_NUMBER2, ADC_TRIGGER_EPWM1_SOCB,ADC_CH_ADCIN1, 10U);ADC_setupSOC(ADCC_BASE, ADC_SOC_NUMBER3, ADC_TRIGGER_EPWM1_SOCB,ADC_CH_ADCIN2, 10U);ADC_setupSOC(ADCC_BASE, ADC_SOC_NUMBER4, ADC_TRIGGER_EPWM1_SOCB,ADC_CH_ADCIN3, 10U);ADC_setupSOC(ADCC_BASE, ADC_SOC_NUMBER5, ADC_TRIGGER_EPWM1_SOCB,ADC_CH_ADCIN5, 10U);}// Clear INT flag for this timerEPWM_clearEventTriggerInterruptFlag(EPWM1_BASE);// Acknowledge interrupt groupInterrupt_clearACKGroup(INTERRUPT_ACK_GROUP3);
}

 

Annie Liu:

为更加有效地解决您的问题,我们建议您将问题发布在E2E英文技术论坛上https://e2e.ti.com/support/microcontrollers/c2000/f/171,将由资深的工程师为您提供帮助。我们的E2E英文社区有TI专家进行回复,并得到全球各地工程师的支持,分享他们的知识和经验。

user4310360:

您好,目前我的是ADCA可以讀取 但是其他的無法,請問您的問題找到答案了嗎?
求解!感謝!

赞(0)
未经允许不得转载:TI中文支持网 » TMS320F280049 ADC采样配置
分享到: 更多 (0)