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

Using timer0 and timer1's interruptions in the same code

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



Joined: 13 Oct 2013
Posts: 2

View user's profile Send private message

Using timer0 and timer1's interruptions in the same code
PostPosted: Sun Oct 13, 2013 2:16 pm     Reply with quote

Hi!

Can it be done? What would be the downside of that?
I'd imagine if the PIC called one of the isr (lets say timer1's isr) then it wouldnt interrupt that isr in order to call timer0's isr, right?

In any case, would you still do it?

Something like (btw, using PIC16F887):



Code:


void main()
{

//Configuracion timer0 - RTCC
setup_timer_0( RTCC_INTERNAL | RTCC_DIV_64);
set_timer0(0);
enable_interrupts(INT_RTCC);

//Configuracion timer1
setup_timer_1(T1_INTERNAL | T1_DIV_BY_8);
set_timer1(0);
enable_interrupts(INT_TIMER1);

enable_interrupts(GLOBAL);
}


#int_rtcc                         
void timer0_isr()
{
}

#INT_TIMER1                       
void clock_isr()                 
{
}


Mike Walne



Joined: 19 Feb 2004
Posts: 1785
Location: Boston Spa UK

View user's profile Send private message

PostPosted: Sun Oct 13, 2013 2:49 pm     Reply with quote

Quote:
Can it be done?
Yes
Quote:
What would be the downside of that?
Depends on the PIC.
With PIC16's you have to wait for one ISR to finish before the other can run.
With PIC18s you get two priorities. The higher level can interrupt the lower level.

Quote:
In any case, would you still do it?
Of course, with the usual caveats.

Mike
seed_87



Joined: 13 Oct 2013
Posts: 2

View user's profile Send private message

PostPosted: Sun Oct 13, 2013 5:49 pm     Reply with quote

Oh, i see..

Many thanks mike!!
Ttelmah



Joined: 11 Mar 2010
Posts: 19346

View user's profile Send private message

PostPosted: Mon Oct 14, 2013 1:01 am     Reply with quote

and (of course) the 'having to wait', shouldn't matter, provided you repeat the mantra (and use it), of 'keep the handlers short'. If the handler just does the job required (read a time, increment a counter, etc. etc.), and exits immediately, the second handler will then be called with only a tiny delay. Smile

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