ADC的序列单次采样是怎么设置的呢? 哪位有源码贴一下
还有就是采样通道是怎么和管教匹配的?
自己昨天写了一个程序,但是发现MEM寄存器的值一直是0x03FF 也就是说可能根本没有采样
// Configure ADC10 ADC10CTL0 |= ADC10ON + ADC10MSC + ADC10SHT_3; // ADC10ON ADC10CTL1 |= ADC10SHP + ADC10CONSEQ_1 + ADC10SSEL_3 + ADC10DIV_1; ADC10CTL2 |= ADC10RES; // 10-bit conversion results ADC10MCTL0 |= ADC10SREF_1; // ADC input select; Vref=2.5V ADC10MCTL0 |= ACC_X_CHANNEL; ADC10MCTL0 |= ACC_Y_CHANNEL; ADC10MCTL0 |= ACC_Z_CHANNEL;
下面这段是main里面的
while(1){ led1_on; while(UCA0STATW & UCBUSY); TXdata = xyz[0]; while (ADC10CTL1 & BUSY); // Wait if ADC10 core is ADC10CTL0 |= ADC10ENC + ADC10SC; // Start sampling led1_off; led2_on; while(UCA0STATW & UCBUSY); TXdata = xyz[1]; while (ADC10CTL1 & BUSY); // Wait if ADC10 core is ADC10CTL0 |= ADC10ENC + ADC10SC; // Start sampling led2_off; led3_on; while(UCA0STATW & UCBUSY); TXdata = xyz[2]; while (ADC10CTL1 & BUSY); // Wait if ADC10 core is ADC10CTL0 |= ADC10ENC + ADC10SC; // Start sampling led3_off; }
此帖出自
小平头技术问答
一周热门 更多>