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
Posted: Sat Aug 21, 2010 10:26 pm
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:
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.
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