
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 capacitance 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. CSD, 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] - BTN0			(CapSense button 0)
	P1[3] - BTN1			(CapSense button 1)
	P3[3] - BTN2			(CapSense button 2)
	P2[1] - BTN3			(CapSense button 3)
	P2[3] - BTN4			(CapSense button 4)
	P1[7] - TX8
	P1[0] - EzI2Cs SDA
	P1[1] - EzI2Cs SCL

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 TX8SW under Digital Comm & place it. Rename it to "TX8SW".
      c. Select EzI2Cs under Digital Comm & place it. Rename it to "EzI2Cs".
  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).
				iDAC Value			192				This parameter sets the iDAC value used for sensor scanning.

				Resolution			16				This parameter determines the scanning resolution in bits.

				Scanning Speed			Slow				This parameter sets the sensor scanning speed.

				Shield Electrode Out	        None				Determines whether to drive out a driven shield signal.

				Precharge Source		Prescaler			Sets the clock source for precharge switches.

				Prescaler 			16				Determines the precharge clock frequency.

				PRS Resolution			12 bits				This parameter changes the PRS sequence length for the CSD IDAC switches.

				Autocalibration			Disabled			This parameter determines how the IDAC is set for sensor scanning.

				Idac range			4x				This parameter sets scale the IDAC current output.

---------------------------------------------------------------------------------------------------------------------------------------------
	
	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.

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


-------------------------------------------------------------------------------------------------------------------
	
       EzI2Cs		       Slave Address		        04				This parameter decides the address that is assigned to the slave. 
												If we set Address_Type 	to 'Dynamic', this can be changed using API
												during runtime. Value assigned can be any vaue	from 0 to 7Fh.

			       Address_Type		        Static				If set to static, I2C address cannot be changed dynamically during 
												runtime, but, saves	one byte of RAM. Setting this option to dynamic 
												allows the firmware to change the address at any time.
														
			       ROM Registers		        Disable				If we set this to Enable, we can use RAM area as one slave and ROM 
												area as another slave with the addresses differing only by MSB of 
												7-bit address.
														
												MSB = 1 ---> ROM Regsters addressed.
									       			MSB = 0 ---> RAM area addressed.
														
												E.g: if slave address is 0x0A, RAM address=0x0A & ROM address=0x4
			       HW Addr Rec		        Disable				This parameter enables/disables the hardware I2C slave address 
				                          
				
			       I2C Clock		        400k Fast			It decides the maximum clock speed that the slave can operate at.
												recognition feature.	
													
			       I2C Pin			 	P1[0]-P1[1]			Pins assigned for SDA and SCL lines of I2C.
-------------------------------------------------------------------------------------------------------------------

 C. Pin Drive modes
 	 1. TX8SW Pins
    	Pin	       Select          Drive
    	----------------------------------------------
    	P1[7]	   TX Pin	   	   Strong
----------------------------------------------------------------------------
   	 2. I2C Lines
        Pin	    Select	            Drive
    	----------------------------------------------
        P1[0]	   I2C SDA	    	Open Drain Low
        P1[1]	   I2C SCL		Open Drain Low
----------------------------------------------------------------------------

	 3. Sensor
    	Pin	       Select          Drive
    	----------------------------------------------
    	        P1[6]	   BTN0	    	HIGH Z Analog
		P1[3]	   BTN1			HIGH Z Analog
		P3[3]	   BTN2			HIGH Z Analog
		P2[1]	   BTN3			HIGH Z Analog
		P2[3]	   BTN4			HIGH Z Analog
		P0[3]	   Cmod			HIGH Z Analog