⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 fet140_sd16_grpchsingconv_isr.c

📁 msp430f14x 系列片内外设的实例代码
💻 C
字号:
//******************************************************************************
//  MSP-FET430P140 Demo - SD16, Single Conversion on Group of Channels
// 
//  This example shows how to perform a single SD16 conversion on a group of 
//  channels. It uses internal reference and performs a single conversion on 
//  channels 0,1&2. The conversion results are stored in SD16MEM0,1&2. Test by 
//  applying a voltage to channels, then setting and running to a break point at
//  the mentioned instruction. To view the conversion results, open watch
//  window in C-Spy and view the contents of "results".
//
//               MSP430FE427
//             ---------------
//            |               |
//            |           I1+ |<---- Vin 1+
//            |           I1- |<---- Vin 1-
//            |           I2+ |<---- Vin 2+
//            |           I2- |<---- Vin 2-
//            |           V1+ |<---- Vin 3+
//            |           V1- |<---- Vin 3-
//            |               |
//
//
//  Harman Grewal
//  Texas Instruments, Inc
//  Oct, 2004
//  IAR Embedded Workbench Version: 2.21B
//******************************************************************************

#include          "msp430xE42x.h"       // Standard Equations

static unsigned int results[3];         // Needs to be global in this example
                                        // Otherwise, the compiler removes it
                                        // because it is not used for anything.

void main(void)
{ 
  volatile unsigned int i;
  
  WDTCTL = WDTPW+WDTHOLD;               // Stop watchdog timer
  FLL_CTL0 |= XCAP14PF;                 // Set load capacitance for xtal.
  for (i = 0; i < 20000; i++);          // Delay - to allow watch crystal to stabilize.
  SD16CTL = SD16REFON+SD16SSEL0;        // Turn on SD16 Ref,SMCLK
  SD16CCTL0 |= SD16SNGL+SD16GRP;        // Enable Grouping with next higher channel,
                                        // Single Conv
  SD16CCTL1 |= SD16SNGL+SD16GRP;        // Enable Grouping with next higher channel,
                                        // Single Conv
  SD16CCTL2 |= SD16SNGL+SD16IE;         // Single Conv, Interrupt Enable
  _EINT();                              // Enable interrupts
  for ( i=0; i<0x3600; i++)             // Delay for reference start-up
  {
  }               
  
  while (1)
  {  
   SD16CCTL2 |= SD16SC;                 // Start conversion
   _BIS_SR(LPM0_bits);                  // Enter LPM0
  }
}  
#pragma vector=SD16_VECTOR
__interrupt void SD16ISR (void)
{
  results[0] = SD16MEM0;                // Move results, IFG is cleared
  results[1] = SD16MEM1;                // Move results, IFG is cleared
  results[2] = SD16MEM2;                // Move results, IFG is cleared    
  _BIC_SR_IRQ(LPM0_bits);               // Clear LPM0,SET BREAKPOINT HERE
}                          

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -