Versions Compared

Key

  • This line was added.
  • This line was removed.
  • Formatting was changed.

The above sequence assumes that the ISR signals or sends a message to a task. However, in many cases, the ISR may not need to notify a task and can simply perform all of its work within the ISR (assuming it can be done quickly). In this case, the ISR will appear as shown in Listing 9-2.

L9-2(1)As mentioned above, an ISR is typically written in assembly language. MyShortISR corresponds to the name of the handler that will handle the interrupting device.L9-2

(2)Here, you save sufficient registers as required to handle the ISR.

L9-2(3)The user probably needs to clear the interrupting device to prevent it from generating the same interrupt once the ISR returns. L9-2

(4)Do not re-enable interrupts at this point since another interrupt could make µC/OS-III calls, forcing a context switch to a higher-priority task. This means that the above ISR would complete, but at a much later time and, possible cause other complications.

L9-2(5)Now you can take care of the interrupting device in assembly language or call a C function, if necessary.L9-2

(6)Once finished, simply restore the saved CPU registers.

L9-2(7)Perform a return from interrupt to resume the interrupted task.