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

28035芯片,如何用定时器0触发ADC采样

void ADC_Config(void)
{

InitAdc(); // 先调用官方AD默认的配置函数初始化(必须)

EALLOW;
PieVectTable.ADCINT3 = &adc_isr;// AD中断函数映射
EDIS;

PieCtrlRegs.PIEIER10.bit.INTx3 = 1; // Enable INT 10.3 in the PIE
IER |= M_INT10; // Enable CPU Interrupt 10

// Configure ADC
EALLOW;

AdcRegs.ADCCTL1.bit.ADCREFSEL = 0; //REF Int
AdcRegs.ADCCTL1.bit.INTPULSEPOS = 1; //ADCINT1 trips after AdcResults latch //–> P39 HIKE,EOCx产生来自源选择
AdcRegs.INTSEL3N4.bit.INT3E = 1; //Enabled ADCINT3
AdcRegs.INTSEL3N4.bit.INT3CONT = 0; //Disable ADCINT3 Continuous mode,single conversion mode

AdcRegs.INTSEL3N4.bit.INT3SEL = 0x00; //setup EOCx to trigger ADCINTx to fire , EOCx is trigger for ADCINTx

//0-7为A0到A7
//8-16为B0到B7 这里选择了B0
AdcRegs.ADCSOC0CTL.bit.CHSEL = 8; //set SOC0 channel select to ADCINB0

AdcRegs.ADCSOC0CTL.bit.TRIGSEL = 0x01; //定时器0

AdcRegs.ADCSOC0CTL.bit.ACQPS = 6;//set SOC0 S/H Window to 7 ADC Clock Cycles

EDIS;
}

还需要改什么地方呢?

mangui zhang:

通过设置ADCSOCxCTL的TRIGSEL位实现。

相关参考https://m.baidu.com/sf_edu_wenku/view/cf01cf8a6137ee06eff9185f.html

void ADC_Config(void)
{

InitAdc(); // 先调用官方AD默认的配置函数初始化(必须)

EALLOW;
PieVectTable.ADCINT3 = &adc_isr;// AD中断函数映射
EDIS;

PieCtrlRegs.PIEIER10.bit.INTx3 = 1; // Enable INT 10.3 in the PIE
IER |= M_INT10; // Enable CPU Interrupt 10

// Configure ADC
EALLOW;

AdcRegs.ADCCTL1.bit.ADCREFSEL = 0; //REF Int
AdcRegs.ADCCTL1.bit.INTPULSEPOS = 1; //ADCINT1 trips after AdcResults latch //–> P39 HIKE,EOCx产生来自源选择
AdcRegs.INTSEL3N4.bit.INT3E = 1; //Enabled ADCINT3
AdcRegs.INTSEL3N4.bit.INT3CONT = 0; //Disable ADCINT3 Continuous mode,single conversion mode

AdcRegs.INTSEL3N4.bit.INT3SEL = 0x00; //setup EOCx to trigger ADCINTx to fire , EOCx is trigger for ADCINTx

//0-7为A0到A7
//8-16为B0到B7 这里选择了B0
AdcRegs.ADCSOC0CTL.bit.CHSEL = 8; //set SOC0 channel select to ADCINB0

AdcRegs.ADCSOC0CTL.bit.TRIGSEL = 0x01; //定时器0

AdcRegs.ADCSOC0CTL.bit.ACQPS = 6;//set SOC0 S/H Window to 7 ADC Clock Cycles

EDIS;
}

还需要改什么地方呢?

GUOAN HUI:

回复 mangui zhang:

您好,这里已经改了(如下),但是不能成功

AdcRegs.ADCSOC0CTL.bit.TRIGSEL = 0x01; //定时器0

