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.

to include delay inside a interrupt sub-routine



Hi,

I am sending & receiving data from hyper-terminal of PC through USB.

Once I will receive 'o' character,  I need to throw back ' . ' character on USB  at every one second for 10s.

but after doing so, I am receiving ' . . . . . . . . . . " altogether only after 10s on hyperterminal

kindly suggest the solution!!

  • Hi sayed,

    "Delay" and "inside interrupt" are no... an ISR should be as fast as possible, meaning it should not have delays. The ISR needs to be fast so it does as little impact to the main code run time as possible.
    If you use a delay that uses for example a timer that interrupts every 1ms then it will not even work! Do you understand why?
    If you need for some reason a small delay, with something like in the order of some cycles you can use SysCtlDelay().

    What you can do is after receiving the 'o', set a timer to interrupt every 1s and send a '.' . After 10 sent it stops (a counter variable should be used)
    Other possibility, more easy, is to have your interrupt for receiving an 'o' set a flag for the main to check. There the main would send the '.' every 1s with a delay being used. There are many ways to do what you ask, some mean a dedicated MCU to make it (by using code blocking delays), others are more "multi-tasking" friendly.
  • sayed tausif said:
    kindly suggest the solution!!

     THE solution is impossible, we need know what happen at your side.

     One solution also need know problem is not explained on text.

     We don't know, we suppose can be some form of buffer overflow no idea where.

     TITLE FOREVER SOUND HORRIBLE as wrote from our good Luis, NEVER add delay on ISR routine, instead use semaphore or message passing and manage on main loop or timed event. NEVER serve IRQ in a non as fast as possible manner, use buffered producer consumer model from programming model.

  • Thank you Luis!!

    I think Inputs provided by you will help me out!!

    I will try delay inside main()!!