|
|
View previous topic :: View next topic |
Author |
Message |
longos
Joined: 27 Mar 2012 Posts: 4
|
12F1840 & Touchpad Library |
Posted: Tue Mar 27, 2012 4:47 am |
|
|
I try to use TOUCHPAD library with 12F1840. When I use only PIN_A2 all is OK, but when I declare
#USE TOUCHPAD(RANGE=H, THRESHOLD=6, SCANTIME=32, PIN_A2='A', PIN_A4='B')
Touch buttons doesn't works. Compiler 4.130. Source code:
Code: |
#include <12LF1840.h>
#include <regPIC12LF1840.h>
#FUSES NOWDT //No Watch Dog Timer
#FUSES INTRC_IO //Internal RC Osc, no CLKOUT
#FUSES WDT_SW //No Watch Dog Timer, enabled in Software
#FUSES NOBROWNOUT //No brownout reset
#FUSES NOLVP //No low voltage prgming, B3(PIC16) or B5(PIC18) used for I/O
#use delay(clock=16000000)
#use FIXED_IO( A_outputs=PIN_A0)
#define LED PIN_A0
#USE TOUCHPAD(RANGE=H, THRESHOLD=15, SCANTIME=32, PIN_A2='B')
//#USE TOUCHPAD(RANGE=H, THRESHOLD=6, SCANTIME=32, PIN_A2='B', PIN_A4='A')
char c;
void main(void){
setup_oscillator(OSC_16MHZ|OSC_NORMAL|OSC_PLL_OFF,0);
enable_interrupts(GLOBAL);
touchpad_state(1);
while(1){
c = TOUCHPAD_GETC();
if(c == 'B' || c=='A'){
c=0;
output_toggle(LED);
output_toggle(PIN_A4);
delay_ms(100);
}
}
}
|
I think there's some bug in CCS library. Some ideas ? |
|
|
PCM programmer
Joined: 06 Sep 2003 Posts: 21708
|
|
Posted: Tue Mar 27, 2012 1:22 pm |
|
|
Quote: |
//#USE TOUCHPAD(RANGE=H, THRESHOLD=6, SCANTIME=32, PIN_A2='B', PIN_A4='A')
void main(void){
if(c == 'B' || c=='A'){
c=0;
output_toggle(LED);
output_toggle(PIN_A4);
delay_ms(100);
}
}
}
|
You are toggling Pin A4. That's the same pin that you assigned as
a Touchpad input. Don't toggle a pin that is used for the touchpad.
Don't do anything to it. It's controlled by the Touchpad library code. |
|
|
longos
Joined: 27 Mar 2012 Posts: 4
|
|
Posted: Wed Mar 28, 2012 3:55 am |
|
|
PCM programmer wrote: | Quote: |
//#USE TOUCHPAD(RANGE=H, THRESHOLD=6, SCANTIME=32, PIN_A2='B', PIN_A4='A')
|
You are toggling Pin A4. | This line is in comment. I use only PIN_A2. |
|
|
|
|
You cannot post new topics in this forum You cannot reply to topics in this forum You cannot edit your posts in this forum You cannot delete your posts in this forum You cannot vote in polls in this forum
|
Powered by phpBB © 2001, 2005 phpBB Group
|