CCS C Software and Maintenance Offers
FAQFAQ   FAQForum Help   FAQOfficial CCS Support   SearchSearch  RegisterRegister 

ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 

CCS does not monitor this forum on a regular basis.

Please do not post bug reports on this forum. Send them to support@ccsinfo.com

external interrupt 12F683

 
Post new topic   Reply to topic    CCS Forum Index -> General CCS C Discussion
View previous topic :: View next topic  
Author Message
sl001



Joined: 04 Jul 2011
Posts: 3

View user's profile Send private message

external interrupt 12F683
PostPosted: Thu Aug 04, 2011 10:08 pm     Reply with quote

Hi Guys,

PCWH Version:4.106

I am attempting to use a simple external ISR that is entered each time GP2 goes from (H_TO_L). I have a pullup to this pin with a button to ground. I'm using the ccs 12f683 dev board.

However, the LED stays on forever, i.e. the isr is not being serviced?
Code:

#include <12f683.H>
#device ICD=TRUE
#fuses intrc_io,nomclr,nowdt,noprotect
#use delay(clock=4000000)

#INT_EXT
void ext_isr() // This is the routine that is run each time an external interrupt is triggered.
{
   delay_ms (20);  //debounce
   output_high (RED_LED);        //contactor off (Engine Ign off)
}

void main()
{
   ext_int_edge(H_TO_L);     
   enable_interrupts(INT_EXT);
   enable_interrupts(GLOBAL);

   do
   {
   output_low (RED_LED);   //Contactor 'on' Engine Running
   }
   while (TRUE);
}

Thanks
Ttelmah



Joined: 11 Mar 2010
Posts: 19328

View user's profile Send private message

PostPosted: Fri Aug 05, 2011 5:52 am     Reply with quote

Unless you have something like a fast scope, would you ever know the interrupt was being serviced?.
If the code goes into the ISR, the LED line will go high, and then less than 20 instructions later will go low again. 20uSec. You'll never see this.
Move your time delay in the interrupt to after changing the LED, and you then will have a chance.

Best Wishes
sl001



Joined: 04 Jul 2011
Posts: 3

View user's profile Send private message

PostPosted: Sat Aug 06, 2011 2:23 am     Reply with quote

Thankyou, you are quite right. However, the ISR is still not being serviced? i.e. RED_LED is remaining lit.
I wonder if there is an issue with this version of compiler?
Code:

#INT_EXT
void ext_isr()
{
   output_high (RED_LED);       
   delay_ms(2000);
}
Ttelmah



Joined: 11 Mar 2010
Posts: 19328

View user's profile Send private message

PostPosted: Sat Aug 06, 2011 3:18 am     Reply with quote

Took the code.
Selected same compiler version.
Added a definition for RED_LED.
Compiled.
Pulsed GP2 line low.
Interrupt fired.

Code:

#include <12F683.h>
#device adc=8

#FUSES NOWDT                    //No Watch Dog Timer
#FUSES INTRC_IO                    //Internal RC Osc
#FUSES NOCPD                    //No EE protection
#FUSES NOPROTECT                //Code not protected from reading
#FUSES NOMCLR                   //Master Clear pin used for I/O
#FUSES PUT                      //Power Up Timer
#FUSES NOBROWNOUT               //No brownout reset
#FUSES NOIESO                   //Internal External Switch Over mode disabled
#FUSES NOFCMEN                  //Fail-safe clock monitor disabled
#FUSES RESERVED                 //Used to set the reserved FUSE bits

#use delay(clock=4000000)

#define RED_LED PIN_A1

#INT_EXT
void ext_isr() {
   output_high (RED_LED);
   delay_ms (200);  //long enough to be visible
}

void main() {
   ext_int_edge(H_TO_L);     
   clear_interrupt(INT_EXT); //May be fired by setting the edge
   enable_interrupts(INT_EXT);
   enable_interrupts(GLOBAL);

   do
   {
   output_low (RED_LED);   //Contactor 'on' Engine Running
   }
   while (TRUE);
}



It works for me.....

Triple check your connections
I initially added two lines:

setup_adc_ports(NO_ANALOGS|VSS_VDD);
setup_comparator(NC_NC);

Because some compiler versions leave these incorrectly setup.
However, once it was working, removed these, and it kept on working.

Best Wishes
sl001



Joined: 04 Jul 2011
Posts: 3

View user's profile Send private message

PostPosted: Sat Aug 06, 2011 8:27 pm     Reply with quote

Thank you for your efforts Ttelmah,

I had been using the small ccs 12f683 dev board that uses a 14 pin ICD chip. I wonder if these have an external interrupt pin on GP2 as their 8 pin cousins? I built a small test circuit using the 8 pin chip and as you say the Interrupt fires.

Thanks again.
Display posts from previous:   
Post new topic   Reply to topic    CCS Forum Index -> General CCS C Discussion All times are GMT - 6 Hours
Page 1 of 1

 
Jump to:  
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