Clearing interrupt flag before setting interrupt