Posted: Tue Feb 17, 2009 3:27 am Post subject: enable INTx triggers interrupt?
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?
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
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
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