This thread has been locked.
If you have a related question, please click the "Ask a related question" button in the top right corner. The newly created question will be automatically linked to this question.
Here is the code which works only if I enter into a Low Power Mode however it is not working in active mode.
Please suggest.
The job you gave the CPU is very easy, it can do it even when you let it to go to sleep (and wake up occasionally by the doorbell to flip the light). However, if you left CPU in active mode and do not instruct it what to do next, it will run away beyond your control. By that time, it won't even answer the doorbell.
Your label Mainloop suggests a solution, but it is not really a loop . Replace that section of code by:
bis.w #GIE,SR ; enable interrupts
Mainloop jmp Mainloop ; stay here, don’t go away
Your Main'loop' is no loop. So if you don't enter LPM, which effectively ends main code execution, the code will continue form main into the ISR and then perform a RETI where the ISR was never called due to interrupt.
You should add a 'jmp $' or similar after the nop, so the code execution stops there.
**Attention** This is a public forum