本帖最后由 DJZ1992 于 2016-1-20 15:20 编辑
请问能看看你的TIMER和采样的配置代码吗?我配制成TIMER0触发ADC,但是就是进不了ADC的中断,希望看下你的,我的是这样的@anqi90
void ADC_INIT(void)
{
SysCtlPeripheralEnable(SYSCTL_PERIPH_ADC0);
SysCtlPeripheralEnable(SYSCTL_PERIPH_GPIOE);
SysCtlPeripheralEnable(SYSCTL_PERIPH_GPIOD);
GPIOPinTypeADC(GPIO_PORTD_BASE, GPIO_PIN_1|GPIO_PIN_2|GPIO_PIN_3);
GPIOPinTypeADC(GPIO_PORTE_BASE, GPIO_PIN_0|GPIO_PIN_1|GPIO_PIN_2|GPIO_PIN_3);
//设置ADC参考电压为外部3V,TM4C123GH6PM只能使用内部参考电压,3.3V
//ADCReferenceSet(ADC0_BASE, ADC_REF_EXT_3V);//若ADC_REF_INT,则指使用内部3V参考电压
//配置ADC采集序列,ADC_TRIGGER_PROCESSOR是软件触发,ADC_TRIGGER_TIMER是定时器触发
ADCSequenceConfigure(ADC0_BASE, 0,ADC_TRIGGER_TIMER, 0);
//ADCSequenceConfigure(ADC0_BASE, 0,ADC_TRIGGER_PROCESSOR, 0);
ADCSequenceStepConfigure(ADC0_BASE, 0, 0, ADC_CTL_CH0 );//PE3/IC
ADCSequenceStepConfigure(ADC0_BASE, 0, 1, ADC_CTL_CH1 );//PE2/IB
ADCSequenceStepConfigure(ADC0_BASE, 0, 2, ADC_CTL_CH2 );//PE1IA
ADCSequenceStepConfigure(ADC0_BASE, 0, 3, ADC_CTL_CH3 );//PE0/VREF
ADCSequenceStepConfigure(ADC0_BASE, 0, 4, ADC_CTL_CH4 );//PD3/UA
ADCSequenceStepConfigure(ADC0_BASE, 0, 5, ADC_CTL_CH5 );//PD2/UB
ADCSequenceStepConfigure(ADC0_BASE, 0, 6, ADC_CTL_CH6 | ADC_CTL_IE |ADC_CTL_END);//PD1/UC
//ADCSequenceStepConfigure(ADC0_BASE, 0, 7, ADC_CTL_CH7 | ADC_CTL_IE |ADC_CTL_END);//PD0未使用
IntMasterEnable();
IntEnable(INT_ADC0SS0); //使能ADC采样序列中断
ADCIntEnable(ADC0_BASE, 0);
//中断触发方式设置ADC_INT_SS0、ADC_INT_DMA_SS0、ADC_INT_DCON_SS0
ADCIntEnableEx(ADC0_BASE,ADC_INT_SS0);//分别代表普通序列触发、DMA触发和数字比较器触发
ADCIntClear(ADC0_BASE, 0);
ADCSequenceEnable(ADC0_BASE, 0);//使能ADC采集序列
TimerControlTrigger(ADC0_BASE,TIMER_A,true);
}
void ADC0IntHandler(void)
{
ADCIntClear(ADC0_BASE, 0);
ADCSequenceDataGet(ADC0_BASE, 0, ADC0_Value);
if (ADC_Ready_Flag == 0)
{
RMS_IC.Save[Cnt_Period] = ADC0_Value[0];
RMS_IB.Save[Cnt_Period] = ADC0_Value[1];
RMS_IA.Save[Cnt_Period] = ADC0_Value[2];
RMS_VR.Save[Cnt_Period] = ADC0_Value[3];
RMS_VA.Save[Cnt_Period] = ADC0_Value[4];
RMS_VB.Save[Cnt_Period] = ADC0_Value[5];
RMS_VC.Save[Cnt_Period] = ADC0_Value[6];
Cnt_Period++;
if (Cnt_Period == 255)
{
Cnt_Period = 0;
ADC_Ready_Flag = 1;
}
}
}
void TIMER0(void)
{
SysCtlPeripheralEnable(SYSCTL_PERIPH_TIMER0);//使能TIMER0
TimerConfigure(TIMER0_BASE, TIMER_CFG_PERIODIC);//周期性计数模式
TimerLoadSet(TIMER0_BASE, TIMER_A,SysCtlClockGet() / 12800);
TimerADCEventSet(TIMER0_BASE,TIMER_ADC_TIMEOUT_A);//超时触发采样设置
TimerADCEventGet(TIMER0_BASE);//获取是否超时触发ADC
//IntEnable(INT_TIMER0A);//TIMEOUT标志位触发中断
//TimerIntEnable(TIMER0_BASE, TIMER_TIMA_TIMEOUT); //使能TIMER0A中断
//IntMasterEnable();
TimerEnable(TIMER0_BASE, TIMER_A);//TIMER0A开始计数,当计数值等于TimerLoadSet,触发中断
}