4480|4

67

帖子

0

TA的资源

一粒金砂(初级)

楼主
 

求助,149.片内AD,采样不稳.居然与断点有关. [复制链接]

代码:
 
//******************************************************************************
//  MSP-FET430P140 Demo - ADC12, Repeated Sequence of Conversions
//
//  This example shows how to perform a repeated sequence of conversions using 
//  "repeat sequence-of-channels" mode.  ××cc is used for the reference and 
//  repeated sequence of conversions is performed on Channels A0, A1, A2, and 
//  A3. Each conversion result is stored in ADC12MEM0, ADC12MEM1, ADC12MEM2, 
//  and ADC12MEM3 respectively. After each sequence, the 4 conversion results 
//  are moved to A0results[], A1results[], A2results[], and A3results[]. Test
//  by applying voltages to channels A0 - A3. Open a watch window in C-Spy and 
//  view the results. Set a breakpoint in the last line to see the array values
//  change sequentially.
//
//  Note that a sequence has no restrictions on which channels are converted. 
//  For example, a valid sequence could be A0, A3, A2, A4, A2, A1, A0, and A7.
//  See the MSP430x1xx User's Guide for instructions on using the ADC12.
//
//
//                 MSP430F149
//             -----------------
//            |                 |
//            |              A0 |<---- Vin0
//            |              A1 |<---- Vin1
//            |              A2 |<---- Vin2
//            |              A3 |<---- Vin3
//            |                 |
//
//
//  M.Mitchell
//  Texas Instruments, Inc
//  January, 2002
//  Built with IAR Embedded Workbench Version: 1.25A
//  December 2003
//  Updated for IAR Embedded Workbench Version: 2.21B
//******************************************************************************

#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
static unsigned int A3results[Num_of_Results];  // they are not used

void main(void)
{ 
  WDTCTL = WDTPW+WDTHOLD;               // Stop watchdog timer
  P6SEL = 0x0F;                         // Ena××e A/D channel inputs
  ADC12CTL0 = ADC12ON+MSC+SHT0_8;       // Turn on ADC12, extend sampling time
                                        // to ××oid overflow of results
  ADC12CTL1 = SHP+CONSEQ_3;             // Use sampling timer, repeated sequence
  ADC12MCTL0 = INCH_0;                  // ref+=××cc, channel = A0
  ADC12MCTL1 = INCH_1;                  // ref+=××cc, channel = A1
  ADC12MCTL2 = INCH_2;                  // ref+=××cc, channel = A2    
  ADC12MCTL3 = INCH_3+EOS;              // ref+=××cc, channel = A3, end seq.
  ADC12IE = 0x08;                       // Ena××e ADC12IFG.3
  ADC12CTL0 |= ENC;                     // Ena××e conversions
  _EINT();                              // Ena××e 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    
  A3results[index] = ADC12MEM3;         // Move A3 results, IFG is cleared  
  index = (index+1)%Num_of_Results;     // Increment results index, modulo; Set Breakpoint here
}
以上就是TI官方的样例.

如果我将断点加在 A3results[index] = ADC12MEM3; 采样很稳定.数组值均为3563

如果我把断点加在 index = (index+1)%Num_of_Results; 有正负200的无规律波动.

奇怪了.

最新回复

这不很正常么  唉……  详情 回复 发表于 2010-8-17 09:03
 
点赞 关注

回复
举报

71

帖子

0

TA的资源

一粒金砂(初级)

沙发
 

没人回,自己顶

没人回,自己顶
 
 

回复

69

帖子

0

TA的资源

一粒金砂(初级)

板凳
 

正常

正常
 
 
 

回复

94

帖子

0

TA的资源

一粒金砂(初级)

4
 
为什么呀?
 
 
 

回复

81

帖子

0

TA的资源

一粒金砂(初级)

5
 
这不很正常么  唉……
 
 
 

回复
您需要登录后才可以回帖 登录 | 注册

随便看看
查找数据手册?

EEWorld Datasheet 技术支持

相关文章 更多>>
关闭
站长推荐上一条 1/7 下一条

 
EEWorld订阅号

 
EEWorld服务号

 
汽车开发圈

About Us 关于我们 客户服务 联系方式 器件索引 网站地图 最新更新 手机版

站点相关: 国产芯 安防电子 汽车电子 手机便携 工业控制 家用电子 医疗电子 测试测量 网络通信 物联网

北京市海淀区中关村大街18号B座15层1530室 电话:(010)82350740 邮编:100190

电子工程世界版权所有 京B2-20211791 京ICP备10001474号-1 电信业务审批[2006]字第258号函 京公网安备 11010802033920号 Copyright © 2005-2025 EEWORLD.com.cn, Inc. All rights reserved
快速回复 返回顶部 返回列表