--- Quote Start ---
I don't want to use while(1).
--- Quote End ---
The point is, when the processor is not running the interrupt code, it
will be running
some code,
somewhere. It would probably be better if it was
your code, rather than some random bits scattered across uninitialized memory somewhere.
--- Quote Start ---
something odd happend ... as the main function (and the alt_main) has endded , the ISR i wrote was still active be the timer interrupt.
--- Quote End ---
All bets are off until you wrap your embedded run-time code in an endless loop. The moment your program 'falls off the end', your program is
over and you should no longer consider yourself in charge of the hardware. The fact that the interrupt routine keeps running after your program ends is more of an example of poor programming practices than something you should be trying to exploit.
--- Quote Start ---
can someone explain what the CPU is doing in this state (only the ISR is active for 200 uSec, and 800 uSec nothing is running).
--- Quote End ---
If it is not running your code, it is running some other code. As long as this completely unknown code does not alter the hardware, or change the stack pointer, or overwrite the stack frame, or any of a huge number of other possiblilities, your interrupt routine will keep running.
--- Quote Start ---
The ISRs still run though, as long as they aren't disabled.
--- Quote End ---
Or the code overwritten, or the stack pointer altered, or the stack data overwritten, or the interrupt pointed at another routine, or any of about a kazillion other possibilities...
Yossi, just put some sort of loop in your code! If you don't like if() and you don't like while(), then do something else, but just
do it!