请教:ADC12 模块的问题,急!!!

2019-03-24 16:06发布

A0results[index] = ADC12MEM0; // Move A0 results, IFG is cleared A1results[index] = ADC12MEM1; // Move A1 results, IFG is cleared A2results[index] = ADC12MEM2; // Move A2 results, IFG is cleared A3results[index] = ADC12MEM3; // Move A3 results, IFG is cleared index = (index+1)%Num_of_Results // Increment results index, modulo; Set Breakpoint here 这些指令是什么意思啊?我C学的不是很好,请各位高手指点一二!跪谢啊! 此帖出自小平头技术问答
友情提示: 此问题已得到解决,问题已经关闭,关闭后问题禁止继续编辑,回答。
该问题目前已经被作者或者管理员关闭, 无法添加新回复
9条回答
wstt
1楼-- · 2019-03-24 23:30
不用谢,共同学习
wstt
2楼-- · 2019-03-25 04:49
< :TI_MSP430_内容页_SA7 --> 没有完整的代码,根据以上这些代码我是这样理解的。
首先我猜测该ADC12模块使用了CONSEQx = 11的模式(A sequence of channels is converted repeatedly),也就是对多个通道连续采样。
就以上代码来看应该是4个通道,数组Axresults(x = 0,1,2,3)是用来存储每个通道的采样的数据。

[ 本帖最后由 wstt 于 2011-3-24 10:48 编辑 ]
wstt
3楼-- · 2019-03-25 05:02
 精彩回答 2  元偷偷看……
fxw451
4楼-- · 2019-03-25 08:29
楼上分析的不错。
小李啧
5楼-- · 2019-03-25 11:56
#include "MSP430x14x.h" // Standard Equations

#define Num_of_Results 8

static unsigned int A0results[Num_of_Results]; // These need to be global in
static unsigned int A1results[Num_of_Results]; // this example. Otherwise, the
static unsigned int A2results[Num_of_Results]; // compiler removes them because they are not used

void main(void)
{
WDTCTL = WDTPW+WDTHOLD; // Stop watchdog timer
P6SEL = 0x0F; // Enable A/D channel inputs
ADC12CTL0 = ADC12ON+MSC+SHT0_8; // Turn on ADC12, extend sampling time
// to avoid overflow of results
ADC12CTL1 = SHP+CONSEQ_3; // Use sampling timer, repeated sequence
ADC12MCTL0 = INCH_0; // ref+=AVcc, channel = A0
ADC12MCTL1 = INCH_1; // ref+=AVcc, channel = A1
ADC12MCTL2 = INCH_2+EOS; // ref+=AVcc, channel = A2, end seq.

ADC12IE = 0x08; // Enable ADC12IFG.3
ADC12CTL0 |= ENC; // Enable conversions
_EINT(); // Enable interrupts
ADC12CTL0 |= ADC12SC; // Start conversion
_BIS_SR(LPM0_bits); // Enter and stay in LPM0
}

#pragma vector=ADC_VECTOR
__interrupt void ADC12ISR (void)
{
static unsigned int index = 0;

A0results[index] = ADC12MEM0; // Move A0 results, IFG is cleared
A1results[index] = ADC12MEM1; // Move A1 results, IFG is cleared
A2results[index] = ADC12MEM2; // Move A2 results, IFG is cleared
index = (index+1)%Num_of_Results; // Increment results index, modulo; Set Breakpoint here
}


谢谢啊!帮我看看,那几句我看了好多天....
小李啧
6楼-- · 2019-03-25 12:40
 精彩回答 2  元偷偷看……

一周热门 更多>

相关问题

    相关文章