MICRO-CONTROLLER MOTOROLA HCS12 Interrupts Mechatronics Department Faculty of Engineering Ain Shams...

13
MICRO-CONTROLLER MOTOROLA HCS12 Interrupts Mechatron ics Departmen t culty of Engineering in Shams University

description

Interrupts Sources of interrupts  Maskable and non-maskable external interrupt pins.  Reset.  Real-Time Interrupt (RTI).  A 16-channel 10-bit A/D converter.  Enhanced Capture Timer (ECT) I/O on PortT.  A watchdog timer (COP).  A clock monitor.  Software interrupts

Transcript of MICRO-CONTROLLER MOTOROLA HCS12 Interrupts Mechatronics Department Faculty of Engineering Ain Shams...

Page 1: MICRO-CONTROLLER MOTOROLA HCS12 Interrupts Mechatronics Department Faculty of Engineering Ain Shams University.

MICRO-CONTROLLER MOTOROLA HCS12Interrupts

Mechatronics

Department

Faculty of EngineeringAin Shams University

Page 2: MICRO-CONTROLLER MOTOROLA HCS12 Interrupts Mechatronics Department Faculty of Engineering Ain Shams University.

Interrupts Handling

Sources of interruptsInterrupt service

routinesInterruption mechanism

Interrupt control registers

Real-time interrupts

Page 3: MICRO-CONTROLLER MOTOROLA HCS12 Interrupts Mechatronics Department Faculty of Engineering Ain Shams University.

Interrupts

Sources of interrupts

Maskable and non-maskable external interrupt pins.

Reset. Real-Time Interrupt (RTI). A 16-channel

10-bit A/D converter. Enhanced Capture Timer

(ECT) I/O on PortT. A watchdog timer (COP). A clock monitor. Software interrupts

Page 4: MICRO-CONTROLLER MOTOROLA HCS12 Interrupts Mechatronics Department Faculty of Engineering Ain Shams University.

Interrupts

Interrupt Service Routines

The script to be executed when an interrupt occurs.

It can be labeled by any label. Never forget to write RTI at the

end of interrupt service routine to pull back the CPU status and return address from the stack.

Page 5: MICRO-CONTROLLER MOTOROLA HCS12 Interrupts Mechatronics Department Faculty of Engineering Ain Shams University.

Interrupts

Interruption mechanism

1. Saving the program counter value.

2. Saving the CPU status in the stack.

3. Identifying the source of the interrupt.

4. Fetch the starting address of the corresponding interrupt service routine.

5. Executing the interrupt service routine.

6. Restoring the CPU status from the stack.

7. Restoring the program counter from the stack.

8. Resuming the interrupted program.

Page 6: MICRO-CONTROLLER MOTOROLA HCS12 Interrupts Mechatronics Department Faculty of Engineering Ain Shams University.

Interrupts

Interruption mechanism

Masking interrupts: The I and X bits in the CCR act globally.

(setting the I bit disables external IRQ and other maskable internal interrupt sources).

CLI is the instruction used to clear the interrupt flag.

ANDCC#%11101111 – is also used to clear the interrupt flag.

ORCC#%00010000 – is used to enable interrupts by setting the interrupt flag.

If the ISR resets the I bit - not recommended - because it may cause nested interrupts.

Page 7: MICRO-CONTROLLER MOTOROLA HCS12 Interrupts Mechatronics Department Faculty of Engineering Ain Shams University.

Interrupts

Interruption Priorities

Six sources are not maskable: (listed according to priority)1. Power-on reset (POR) or RESET pin2. Clock monitor reset3. Computer operating properly (COP) watchdog reset4. Unimplemented instruction trap5. Software interrupt instruction (SWI)6. XIRQ signal if X bit in CCR = 0The remaining sources are maskable, and any one of them can be given priority over other maskable interrupts.

Page 8: MICRO-CONTROLLER MOTOROLA HCS12 Interrupts Mechatronics Department Faculty of Engineering Ain Shams University.

Interrupts

Interrupt control registers Interrupt Control Register

(INTCR)

Highest Priority Control Register (HPRIO)

Page 9: MICRO-CONTROLLER MOTOROLA HCS12 Interrupts Mechatronics Department Faculty of Engineering Ain Shams University.

Interrupts

Interrupt control registers

Interrupt Control Register (INTCR)

Page 10: MICRO-CONTROLLER MOTOROLA HCS12 Interrupts Mechatronics Department Faculty of Engineering Ain Shams University.

Interrupts

Interrupt control registers

Highest Priority Control Register (HPRIO)

We distinct between interrupt sources with their VectorsThis byte includes the vector of the interrupt with highest

priority.

Page 11: MICRO-CONTROLLER MOTOROLA HCS12 Interrupts Mechatronics Department Faculty of Engineering Ain Shams University.

InterruptsInterrupts vectors • The interrupt vector is the

address of the memory register keeping the address of the ISR instructions.

• Each interrupt type has it’s own vector pointing to it’s own service routine.

• RESET has also a vector pointing to the entry of the main program.

Page 12: MICRO-CONTROLLER MOTOROLA HCS12 Interrupts Mechatronics Department Faculty of Engineering Ain Shams University.

InterruptsInterrupts vectors

definitionCan de defined using either:• Assembly Directives• Assembly instructions

ORG $FFF2 DC.W IRQ

MOVW #ISR,$FFF2

Page 13: MICRO-CONTROLLER MOTOROLA HCS12 Interrupts Mechatronics Department Faculty of Engineering Ain Shams University.

Eng. Mohamed Mahmoud HamdyEng. Mostafa Ahmed ArafaEng. Abd Allah Mahmoud Selim

Prepared by: