HT82B40A HOLTEK [Holtek Semiconductor Inc], HT82B40A Datasheet - Page 21

no-image

HT82B40A

Manufacturer Part Number
HT82B40A
Description
I/O MCU with USB Interface
Manufacturer
HOLTEK [Holtek Semiconductor Inc]
Datasheet

Available stocks

Company
Part Number
Manufacturer
Quantity
Price
Company:
Part Number:
HT82B40A-T13D
Quantity:
2 000
org 04h
reti
org 08h
jmp tmr0int
:
org 20h
;internal Timer/Event Counter 0 interrupt routine
Tmr0int:
:
; Timer/Event Counter 0 main program placed here
:
reti
:
:
begin:
;setup Timer registers
mov a,09bh
mov tmr0,a;
mov a,080h
mov tmr0c,a
; setup interrupt register
mov a,005h
mov intc,a
set tmr0c.4
Interrupts
Interrupts are an important part of any microcontroller
system. When an internal function such as a Timer/Event
Counter overflow or a USB interrupt occur, their corre-
sponding interrupt will enforce a temporary suspension of
the main program allowing the microcontroller to direct
attention to their respective needs. while the internal in-
terrupts are controlled by the Timer/Event Counter over-
flow, USB interrupt or reception.
Interrupt Register
Overall interrupt control, which means interrupt enabling
and request flag setting, is controlled by an interrupt
control register. By controlling the appropriate enable
bits in this register each individual interrupt can be en-
abled or disabled. Also when an interrupt occurs, the
corresponding request flag will be set by the
microcontroller. The global enable flag if cleared to zero
will disable all interrupts.
Interrupt Operation
When a USB interrupt occurs or one of the Timer/Event
Counters overflow, if their appropriate interrupt enable
bit is set, the Program Counter, which stores the ad-
dress of the next instruction to be executed, will be
transferred onto the stack. The Program Counter will
then be loaded with a new address which will be the
value of the corresponding interrupt vector. The
microcontroller will then fetch its next instruction from
Rev. 1.10
; USB interrupt vector
; Timer/Event Counter interrupt vector
; jump here when Timer0 overflows
; main program
; setup Timer preload value
; setup Timer control register
; timer mode
; enable master interrupt and timer interrupt
; start Timer/Event Counter - note mode bits must be previously setup
21
this interrupt vector. The instruction at this vector will
usually be a JMP statement which will jump to another
section of program which is known as the interrupt ser-
vice routine. Here is located the code to control the ap-
propriate interrupt. The interrupt service routine must be
terminated with a RETI statement, which retrieves the
original Program Counter address from the stack and al-
lows the microcontroller to continue with normal execu-
tion at the point where the interrupt occurred.
The various interrupt enable bits, together with their as-
sociated request flags, are shown in the accompanying
diagram with their order of priority.
Once an interrupt subroutine is serviced, all the other in-
terrupts will be blocked, as the EMI bit will be cleared au-
tomatically. This will prevent any further interrupt nesting
from occurring. However, if other interrupt requests oc-
cur during this interval, although the interrupt will not be
immediately serviced, the request flag will still be re-
corded. If an interrupt requires immediate servicing
while the program is already in another interrupt service
routine, the EMI bit should be set after entering the rou-
tine, to allow interrupt nesting. If the stack is full, the in-
terrupt request will not be acknowledged, even if the
related interrupt is enabled, until the Stack Pointer is
decremented. If immediate service is desired, the stack
must be prevented from becoming full.
HT82B40R/HT82B40A
September 4, 2009

Related parts for HT82B40A