08.06.2013 Views

C8051F326/7 - Silicon Labs

C8051F326/7 - Silicon Labs

C8051F326/7 - Silicon Labs

SHOW MORE
SHOW LESS

You also want an ePaper? Increase the reach of your titles

YUMPU automatically turns print PDFs into web optimized ePapers that Google loves.

6.3.2. External Interrupts<br />

<strong>C8051F326</strong>/7<br />

The /INT0 external interrupt source can be configured as edge or level sensitive. The IT0 bit (TCON.0, see<br />

Figure 14.1 on Page 128) selects level or edge sensitivity. When global port I/O inputs are enabled, /INT0<br />

will monitor the voltage at the input pin. The CPU will vector to the /INT0 interrupt service routine whenever<br />

the pin detects the condition the external interrupt has been configured to monitor. TMOD.3 (GATE0) controls<br />

the functionality of /INT0 as is shown in Table 6.4.<br />

The /INT1 interrupt source provides an interrupt on two events, based on the logic level of GATE1<br />

(TMOD.7). If GATE1 is set to logic 1, an interrupt is generated every two Low Frequency Internal Oscillator<br />

clock cycles. This allows the CPU to vector to the /INT1 interrupt service routine at a rate of 40 kHz. If<br />

GATE1 is set to logic 0, an interrupt is generated when the internal oscillator resumes from a suspended<br />

state.<br />

The pending flags for the /INT0 and /INT1 interrupts are set upon reset. If the /INT0 or /INT1 interrupt is<br />

used, the respective flag should be cleared before enabling the interrupts to prevent an accidental interrupt.<br />

The pending flags are for the /INT0 and /INT1 interrupt are in the TCON register.<br />

6.3.3. Interrupt Priorities<br />

Each interrupt source can be individually programmed to one of two priority levels: low or high. A low priority<br />

interrupt service routine can be preempted by a high priority interrupt. A high priority interrupt cannot be<br />

preempted. Each interrupt has an associated interrupt priority bit in an SFR (IP or EIP2) used to configure<br />

its priority level. Low priority is the default. If two interrupts are recognized simultaneously, the interrupt with<br />

the higher priority is serviced first. If both interrupts have the same priority level, a fixed priority order is<br />

used to arbitrate, given in Table 6.5.<br />

6.3.4. Interrupt Latency<br />

Table 6.4. TMOD.3 Control of /INT0<br />

TMOD.3 = 0 TMOD.3 = 1<br />

/INT0 Pinout P0.0 P0.2<br />

Edge Sensitivity Rising Edge Falling Edge<br />

Level Sensitivity Active High Active Low<br />

Interrupt response time depends on the state of the CPU when the interrupt occurs. Pending interrupts are<br />

sampled and priority decoded each system clock cycle. Therefore, the fastest possible response time is 5<br />

system clock cycles: 1 clock cycle to detect the interrupt and 4 clock cycles to complete the LCALL to the<br />

ISR. If an interrupt is pending when a RETI is executed, a single instruction is executed before an LCALL<br />

is made to service the pending interrupt. Therefore, the maximum response time for an interrupt (when no<br />

other interrupt is currently being serviced or the new interrupt is of greater priority) occurs when the CPU is<br />

performing an RETI instruction followed by a DIV as the next instruction. In this case, the response time is<br />

18 system clock cycles: 1 clock cycle to detect the interrupt, 5 clock cycles to execute the RETI, 8 clock<br />

cycles to complete the DIV instruction and 4 clock cycles to execute the LCALL to the ISR. If the CPU is<br />

executing an ISR for an interrupt with equal or higher priority, the new interrupt will not be serviced until the<br />

current ISR completes, including the RETI and following instruction.<br />

The CPU is stalled during Flash write/erase operations. Interrupt service latency will be increased for interrupts<br />

occurring while the CPU is stalled. The latency for these situations will be determined by the standard<br />

interrupt service procedure (as described above) and the amount of time the CPU is stalled.<br />

Rev. 1.1 49

Hooray! Your file is uploaded and ready to be published.

Saved successfully!

Ooh no, something went wrong!