|
|
View previous topic :: View next topic |
Author |
Message |
z3ngew
Joined: 20 Apr 2013 Posts: 50
|
interrupt register |
Posted: Thu Jun 06, 2013 5:10 pm |
|
|
Hello everyone,
I know that every pic microcontroller has a certain interrupt registers which are related to some events, for example, like timer overflow interrupt.
My question is, is it possible to control the interrupt register without using the firing event?
for example, use the timer interrupt register without actually using the timer, or making it overflow.
Thanks in advance,
z3ngew |
|
|
PCM programmer
Joined: 06 Sep 2003 Posts: 21708
|
|
Posted: Thu Jun 06, 2013 6:30 pm |
|
|
Give some more details about what you want the program to do,
and why you want to use a Timer interrupt in a special way.
There are at least two possible answers I can think of, but I don't have
enough information from your post to be sure of what the question is.
Also, post the PIC that you are using, and the exact timer that you
want to use (Timer0, Timer1, or Timer2, etc). |
|
|
asmboy
Joined: 20 Nov 2007 Posts: 2128 Location: albany ny
|
|
Posted: Thu Jun 06, 2013 9:28 pm |
|
|
Quote: |
the timer interrupt register
|
there is no such thing per se.
there is a timer interrupt BIT in a register
with other UNRELATED bits
and
depending on the pic
other control and masking bits
in other registers too.
the data sheets paint a pretty clear picture
you CAN use the timer overflow flag bit
w/o activating an interrupt handler also. |
|
|
Ttelmah
Joined: 11 Mar 2010 Posts: 19504
|
|
Posted: Fri Jun 07, 2013 1:00 am |
|
|
"is it possible to control the interrupt register"
As Asmboy says, bit, not register.
As a comment, I'd say "no, you can't really 'control it'". You can _test_ it.
There is a 'sequence' of four bits associated with interrupts on the PIC18. Two on a PIC16.
Basically there is the event 'bit' or 'flag' set by the hardware.
Then there is the individual interrupt enable bit to say whether the hardware is going to trigger a response to this. (both 16 and 18).
Then there is the 'priority' bit to say which hardware handler is to react (18 only, and not on all interrupts).
Then there is the corresponding global enable (just one on the 16).
When all the sequence goes 'true' - flag, enable, priority & It's global enable, then the handler is called.
You can leave (say) the individual 'enable' off, and poll the interrupt flag instead of using the hardware call. Then you can also clear the flag (for timers). This can often be a faster way of handling an individual event.
However trying to write the bit to give a software 'trigger' of an interrupt event, is potentially quite dangerous (most PIC data sheets have a warning that this can give 'erratic results'). If you wanted to do that, far better to just set the timer 'to' the maximum count-1, so it triggers normally on the next cycle. If you wanted to do this, the only 'safe' way, is to disable the interrupt, then change the flag, then re-enable the interrupt. Also manually triggering the event this way brings further problems, since then the 'real' trigger could occur almost immediately after.
As PCM programmer says "what do you actually want to do - what PIC, what timer"?.
Best Wishes |
|
|
z3ngew
Joined: 20 Apr 2013 Posts: 50
|
|
Posted: Fri Jun 07, 2013 3:42 am |
|
|
Thanks for you all, your answers made everything clear for me
z3ngew |
|
|
asmboy
Joined: 20 Nov 2007 Posts: 2128 Location: albany ny
|
|
Posted: Fri Jun 07, 2013 4:08 pm |
|
|
I am willing to be shown as wrong but
Quote: |
trying to write the bit
|
i would agree with the semantic alteration to read
"SET the bit" and i Believe that is what Ttelmah meant.
- as i have found - so long as NO INTS are
enabled for a timer overflow bit
CLEARING the bit is always safe - never had it fail
and have depended on that behavior for some high precision
I/O control at times.
in fact it is an ideal way to poll a timer w/o any INT at all.
In a tight wait loop - wait for the overflow bit to flip and THEN ACT.
program response can be FASTER than with INTS enabled,
by a potentially significant number of instruct cycles
since there is no setup/restore context overhead
added by a pesky handler...
IN fact, even though it would be awfully dumb -
i believe you can TRY clear the timer int flag even with ints on! |
|
|
|
|
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
|