
Overview
========

 CapSense systems detect the presence of a touch by monitoring changes in measured sensor capacitance.
 The discrimination of touch events from random noise are based solely on the differences in sensor 
 capacitance caused by a touch. However, there are times when measuring the absolute as opposed to 
 relative capacitance is useful. Tuning is one example. To tune a CapSense system, the absolute 
 capacitance of the sensors must be known. This project measures the absolute capacitance of sensors 
 with parasitic capacitance (Cp) up to 60pF, within 1pF accuracy.	
	
Operation
=========
 On reset, all hardware settings from the device configuration are loaded into the device and main.c 
 is executed. CCSD, EzI2Cs (if enabled in firmware) and TX8SW (if enabled in firmware) User Modules are
 initialized. The sensitivity of each sensor is calculated and the raw count is divided by the sensitivity 
 to obtain the Cp. If TX8SW is enabled then the result is displayed on the HyperTerminal.
 If EzI2Cs is enabled then the result is displayed on the BridgeControl Panel.

 
Pin Assignment
==============

	P0[3] - Cmod		        (Connect Capacitor, 2.2nF between Pin P0[3] & Gnd)
	P1[6] - SW0			(CapSense button 0)
	P1[3] - SW1			(CapSense button 1)
	P3[3] - SW2			(CapSense button 2)
	P2[1] - SW3			(CapSense button 3)
	P2[3] - SW4			(CapSense button 4)
	P1[0] - EzI2Cs SDA
	P1[1] - EzI2Cs SCL
        P1[7] - TX8SW

Project Settings
================

 The following changes have to be made in the Device Editor:
  1. Selecting & placing user modules from "User Modules" catalog
      a. Select CSD under Cap Sensors & place it. Rename it to 
	    "CSD".
      b. Select EzI2Cs under Digital Comm & place it. Rename it to "EzI2Cs".
      c. Select TX8SW under Digital Comm & place it. Rename it to "TX8SW".
  2. Configure the global resources & user modules settings as given below.
  3. Assign pins for buttons from CSD wizard.
 
 A. Global Resources
     IMO Setting  = 24MHz     ;System clock is set to 24MHz
  	 CPU_Clock    = SysClk/2  ;CPU clock set to 12 MHz
	 [leave all other parameters with default values]

 B. User Module parameter Settings
-------------------------------------------------------------------------------------------------------------------------------------
 	UserModule	Parameter 				Value 			Comments   
-------------------------------------------------------------------------------------------------------------------------------------
	CSD			Finger Threshold		60				After the difference count crosses finger threshold plus hysteresis, the button is said to 
												be in ON condition (not used by this project).
														
				Noise Threshold			10				The baseline follows the raw count as long as the difference count is less than the noise 
												threshold, since it is interpreted as noise. If the difference count goes more than the noise 
												threshold, the baseline is not updated (not used by this project).
														
				BaseLine Update			100				This parameter decides how fast the baseline follows the raw count value. If this threshold 
				Threshold							value is high, the baseline will take more time to update, and vice versa. (not used by this 
												project).
				
				Sensors Autoreset		Enabled				This parameter can be used to reset a sensor. When the parameter is set to disabled, the baseline 
												is updated only when difference count is below the noise threshold parameter (not used by this 
												project).
																											
				Hysteresis			10				This parameter takes care of signal state chattering (due to noise) whenever a button is pressed. 
														It should be set to 15% of the difference count (signal) (not used by this project).
														
				Debounce			3				This parameter prevents false button triggering, by specifying a minimum number of samples to 
												be taken for a button press. If the difference count is more than finger threshold for less than 
												'Debounce' number of samples, it is not taken as a button press (not used by this project).

				Negative Noise			10				The baseline follows the raw count even if it is lesser than the baseline, as long as the difference 
				Threshold							count is less than the Negative Noise threshold (not used by this project).
				
				Low BaseLine Reset 		50				This parameter is used to correct the finger-at-startup condition. If the raw count is below 
												baseline and the difference count is more than negative noise threshold for number of samples given 
												by this parameter, the baseline resets to the new raw count (not used by this project).
				
				Scanning Speed			Slow				This parameter sets the sensor scanning speed.

				
				Resolution			16				This parameter determines the scanning resolution in bits.

				Reference			ASE11				This parameter sets the source of the comparator reference.
				
				Ref Value			5				This parameter sets the comparator reference value

				Prescaler Period		5				This parameter sets the prescaler period register and determines the precharge switch output frequency.
				
				ShieldElectrodeout     		None				This parameter sets the shielding electrode signal source

---------------------------------------------------------------------------------------------------------------------------------------------
	
	EzI2Cs		        Slave_address			0		                Selects the address of slave to be 0H.
														
				Address_Type			Static		                Selects the address type of slave to static
				
				ROM_Registers			Disable			        Disables ROM registers during I2C communication

				I2C_Clock			400K Fast			Selects the speed of I2C to 400K
					
				I2C_Pin				P1[0] , P1[1]			Selects the I2C communication port to be P1[0],P1[1]
				
---------------------------------------------------------------------------------------------------------------------------------------------- 
	
	TX8SW		        Port				Port_1			Selects the port to send data out.
														
				Pin				Port_1_7		Selects the pin of the selected port to send data out.
				
				Baud Rate			115200			Selects baud rate in bits per second.

				Parity				None			Selects the parity type to be used for transmission.
					
				StopBits			One			Selects the number of stop bits to be transmitted after a chunk of data bits.
				
				DataBits			8			Selects the number of data bits to be transmitted at one time.				

---------------------------------------------------------------------------------------------------------------------------------------------- 


 C. Pin Drive modes
 	 1. EzI2Cs Pins
    	Pin	           Select                  Drive
    	--------------------------------------------------------------------
    	P1[0],P1[1]	   EzI2Cs Pin	   	   Strong
----------------------------------------------------------------------------
          2. TX8SW Pins
    	Pin	       Select          Drive
    	----------------------------------------------
    	P1[7]	       TX Pin	   	   Strong
----------------------------------------------------------------------------
	 3. Sensor
    	Pin	       Select          Drive
    	----------------------------------------------
    	P1[6]	   SW0	    	HIGH Z Analog
		P1[3]	   SW1			HIGH Z Analog
		P3[3]	   SW2			HIGH Z Analog
		P2[1]	   SW3			HIGH Z Analog
		P2[3]	   SW4			HIGH Z Analog
		P0[3]	   Cmod			HIGH Z Analog