View previous topic :: View next topic |
Author |
Message |
Zachr
Joined: 12 Mar 2010 Posts: 10
|
Cap touch on 12f1822 |
Posted: Fri Jan 06, 2012 11:05 am |
|
|
Hi All,
I've been trying to get the cap touch module up and running with 4.121 and having very little success.
The first thing I tried was some slightly modified help file code: Code: |
#include <12F1822.h>
#FUSES NOWDT, INTRC_IO, NOMCLR, NOBROWNOUT, NOLVP
#use delay(int=8000000)
#USE TOUCHPAD (THRESHOLD=5, PIN_A0='5')
void main(void){
char c;
setup_oscillator(OSC_8MHZ|OSC_INTRC|OSC_PLL_OFF,0);
enable_interrupts(GLOBAL);
while(1){
c = TOUCHPAD_GETC(); //will wait until a pin is detected
output_high(pin_a5); //flashes an LED
delay_ms(10);
output_low(pin_a5);
delay_ms(10);
}
}
|
No luck. I tried adjusting thresholds, adding calibration, still nothing.
Then I tried setting up the CPM manually and just tried to see if I could get the CPSOUT bit to toggle.
Code: |
#include <12F1822.h>
#FUSES NOWDT, INTRC_IO, NOMCLR, NOBROWNOUT, NOLVP
#use delay(int=8000000)
#byte CPSCON1=0x1f
#byte CPSCON0=0x1e
void main()
{
int1 c;
setup_oscillator(OSC_8MHZ|OSC_INTRC|OSC_PLL_OFF,0);
enable_interrupts(GLOBAL);
#asm movlb 00 #endasm //just to be sure we are using the right bank
CPSCON0=0x8c;
CPSCON1=0;
while(1)
{
#asm movlb 00 #endasm
c=bit_test(CPSCON0,1);
output_bit(pin_a5,c); //look at pin on o-scope
}
}
|
Looking at pin_a5 with an oscilloscope, I just see a high signal. Any ideas on what I am missing?
Thanks,
Zach |
|
|
PCM programmer
Joined: 06 Sep 2003 Posts: 21708
|
|
Posted: Fri Jan 06, 2012 1:32 pm |
|
|
You are testing the CPSOUT bit. What do you expect that bit to do,
and why ? What is your hardware test circuit ? What stimulus are
you doing to cause the CPSOUT bit to change ? |
|
|
Zachr
Joined: 12 Mar 2010 Posts: 10
|
|
Posted: Fri Jan 06, 2012 2:56 pm |
|
|
Based on FIGURE 26-1 of the data sheet, it looks like CPSOUT should toggle at a rate proportional to the cap sense oscillator if the module is active. Any sensed capacitance should change the speed of this oscillator. Typically CPSOUT increments either timer0 or timer1 then you use some fixed time reference to sample that timer to detect the delta. Just checking CPSOUT seemed like a good first step...
As for hardware, I just have four pads connected to a0-a3 surrounded by a gnd trace. I've used the cap sense on other PICs with a similar pad layout. Plus an LED on a5. Running at 3.3v. |
|
|
PCM programmer
Joined: 06 Sep 2003 Posts: 21708
|
|
Posted: Fri Jan 06, 2012 4:28 pm |
|
|
Quote: | I've used the cap sense on other PICs with a similar pad layout. |
If you have your existing touchpad working with a different PIC (other
than the 12F1822), and with the same CCS compiler version, then the
.LST files could be compared to look for differences. To see the CCS
touchpad library code, you have to comment out the #nolist statement
in the 12F1822.h file, and re-compile.
Post a list of all the "cap sense" PICs that you have tested with your
touchpad, and you know they work. |
|
|
Zachr
Joined: 12 Mar 2010 Posts: 10
|
|
Posted: Fri Jan 06, 2012 4:48 pm |
|
|
Just figured it out... My ICD was connected to the circuit when I was testing it. PGD sits on pin a0 and was killing the oscillator. I usually try to avoid sharing pins with the programming lines, but with only 6 i/o it's almost unavoidable.
Thanks for you help,
Zach |
|
|
|