View previous topic :: View next topic |
Author |
Message |
hamedhamedi
Joined: 12 Feb 2012 Posts: 70
|
Posted: Wed Nov 19, 2014 9:24 pm Post subject: clear pending interrupt of external-int0 |
|
|
Hi
i want to disable int0 in some section of my code and enable it again in other section of my code,but a problem occur .
when i enable int0 again my code,the pending interrupts that occur during disabled it0, led to run routine of int0 once.
so i want to clear pending interrupts before i enable it again.
i know from datasheet that writing logic one to flag of an interrupt clear it,but refer to some website like this below,confuse me!
http://www.avrfreaks.net/forum/clearing-pending-interrupts
any idea for clear pending interrupt in bascom avr?
Thanks
(BASCOM-AVR version : 2.0.7.7 ) |
|
Back to top |
|
|
dabatek
Joined: 31 Jul 2013 Posts: 32 Location: Serbia
|
Posted: Wed Nov 19, 2014 9:40 pm Post subject: |
|
|
GIFR=64 |
|
Back to top |
|
|
hamedhamedi
Joined: 12 Feb 2012 Posts: 70
|
Posted: Wed Nov 19, 2014 10:23 pm Post subject: |
|
|
thanks dabatek
how it work? |
|
Back to top |
|
|
dabatek
Joined: 31 Jul 2013 Posts: 32 Location: Serbia
|
Posted: Thu Nov 20, 2014 9:10 am Post subject: |
|
|
From Data sheet:
General Interrupt Flag
Register – GIFR[/b]
• Bit 6 – INTF0: External Interrupt Flag 0
When an edge or logic change on the INT0 pin triggers an interrupt request, INTF0 becomes set
(one). If the I-bit in SREG and the INT0 bit in GICR are set (one), the MCU will jump to the corresponding
interrupt vector. The flag is cleared when the interrupt routine is executed.
Alternatively, the flag can be cleared by writing a logical one to it. This flag is always cleared
when INT0 is configured as a level interrupt.
Have a nice day, Hamed |
|
Back to top |
|
|
AdrianJ
Joined: 16 Jan 2006 Posts: 2483 Location: Queensland
|
Posted: Fri Nov 21, 2014 12:05 am Post subject: |
|
|
@databek
Perhaps it would have been more obvious if you had written
set GIFR.INTF0
rather than
GIFR = 64
I know its ( almost ) the same thing, since clearing bits in the GIFR does nothing, but maybe other people dont. _________________ Adrian Jansen
Computer language is a framework for creativity |
|
Back to top |
|
|
hamedhamedi
Joined: 12 Feb 2012 Posts: 70
|
Posted: Fri Nov 21, 2014 7:44 am Post subject: |
|
|
in the website i post its link,there are different ways of set a bit,and there are very description for its different type. as different way AdrinJ and dabatek say.
some other way is shifting GIFR register. i want to know what of them should work true in bascom avr?
thanks |
|
Back to top |
|
|
AdrianJ
Joined: 16 Jan 2006 Posts: 2483 Location: Queensland
|
Posted: Fri Nov 21, 2014 8:37 am Post subject: |
|
|
databek is correct, its better to write the entire register with just the one bit set that you want to clear, rather than use the SET instruction, which does a read-modify-write. This only applies to these really odd registers like GIFR, which use setting a bit to clear it ! _________________ Adrian Jansen
Computer language is a framework for creativity |
|
Back to top |
|
|
albertsm
Joined: 09 Apr 2004 Posts: 5913 Location: Holland
|
Posted: Fri Nov 21, 2014 11:30 am Post subject: |
|
|
SET does not read/write modify on FLAG registers.
Set uses SBI when possible, and when the register is marked in the [FLAG] section and is an extended register, it will not do a read but just a write.
So it is safe to use SET _________________ Mark |
|
Back to top |
|
|
|