fet140_sd16_singchsingconv_ifg.c

来自「msp430f14x 系列片内外设的实例代码」· C语言 代码 · 共 53 行

C
53
字号
//******************************************************************************
//  MSP-FET430P140 Demo - SD16, Single Conversion on Single Channel using IFG
// 
//  This example shows how to perform a single SD16 conversion on a single 
//  channel by polling the Interrupt Flag. 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 "_NOP()" 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;                  // Turn on SD16 Ref
  SD16CCTL2 |= SD16SNGL; 
  
  for ( i=0; i<0x3600; i++)             // Delay for reference start-up
  {
  }               
  
    
  while (1)
  {     
    SD16CCTL2 |= SD16SC;                // Start conversion
    while ((SD16CCTL2 & SD16IFG)==0);   // Poll Interrup Flag for Ch2
    results = SD16MEM2;                 // clears SD16IFG
    _NOP();                             // SET BREAKPOINT HERE
  }
  
}

⌨️ 快捷键说明

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