谁能给个430 AD转换的代码啊

2019-03-24 14:16发布

哪位大神能给个430 AD转换的程序啊? 这几天搞这个AD转换老是陷入各种迷惑中。  我的系统是由TimerA控制的,每个脉冲到来的时候就进行一次AD转换,然后把转换的数据存起来。AD转换是单通道的。 此帖出自小平头技术问答
友情提示: 此问题已得到解决,问题已经关闭,关闭后问题禁止继续编辑,回答。
该问题目前已经被作者或者管理员关闭, 无法添加新回复
3条回答
starswings
1楼-- · 2019-03-24 18:12
 精彩回答 2  元偷偷看……
wayne07
2楼-- · 2019-03-24 23:08
< :TI_MSP430_内容页_SA7 --> 例程里面没有TA触发的AD转换  哎~
wojiaomt
3楼-- · 2019-03-25 03:27
怎会没有呢?
以下就是F2××的例程,可能就是你想要的功能:
  1. //******************************************************************************
    //  MSP430F21x2 Demo - ADC10, Sample A0, 1.5V, TA1 Trig, Set P1.0 if > 0.5V
    //
    //  Description: A0 is sampled 16/second (ACLK/2048) with reference to 1.5V.
    //  Timer_A is run in upmode and TA1 is used to automatically trigger
    //  ADC10 conversion, TA0 defines the period. Internal oscillator times sample
    //  (16x) and conversion (13x). Inside ADC10_ISR if A0 > 0.5Vcc, P1.0 is set,
    //  else reset. Normal mode is LPM3.
    //  //* An external watch crystal on XIN XOUT is required for ACLK *//
    //
    //               MSP430F21x2
    //            -----------------
    //        /||              XIN|-
    //         | |                 | 32kHz
    //         --|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
      ADC10CTL1 = SHS_1 + CONSEQ_2;             // TA1 trigger sample start
      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
      ADC10CTL0 |= ENC;                         // ADC10 Enable
      ADC10AE0 |= 0x01;                         // P2.0 ADC10 option select
      P1DIR |= 0x01;                            // Set P1.0 output
      TACCR0 = 2048-1;                          // PWM Period
      TACCTL1 = OUTMOD_3;                       // TACCR1 set/reset
      TACCR1 = 2047;                            // TACCR1 PWM Duty Cycle
      TACTL = TASSEL_1 + MC_1;                  // ACLK, up mode

      __bis_SR_register(LPM3_bits + GIE);       // Enter LPM3 w/ interrupts
    }

    // ADC10 interrupt service routine
    #pragma vector=ADC10_VECTOR
    __interrupt void ADC10_ISR(void)
    {
      if (ADC10MEM < 0x155)                     // ADC10MEM = A0 > 0.5V?
        P1OUT &= ~0x01;                         // Clear P1.0 LED off
      else
        P1OUT |= 0x01;                          // Set P1.0 LED on
    }

    #pragma vector=TIMER0_A0_VECTOR
    __interrupt void TA0_ISR(void)
    {
      TACTL = 0;                                // Clear Timer_A control registers
      __bic_SR_register_on_exit(CPUOFF);        // Clear CPUOFF bit from 0(SR)
    }
复制代码

一周热门 更多>

相关问题

    相关文章