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

📄 main.c

📁 launchpad msp430官方示例
💻 C
字号:
//******************************************************************************
//   RO method capactiance measurement using CompA+, TimerA0, and SW loop
//
//                             MSP430F2132
//                           +---------------+
//                           |
//                           +--<P3.7 
//                           |  
//                           R  
//                           |  
//                       +---+-->P2.3/CA0
//                       |   |  
//                       R   R                
//                       |   |  
//                      GND  +-->P1.0/TACLK
//                           |  
//c-+---------------------R--+--<P2.2/CAOUT  
//  |                        |
//  | c-+-----------------R--+ 
//  |   |                    |
//  |   | c-+-------------R--+ 
//  |   |   |                |
//  |   |   | c-+---------R--+  
//  |   |   |   |            |
//  |   |   |   | c-+-----R--+  
//  |   |   |   |   |        |
//  |   |   |   |   | c-+-R--+                               
//  |   |   |   |   |   |
//  |   |   |   |   |   +------->P2.7/CA7
//  |   |   |   |   +----------->P2.6/CA6
//  |   |   |   +--------------->P2.5/CA5
//  |   |   +------------------->P2.1/CA3
//  |   +----------------------->P2.0/CA2
//  +--------------------------->P2.4/CA1
//
//         The timer counts to TA0CCR0 representing the measurement window. The
//          number of counts within the SW loop that have accumulated during the
//          measurement window represents the capacitance of the element.
//******************************************************************************
#include "CTS_Layer.h"

uint16_t position;
struct Element * direction;
//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);
  TI_CAPT_Init_Baseline(&menu);
  TI_CAPT_Update_Baseline(&menu,5);

  // Main loop starts here
  while (1)
  {
    // TI_CAPT_Raw(&slider,dCNT);
	// TI_CAPT_Custom(&slider,dCNT);
    position = TI_CAPT_Slider(&slider);
	direction = (struct Element*)TI_CAPT_Buttons(&menu); 
	if(direction == (struct Element*)&right)
	{
	    __no_operation();
	}
	if(direction == (struct Element*)&left);
	{
	    __no_operation();
	}
    if(position != ILLEGAL_SLIDER_WHEEL_POSITION)   
    {
        __no_operation();
    }
    __delay_cycles(100); 
  }
} // End Main

⌨️ 快捷键说明

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