I i2c2k New Member Jun 3, 2004 #1 Hi! I tried to write interrupts but the code doesn't work on my PIC16F876A: CCS C-Compiler Code: Code: #include <16f876A.h> #fuses HS,NOWDT,NOPROTECT,NOLVP #use delay(clock=4000000) inthdl_ext(); void main() { SET_TRIS_A ( 0b11111010 ); SET_TRIS_B ( 0b00000001 ); SET_TRIS_C ( 0b00000000 ); enable_interrupts(INT_EXT); ext_int_edge(H_TO_L); } #INT_EXT inthdl_ext() { output_bit(PIN_A2, 1); delay_ms(2000); output_bit(PIN_A2, 0); } The LED on Ra2 should be on for 2 seconds, but it doesn't unfortunately. By the way putting "void" before "inthdl_ext()" does not affect the result. cya i2c2k[/code]
Hi! I tried to write interrupts but the code doesn't work on my PIC16F876A: CCS C-Compiler Code: Code: #include <16f876A.h> #fuses HS,NOWDT,NOPROTECT,NOLVP #use delay(clock=4000000) inthdl_ext(); void main() { SET_TRIS_A ( 0b11111010 ); SET_TRIS_B ( 0b00000001 ); SET_TRIS_C ( 0b00000000 ); enable_interrupts(INT_EXT); ext_int_edge(H_TO_L); } #INT_EXT inthdl_ext() { output_bit(PIN_A2, 1); delay_ms(2000); output_bit(PIN_A2, 0); } The LED on Ra2 should be on for 2 seconds, but it doesn't unfortunately. By the way putting "void" before "inthdl_ext()" does not affect the result. cya i2c2k[/code]
I i2c2k New Member Jun 4, 2004 #3 Thanks! The fnterrupt works fine! Does anybody know, how my C-Code can recognize, which of several buttons is pressed, when I have only one interrupt line and one input-pins for each button? cya i2c2k
Thanks! The fnterrupt works fine! Does anybody know, how my C-Code can recognize, which of several buttons is pressed, when I have only one interrupt line and one input-pins for each button? cya i2c2k
S StupidDum New Member Jun 4, 2004 #4 After interrupt occur, check each pin to determine interrupt source
I i2c2k New Member Jun 4, 2004 #5 Yes, that's clear, but how do I supply two inputs (1 for interrupt, 1 for which button is pressed) with only one button?
Yes, that's clear, but how do I supply two inputs (1 for interrupt, 1 for which button is pressed) with only one button?
RGBrainbow New Member Jun 4, 2004 #6 Code: T --- +5V----o-----o o------o--------------- Key 1 IN | | | o->|-o | T | | --- | o-----o o------o----|---------- Key 2 IN | | | | o->|-o | T | | --- | o-----o o------o----|---------- Key 3 IN | | o->|-o---------- interrupt IN 3x 1N4148 created by Andy´s ASCII-Circuit v1.24.140803 Beta [url]www.tech-chat.de[/url] Hi, this one 'or's all keys to the interrupt pin. hth joachim edit: sorry, i forgot the pulldown resistors.
Code: T --- +5V----o-----o o------o--------------- Key 1 IN | | | o->|-o | T | | --- | o-----o o------o----|---------- Key 2 IN | | | | o->|-o | T | | --- | o-----o o------o----|---------- Key 3 IN | | o->|-o---------- interrupt IN 3x 1N4148 created by Andy´s ASCII-Circuit v1.24.140803 Beta [url]www.tech-chat.de[/url] Hi, this one 'or's all keys to the interrupt pin. hth joachim edit: sorry, i forgot the pulldown resistors.