EDF - OnePIC MCU
v1.1.0
|
00001 /****************************************************************************** 00002 00003 PIC232 MTOUCH CVD Eval Board configuration file (Header File) 00004 00005 Description: 00006 This file defines variables of interest to the way the touch sense 00007 keys operate. 00008 00009 ******************************************************************************/ 00010 00011 /***************************************************************************** 00012 00013 * FileName: mTouchConfig.h 00014 * Dependencies: None. 00015 * Processor: PIC32MX795F512H 00016 * Compiler: C32 00017 * Company: Microchip Technology, Inc. 00018 00019 Software License Agreement: 00020 00021 The software supplied herewith by Microchip Technology Incorporated 00022 (the “Company”) for its PIC® Microcontroller is intended and 00023 supplied to you, the Company’s customer, for use solely and 00024 exclusively on Microchip PIC Microcontroller products. The 00025 software is owned by the Company and/or its supplier, and is 00026 protected under applicable copyright laws. All rights are reserved. 00027 Any use in violation of the foregoing restrictions may subject the 00028 user to criminal sanctions under applicable laws, as well as to 00029 civil liability for the breach of the terms and conditions of this 00030 license. 00031 00032 THIS SOFTWARE IS PROVIDED IN AN “AS IS” CONDITION. NO WARRANTIES, 00033 WHETHER EXPRESS, IMPLIED OR STATUTORY, INCLUDING, BUT NOT LIMITED 00034 TO, IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A 00035 PARTICULAR PURPOSE APPLY TO THIS SOFTWARE. THE COMPANY SHALL NOT, 00036 IN ANY CIRCUMSTANCES, BE LIABLE FOR SPECIAL, INCIDENTAL OR 00037 CONSEQUENTIAL DAMAGES, FOR ANY REASON WHATSOEVER. 00038 00039 Change History: 00040 Author Date Comments 00041 ------------------------------------------------------------------------------- 00042 BDB 26-Jun-2008 Initial release 00043 SB 22-Oct-2008 00044 NMS/NK 10-Feb-2009 Folder/Files restructuring 00045 MC 22-Ian-2009 Porting for PIC32MX795F512 00046 MWM 28 Mar 2011 Moved key performance #define's up to this file 00047 ******************************************************************************/ 00048 #ifndef __MTOUCH_CONFIG_H 00049 #define __MTOUCH_CONFIG_H 00050 00051 /* ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ */ 00052 /* ~~~~~~~~~~~~~~~~~~~~~ Includes ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ */ 00053 /* ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ */ 00054 #include "Compiler.h" 00055 #include "GenericTypeDefs.h" 00056 #include "bsp.h" 00057 //#include "HardwareProfile.h" 00058 00059 /* ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ */ 00060 /* ~~~~~~~~~~~~~~~~~~~~~ Demo Chosen ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ */ 00061 /* ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ */ 00062 #define USE_DIRECT_KEYS 00063 00064 /* ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ */ 00065 /* ~~~~~~~~~~~~~~~~~~~~~ Timer Call Back ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ */ 00066 /* ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ */ 00067 //#define TIMERCALLBACKFUNC TimerCallbackFunc1 // single or differential 00068 //#define TIMERCALLBACKFUNC TimerCallbackFunc2 // single or differential 00069 #define TIMERCALLBACKFUNC TimerCallbackFunc3 // differential only 00070 //#define TIMERCALLBACKFUNC TimerCallbackFunc4 // Using CTMU 00071 00072 /* ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ */ 00073 /* ~~~~~~~~~~~~~~~~~~~~~ Constants / Macros ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ */ 00074 /* ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ */ 00075 #define REF_CHANNEL 10 // Use AN10/RB10 as reference channel 00076 00077 #define TICKLE_LED1 //for diagnostic signal on LED 1 00078 #undef TICKLE_LED1 //for diagnostic signal on LED 1 00079 00080 /* Debug count for key press */ 00081 #define DEBOUNCECOUNT 3 // Defines How Many consecutive reads for 00082 00083 #define TIMER4_PERIOD 600 // Timer4 clock ticks between button scans 00084 00085 #define NUM_HF_READS 6 // number of reads in CVD Channels 00086 // that are averaged to produce "current" value 00087 00088 #define ALPHA_INVERSE 32 // Weight in updating average based on current value 00089 #define LOG2_ALPHA_INVERSE 5 // Equivalent bit shift to averaging weight 00090 00091 #define KEYTRIPDIV 40 00092 #define HYSTERESIS_VALUE 50 00093 00094 #define DEFAULT_TRIP_VALUE 100 // Default trip value for all channels, in adjusted ADC counts 00095 // Only used to initialize array tripValue[ ] 00096 /* 00097 "Average" data is calculated using the algorithm 00098 00099 Average[new] = (1 - alpha)*Average[old] + alpha*CurFiltdData[new] 00100 00101 implemented in C code such as 00102 00103 averageData[iChannel] = averageData[iChannel] 00104 - (averageData[iChannel]>>Log2AlphaInverse) 00105 + (CurFiltdData[iChannel]>>Log2AlphaInverse); 00106 00107 The "current" raw data value is based on ADC measurements taken in 00108 the Timer 4 ISR call back function, "TimerCallbackFuncN" (N=1,2,3,4), found in 00109 TimerCallbackFuncN.c (N=1,2,3,4), with additional filtering and averaging done by 00110 "mTouchCapPhy_UpdateData" in mTouchCapPhy.c . 00111 00112 Trip value and hysteris value are defined by 00113 tripValue[iChannel] = averageData[iChannel] / KEYTRIPDIV; 00114 hystValue[iChannel] = tripValue[iChannel] / HYSTERESIS_VALUE; 00115 00116 A button is "pressed" if 00117 CurFiltdData[iChannel] < averageData[iChannel] - tripValue[iChannel] 00118 00119 A button is "released" if 00120 CurFiltdData[iChannel] > averageData[iChannel] - tripValue[iChannel] + hystValue[iChannel] 00121 */ 00122 00123 /* Allow Enough Time to initialize all channels in mTouchCapPhy_StablizeChannelData */ 00124 // Startup Count: Just loop through meassurements and update averages using slow averaging 00125 #define STABILIZE_STARTUP_COUNT (4*ALPHA_INVERSE) 00126 00127 00128 /* 00129 Charge/discharge cycles for Rev 1 and Rev 2 00130 00131 Multiple cycles needed because ADC's sample and hold (SAH) 00132 capacitor is much smaller than typical button capacitor. 00133 00134 */ 00135 // Also used for Rev 3, Vpositive 00136 #define CHARGE_DISCHARGE_CYCLE_1 00137 #define CHARGE_DISCHARGE_CYCLE_2 00138 #define CHARGE_DISCHARGE_CYCLE_3 00139 #define CHARGE_DISCHARGE_CYCLE_4 00140 00141 //Button charge cycles for Rev 3, Vnegative 00142 #define BUTTON_CHARGE_CYCLE_1 00143 #define BUTTON_CHARGE_CYCLE_2 00144 #define BUTTON_CHARGE_CYCLE_3 00145 //#define BUTTON_CHARGE_CYCLE_4 00146 00147 //Button discharge cycles for Rev 3, Vnegative 00148 #define BUTTON_DISCHARGE_CYCLE_1 00149 #define BUTTON_DISCHARGE_CYCLE_2 00150 #define BUTTON_DISCHARGE_CYCLE_3 00151 #define BUTTON_DISCHARGE_CYCLE_4 00152 00153 00154 // CTMU charge timing for Rev 4 00155 #if defined( PIC24HJ128_CAP_TOUCH_EVAL_BOARD ) 00156 00157 00158 #elif defined( DSPIC33FJ128_CAP_TOUCH_EVAL_BOARD ) 00159 00160 00161 #elif defined( PIC32MC764F128_EXPLORER_16_BOARD ) | \ 00162 defined( PIC32MX795_CAP_TOUCH_EVAL_BOARD ) 00163 #define ChargeDelay() asm("NOP");asm("NOP");asm("NOP");asm("NOP") // 50 ns 00164 00165 // Eleven ChargeDelay's brings unasserted button voltage to half scale 00166 #define CTMU_CHARGE_DELAYS ChargeDelay(); ChargeDelay(); \ 00167 ChargeDelay(); ChargeDelay(); \ 00168 ChargeDelay(); ChargeDelay(); \ 00169 ChargeDelay(); ChargeDelay(); \ 00170 ChargeDelay(); ChargeDelay(); \ 00171 ChargeDelay(); 00172 00173 #elif defined( PIC32MX220_CAP_TOUCH_EVAL_BOARD ) | \ 00174 defined( PIC32MX220_STARTER_KIT_BOARD ) 00175 #define ChargeDelay() asm("NOP");asm("NOP") // 50 ns 00176 00177 // Eleven ChargeDelay's brings unasserted button voltage to half scale 00178 #define CTMU_CHARGE_DELAYS ChargeDelay(); ChargeDelay(); \ 00179 ChargeDelay(); ChargeDelay(); \ 00180 ChargeDelay(); ChargeDelay(); \ 00181 ChargeDelay(); ChargeDelay(); \ 00182 ChargeDelay(); ChargeDelay(); \ 00183 ChargeDelay(); 00184 00185 #endif 00186 00187 00188 //Button assert decode methods: 00189 // { DECODE_METHOD_MOST_PRESSED | DECODE_METHOD_PRESS_ASSERT } 00190 #define DEFAULT_DECODE_METHOD DECODE_METHOD_MOST_PRESSED 00191 00192 //Average button voltage filtering methods: 00193 // { FILTER_METHOD_SLOWAVERAGE | FILTER_METHOD_GATEDAVERAGE | FILTER_METHOD_FASTAVERAGE } 00194 //#define DEFAULT_FILTER_METHOD FILTER_METHOD_SLOWAVERAGE 00195 #define DEFAULT_FILTER_METHOD FILTER_METHOD_GATEDAVERAGE 00196 00197 // Limit change between consecutive voltage measurements to +/- 1 ADC LSB ? 00198 #define LIMIT_SLEW_RATE 00199 //#undef LIMIT_SLEW_RATE 00200 00201 // Use differential instead of single-ended measurements ? 00202 #define USE_DIFFERENTIAL_MEASUREMENTS 00203 //#undef USE_DIFFERENTIAL_MEASUREMENTS 00204 00205 // Dump mTouch diagnostics out UART? 00206 #define DUMP_DIAGNOSTICS_VIA_UART 00207 //#undef DUMP_DIAGNOSTICS_VIA_UART 00208 00209 #if defined( DUMP_DIAGNOSTICS_VIA_UART ) 00210 // Dump raw ADC counts out UART? 00211 #define UART_DUMP_RAW_COUNTS 00212 #undef UART_DUMP_RAW_COUNTS 00213 00214 #ifndef UART_DUMP_RAW_COUNTS 00215 # define UART_DUMP_ALL_COUNTS // Dump Vpos, Vneg, Vmeas 00216 # undef UART_DUMP_ALL_COUNTS 00217 #endif 00218 00219 #endif//defined( DUMP_DIAGNOSTICS_VIA_UART ) 00220 00221 #endif // _CONFIG_H