Electronic Components Datasheet Search
  New Zealand  ▼
ALLDATASHEET.CO.NZ

X  

AN1250 Datasheet(PDF) 8 Page - Microchip Technology

Part # AN1250
Description  Microchip CTMU for Capacitive Touch Applications
PDF  22 Pages
Scroll/Zoom Zoom In 100%  Zoom Out
Manufacturer  MICROCHIP [Microchip Technology]
Direct Link  http://www.microchip.com
Logo MICROCHIP - Microchip Technology

AN1250 Datasheet(HTML) 8 Page - Microchip Technology

Back Button AN1250 Datasheet HTML 4Page - Microchip Technology AN1250 Datasheet HTML 5Page - Microchip Technology AN1250 Datasheet HTML 6Page - Microchip Technology AN1250 Datasheet HTML 7Page - Microchip Technology AN1250 Datasheet HTML 8Page - Microchip Technology AN1250 Datasheet HTML 9Page - Microchip Technology AN1250 Datasheet HTML 10Page - Microchip Technology AN1250 Datasheet HTML 11Page - Microchip Technology AN1250 Datasheet HTML 12Page - Microchip Technology Next Button
Zoom Inzoom in Zoom Outzoom out
 8 / 22 page
background image
AN1250
DS01250A-page 8
© 2009 Microchip Technology Inc.
EXAMPLE 4:
READING THE CAPACITIVE TOUCH SENSOR CIRCUIT SOFTWARE ALGORITHM
(PIC18F)
The main() function contains a while(1) loop
(endless) that checks for the dataReadyCTMU flag (set
by the Timer1 interrupt handler). If the dataReadyCTMU
flag is not set, other tasks are performed while it waits. In
the case of the PICDEM Touch Sense 2 Demo Board,
communication of data over the USB is serviced. If the
dataReadyCTMU
flag is set, the main() function clears
the flag and calls the routines necessary to process the
newly acquired data. The main() function temporarily
disables Timer1 to insure that no new data is introduced
in the middle of the routines that are handling data
processing. After all processing of the capacitive touch
sensor data is complete, and the LED display informa-
tion is also updated, Timer1 is re-enabled, and the whole
process begins again.
The structuring of the code in this manner is done to
make the system deterministic. Using a fixed timer to
read each capacitive touch sensor channel at a 1 ms
rate fixes the update rate to approximately 16 ms (1 ms
times 16 channels). The actual update rate is slightly
slower, since Timer1 is disabled while the new data is
processed.
//Read CTMU (Get the raw sensor reading)
ANCON0bits.PCFG= 0xFF;
//set all A/D channels to digital I/O pins
ANCON1bits.PCFG= 0x1F;
//set all A/D channels to digital I/O pins
TRISA = 0x00;
TRISB = 0x00;
TRISC = 0x00;
TRISE = 0x00;
LATA = 0x00;
LATB = 0x00;
LATC = 0x00;
LATE = 0x00;
PORTB = 0x00;
//set all channels to logical 0 outputs
Nop(); Nop(); Nop(); Nop();
Nop(); Nop(); Nop(); Nop();
//Wait for charge to drain
TRISA = ADPASELECT[Index];
TRISB = ADPBSELECT[Index];
TRISC = ADPCSELECT[Index];
TRISE = ADPESELECT[Index];
//set selected channel to input
ANCON0bits.PCFG = ~AD0SELECT[Index];
ANCON1bits.PCFG = ~AD1SELECT[Index];
//set selected channel to analog A/D input
Nop(); Nop(); Nop(); Nop();
Nop(); Nop(); Nop(); Nop();
//wait for A/D to connect to channel
ADCON0bits.CHS = Index;
//select A/D channel
CTMUCONHbits.IDISSEN =
1;
//Drain any charge on the A/D circuit
Nop(); Nop(); Nop(); Nop(); Nop();
//Wait for charge to drain
CTMUCONHbits.IDISSEN =
0;
//Stop discharge of A/D circuit
Nop(); Nop();
CTMUCONLbits.EDG2STAT = 0;
// Make sure edge2 is 0
CTMUCONLbits.EDG1STAT = 1;
// Set edge1 - Start Charge
for (count = 0; count < loopCount; count++);
// Delay for CTMU charge time
CTMUCONLbits.EDG1STAT = 0;
//Clear edge1 - Stop Charge
AD1CON0bits.GODONE =
1;
//Set Go bit to begin A/D conversion
while(ANCON0bits.GODONE);
//Wait for the A/D conversion to finish
immediateValue = ADRESH;
immediateValue = immediateValue << 8;
immediateValue = immediateValue + ADRESL;
//Read the value from the A/D conversion
//End of CTMU read



Html Pages

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22


Datasheet Download

Go To PDF Page


Link URL



Does ALLDATASHEET help your business so far?  [ DONATE ] 

About Alldatasheet   |   Advertisement   |   Contact us   |   Privacy Policy   |   Link to Datasheet    |   Link Exchange   |   Manufacturer List
All Rights Reserved©Alldatasheet.com


Mirror Sites
English : Alldatasheet.com  |   English : Alldatasheet.net  |   Chinese : Alldatasheetcn.com  |   German : Alldatasheetde.com  |   Japanese : Alldatasheet.jp
Russian : Alldatasheetru.com  |   Korean : Alldatasheet.co.kr  |   Spanish : Alldatasheet.es  |   French : Alldatasheet.fr  |   Italian : Alldatasheetit.com
Portuguese : Alldatasheetpt.com  |   Polish : Alldatasheet.pl  |   Vietnamese : Alldatasheet.vn
Indian : Alldatasheet.in  |   Mexican : Alldatasheet.com.mx  |   British : Alldatasheet.co.uk  |   New Zealand : Alldatasheet.co.nz
Family Site : ic2ic.com  |   icmetro.com