| mutthunaveen 
 
 
 Joined: 08 Apr 2009
 Posts: 100
 Location: Chennai, India
 
 
			    
 
 | 
			
				| how to enable and disable timer1 runtime |  
				|  Posted: Mon Feb 21, 2011 3:27 am |   |  
				| 
 |  
				| hi all   
 here's my code
 
 
  	  | Code: |  	  | #int timer1 void isr(){
 xxx....xxxx; //expression, to disable interrupt, however this works fine.
 }
 
 void main(){
 setup_timer_1(clk_internal,div_by_8) // code is not completly accurate but i forgot the actual, because i am very far from now (work)
 enable_interrupts(GLOBAL)
 
 while(true){
 if (pin_d1){
 enable_interrupts(Timer_1)
 }
 }
 }
 
 
 | 
 
 here when i run this code the interrupt is not enabling
  ., after a long time of different combinations   if i declare enable interrupts like the below it works good
   
  	  | Code: |  	  | if (pin_d1){
 setup_timer_1(clk_internal,div_by_8)
 enable_interrupts(GLOBAL)
 enable_interrupts(Timer_1)
 }
 
 | 
 
 is this the correct way to enable the interrupt (timer1 or 0) dyanmically. r am i doing some mistake plz help me
  |  |