共2条
1/1 1 跳转至页
f149adc12,ad f149adc12多通道重复序列的ad转换开关问题
问
f149adc12多通道重复序列的ad转换开关问题
我用f149adc12做波形采样,由于采样点比较多,故我设成多通道重复序列,每个
通道全部设成p6.0,现在我按一个键时,触发timera,产生采样时序,
问:
1。开始采样时要如何做,是不是只要设置开启TA,要不要再给一个ADC12SC??
如果是这两个操作之间要不要延时??
2。当我按另一个键时应当关闭采样,应当如何操作,是不是只要~ENC?
要不要关闭TA?如果是这两个操作之间要不要延时??
3。用如下语句是否会把相应的IFG复位?
(我在运行时强行暂停程序时查看寄存器好像IFG没被清空)
ADtemp1=ADtemp1+ADC12MEM12; // Move results, IFG is cleared
程序如下,请大虾指教。。。
void ADC12Init(void)
{
//设置TA产生采样时序,光电信号可用来引发TA启动计数MC_2
TACTL = TASSEL_2+ID_3; // TA选用SMCLK,8分频,不产生中断
TACCTL1 = OUTMOD_3; // CCR1 setup输出为PWM置位/复位
TACCR1 = 0xefff; // Compare value 设置ccr1的值
ADC12CTL0&=~ENC; //关闭adc12转换允许位
ADC12CTL0 = SHT0_8+SHT1_8+MSC+ADC12ON; //开adc12内核,多次采样转换,T(sample)=4*64*T(adc12clk)
ADC12CTL1 = SHS_1+SHP+CONSEQ_3; //序列转换首地址为0,采样信号源TA.out1,序列通道多次
// ADC12CTL1 = SHS_1+SHP+CONSEQ_1; //序列转换首地址为0,采样信号源TA.out1,序列通道多次
ADC12MCTL0 = INCH_0; // ref+=AVcc, channel = A0
ADC12MCTL1 = INCH_0; // ref+=AVcc, channel = A0
ADC12MCTL2 = INCH_0; // ref+=AVcc, channel = A0
ADC12MCTL3 = INCH_0; // ref+=AVcc, channel = A0
ADC12MCTL4 = INCH_0; // ref+=AVcc, channel = A0
ADC12MCTL5 = INCH_0; // ref+=AVcc, channel = A0
ADC12MCTL6 = INCH_0; // ref+=AVcc, channel = A0
ADC12MCTL7 = INCH_0; // ref+=AVcc, channel = A0
ADC12MCTL8 = INCH_0; // ref+=AVcc, channel = A0
ADC12MCTL9 = INCH_0; // ref+=AVcc, channel = A0
ADC12MCTL10 = INCH_0; // ref+=AVcc, channel = A0
ADC12MCTL11 = INCH_0; // ref+=AVcc, channel = A0
ADC12MCTL12 = INCH_0; // ref+=AVcc, channel = A0
ADC12MCTL13 = INCH_0; // ref+=AVcc, channel = A0
ADC12MCTL14 = INCH_0; // ref+=AVcc, channel = A0
ADC12MCTL15 = EOS+INCH_0; // ref+=AVcc, channel = A0
ADC12IE = 0xffff; // Enable ADC12IFG.0~ADC12IFG.15
}
// ADC中断服务程序
interrupt [ADC_VECTOR] void ADC(void)
{
unsigned char x1;
unsigned int ADtemp1=0; //设置16次平均值模数采样的总值初始为0
ADtemp1=ADtemp1+ADC12MEM0; // Move results, IFG is cleared
ADtemp1=ADtemp1+ADC12MEM1; // Move results, IFG is cleared
ADtemp1=ADtemp1+ADC12MEM2; // Move results, IFG is cleared
ADtemp1=ADtemp1+ADC12MEM3; // Move results, IFG is cleared
ADtemp1=ADtemp1+ADC12MEM4; // Move results, IFG is cleared
ADtemp1=ADtemp1+ADC12MEM5; // Move results, IFG is cleared
ADtemp1=ADtemp1+ADC12MEM6; // Move results, IFG is cleared
ADtemp1=ADtemp1+ADC12MEM7; // Move results, IFG is cleared
ADtemp1=ADtemp1+ADC12MEM8; // Move results, IFG is cleared
ADtemp1=ADtemp1+ADC12MEM9; // Move results, IFG is cleared
ADtemp1=ADtemp1+ADC12MEM10; // Move results, IFG is cleared
ADtemp1=ADtemp1+ADC12MEM11; // Move results, IFG is cleared
ADtemp1=ADtemp1+ADC12MEM12; // Move results, IFG is cleared
ADtemp1=ADtemp1+ADC12MEM13; // Move results, IFG is cleared
ADtemp1=ADtemp1+ADC12MEM14; // Move results, IFG is cleared
ADtemp1=ADtemp1+ADC12MEM15; // Move results, IFG is cleared
ADvalue[ADindex]=(ADtemp1/4096); //求16次采样的算术平均数再除256,使值在0~16范围内
}
void ADC_start(void)
{
TACTL = TACTL+MC_2; //启动TA
_NOP();_NOP();_NOP();_NOP(); //需要延时吗??
ADC12CTL0 |= ENC; // Enable conversions
ADC12CTL0 |= ADC12SC; // Start conversion
}
void ADC_stop(void)
{
ADC12CTL0&=~ENC; //关闭adc12转换允许位
_NOP();_NOP();_NOP();_NOP(); //需要延时吗??
TACTL = TASSEL_2+ID_3; //需要暂停TA吗??
}
我用f149adc12做波形采样,由于采样点比较多,故我设成多通道重复序列,每个
通道全部设成p6.0,现在我按一个键时,触发timera,产生采样时序,
问:
1。开始采样时要如何做,是不是只要设置开启TA,要不要再给一个ADC12SC??
如果是这两个操作之间要不要延时??
2。当我按另一个键时应当关闭采样,应当如何操作,是不是只要~ENC?
要不要关闭TA?如果是这两个操作之间要不要延时??
3。用如下语句是否会把相应的IFG复位?
(我在运行时强行暂停程序时查看寄存器好像IFG没被清空)
ADtemp1=ADtemp1+ADC12MEM12; // Move results, IFG is cleared
程序如下,请大虾指教。。。
void ADC12Init(void)
{
//设置TA产生采样时序,光电信号可用来引发TA启动计数MC_2
TACTL = TASSEL_2+ID_3; // TA选用SMCLK,8分频,不产生中断
TACCTL1 = OUTMOD_3; // CCR1 setup输出为PWM置位/复位
TACCR1 = 0xefff; // Compare value 设置ccr1的值
ADC12CTL0&=~ENC; //关闭adc12转换允许位
ADC12CTL0 = SHT0_8+SHT1_8+MSC+ADC12ON; //开adc12内核,多次采样转换,T(sample)=4*64*T(adc12clk)
ADC12CTL1 = SHS_1+SHP+CONSEQ_3; //序列转换首地址为0,采样信号源TA.out1,序列通道多次
// ADC12CTL1 = SHS_1+SHP+CONSEQ_1; //序列转换首地址为0,采样信号源TA.out1,序列通道多次
ADC12MCTL0 = INCH_0; // ref+=AVcc, channel = A0
ADC12MCTL1 = INCH_0; // ref+=AVcc, channel = A0
ADC12MCTL2 = INCH_0; // ref+=AVcc, channel = A0
ADC12MCTL3 = INCH_0; // ref+=AVcc, channel = A0
ADC12MCTL4 = INCH_0; // ref+=AVcc, channel = A0
ADC12MCTL5 = INCH_0; // ref+=AVcc, channel = A0
ADC12MCTL6 = INCH_0; // ref+=AVcc, channel = A0
ADC12MCTL7 = INCH_0; // ref+=AVcc, channel = A0
ADC12MCTL8 = INCH_0; // ref+=AVcc, channel = A0
ADC12MCTL9 = INCH_0; // ref+=AVcc, channel = A0
ADC12MCTL10 = INCH_0; // ref+=AVcc, channel = A0
ADC12MCTL11 = INCH_0; // ref+=AVcc, channel = A0
ADC12MCTL12 = INCH_0; // ref+=AVcc, channel = A0
ADC12MCTL13 = INCH_0; // ref+=AVcc, channel = A0
ADC12MCTL14 = INCH_0; // ref+=AVcc, channel = A0
ADC12MCTL15 = EOS+INCH_0; // ref+=AVcc, channel = A0
ADC12IE = 0xffff; // Enable ADC12IFG.0~ADC12IFG.15
}
// ADC中断服务程序
interrupt [ADC_VECTOR] void ADC(void)
{
unsigned char x1;
unsigned int ADtemp1=0; //设置16次平均值模数采样的总值初始为0
ADtemp1=ADtemp1+ADC12MEM0; // Move results, IFG is cleared
ADtemp1=ADtemp1+ADC12MEM1; // Move results, IFG is cleared
ADtemp1=ADtemp1+ADC12MEM2; // Move results, IFG is cleared
ADtemp1=ADtemp1+ADC12MEM3; // Move results, IFG is cleared
ADtemp1=ADtemp1+ADC12MEM4; // Move results, IFG is cleared
ADtemp1=ADtemp1+ADC12MEM5; // Move results, IFG is cleared
ADtemp1=ADtemp1+ADC12MEM6; // Move results, IFG is cleared
ADtemp1=ADtemp1+ADC12MEM7; // Move results, IFG is cleared
ADtemp1=ADtemp1+ADC12MEM8; // Move results, IFG is cleared
ADtemp1=ADtemp1+ADC12MEM9; // Move results, IFG is cleared
ADtemp1=ADtemp1+ADC12MEM10; // Move results, IFG is cleared
ADtemp1=ADtemp1+ADC12MEM11; // Move results, IFG is cleared
ADtemp1=ADtemp1+ADC12MEM12; // Move results, IFG is cleared
ADtemp1=ADtemp1+ADC12MEM13; // Move results, IFG is cleared
ADtemp1=ADtemp1+ADC12MEM14; // Move results, IFG is cleared
ADtemp1=ADtemp1+ADC12MEM15; // Move results, IFG is cleared
ADvalue[ADindex]=(ADtemp1/4096); //求16次采样的算术平均数再除256,使值在0~16范围内
}
void ADC_start(void)
{
TACTL = TACTL+MC_2; //启动TA
_NOP();_NOP();_NOP();_NOP(); //需要延时吗??
ADC12CTL0 |= ENC; // Enable conversions
ADC12CTL0 |= ADC12SC; // Start conversion
}
void ADC_stop(void)
{
ADC12CTL0&=~ENC; //关闭adc12转换允许位
_NOP();_NOP();_NOP();_NOP(); //需要延时吗??
TACTL = TASSEL_2+ID_3; //需要暂停TA吗??
}
共2条
1/1 1 跳转至页
回复
有奖活动 | |
---|---|
【有奖活动】分享技术经验,兑换京东卡 | |
话不多说,快进群! | |
请大声喊出:我要开发板! | |
【有奖活动】EEPW网站征稿正在进行时,欢迎踊跃投稿啦 | |
奖!发布技术笔记,技术评测贴换取您心仪的礼品 | |
打赏了!打赏了!打赏了! |