Forum - MCS Electronics

 

FAQFAQ SearchSearch RegisterRegister Log inLog in

clear pending interrupt of external-int0

 
Post new topic   Reply to topic    www.mcselec.com Forum Index -> BASCOM-AVR
View previous topic :: View next topic  
Author Message
hamedhamedi

Bascom Member



Joined: 12 Feb 2012
Posts: 70

PostPosted: Wed Nov 19, 2014 9:24 pm    Post subject: clear pending interrupt of external-int0 Reply with quote

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
View user's profile
dabatek

Bascom Member



Joined: 31 Jul 2013
Posts: 27
Location: Serbia

blank.gif
PostPosted: Wed Nov 19, 2014 9:40 pm    Post subject: Reply with quote

GIFR=64
Back to top
View user's profile
hamedhamedi

Bascom Member



Joined: 12 Feb 2012
Posts: 70

PostPosted: Wed Nov 19, 2014 10:23 pm    Post subject: Reply with quote

thanks dabatek
how it work?
Back to top
View user's profile
dabatek

Bascom Member



Joined: 31 Jul 2013
Posts: 27
Location: Serbia

blank.gif
PostPosted: Thu Nov 20, 2014 9:10 am    Post subject: Reply with quote

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 Smile
Back to top
View user's profile
AdrianJ

Bascom Expert



Joined: 16 Jan 2006
Posts: 2473
Location: Queensland

australia.gif
PostPosted: Fri Nov 21, 2014 12:05 am    Post subject: Reply with quote

@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
View user's profile Visit poster's website
hamedhamedi

Bascom Member



Joined: 12 Feb 2012
Posts: 70

PostPosted: Fri Nov 21, 2014 7:44 am    Post subject: Reply with quote

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
View user's profile
AdrianJ

Bascom Expert



Joined: 16 Jan 2006
Posts: 2473
Location: Queensland

australia.gif
PostPosted: Fri Nov 21, 2014 8:37 am    Post subject: Reply with quote

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
View user's profile Visit poster's website
albertsm

Administrator



Joined: 09 Apr 2004
Posts: 5093
Location: Holland

blank.gif
PostPosted: Fri Nov 21, 2014 11:30 am    Post subject: Reply with quote

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
View user's profile Visit poster's website
Display posts from previous:   
Post new topic   Reply to topic    www.mcselec.com Forum Index -> BASCOM-AVR All times are GMT + 1 Hour
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
You cannot attach files in this forum
You cannot download files in this forum