|
|
View previous topic :: View next topic |
Author |
Message |
konig
Joined: 31 May 2012 Posts: 1 Location: south
|
mtouch problem... |
Posted: Thu May 31, 2012 4:46 pm |
|
|
hi,
I'm testing with the pic16F1827 mTouch, according to the manual touchpad_hit () returns true if a sensor is pressed and false if not pressed.
In the code by pressing the sensor output LED never force (implements one else at the end). If you do not get the "else" output LED is permanently on
What is the problem
Greetings.
Code: |
#include <16F1827.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 PUT //Power Up Timer
#FUSES NOMCLR //Master Clear pin used for I/O
#FUSES NOBROWNOUT //No brownout reset
#FUSES NOSTVREN //Stack full/underflow will not cause reset
//#FUSES BORV27 //Brownout reset at 2.7V
#FUSES NOLVP //No low voltage prgming, B3(PIC16) or B5(PIC18) used for I/O
#use delay(int=4000000)
#USE TOUCHPAD(THRESHOLD=6, SCANTIME=32, PIN_B5='A', PIN_B6='B', PIN_B7='C')
#define L1 PIN_A2
#define L2 PIN_A1
#define L3 PIN_A0
void off (void);
char c;
void main()
{
enable_interrupts(GLOBAL);
setup_timer_4(T4_DISABLED,0,1);
setup_timer_6(T6_DISABLED,0,1);
setup_comparator(NC_NC_NC_NC);
output_low(L1);
output_low(L2);
output_low(L3);
while(TRUE)
{
if(touchpad_hit())
{
c=touchpad_getc();
switch(c){
/*1*/ case 'A':
output_high(L1);
break;
/*2*/ case 'B':
output_high(L2);
break;
/*3*/ case 'C':
output_high(L3);
break;
} //end switch
} //end touchpad_hit
else off(); // this else is a problem?
} //end while
} //end main
////////////////////////////////FUNCTION/////////////////////////////////////////
void off (){
output_low(L1);
output_low(L2);
output_low(L3);
}
////////////////////////////////////////////////////////////////////////////////
|
|
|
|
temtronic
Joined: 01 Jul 2010 Posts: 9221 Location: Greensville,Ontario
|
|
Posted: Fri Jun 01, 2012 12:26 pm |
|
|
hint #1. you've enabled ALL the interrupts but have NO ISRs that I can see. BIG,big trouble.... |
|
|
PCM programmer
Joined: 06 Sep 2003 Posts: 21708
|
|
Posted: Fri Jun 01, 2012 12:54 pm |
|
|
The CCS touchpad() library has an internal timer interrupt routine in it.
They want you to enable global interrupts, but the library code handles
the rest of it. |
|
|
temtronic
Joined: 01 Jul 2010 Posts: 9221 Location: Greensville,Ontario
|
|
Posted: Fri Jun 01, 2012 1:10 pm |
|
|
hmm...ok...I've learned something.....
The way I read the logic flow...
Unless the touchpad is pressed the program loops forever(while(true)), turning OFF all the LEDS.
Only when a key is pressed will that LED turn on, but only for a few microseconds, since it goes back to the 'forever while' part of 'main', which then turns off the LEDS.
If you add a delay_ms(500); at the end of the switch code or just before the 'else off() code.... that should prove how the program is running..... |
|
|
PCM programmer
Joined: 06 Sep 2003 Posts: 21708
|
|
Posted: Fri Jun 01, 2012 1:39 pm |
|
|
Quote: | I'm testing with the pic16F1827 mTouch
|
1. Post a description of your hardware. If you bought an mTouch board,
then post the manufacturer, part number, and a link to the website for
the board. If you made the board yourself, then post a link to the
schematic. Also post a link to the website for the Touch panel, if it's
separate from the board.
2. Post your CCS compiler version. It's given at the top of the .LST file,
which will be in your project directory after a successful compile.
Example of CCS version numbers:
http://www.ccsinfo.com/devices.php?page=versioninfo
3. Also, you should call touchpad_state(1) near the start of main().
4. Tell us if this is a Proteus or other simulator project. Or is it real
hardware ? |
|
|
|
|
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
|