CCS Compiler: Interrupts

Status
Not open for further replies.

i2c2k

New Member
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]
 
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
 
Yes, that's clear, but how do I supply two inputs (1 for interrupt, 1 for which button is pressed) with only one button?
 
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.
 
Status
Not open for further replies.
Cookies are required to use this site. You must accept them to continue using the site. Learn more…