main.c

来自「launchpad msp430官方示例」· C语言 代码 · 共 70 行

C
70
字号
//******************************************************************************
//  RO method capactiance measurement using CompA+, TimerA0, and WDT+
//        Schematic Description of CompA+ forming relaxation oscillator and
//        coupling (connection) between the relaxation oscillator and TimerA0.
//        <- Output
//        -> Input
//        R  Resistor (typically 100Kohms)
//
//                             MSP430F2011
//                          +---------------+
//                          
//                       +--<P1.6 
//                       |  
//                       R  
//                       |  
//                   +---+-->P1.1/CA1
//                   |   |  
//                   R   R                
//                   |   |  
//                  GND  +-->P1.0/TACLK
//                       |  
//    c-+-----------+-R--+--<P1.7/CAOUT  
//      |                |
//      | c-+-------+-R--+  
//      |   |            |
//      |   | c-+-----R--+  
//      |   |   |        |
//      |   |   | c-+-R--+                               
//      |   |   |   |
//      |   |   |   +------->P1.5/CA5
//      |   |   +----------->P1.4/CA4
//      |   +--------------->P1.3/CA3
//      +------------------->P1.2/CA2
//
//          The WDT+ interval represents the measurement window.  The number of 
//          counts within the TA0R that have accumulated during the measurement
//          window represents the capacitance of the element.  Using the WDT is
//          a low power implementation, either LPM3 (when WDT+ is sourced from 
//          ACLK) or LPM0 (when WDT+ sourced from SMCLK).
//
//******************************************************************************
#include "CTS_Layer.h"

unsigned int position;
//unsigned int dCnt[4];

// Main Function
void main(void)
{ 
  WDTCTL = WDTPW + WDTHOLD;             // Stop watchdog timer

  // establish baseline
  TI_CAPT_Init_Baseline(&slider);
  TI_CAPT_Update_Baseline(&slider,5);

  // Main loop starts here
  while (1)
  {
    position = TI_CAPT_Slider(&slider);
    //TI_CAPT_Custom(&slider,dCnt);
    if(position != ILLEGAL_SLIDER_WHEEL_POSITION)   
    {
        __no_operation();
    }
    __delay_cycles(100); 

  }
} // End Main

⌨️ 快捷键说明

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