|
|
View previous topic :: View next topic |
Author |
Message |
Futterama
Joined: 17 Oct 2005 Posts: 98
|
Interrupt on pin change with PIC16F684 |
Posted: Wed Jun 28, 2006 2:57 am |
|
|
Hello forum,
I know this question has been asked many times, and I have read many post about it, but I can't make it work.
I have a simple test app:
I'm trying to light a LED when a pin goes high. I'm using PIN_A4 for the interrupt input pin, with a pull-down resistor of 22k. Then I have connected a LED to PIN_C2 and another LED to PIN_C3.
The LED on PIN_C3 (and the code in the main while loop) is only for me to make sure the PIC is running.
Code: | .h file:
#include <16F684.h>
#device adc=8
#FUSES NOWDT //No Watch Dog Timer
#FUSES
#use delay(clock=8000000)
.c file:
#include "684-test-pin-int.h"
#int_RA
RA_isr()
{
int8 i;
output_high(PIN_C2); // Set PIN_C2 high
i = input(PIN_A4); // Make sure to read the interrupt pin
}
void main()
{
setup_adc_ports(NO_ANALOGS|VSS_VDD);
setup_adc(ADC_OFF);
setup_timer_0(RTCC_INTERNAL|RTCC_DIV_1);
setup_timer_1(T1_DISABLED);
setup_timer_2(T2_DISABLED,0,1);
setup_comparator(NC_NC);
setup_vref(FALSE);
enable_interrupts(INT_RA4);
enable_interrupts(GLOBAL);
setup_oscillator(OSC_8MHZ);
set_tris_a(0b00010000); // Make PIN_A4 an input
output_low(PIN_C2); // Make sure pin is low
while(1)
{
// Blink LED on PIN_C3 to see the PIC is running
output_high(PIN_C3);
delay_ms(500);
output_low(PIN_C3);
delay_ms(500);
}
}
|
I connect PIN_A4 to Vdd to pull it high to activate the interrupt. But nothing happens.
Any suggestions?
I have been looking at the function ext_int_edge() to see if I could make the PIC interrupt on either a rising edge or a falling edge, but since I can't make it interrupt at all, I'm waiting a bit with this. Any comments on ext_int_edge() is also welcome.
Edit: I forgot to mention that I use version 3.249 of the CCS compiler. |
|
|
Futterama
Joined: 17 Oct 2005 Posts: 98
|
|
Posted: Wed Jun 28, 2006 3:45 am |
|
|
I found the solution... MY GOD!
All the fuses my old version of CCS made for me, is now gone. So, I was missing the INTRC_IO fuse because I made a new project with my new version of CCS, and the field "Fuses" ind the "General" tab is empty. So I suppose I had PIN_A4 configured as CLKOUT or something.
But where did the fuses go?
And where is the explanation of each fuse? |
|
|
|
|
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
|