View previous topic :: View next topic |
Author |
Message |
Sensor
Joined: 04 Nov 2004 Posts: 33
|
Clear Interrupts |
Posted: Thu Nov 09, 2006 9:38 am |
|
|
Compiler: PCWH version 3.236
Controller: PIC16F628A
Supply Voltage: 5V
Is there a way to clear all interrupts? While searching in this forum I found the command "clear_interrupt(INT_TIMER0);" but it does not work with my version of compiler.
When I get in RB interrupt routine, I want to be to clear all other interrupts flags when I exit the RB interrupt in case my other interrupts occured while I was in the RB interrupt routine.
So, is there a C command which will clear all interrupt flags?
Thanks |
|
|
PCM programmer
Joined: 06 Sep 2003 Posts: 21708
|
|
Posted: Thu Nov 09, 2006 12:30 pm |
|
|
Quote: | Is there a way to clear all interrupts? |
In the 16F628A, the interrupt flags for the peripheral modules are
contained in two registers: PIR1 and INTCON. You could declare the
address of PIR1 with the #byte directive and then write 0x00 to it with
a line of code. You could declare the RBIF, INTF, and T0IF bits in
INTCON with the #bit directive and then write 0 to each one of them
with a line of code.
Look in the 16F628A data sheet, in the section on Special Function
registers, for a list of all the register addresses and bit locations. |
|
|
Humberto
Joined: 08 Sep 2003 Posts: 1215 Location: Buenos Aires, La Reina del Plata
|
|
Posted: Thu Nov 09, 2006 3:28 pm |
|
|
Quote: |
Is there a way to clear all interrupts?
|
Sorry if I miss understood your question but I can�t imagine a situation where it
will be necessary or useful to clear ALL interrupts.
It seems to me that there is an erroneous interpretation of interrupts handling.
An interruption is not generated if previously it has not arranged that this happens,
that is ENABLE_INTERRUPT(xxx).
If an interrupt had been triggered by an event, the corresponding interrupt
flag is cleared when such interrupt is serviced.
Erase ALL the interruptions without knowing wich of the peripherals generated
this interruption is at least a contradiction.
If you want to clear ALL interrupts, simply do not use them or do not ENABLE it.
The compiler versions that you are using handle interrupts properly, hence
let the compiler to do his job.
Anyway I suggest you to read a very good tutorial regarding interrupts written
by Peter Anderson.
http://www.phanderson.com/PIC/16C84/interrupts/interrupt_1.html
cheers,
Humberto |
|
|
|