6-1 Infineon 167 Interrupts The C167CS provides 56 separate interrupt sources that may be assigned...

14
6-1 Infineon 167 Interrupts The C167CS provides 56 separate interrupt sources that may be assigned to 16 priority levels. The C167CS uses a vectored interrupt system. Each interrupt source is controlled through a control register that contains the interrupt request flag interrupt enable bit interrupt priority level

Transcript of 6-1 Infineon 167 Interrupts The C167CS provides 56 separate interrupt sources that may be assigned...

Page 1: 6-1 Infineon 167 Interrupts The C167CS provides 56 separate interrupt sources that may be assigned to 16 priority levels. The C167CS uses a vectored interrupt.

6-1

Infineon 167 Interrupts

The C167CS provides 56 separate interrupt sources that may be assigned to 16 priority levels.

The C167CS uses a vectored interrupt system. Each interrupt source is controlled through a

control register that contains the interrupt request flag interrupt enable bit interrupt priority level

Page 2: 6-1 Infineon 167 Interrupts The C167CS provides 56 separate interrupt sources that may be assigned to 16 priority levels. The C167CS uses a vectored interrupt.

6-2

167 Interrupts

System specific vector locations in the memory space are reserved for the reset, trap, and interrupt service functions

Whenever a request occurs, the CPU branches to the location that is associated with the respective interrupt source. This allows direct identification of the source that caused the request.

The only exceptions are the class B hardware traps which all share the same interrupt vector.

Page 3: 6-1 Infineon 167 Interrupts The C167CS provides 56 separate interrupt sources that may be assigned to 16 priority levels. The C167CS uses a vectored interrupt.

6-3

167 Interrupts

The jump table is made up of the appropriate jump instructions that transfer control to the interrupt or trap service routines, which may be located anywhere within the address space. The entries of the jump table are located at the lowest address space.

Each entry occupies 2 words, except for the reset vector and the hardware trap vectors, which occupy 4 or 8 words.

Page 4: 6-1 Infineon 167 Interrupts The C167CS provides 56 separate interrupt sources that may be assigned to 16 priority levels. The C167CS uses a vectored interrupt.

6-4

Hardware Trap Summary

Page 5: 6-1 Infineon 167 Interrupts The C167CS provides 56 separate interrupt sources that may be assigned to 16 priority levels. The C167CS uses a vectored interrupt.

6-5

Interrupt Vectors

Page 6: 6-1 Infineon 167 Interrupts The C167CS provides 56 separate interrupt sources that may be assigned to 16 priority levels. The C167CS uses a vectored interrupt.

6-6

Processor Status Word (PSW)

Page 7: 6-1 Infineon 167 Interrupts The C167CS provides 56 separate interrupt sources that may be assigned to 16 priority levels. The C167CS uses a vectored interrupt.

6-7

Saving the Program Environment

IP - Instruction Pointer (same as PC)

PSW - Processor Status Word

Page 8: 6-1 Infineon 167 Interrupts The C167CS provides 56 separate interrupt sources that may be assigned to 16 priority levels. The C167CS uses a vectored interrupt.

6-8

Interrupt Processing

An interrupt service routine should save all the registers it uses on the stack, and restore them before returning.

The more registers a routine uses, the more time is wasted with saving and restoring.

The C167CS allows switching the complete bank of CPU registers with a single instruction, so the service routine executes within its own, separate context. (Context switch)

Page 9: 6-1 Infineon 167 Interrupts The C167CS provides 56 separate interrupt sources that may be assigned to 16 priority levels. The C167CS uses a vectored interrupt.

6-9

Interrupt Control Registers

All interrupt control registers are organized identically.

The lower 8 bits of an interrupt control register contain the complete interrupt status information of the associated source, which is required during one round of prioritisation

The upper 8 bits of the respective register are reserved.

Each interrupt source has its own Interrupt control register ,xxIC , where xx stands for the mnemonic for the respective source. Example: T2IC, ADCIC etc.

Page 10: 6-1 Infineon 167 Interrupts The C167CS provides 56 separate interrupt sources that may be assigned to 16 priority levels. The C167CS uses a vectored interrupt.

6-10

Interrupt Control Registers

Page 11: 6-1 Infineon 167 Interrupts The C167CS provides 56 separate interrupt sources that may be assigned to 16 priority levels. The C167CS uses a vectored interrupt.

6-11

Interrupt Techniques

For input interrupts Process data in the ISR or Process data in main program :-

In ISR store data in a buffer( a single variable or an array) Set a flag Main program polls the flag periodically, processing data

when flag is set, and resetting flag

Use of "Circular Buffers" to provide optimum buffer usage.

Page 12: 6-1 Infineon 167 Interrupts The C167CS provides 56 separate interrupt sources that may be assigned to 16 priority levels. The C167CS uses a vectored interrupt.

6-12

Interrupt Processing

For output interrupts Process data in the ISR or Process data in main program :-

In main program store data in a buffer Enable the interrupt if the interrupt is disabled In ISR output data from buffer and disable interrupt if this is

last data item.

Use of "Circular Buffers" to provide optimum buffer usage.

Page 13: 6-1 Infineon 167 Interrupts The C167CS provides 56 separate interrupt sources that may be assigned to 16 priority levels. The C167CS uses a vectored interrupt.

6-13

Keil C166 'C' Language Extensions

Compiler allows designation of a 'C' function as an ISR:-void ISR( ) interrupt A using B

A is the vector number associated with the device causing the interrupt

using B is optional and will cause a register bank switch which can save time if many registers need to be stored and later restored. But can be slower if only a few registers need to be saved.

Note return type MUST be void

Page 14: 6-1 Infineon 167 Interrupts The C167CS provides 56 separate interrupt sources that may be assigned to 16 priority levels. The C167CS uses a vectored interrupt.

6-14

Interrupt Service Routine

ISR and local variables local variables a created on each ISR invocation use static keyword to preserve value between ISR

invocations

Communicating with main program – use shared variables I.e. global variables. Problems!! Need mutual exclusion Could use simple variables ensuring atomic access Or simply disable interrupt during access to shared

variable.