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

The very first interrupt.

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







The very first interrupt.
PostPosted: Thu Jan 09, 2003 7:01 am     Reply with quote

<font face="Courier New" size=-1>I am trying to time an asynchronous event using timer2. I want the event to call enble_interrupts to start the measurement, rather than keeping the interrupt going and using set_timer2(0) to initiate it (see code fragment below).
But the call to enable_interrupts causes an imediate interrupt, has anyone any ideas?

setup_timer_2(T2_DIV_BY_16,200,5);
// timer set to 5.2ms with 12.288 MHz xtal

// some event
set_timer2(0);
enable_interrupts(INT_TIMER2);
// I would expect first interrupt 5.2ms later.. But it happens imedeately.
//Interrupts there after occur correctly at 5.2ms intervals as expected.

</font>
___________________________
This message was ported from CCS's old forum
Original Post ID: 10557
PCM Novice
Guest







Re: The very first interrupt. Solved!
PostPosted: Thu Jan 09, 2003 8:45 am     Reply with quote

Solved using
set_timer2(0);
#asm
BCF PIR1, TMR2IF // clear the timer 2 interrupt flag
#endasm
enable_interrupts(INT_TIMER2);

:=<font face="Courier New" size=-1>I am trying to time an asynchronous event using timer2. I want the event to call enble_interrupts to start the measurement, rather than keeping the interrupt going and using set_timer2(0) to initiate it (see code fragment below).
:=But the call to enable_interrupts causes an imediate interrupt, has anyone any ideas?
:=
:=setup_timer_2(T2_DIV_BY_16,200,5);
:=// timer set to 5.2ms with 12.288 MHz xtal
:=
:=// some event
:=set_timer2(0);
:=enable_interrupts(INT_TIMER2);
:=// I would expect first interrupt 5.2ms later.. But it happens imedeately.
:=//Interrupts there after occur correctly at 5.2ms intervals as expected.
:=
:=</font>
___________________________
This message was ported from CCS's old forum
Original Post ID: 10563
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