Professional Documents
Culture Documents
Author Message
I have written a test program on INT0 but I am not able to test it out on the hardware yet due
to unavalibility. Can someone be kind enough to tell me whether the code will works.
A push button is connected to Pin B0 which when pushed will caused the chip to go into SLEEP
mode. A second push on the pushbutton will bring the chip active and reset via reset_cpu().
Code:
#include <18F458.h>
#fuses HS,NOWDT,NOPROTECT,NOLVP
#use delay(clock=20000000)
void main()
{
1 от 2 27.2.2007 г. 09:48
CCS :: View topic - Using Hardware Interrupt (INT0) http://ccsinfo.com/forum/viewtopic.php?t=18610&highlight=int0...
Thanks
Code:
#INT_EXT
void ext_isr()
{
if(button_pressed_once) // if button action and was not
// pressed
{
button_pressed_once=FALSE; //to activate the next button pressed
// which is to reset the thing
sleep();
}
else
{
button_pressed_once=TRUE; // the button is now up
reset_cpu();
}
}
void main()
{
it may just be me but i don't like the idea of going to sleep inside an interrupt handler function. i
believe that this is asking for debugging troubles and it's just not good programming practice.
why not just set a flag in #int_ext and test it in main()? keep your inerrupt handlers simple.
jds-pic
Page 1 of 1
2 от 2 27.2.2007 г. 09:48