TIMER触发ADC配制方法一直进不去中断,麻烦看看有没有问题呢,用ADC_TRIGGER_PROCESSOR方式可以进中断,ADC_TRIGGER_TIMER方式就不行,四句红 {MOD}的是我觉得配置的语句,有老大帮忙看看为什么定时器到了时间可以进定时器中断(我修改代码后试过),但是不会进ADC中断么
void ADC_INIT(void)
{
SysCtlPeripheralEnable(SYSCTL_PERIPH_ADC0);
SysCtlPeripheralEnable(SYSCTL_PERIPH_GPIOE);
GPIOPinTypeADC(GPIO_PORTD_BASE, GPIO_PIN_1|GPIO_PIN_2|GPIO_PIN_3);
ADCSequenceConfigure(ADC0_BASE, 0,ADC_TRIGGER_TIMER, 0); ADCSequenceStepConfigure(ADC0_BASE, 0, 0, ADC_CTL_CH0| ADC_CTL_IE |ADC_CTL_END );//PE3/IC IntMasterEnable();
IntEnable(INT_ADC0SS0); //使能ADC采样序列中断
ADCIntEnable(ADC0_BASE, 0);
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];
Cnt_Period++;
if (Cnt_Period == 255)
{
Cnt_Period = 0;
ADC_Ready_Flag = 1;
}
}
}
void TIMER0(void){SysCtlPeripheralEnable(SYSCTL_PERIPH_TIMER0);//使能TIMER0TimerConfigure(TIMER0_BASE, TIMER_CFG_PERIODIC);//周期性计数模式TimerLoadSet(TIMER0_BASE, TIMER_A,SysCtlClockGet() / 12800);TimerADCEventSet(TIMER0_BASE,TIMER_ADC_TIMEOUT_A);//超时触发采样设置
TimerADCEventGet(TIMER0_BASE);//获取是否超时触发ADCTimerEnable(TIMER0_BASE, TIMER_A);//TIMER0A开始计数,当计数值等于TimerLoadSet,触发中断}
此帖出自
小平头技术问答
分享一下呗
一周热门 更多>