-
应该是在-端对地接入一个电阻
-
这种机会多多益善 学习无止境 能人一大批
-
想先看看截图
-
大神 可以带我翔不
-
谢了亲 论坛什么的最好了
-
好人 我现在又该学ucos了 因为上班了。。
-
好人 我现在又该学ucos了 因为上班了。。
-
怎么开始学啊 从那块开始啊
-
还是不会 啊啊 谢谢谢哈
-
我想学习下 但是时间紧啊
-
书中错误还是比较多的
-
我用的也是F5529,用的也是ccsv5
-
kankna
-
大神教育的是,自己还是太菜鸟,有些问题没弄清,自己也没好好研究。这是个坏习惯。大神提醒看配置,我试了试弄好了!谢谢“卡尔夫”,以后还要多赐教!
#include
int main(void)
{
WDTCTL = WDTPW + WDTHOLD; // Stop WDT
P6SEL |= 0x80; // P6.0 ADC option select
ADC12CTL0 = ADC12SHT02 + ADC12ON; // Sampling time, ADC12 on
ADC12CTL1 = ADC12SHP+ADC12CSTARTADD_7; // Use sampling timer
ADC12MCTL7 = ADC12INCH_7;
ADC12IE = 0x80; // Enable interrupt
ADC12CTL0 |= ADC12ENC;
P1DIR |= 0x01; // P1.0 output
while (1)
{
ADC12CTL0 |= ADC12SC; // Start sampling/conversion
__bis_SR_register(LPM0_bits + GIE); // LPM0, ADC12_ISR will force exit
__no_operation(); // For debugger
}
}
#pragma vector = ADC12_VECTOR
__interrupt void ADC12_ISR(void)
{
switch(__even_in_range(ADC12IV,34))
{
case 0: break; // Vector 0: No interrupt
case 2: break; // Vector 2: ADC overflow
case 4: break; // Vector 4: ADC timing overflow
case 6: break; // Vector 6: ADC12IFG0
case 8: break; // Vector 8: ADC12IFG1
case 10: break; // Vector 10: ADC12IFG2
case 12: break; // Vector 12: ADC12IFG3
case 14: break; // Vector 14: ADC12IFG4
case 16: break; // Vector 16: ADC12IFG5
case 18: break; // Vector 18: ADC12IFG6
case 20: if (ADC12MEM7 >= 0x7ff) // ADC12MEM = A0 > 0.5AVcc?
P1OUT &= ~BIT0;
else
P1OUT |= BIT0;
__bic_SR_register_on_exit(LPM0_bits); // Vector 20: ADC12IFG7
case 22: break; // Vector 22: ADC12IFG8
case 24: break; // Vector 24: ADC12IFG9
case 26: break; // Vector 26: ADC12IFG10
case 28: break; // Vector 28: ADC12IFG11
case 30: break; // Vector 30: ADC12IFG12
case 32: break; // Vector 32: ADC12IFG13
case 34: break; // Vector 34: ADC12IFG14
default: break;
}
}
-
这个是我修改的部分:
ADC12IE |= 0x80; // Enable interrupt
ADC12CTL0 |= ADC12ENC;
P6SEL |= 0x80; // P6.7 ADC option select
P1DIR |= 0x01;
P6.7输入
是不是转换只能从P6.0开始,不能单路选通??
-
调试中,ADC12IV 应该是有 数据值的 但是修改后,没有值,ADC12MEM0有值,ADC12MEM7 为0;P1.0输出也为高
我所理解的正确是应该ADC12IV ADC12MEM7均有值,,P1.0输出受控制
[ 本帖最后由 woaiweibo 于 2013-10-29 19:13 编辑 ]
-
这个是我修改的部分
#include
int main(void)
{
WDTCTL = WDTPW + WDTHOLD; // Stop WDT
ADC12CTL0 = ADC12SHT02 + ADC12ON; // Sampling time, ADC12 on
ADC12CTL1 = ADC12SHP; // Use sampling timer
ADC12IE |= 0x80; // Enable interrupt
ADC12CTL0 |= ADC12ENC;
P6SEL |= 0x80; // P6.0 ADC option select
P1DIR |= 0x01; // P1.0 output
while (1)
{
ADC12CTL0 |= ADC12SC; // Start sampling/conversion
__bis_SR_register(LPM0_bits + GIE); // LPM0, ADC12_ISR will force exit
__no_operation(); // For debugger
}
}
#pragma vector = ADC12_VECTOR
__interrupt void ADC12_ISR(void)
{
switch(__even_in_range(ADC12IV,34))
{
case 0: break; // Vector 0: No interrupt
case 2: break; // Vector 2: ADC overflow
case 4: break; // Vector 4: ADC timing overflow
case 6: break; // Vector 6: ADC12IFG0
/* if ( ADC12MEM0 >= 0x7ff ) // ADC12MEM = A0 > 0.5AVcc?
P1OUT |= BIT0; // P1.0 = 1
else
P1OUT &= ~BIT0; // P1.0 = 0
__bic_SR_register_on_exit(LPM0_bits); */// Exit active CPU
case 8: break; // Vector 8: ADC12IFG1
case 10: break; // Vector 10: ADC12IFG2
case 12: break; // Vector 12: ADC12IFG3
case 14: break; // Vector 14: ADC12IFG4
case 16: break; // Vector 16: ADC12IFG5
case 18: break; // Vector 18: ADC12IFG6
case 20: if (ADC12MEM7 >= 0x7ff)
P1OUT |= BIT0; // P1.0 = 1
else
P1OUT &= ~BIT0; // P1.0 = 0
__bic_SR_register_on_exit(LPM0_bits); // Vector 20: ADC12IFG7
case 22: break; // Vector 22: ADC12IFG8
case 24: break; // Vector 24: ADC12IFG9
case 26: break; // Vector 26: ADC12IFG10
case 28: break; // Vector 28: ADC12IFG11
case 30: break; // Vector 30: ADC12IFG12
case 32: break; // Vector 32: ADC12IFG13
case 34: break; // Vector 34: ADC12IFG14
default: break;
}
}
-
Index[2]表示两个字节存放一个汉字,那么Index[3表示什么?难道后面还有一个 /0 ? 忘了谢谢这么快的答复哈!
-
谢谢了啊版主,以后还要多讨教!
-
谢谢啊 ,好欣喜,谢谢版主了,我刚去投简历去了,心情还郁闷着没人要,这下有精神食粮了,心情好点了