void ADC_Config(void)
{

InitAdc(); // 先调用官方AD默认的配置函数初始化(必须)

EALLOW;
PieVectTable.ADCINT3 = &adc_isr;// AD中断函数映射
EDIS;

PieCtrlRegs.PIEIER10.bit.INTx3 = 1; // Enable INT 10.3 in the PIE
IER |= M_INT10; // Enable CPU Interrupt 10

// Configure ADC
EALLOW;

AdcRegs.ADCCTL1.bit.ADCREFSEL = 0; //REF Int
AdcRegs.ADCCTL1.bit.INTPULSEPOS = 1; //ADCINT1 trips after AdcResults latch //–> P39 HIKE,EOCx产生来自源选择
AdcRegs.INTSEL3N4.bit.INT3E = 1; //Enabled ADCINT3
AdcRegs.INTSEL3N4.bit.INT3CONT = 0; //Disable ADCINT3 Continuous mode,single conversion mode

AdcRegs.INTSEL3N4.bit.INT3SEL = 0x00; //setup EOCx to trigger ADCINTx to fire , EOCx is trigger for ADCINTx

//0-7为A0到A7
//8-16为B0到B7 这里选择了B0
AdcRegs.ADCSOC0CTL.bit.CHSEL = 8; //set SOC0 channel select to ADCINB0

AdcRegs.ADCSOC0CTL.bit.TRIGSEL = 0x01; //定时器0

AdcRegs.ADCSOC0CTL.bit.ACQPS = 6;//set SOC0 S/H Window to 7 ADC Clock Cycles

EDIS;
}

还需要改什么地方呢?

Eric Ma:

回复 GUOAN HUI:

您好,这里已经改了(如下),但是不能成功

AdcRegs.ADCSOC0CTL.bit.TRIGSEL = 0x01; //定时器0

Eric:

没看见你初始化定时器0,会不会是定时器初始化出问题?

void ADC_Config(void)
{

InitAdc(); // 先调用官方AD默认的配置函数初始化(必须)

EALLOW;
PieVectTable.ADCINT3 = &adc_isr;// AD中断函数映射
EDIS;

PieCtrlRegs.PIEIER10.bit.INTx3 = 1; // Enable INT 10.3 in the PIE
IER |= M_INT10; // Enable CPU Interrupt 10

// Configure ADC
EALLOW;

AdcRegs.ADCCTL1.bit.ADCREFSEL = 0; //REF Int
AdcRegs.ADCCTL1.bit.INTPULSEPOS = 1; //ADCINT1 trips after AdcResults latch //–> P39 HIKE,EOCx产生来自源选择
AdcRegs.INTSEL3N4.bit.INT3E = 1; //Enabled ADCINT3
AdcRegs.INTSEL3N4.bit.INT3CONT = 0; //Disable ADCINT3 Continuous mode,single conversion mode

AdcRegs.INTSEL3N4.bit.INT3SEL = 0x00; //setup EOCx to trigger ADCINTx to fire , EOCx is trigger for ADCINTx

//0-7为A0到A7
//8-16为B0到B7 这里选择了B0
AdcRegs.ADCSOC0CTL.bit.CHSEL = 8; //set SOC0 channel select to ADCINB0

AdcRegs.ADCSOC0CTL.bit.TRIGSEL = 0x01; //定时器0

AdcRegs.ADCSOC0CTL.bit.ACQPS = 6;//set SOC0 S/H Window to 7 ADC Clock Cycles

EDIS;
}

还需要改什么地方呢?

GUOAN HUI:

回复 Eric Ma:

您好,现在已经可以通过timer0触发ADC采样,设置了10us一次触发(我的理解:定时器0设置了10us);在此情况下,又通过timer0来计时,控制一个LED灯的闪烁,时间是1秒(设置一个计数变量,累计计数100000次);

现象:ADC能够采样到数值,但是灯不能按照间隔1秒闪烁

请教:我单独用timer0去分别触发ADC和控制LED闪烁都是可以的,同时进行为什么就不行呢?

赞(0)
未经允许不得转载:TI中文支持网 » 28035芯片,如何用定时器0触发ADC采样
分享到: 更多 (0)