Forum - MCS Electronics

 

FAQFAQ SearchSearch RegisterRegister Log inLog in

enable INTx triggers interrupt?

 
This forum is locked: you cannot post, reply to, or edit topics.   This topic is locked: you cannot edit posts or make replies.    www.mcselec.com Forum Index -> BASCOM-AVR Archive
View previous topic :: View next topic  
Author Message
seravitae

Bascom Member



Joined: 10 Feb 2009
Posts: 7

blank.gif
PostPosted: Tue Feb 17, 2009 3:27 am    Post subject: enable INTx triggers interrupt? Reply with quote

Hey there,
I was just wondering if enabling an interrupt causes the interrupt to be triggered. I ask because Im currently using a pin change interrupt to get remote signals. After i get the full remote code, even if i introduce a massive delay like waitms 5000 at the end of the interrupt sequence, after i re-enable the interrupt, sure enough after 5 seconds (well after the remote has finished responding) the interrupt routine is triggered again. Do i need to manually set/unset some flag to stop this happening?

Cheers Smile
Back to top
View user's profile
ibilzh

Bascom Member



Joined: 11 Jul 2007
Posts: 151
Location: Germany

blank.gif
PostPosted: Tue Feb 17, 2009 9:06 am    Post subject: Reply with quote

Hello seravitae,

when you trigger an interrupt and you jump prhaps into a sub or function,
the nex interrupt is stored. After return interrupt the int is executed then.
Try to disable interrupt at the first step into the sub and enable it
as last step before return.
To see what hapens a good trick is to start a counter into the sub and increment
it during the sub.

sub_counter = 0
on int0 blahblah
do
print sub_counter
.
.
loop


sub blahblah
incr sub_counter
disable interrupt

enable interrupt
end sub
Back to top
View user's profile Visit poster's website
mattcro

Bascom Member



Joined: 03 Oct 2007
Posts: 327
Location: Scotland

uk.gif
PostPosted: Tue Feb 17, 2009 11:56 am    Post subject: Reply with quote

You can try clearing the relevant interrupt flag just before you exit the interrupt handler (or just before the interrupt gets re-enabled). That way, any pending interrupt (triggered during reception of the remote command in your case?) will be ignored. You can manually clear the PCINT flags by writing 1 (not 0) to the appropriate bit in the PCINT flags register (PCIFR on mega128x series).
_________________
If all else fails, read the manual. Even better: read the manual before something fails. If you can't find it in the manual, search the forum.
BascomAVR 2.0.8.5
Back to top
View user's profile
Display posts from previous:   
This forum is locked: you cannot post, reply to, or edit topics.   This topic is locked: you cannot edit posts or make replies.    www.mcselec.com Forum Index -> BASCOM-AVR Archive 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