STC12C5Axx
Technical Summary
27
Interrupt
There are 10 interrupt sources available in STC12C5Axx. Each interrupt source can be individually
enabled or disabled by setting or clearing a bit in the SFR named
IE
. This register also contains a global
disable bit (
EA
), which can be cleared to disable all interrupts at once.
Each interrupt source has two corresponding bits to represent its priority. One is located in SFR named
IPH
and the other in
IP
register. Higher-priority interrupt will be not interrupted by lower-priority interrupt
request. If two interrupt requests of different priority levels are received simultaneously, the request of
higher priority is serviced. If interrupt requests of the same priority level are received simultaneously, an
internal polling sequence determine which request is serviced. The following table shows the internal
polling sequence in the same priority level and the interrupt vector address.
Source
Vector address
Priority within level
/INT0
03H
0 (highest)
Timer 0
0BH
1
/INT1 13H
2
Timer1 1BH
3
UART 23H
4
ADC 2BH
5
LVD 33H
6
PCA 3BH
7
UART2 43H
8
SPI 4BH
9
The external interrupt /INT0, and /INT1 can each be either level-activated or transition-activated,
depending on bits
IT0
and
IT1
in register
TCON
. The flags that actually generate these interrupts are bits
IE0
and
IE1
in
TCON
. When an external interrupt is generated, the flag that generated it is cleared by
the hardware when the service routine is vectored to
only if the interrupt was transition –activated
,
otherwise the external requesting source is what controls the request flag, rather than the on-chip
hardware.
The Timer0 and Timer1 interrupts are generated by TF0 and TF1, which are set by a rollover in their
respective Timer/Counter registers in most cases. When a timer interrupt is generated, the flag that
generated it is cleared by the on-chip hardware when the service routine is vectored to.
The serial port interrupt is generated by the logical “1” of RI and TI. Neither of these flags is cleared by
hardware when the service routine is vectored to. The service routine should poll RI and TI to determine
which one to request service and it will be cleared by software.
The SPI interrupt is generated by the flag
SPIF
.
It can only be cleared by writing a “1” to SPIF bit in
software
.
The ADC interrupt is generated by the flag
ADC_FLAG
. It should be cleared by software.
http://www.DataSheet4U.net/
datasheet pdf - http://www.DataSheet4U.net/