background image

EXTERNAL INTERRUPTS 

Chapter 2 External Interrupts 

MCU-AN -300203-E-V17 

- 6 - 

© Fujitsu Microelectronics Europe GmbH 

2 External Interrupts 

THE BASIC FUNCTIONALITY OF THE EXTERNAL INTERRUPT MODULE 

2.1 Block 

Diagram 

Figure 2-1 shows the internal block diagram of an External Interrupt channel. 

Figure 2-1: External Interrupts  Block Diagram 

 

2.2 Connection 

Diagram 

Figure 2-2 shows the connection diagram depicting how the external interrupt pin INTn is 
interfaced to the external circuitry.  

The pull up resistor R is connected to limit the current when the key is pressed. The 
capacitor (hardware debounce) circuit shown with the dotted line is optional and is used to 
eliminate the bouncing of the switch. The RC time constant needs to be chosen according to 
the bouncing time or debounce delay of the switch. If such arrangement is not used then the 
bouncing needs to be taken care in the software and also vice a versa. 

Here the INTn needs to be configured to detect a falling edge. 

 

Figure 2-2: External Interrupts Connection Diagram 

C

R

Vcc

MCU 

 

INTn 

Pin INTn 

Interrupt 
Request 

Edge 

Detection  

Circuit 

MCU 

Summary of Contents for ALL Series

Page 1: ...Fujitsu Microelectronics Europe Application Note MCU AN 300203 E V17 F MC 16FX FAMILY 16 BIT MICROCONTROLLER ALL SERIES EXTERNAL INTERRUPTS APPLICATION NOTE ...

Page 2: ...7 02 21 V1 2 Updated with re review findings from PHu MPi 2007 03 01 V1 3 Updated with re review findings from HWe MPi 2007 06 05 V1 4 Updated with re review findings from PHu MPi 2007 08 23 V1 5 Fixed typos added flowchart and modified code for disturbed signal MPi 2007 08 28 V1 6 Updated key features and added external interrupt timing MPi 2008 06 24 V1 7 add information on Port Input Enable PHu...

Page 3: ...y the customer 2 Should a Product turn out to be defect Fujitsu Microelectronics Europe GmbH s entire liability and the customer s exclusive remedy shall be at Fujitsu Microelectronics Europe GmbH s sole discretion either return of the purchase price and the license fee or replacement of the Product or parts thereof if the Product is returned to Fujitsu Microelectronics Europe GmbH in original pac...

Page 4: ...terrupt Enable Register ENIR 7 2 3 2 External Interrupt Request Register EIRR 7 2 3 3 Request Level Setting Register ELVR 7 2 3 4 Port Input Enable Register 7 3 EXTERNAL INTERRUPT TIMING 8 4 EXTERNAL INTERRUPT EXAMPLES 9 4 1 Basic Functionality 9 4 2 Disturbed Signals 10 4 2 1 Sequence Diagram 11 4 2 2 External Interrupts and DMA 14 4 3 External Interrupts and Wake Up from Stop Mode 14 4 3 1 Examp...

Page 5: ...ibes the functionality of the External Interrupts and gives some examples 1 1 Key Features The external interrupts have the following features Edge sensitivity rising and falling selectable Level sensitivity low and high selectable ISR execution is started in 200 ns minimum 10 CPU cycles after first rising falling edge at external interrupt pin ...

Page 6: ...terfaced to the external circuitry The pull up resistor R is connected to limit the current when the key is pressed The capacitor hardware debounce circuit shown with the dotted line is optional and is used to eliminate the bouncing of the switch The RC time constant needs to be chosen according to the bouncing time or debounce delay of the switch If such arrangement is not used then the bouncing ...

Page 7: ... the corresponding Interrupt Enable bit is disabled 2 3 3 Request Level Setting Register ELVR This register contains a pair of control bits LBx LAx for each channel for the detection kind The following table shows the possible settings LBx LAx Functionality 0 0 L Level Input 0 1 H Level Input 1 0 Rising Edge Pin Input 1 1 Falling Edge Pin Input Table 2 1 ELVR Where x 0 to 7 for ELVR0 and 8 to 15 f...

Page 8: ...nitely more than all other instructions For further details please refer section 2 4 2 of Interrupts application note MCU AN 300210 Time required for the context saving is dependent on various factors Those are described in section 2 4 1 of Interrupts application note MCU AN 300210 The above mentioned time of 10 cycles is the minimum timing required for context saving External interrupt ISR execut...

Page 9: ...NY ERRORS OR ELIGIBILITY FOR ANY PURPOSES C Fujitsu Microelectronics Europe GmbH void InitIrqLevels void ICR 17 0xFF 8 6 Priority Level 6 for External Interrupt 0 of MB96340 Series __interrupt void IRQHandler_EI0 void Prototype pragma intvect IRQHandler_EI0 17 EXT0 of MB96340 Series THIS SAMPLE CODE IS PROVIDED AS IS AND IS SUBJECT TO ALTERATIONS FUJITSU MICROELECTRONICS ACCEPTS NO RESPONSIBILITY ...

