AD转换的程序

2019-08-02 15:49发布

哪位大神能给个430 AD转换的程序啊?
友情提示: 此问题已得到解决,问题已经关闭,关闭后问题禁止继续编辑,回答。
该问题目前已经被作者或者管理员关闭, 无法添加新回复
7条回答
pengf
1楼-- · 2019-08-02 17:53
什么要求啊
chuxh
2楼-- · 2019-08-02 21:45
系统是由TimerA控制的,每个脉冲到来的时候就进行一次AD转换,然后把转换的数据存起来。
chuxh
3楼-- · 2019-08-03 03:06
AD转换是单通道的。
栩栩如生
4楼-- · 2019-08-03 08:11
 精彩回答 2  元偷偷看……
houcs
5楼-- · 2019-08-03 08:42
//******************************************************************************
//  MSP430F21x2 Demo - ADC10, Sample A0, 1.5V Ref, Set P1.0 if A0 > 0.2V
//
//  Description: A single sample is made on A0 with reference to internal
//  1.5V Vref. Software sets ADC10SC to start sample and conversion - ADC10SC
//  automatically cleared at EOC. ADC10 internal oscillator times sample (16x)
//  and conversion. In Mainloop MSP430 waits in LPM0 to save power until ADC10
//  conversion complete, ADC10_ISR will force exit from LPM0 in Mainloop on
//  reti. If A0 > 0.2V, P1.0 set, else reset.
//
//                MSP430F21x2
//             -----------------
//         /||              XIN|-
//          | |                 |
//          --|RST          XOUT|-
//            |                 |
//        >---|P2.0/A0      P1.0|-->LED
//
//  A. Dannenberg
//  Texas Instruments Inc.
//  December 2007
//  Built with CCE Version: 3.2.0 and IAR Embedded Workbench Version: 3.41A
//******************************************************************************
#include "msp430x21x2.h"

void main(void)
{
   WDTCTL = WDTPW + WDTHOLD;                 // Stop WDT
   ADC10CTL0 = SREF_1 + ADC10SHT_2 + REFON + ADC10ON + ADC10IE;
   TACCR0 = 30;                              // Delay to allow Ref to settle
   TACCTL0 |= CCIE;                          // Compare-mode interrupt.
   TACTL = TASSEL_2 + MC_1;                  // TACLK = SMCLK, Up mode.
   __bis_SR_register(CPUOFF + GIE);          // LPM0, TA0_ISR will force exit
   TACCTL0 &= ~CCIE;                         // Disable timer Interrupt
   ADC10AE0 |= 0x01;                         // P2.0 ADC option select
   P1DIR |= 0x01;                            // Set P1.0 to output direction

  for (;;)
   {
     ADC10CTL0 |= ENC + ADC10SC;             // Sampling and conversion start
     __bis_SR_register(CPUOFF + GIE);        // LPM0, ADC10_ISR will force exit
     if (ADC10MEM < 0x88)                    // ADC10MEM = A0 > 0.2V?
       P1OUT &= ~0x01;                       // Clear P1.0 LED off
     else
       P1OUT |= 0x01;                        // Set P1.0 LED on
   }
}

// ADC10 interrupt service routine
#pragma vector=ADC10_VECTOR
__interrupt void ADC10_ISR(void)
{
   __bic_SR_register_on_exit(CPUOFF);        // Clear CPUOFF bit from 0(SR)
}

#pragma vector=TIMERA0_VECTOR
__interrupt void TA0_ISR(void)
{
   TACTL = 0;
   LPM0_EXIT;                                // Exit LPM0 on return
}
chuxh
6楼-- · 2019-08-03 11:24
嗯,我知道了

一周热门 更多>