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 CCS Technical Support

int_ext + int_timer1 problem !!

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



Joined: 09 Aug 2011
Posts: 6

View user's profile Send private message

int_ext + int_timer1 problem !!
PostPosted: Fri Aug 12, 2011 6:52 am     Reply with quote

my program set to 1 the PIN A1 for 5 seconds and set to 0 for the same delay !! now I'm trying to use the external interrupt using a switch related to PIN B0 !! but it doesn't work !! the timer1 still working although I disabled the timer1 interruption in external interruption's code !!
Code:

#include <16F628A.h>

#FUSES NOWDT                    //No Watch Dog Timer
#FUSES LP                       //Low power osc < 200 khz
#FUSES NOPUT                    //No Power Up Timer
#FUSES NOPROTECT                //Code not protected from reading
#FUSES NOBROWNOUT               //No brownout reset
#FUSES NOMCLR                   //Master Clear pin used for I/O
#FUSES NOLVP                    //No low voltage prgming, B3(PIC16) or B5(PIC18) used for I/O
#FUSES NOCPD                    //No EE protection

#use delay(clock=4000000)
#use rs232(baud=9600,parity=N,xmit=PIN_A3,rcv=PIN_A2,bits=8)

#define so 10   // définir les adresse mémoir EEPROM qu'on va les utiliser
#define mo 15
#define sf 20
#define mf 25

unsigned int16 count=0;

#int_ext
void ext_isr()
{
   disable_interrupts(int_timer1);
   count=0;
   output_high(pin_a2);
   output_low(pin_a1);
   enable_interrupts(int_timer1);
}

#int_timer1
void timer1(){
count++;
}

int16 delay=0;

void main()
{
   setup_timer_0(RTCC_INTERNAL|RTCC_DIV_1);
   setup_timer_2(T2_DISABLED,0,1);
   setup_comparator(NC_NC_NC_NC);
   setup_vref(FALSE);
//Setup_Oscillator parameter not selected from Intr Oscillotar Config tab
   set_timer1(delay);
   EXT_INT_EDGE(H_TO_L);
   setup_timer_1(T1_INTERNAL|T1_DIV_BY_8);
   enable_interrupts(INT_EXT);
   enable_interrupts(INT_TIMER1);
   enable_interrupts(GLOBAL);
   while(1){
   while(count<=10){
   output_high(pin_a1);}
   count=0;
   while(count<=10){
   output_low(pin_a1);}
   count=0;
}
}
Ttelmah



Joined: 11 Mar 2010
Posts: 19513

View user's profile Send private message

PostPosted: Fri Aug 12, 2011 8:10 am     Reply with quote

You do realise that as shown, the timer will be disabled for only about 30uSec.
The EXT interrupt only triggers when there is an _edge_ on the external pin. Not a level. Just for 30uSec or so, while the int_ext is serviced (for the whole time, nothing to do with your disable instructions - the _hardware_ disables all other interrupts when one is being serviced), the timer will be disabled, and then re-enabled when the routine exits. Since the timer triggers about every 1000uSec, this will make no difference at all to the operation of the timer.

Best Wishes
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