
Overview
========

 In this code example, the CSD UM scans all the buttons and slider segments 
 on the SLM continuously and an EzI2Cs buffer is updated with the various 
 CapSense parameters continuously so that the I2CUSB bridge/MiniProg3 can be used to read 
 the capsense parameters and display the same on PC using bridge control panel. 
 The code example also turns ON/OFF the LEDs present on the SLM  to indicate the button 
 status and slider position.

Operation
=========

 Upon program execution all hardware settings from the device configuration are
 loaded into the device and main.c is executed. CSD, EzI2Cs UMs are 
 initialized. All sensors are scanned continuously & the RawCounts, difference counts
 and the baseline data is updated in the EzI2Cs buffer. When any button is 
 touched by the user, its corresponding LED is  turned ON. and it is turned OFF 
 when the button is released. When Slider is touched, One LED is turned on 
 depending on the finger position on slider.
	
Pin Assignment
==============

	P0[3] - Cmod		(Connect Capacitor, 10nF between Pin P0[3] & Gnd)
	P3[1] - Rb			(Connect Resistor, 2.2KOhm between P3[1] & P0[3])
	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[4] - SLD0		(Slider Segment 0)
	P0[6] - SLD1		(Slider Segment 1)
	P0[4] - SLD2		(Slider Segment 2)
	P0[2] - SLD3		(Slider Segment 3)
	P2[6] - SLD4		(Slider Segment 4)
	P2[4] - SLD5		(Slider Segment 5)
	P2[2] - SLD6		(Slider Segment 6)
	P2[0] - SLD7		(Slider Segment 7)
	P3[2] - SLD8		(Slider Segment 8)
	P3[0] - SLD9		(Slider Segment 9)
	P2[5] - LED0		(Active Low)
	P2[7] - LED1		(Active Low)
	P0[1] - LED2		(Active Low)
	P0[5] - LED3		(Active Low)
	P1[2] - LED4		(Active Low)
	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 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".
  2. Configure the global resources & user modules settings as given below.
  3. Assign pins for sensor buttons & slider from CapSense wizard
  4. Assign pins for LED in Pinout section
 
 A. Global Resources
     IMO Setting  = 24MHz     ;System clock is set to 24MHz
  	 CPU_Clock    = SysClk/1  ;CPU clock set to 24 MHz
	 [leave all other parameters with default values]

 B. User Module parameter Settings
-------------------------------------------------------------------------------------------------------------------------------------
 	UserModule	Parameter 				Value 			Comments   
-------------------------------------------------------------------------------------------------------------------------------------
	CSD			Finger Threshold		74				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			40				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			79				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			15				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			40				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 		10				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			Normal				This parameter sets the sensor scanning speed.

				
				Resolution			13				This parameter determines the scanning resolution in bits.

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

				Prescaler Period		3				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		04				This parameter decides the address that is assigned to the slave.If we set Address_Type 
													to 'Dynamic', this can be changed using APIs during the Run. Value assigned can be any vaue
													from 0 to 127 (decimal)
														
				ROM Registers		Disable			If we set this to Enable, we can use RAM area as one slave and ROM area as one slave with 
													the addresses differing by only MSB of 7-bit address.
													
													MSB = 1 ---> ROM Regsters addressed.
													MSB = 0 ---> RAM area addressed.
													
				HW Addr Rec			Disabled		This parameter enables/disables the hardware I2C slave address recognition feature. It
													affects ROM/RAM usage and EzI2Cs ISR execution time.
														
				I2C Pin				P1[0]-P1[1]		This tells which pins are going to be used as SDA and SCL lines of I2C.
				
				I2C Clock			400k Standard	It decides the maximum clock speed that the slave can operate at.
	-------------------------------------------------------------------------------------------------------------------------------------------- 
 C. Pin Drive modes
   	 1. EzI2Cs pins
       	 Pin	    Select	            Drive
    	 ----------------------------------------------
    	 P1[0]	   	EzI2CsSDA    		Open Drain Low, Initial Value=1	
		 P1[1]		EzI2CsSCL			Open Drain Low, Initial Value=1	
		 ----------------------------------------------
	 2. Sensor & LED
     	 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
		 P1[4]		SLD0	HIGH Z Analog
		 P0[6]		SLD1	HIGH Z Analog
		 P0[4]		SLD2	HIGH Z Analog
		 P0[2]		SLD3	HIGH Z Analog
		 P2[6]		SLD4	HIGH Z Analog
		 P2[4]		SLD5	HIGH Z Analog
		 P2[2]		SLD6	HIGH Z Analog
		 P2[0]		SLD7	HIGH Z Analog
		 P3[2]		SLD8	HIGH Z Analog
		 P3[0]		SLD9	HIGH Z Analog
		 P0[3]	   	Cmod	HIGH Z Analog
		 P2[5]		LED0	STRONG, Initial Value=1
		 P2[7]		LED1	STRONG, Initial Value=1
		 P0[1]		LED2	STRONG, Initial Value=1
		 P0[5]		LED3	STRONG, Initial Value=1
		 P1[2]		LED4	STRONG, Initial Value=1
		