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

how to enable and disable timer1 runtime

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



Joined: 08 Apr 2009
Posts: 100
Location: Chennai, India

View user's profile Send private message

how to enable and disable timer1 runtime
PostPosted: Mon Feb 21, 2011 3:27 am     Reply with quote

hi all Smile

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 Shocked ., after a long time of different combinations Embarassed
if i declare enable interrupts like the below it works good Laughing
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 Confused
Ttelmah



Joined: 11 Mar 2010
Posts: 19498

View user's profile Send private message

PostPosted: Mon Feb 21, 2011 3:37 am     Reply with quote

The problem is with your test. PIN_D1, is a constant. If you want to test the value present 'on' the pin, the syntax is "if (input(PIN_D1)) {"

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