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

delay_us

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



Joined: 10 Sep 2003
Posts: 60

View user's profile Send private message Send e-mail Yahoo Messenger MSN Messenger ICQ Number

delay_us
PostPosted: Tue May 03, 2005 9:47 am     Reply with quote

Dear all,

I am using 2 timer interrupt in my program (timer 0 and timer 1). Timer 0 is used to count for 1s. In this 1 second interval, timer 1 is used to count the pulses that is received. I would like to use Pin B0 interrupt which will set Pin C0 high for 7us. If I have a delay_us(7) in the pin B0 interrupt routine, will this affect the other timers operation? What will happen during the delay_us(7) line?

Thanks a lot
_________________
Einly
rwyoung



Joined: 12 Nov 2003
Posts: 563
Location: Lawrence, KS USA

View user's profile Send private message Send e-mail

PostPosted: Tue May 03, 2005 10:04 am     Reply with quote

Using the delay_us, delay_ms and delay_cycles functions inside interrupt service routines is generally a bad idea.

Unless you are writing your own interrupt handler there is a significant chance you will increase the latency of other interrupts because you have blocked them with a dead-head loop of NOPs inside another ISR.

ISRs should be short and to the point. Get in and get out of the ISR as quickly as you can.
_________________
Rob Young
The Screw-Up Fairy may just visit you but he has crashed on my couch for the last month!
PCM programmer



Joined: 06 Sep 2003
Posts: 21708

View user's profile Send private message

PostPosted: Tue May 03, 2005 12:13 pm     Reply with quote

Quote:
If I have a delay_us(7) in the pin B0 interrupt routine, will this affect the
other timers operation? What will happen during the delay_us(7) line?

The relative affect of a 7 usec delay also depends upon your oscillator
frequency. If you are using a 4 MHz crystal, then one instruction cycle
takes 1 usec. Just to get in and out of an interrupt service routine
will take at least 50 usec, due to the length of the CCS interrupt
dispatcher routine. Let's say your other code in the isr takes 10 usec
then you now have 60 usec just to process your interrupt. Adding 7
more usec to that, really isn't going to hurt anything.
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