MSP430G2553多路ADC问题

2019-03-24 12:05发布

想用MSP430G2553做一个多路ADC,至少8个不同的ADC同时工作,不知道直接接可以实现吗?还是要用多路开关?具体实现思路应该怎样?希望大大们说得详细点,谢谢! 此帖出自小平头技术问答
友情提示: 此问题已得到解决,问题已经关闭,关闭后问题禁止继续编辑,回答。
该问题目前已经被作者或者管理员关闭, 无法添加新回复
9条回答
wstt
1楼-- · 2019-03-25 21:50
  1. //******************************************************************************
  2. //  MSP430G2x33/G2x53 Demo - ADC10, DTC Sample A2-0, AVcc, Single Sequence, DCO
  3. //
  4. //  Description: Sample A3/A2/A1 as single sequence with reference to AVcc.
  5. //  Software sets ADC10SC to trigger sample sequence. In Mainloop MSP430 waits
  6. //  in LPM0 to save power until ADC10 conversion complete, ADC10_ISR(DTC) will
  7. //  force exit from any LPMx in Mainloop on reti. ADC10_ISR will force any LPMx
  8. //  exit. ADC10 internal oscillator times sample period (16x) and conversion
  9. //  (13x). DTC transfers conversion code to RAM 200h - 206h. P1.0 set at start
  10. //  of conversion burst, reset on completion.
  11. //
  12. //               MSP430G2x33/G2x53
  13. //            -----------------
  14. //        /||              XIN|-
  15. //         | |                 |
  16. //         --|RST          XOUT|-
  17. //           |                 |
  18. //       >---|P1.3/A3      P1.0|-->LED
  19. //       >---|P1.2/A2          |
  20. //       >---|P1.1/A1          |
  21. //
  22. //  D. Dang
  23. //  Texas Instruments Inc.
  24. //  December 2010
  25. //   Built with CCS Version 4.2.0 and IAR Embedded Workbench Version: 5.10
  26. //******************************************************************************
  27. #include  "msp430g2553.h"

  28. void main(void)
  29. {
  30.   WDTCTL = WDTPW + WDTHOLD;                 // Stop WDT
  31.   ADC10CTL1 = INCH_3 + CONSEQ_1;            // A3/A2/A1, single sequence
  32.   ADC10CTL0 = ADC10SHT_2 + MSC + ADC10ON + ADC10IE;
  33.   ADC10DTC1 = 0x03;                         // 3 conversions
  34.   ADC10AE0 |= 0x0E;                         // P1.3,2,1 ADC10 option select
  35.   P1DIR |= 0x01;                            // Set P1.0 output

  36.   for (;;)
  37.   {
  38.     ADC10CTL0 &= ~ENC;
  39.     while (ADC10CTL1 & BUSY);               // Wait if ADC10 core is active
  40.     ADC10SA = 0x200;                        // Data buffer start
  41.     P1OUT |= 0x01;                          // P1.0 = 1
  42.     ADC10CTL0 |= ENC + ADC10SC;             // Sampling and conversion start
  43.     __bis_SR_register(CPUOFF + GIE);        // LPM0, ADC10_ISR will force exit
  44.     P1OUT &= ~0x01;                         // P1.0 = 0
  45.   }
  46. }

  47. // ADC10 interrupt service routine
  48. #pragma vector=ADC10_VECTOR
  49. __interrupt void ADC10_ISR(void)
  50. {
  51.   __bic_SR_register_on_exit(CPUOFF);        // Clear CPUOFF bit from 0(SR)
  52. }
复制代码
wstt
2楼-- · 2019-03-25 22:25
采样频率
  1. //******************************************************************************
  2. //  MSP430G2x33/G2x53 Demo - ADC10, Sample A1, 1.5V, TA1 Trig, Set P1.0 if > 0.5V
  3. //
  4. //  Description: A1 is sampled 16/second (ACLK/2048) with reference to 1.5V.
  5. //  Timer_A is run in upmode and TA1 is used to automatically trigger
  6. //  ADC10 conversion, TA0 defines the period. Internal oscillator times sample
  7. //  (16x) and conversion (13x). Inside ADC10_ISR if A1 > 0.5Vcc, P1.0 is set,
  8. //  else reset. Normal mode is LPM3.
  9. //  //* An external watch crystal on XIN XOUT is required for ACLK *//
  10. //
  11. //               MSP430G2x33/G2x53
  12. //            -----------------
  13. //        /||              XIN|-
  14. //         | |                 | 32kHz
  15. //         --|RST          XOUT|-
  16. //           |                 |
  17. //       >---|P1.1/A1     P1.0 |--> LED
  18. //
  19. //  D. Dang
  20. //  Texas Instruments Inc.
  21. //  December 2010
  22. //   Built with CCS Version 4.2.0 and IAR Embedded Workbench Version: 5.10
  23. //******************************************************************************
  24. #include  "msp430g2553.h"

  25. void main(void)
  26. {
  27.   WDTCTL = WDTPW + WDTHOLD;                 // Stop WDT
  28.   ADC10CTL1 = SHS_1 + CONSEQ_2 + INCH_1;    // TA1 trigger sample start
  29.   ADC10CTL0 = SREF_1 + ADC10SHT_2 + REFON + ADC10ON + ADC10IE;
  30.   __enable_interrupt();                     // Enable interrupts.
  31.   TACCR0 = 30;                              // Delay to allow Ref to settle
  32.   TACCTL0 |= CCIE;                          // Compare-mode interrupt.
  33.   TACTL = TASSEL_2 + MC_1;                  // TACLK = SMCLK, Up mode.
  34.   LPM0;                                     // Wait for delay.
  35.   TACCTL0 &= ~CCIE;                         // Disable timer Interrupt
  36.   __disable_interrupt();
  37.   ADC10CTL0 |= ENC;                         // ADC10 Enable
  38.   ADC10AE0 |= 0x02;                         // P1.1 ADC10 option select
  39.   P1DIR |= 0x01;                            // Set P1.0 output
  40.   TACCR0 = 2048-1;                          // PWM Period
  41.   TACCTL1 = OUTMOD_3;                       // TACCR1 set/reset
  42.   TACCR1 = 2047;                            // TACCR1 PWM Duty Cycle
  43.   TACTL = TASSEL_1 + MC_1;                  // ACLK, up mode

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

  46. // ADC10 interrupt service routine
  47. #pragma vector=ADC10_VECTOR
  48. __interrupt void ADC10_ISR(void)
  49. {
  50.   if (ADC10MEM < 0x155)                     // ADC10MEM = A1 > 0.5V?
  51.     P1OUT &= ~0x01;                         // Clear P1.0 LED off
  52.   else
  53.     P1OUT |= 0x01;                          // Set P1.0 LED on
  54. }

  55. #pragma vector=TIMER0_A0_VECTOR
  56. __interrupt void ta0_isr(void)
  57. {
  58.   TACTL = 0;
  59.   LPM0_EXIT;                                // Exit LPM0 on return
  60. }
复制代码
华叶春秋
3楼-- · 2019-03-25 23:01
 精彩回答 2  元偷偷看……

一周热门 更多>

相关问题

    相关文章