Hi, I am currently trying to complete a project which would be best if interrupts were used. However, in trying to create a simple interrupts program in which an LED on pin C6 is blinking in a loop for the main code and whenever an interrupt occurs, an LED on pin C7 will blink once. However, the LED on pin C7 will blink constantly as if an interrupt is constantly being triggered. I contacted CCS and they told me to read port B, which is the port I am using to interrupt (int_RB). However, all that this seemed to do was make C7 blink a few times and then no light changes state for what seems like an arbitrary amount of time.
Code:
#include "C:\Documents and Settings\BrianTi\My Documents\My Projects\Distributorless Ignition Module\Interrupts\StepOne.h"\
int dummy;
#int_RB
void RB_isr(void)
{
dummy = input_b(); // Read Port B
output_high(PIN_C6); // Blink light once
delay_ms(200);
output_low(PIN_C6);
delay_ms(200);
}
#FUSES NOWDT //No Watch Dog Timer
#FUSES RC_IO //Resistor/Capacitor Osc
#FUSES PROTECT //Code protected from reads
#FUSES BROWNOUT //Reset when brownout detected
#FUSES MCLR //Master Clear pin enabled
#FUSES NOCPD //No EE protection
#FUSES NOPUT //No Power Up Timer
#FUSES IESO //Internal External Switch Over mode enabled
#FUSES FCMEN //Fail-safe clock monitor enabled
#use delay(clock=20000000)
[/header]
Douglas Kennedy
Joined: 07 Sep 2003 Posts: 755 Location: Florida
Posted: Mon Jun 02, 2008 8:25 am
A very good practice is to never never ever get in the habit of putting delays in interrupts.
Instead set a global flag in the interrupt and in main use the flag to control your LED.
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