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

📄 fet140_sd16_singchsingconv_isr.c

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

#include          "msp430xE42x.h"        // Standard Equations
unsigned int results;

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
  SD16CCTL2 |= SD16SNGL+SD16IE ;        // Single Conv, Interrupt Enable
  SD16INCTL2 |= SD16INTDLY0;            // First Interrupt on 3rd Sample
  _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 = SD16MEM2;                   // clears SD16IFG
  _BIC_SR_IRQ(LPM0_bits);               // Clear LPM0,SET BREAKPOINT HERE
}                          

⌨️ 快捷键说明

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