Page 10: ... at External Interrupt input pin INT0 the interrupt service routine IRQHandler_EI0 will be executed and since the initial value of FLAG variable is TRUE the Reload Timer RLT0 will be started A in the above figure and no further processing would happen After 0 26 seconds debouncing time this can be chosen depending upon the type of key switch the interrupt service routine IRQHandle_RLT0 will be exe...

Page 11: ...ag remains set Consecutive rising edges at INT0 debounce of key Return Return RLT0 key debounce timer started Trigger RLT0 and enable RLT0 interrupt Clear El0 interrupt flag and disable EI0 interrupt EI0 interrupt flag cleared EI0 interrupts disabled IRQHandler_EI0 First rising edge at INT0 Key press Waiting for External interrupt External Interrupt channel 0 is initialized for rising edge interru...

Page 12: ...st ENIR0_EN0 1 enable interrupt request void InitRLT0 void TMRLR0 0xFFFF Reload value about 0 26 s 16 MHz TMCSR0 0x0800 Prescaler 1 64 void main void InitRLT0 initialize RLT0 InitExtInt0 initialize EXT0 while 1 __interrupt void IRQHandler_EI0 void EIRR0_ER0 0 clear interrupt request if FLAG TRUE ENIR0_EN0 0 disable interrupt request Figure 3 1 A TMCSR0_UF 0 clear Reload Timer 0 TMCSR0_TRG 1 trigge...

Page 13: ...E IS PROVIDED AS IS AND IS SUBJECT TO ALTERATIONS FUJITSU MICROELECTRONICS ACCEPTS NO RESPONSIBILITY OR LIABILITY FOR ANY ERRORS OR ELIGIBILITY FOR ANY PURPOSES C Fujitsu Microelectronics Europe GmbH void InitIrqLevels void ICR 17 0xFF 8 6 Priority Level 6 for External Interrupt 0 of MB96340 Series ICR 51 0xFF 8 5 Priority Level 5 for Reload Timer 0 of MB96340 Series __interrupt void IRQHandler_EI...

Page 14: ...hout noise would appear at the external interrupt pin 4 3 External Interrupts and Wake Up from Stop Mode 4 3 1 Example I The following example shows that External Interrupts can be used to request a stop mode and can wake up the MCU from this mode External Interrupt 0 is used to wake up the MCU and External Interrupt 1 is used to request a stop mode Before stop mode 0x0F is written to Port00 durin...

Page 15: ... STOPREQUEST stop mode request PDR00 0x0F SMCR 0x03 goto stop mode preserve pin state else run mode for i 0 i 50000 i wait loop __asm NOP __asm NOP PDR00 show that MCU is running ISR external Int 0 __interrupt void IRQ_extint0 void status RUNMODE EIRR0_ER0 0 clear ext int 0 request flag ENIR0_EN0 0 disable ext int0 EIRR0_ER1 0 clear ext int 1 request flag ENIR0_EN1 1 enable ext int1 ISR external I...

Page 16: ...TSU MICROELECTRONICS ACCEPTS NO RESPONSIBILITY OR LIABILITY FOR ANY ERRORS OR ELIGIBILITY FOR ANY PURPOSES C Fujitsu Microelectronics Europe GmbH void InitIrqLevels void ICR 17 0xFF 8 6 Priority Level 6 for External Interrupt 0 of MB96340 Series ICR 18 0xFF 8 6 Priority Level 6 for External Interrupt 1 of MB96340 Series __interrupt void IRQ_extint0 void Prototype EXT0 __interrupt void IRQ_extint1 ...

Page 17: ...FUJITSU MICROELECTRONICS ACCEPTS NO RESPONSIBILITY OR LIABILITY FOR ANY ERRORS OR ELIGIBILITY FOR ANY PURPOSES C Fujitsu Microelectronics Europe GmbH Initialise external int 0 void Init_extint0 void ADER2_ADE16 0 select IO mode PIER07_IE0 1 ENIR0_EN0 0 disable ext int 0 ELVR0_LA0 1 ELVR0_LB0 1 LB0 LA0 11 falling edge EIRR0_ER0 0 clear ext int 0 request flag Request stop mode void Request_stop void...

Page 18: ...Information Information about FUJITSU Microcontrollers can be found on the following Internet page http mcu emea fujitsu com The software examples related to this application note is 96340_irq_ext 96340_irq_ext_stop_wakeup It can be found on the following Internet page http mcu emea fujitsu com mcu_product mcu_all_software htm ...

Page 19: ...U AN 300203 E V17 List of Figures Figure 2 1 External Interrupts Block Diagram 6 Figure 2 2 External Interrupts Connection Diagram 6 Figure 3 1 External Interrupt Timing 8 Figure 4 1 Interrupt Timing Disturbed Input Signal 10 Figure 4 2 Sequence Diagram Disturbed Input Signal 11 ...

Page 20: ...EXTERNAL INTERRUPTS List of Tables MCU AN 300203 E V17 20 Fujitsu Microelectronics Europe GmbH List of Tables Table 2 1 ELVR 7 ...

Reviews: