
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 1.5pF accuracy.	
	
Operation
=========
 On reset, all hardware settings from the device configuration are loaded into the device and main.c 
 is executed. The main.c has two functions, one for calculating the IDAC code of each sensor, which
 is then stored in an I2C buffer to be read by the user, and another for directing that amount of 
 current to a port pin to be physically measured by the user. Once the user measures the amount of 
 current on the port pin, the corresponding Cp can be calculated for that sensor.
 
Pin Assignment
==============

	P0[3] - Cmod		(Connect Capacitor, 3.9nF 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

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

 The following changes have to be made in the Device Editor:
  1. Selecting & placing user modules from "User Modules" catalog
      a. Select CSA_EMC under Cap Sensors & place it. Rename it to 
	    "CSA".
	  b. 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  = 12MHz     ;System clock is set to 12MHz
  	 CPU_Clock    = SysClk/2  ;CPU clock set to 6 MHz
	 [leave all other parameters with default values]

 B. User Module parameter Settings
-------------------------------------------------------------------------------------------------------------------------------------
 	UM			Parameter 				Value 			Comments   
-------------------------------------------------------------------------------------------------------------------------------------
	CSA			Finger Threshold		60	 			Once the Difference Count crosses Finger Threshold plus Hysteresis, Button 
														is said to be in ON condition (not used by this project).
														
				Noise Threshold			10				If the Difference Count is less than this, then it is treated as noise and 
														BaseLine Update Algorithm takes care of this by putting it into Update Bucket
														(not used by this project).
														
				BaseLine Update			100				As the Noise increases, the Update bucket will get filled and every time it 
				Threshold								crosses this threshold, Baseline is incremented by 1 and algorithm continues
														(not used by this project).
														
				Settling Time			255				The settling time parameter controls the duration of the capacitance to voltage 
														conversion phase. The parameter setting controls a software delay that allows the 
														voltage on the Cmod and Cbus capacitance to stabilize and is dependent on the 
														Clock Setting.
														Note: Refer Data Sheet for more details on Settling Time.
														
				Hysteresis				10				It is generally to take care of false ON and OFF situations whenever Button is 
														pressed. It is generally suggested to set it equal to the Noise Threshold. (not 
														used by this project)
														
				Debounce				3				If the Difference count is more than Finger Threshold for less than 'Debounce' number 
														of samples, it will not be taken as a Button Press (not used by this project).
				
				Negative Noise			10				If the Raw Count is below BaseLine and the Difference Count is more than this
				Threshold								threshold, the BaseLine will not update (not used by this project).
				
				Low BaseLine Reset 		50				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 
														will reset to new Raw Count (not used by this project).

				Sensors Autoreset		Disabled		When the parameter is set to disabled, the baseline is updated only when raw count 
														& baseline difference is below the noise threshold parameter (not used by this project).
														
				Freq Num				3				This parameter allows each sensor to be scanned 3 times to reduce Electromagnetic 
														interference. But this results in more time for each sensor scan. (not used by this
														project)

				Spread Spectrum			Disable			Also used to reduce electromagnetic interference. Changes clock value randomly for
														sensor scans. Enable if Freq Num is set to 1. (not used by this project)

				RawData Median Filter	Disable			Used to remove short noise spikes. Gives the median value for the last 3 samples 
														generated for the sensor (not used by this project).

				RawData IIR Filter		Disable			Filters noise in the raw count of each sensor (not used by this project).

				RawData IIR Filter 		2				This parameter gives the coefficient of the IIR Filter, if enabled. (not used by this 
				Coeff									project).

				Clock					IMO/8			Normally, this parameter is left at default IMO setting. Setting a larger divider
														of IMO increases the effective resistance of sensor, compensating for the high capacitance.

	-------------------------------------------------------------------------------------------------------------------
	
	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=0x4A

				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. I2C Lines
       	 Pin	    Select	            Drive
    	 ----------------------------------------------
    	 P1[0]	   I2C SDA	    	Open Drain Low
		 P1[1]	   I2C SCL			Open Drain Low
		 ----------------------------------------------
	 2. 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
