|
|
View previous topic :: View next topic |
Author |
Message |
PCM Novice Guest
|
The very first interrupt. |
Posted: Thu Jan 09, 2003 7:01 am |
|
|
<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! |
Posted: Thu Jan 09, 2003 8:45 am |
|
|
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 |
|
|
|
|
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
|