CCS C Software and Maintenance Offers
FAQFAQ   FAQForum Help   FAQOfficial CCS Support   SearchSearch  RegisterRegister 

ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 

CCS does not monitor this forum on a regular basis.

Please do not post bug reports on this forum. Send them to CCS Technical Support

Help with command input(PIN_B3)

 
Post new topic   Reply to topic    CCS Forum Index -> General CCS C Discussion
View previous topic :: View next topic  
Author Message
jpapu



Joined: 21 Aug 2010
Posts: 3

View user's profile Send private message

Help with command input(PIN_B3)
PostPosted: Sat Aug 21, 2010 10:27 am     Reply with quote

After I perform a task I end up at line 3 where I sit and wait for the operator to press an OFF button. When the OFF button is pressed a ground will be applied to my PIC16F727 PortB pin RB3. Here is the problem I am experiencing. I am using the CCS ICD-U64 with a break point set at line 10. When I press the off button I do not exit the loop and hit the break point set at line 10. I can see the status in the lower right hand corner indicating that the software is running. If I select the HALT PROGRAM icon on the debugger I can see the program pointer pointing to line 3. If I follow by selecting the GO ICON the program then falls through and hits the breakpoint I have set. What am I doing wrong.


LINE #
1 //---WAIT FOR OPERATOR TO PRESS OFF
2 //
3 while(input(PIN_B3))
4 {
5 loop_select++;
6 }
7
8 //---OPERATOR HAS PRESSED OFF
9 //
10 EXIT_LOOP = 1;
11 loop_select = 1;
12 goto RESET_START_POINT;
PCM programmer



Joined: 06 Sep 2003
Posts: 21708

View user's profile Send private message

PostPosted: Sat Aug 21, 2010 10:26 pm     Reply with quote

Here is sample program that shows how to debounce a pushbutton
switch. It also waits for the user to press the button:
http://www.ccsinfo.com/forum/viewtopic.php?t=19874&start=1
This code expects the following circuit to be connected to your PIC pin
(in your case, Pin B3). The circuit consists of a pull-up resistor and
a switch. Normally the pin is held at a logic "1" by the pull-up. When
you push the button it will go to a logic "0", until you release it:
Code:

           +5v
            |
            <
            > 4.7K       
            <         ___ Push button switch 
To          |        _|_|_
PIC -----------------o   o------
pin                            |             
                              --- GND
                               -   
 
jpapu



Joined: 21 Aug 2010
Posts: 3

View user's profile Send private message

Thank you PCM Programmer
PostPosted: Sun Aug 22, 2010 4:50 am     Reply with quote

Thanks for your suggestion PCM Programmer. I noticed in your sample code that you used the input( ) in an if statement so I tried moving it into an if but still had the same problem. I started thinking about my problem and my original code which seemed to be related to speed (when running the program does not work, when stepping through the program it works) so I figured I would decrease the length of the cable that ran from the ICD-U64 to the target by 12 inches, now my original code works.

CONCLUSION
When you purchase the ICD-U64 and you make your own cable that will run from the ICD-U64 to the target keep it under 12 inches.
Display posts from previous:   
Post new topic   Reply to topic    CCS Forum Index -> General CCS C Discussion All times are GMT - 6 Hours
Page 1 of 1

 
Jump to:  
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