Interrupt Handling

Top  Previous  Next

Diamond allows you to use interrupts to control the execution of your application, although many users will not need these facilities.

 

The general procedure for managing interrupts is as follows:

1.

If you are using an external interrupt line, reserve it for your exclusive use; see External Interrupts. You need to do this to prevent your application and the Diamond kernel from both using the same external interrupt line. Other C6000  interrupt lines do not need to be claimed in this way.

2.

Attach a high-level or a low-level handler for the interrupt to the appropriate interrupt source.

3.

Enable the appropriate interrupt. This usually requires setting a combination of enable bits in the processor’s Interrupt Enable Register, IER, and in device-specific registers. When the interrupt occurs, your handler is invoked and runs with interrupts globally enabled but the specific interrupt that has occurred is disabled in IER. The interrupt is re-enabled in IER when the handler returns.

4.

Typically, your application waits for a semaphore or event that the handler signals to indicate that the interrupt has happened.

 

Dragons003You should try to keep all interrupt handlers as short as possible; it is a mistake to try to do too much inside a handler.

Dragons003You should never write handlers that call functions that can have any interaction with the kernel except those explicitly permitted in the following sections. In  particular, you should not use any I/O functions (printf, chan_in_message, etc).