3

I'm using 12MHz HFXTCLK with full strength on my launchpad.I did not use any presacalar value for SMCLK (I used prescalar only for the timer). I'm using full speed 12MHz clock to my system. I want to use a 16-bit timer delay to create a 64ms ON Pulse at once the interrupt occurrence. The i/o pin gives 64ms ON Pulse after the interrupt occurred. But, after the handler code execution the code ends once and after I can't create same interrupt. In debugging mode, step by step debugging process it tends me to the ISR_Trap after the execution of handler code. Just as all i wanted to create a timer delay in a i/o interrupt handler.Is there any possible way to sort out this, pls do hlp me...

Shiv
  • 31
  • 2
  • 3
    Can you? Yes. Should you? No. Much better to write non-blocking code. – Spehro Pefhany Dec 28 '21 at 05:43
  • Does the MCU have to do anything else while this pulse is being generated? _"after the handler code execution the code ends once and after I can't create same interrupt."_ - how did you create the first interrupt? – Bruce Abbott Dec 28 '21 at 16:26

2 Answers2

5

If you are just going to loop and wait around inside the interrupt handler until the delay is over (i.e. polling the value of the timer while inside your interrupt handler to check whether the delay time has passed or not), then no. Don't do that.

But there is no need to do that if you are using a timer interrupt. If you make your interrupt handler setup the timer to trigger another interrupt in the future where the task will continue, then exit your current interrupt handler while the timer counts down the delay, then that is fine. Now your microcontroller can go about doing other tasks during the delay. A very advanced form of this is the multi-tasking that operating systems use.

You just do not want to dwell around inside your interrupt handler.

DKNguyen
  • 54,733
  • 4
  • 67
  • 153
1

You'd better not to embed interrupt handler. It means there is a priority processing deal. If it runs into a I/O interrupt handler now, suddenly, a timer interrupt occurs, what should it do? And a stupid idea to waste longer time in interrupt signal routine. More shorter the ISR takes, more excellent performance your code are!

  • Your answer could be improved with additional supporting information. Please [edit] to add further details, such as citations or documentation, so that others can confirm that your answer is correct. You can find more information on how to write good answers [in the help center](/help/how-to-answer). – Community Dec 28 '21 at 07:30