Outline: NVIC and Its Functions
Outline: NVIC and Its Functions
1 2
3 4
5 6
Exceptions and Interrupts
NVIC
7 8
9 10
!"#$%&'()*+%#,-.%#/01*
!"#"$ %&'())*+',-.'/0(,1/',2(3/4'()4
!"#$%&'()'*+,-.%&'()'*+,/$0#1234#03$2562784#$9"27"$254#00:;43$80#$8742<#=$>##$4"#$0#1234#0$
3:??80@$25$!8AB# C.D$E5$;81# C.F$GE0$4"#$0#1234#0$84402A:4#3=
!"#$A24$833215?#543$80#H$
31 0
ACTIVE bits
Interrupt Controller
OFPH-Q *(!'&M '54#00:;4$8742<#$GB813H
(NVIC) -$R$254#00:;4$5E4$8742<#
Module
The NVIC_IPR0-NVIC_IPR59
!"#"5 registers
Table 3-2. Reference links to related
%&'())*+',6)/7)/'8,2(3/4'()4
informationprovide an 8-bit
Bits Name priority field for each interrupt and each register holds four
Topic!"#$%&'()'I,-.%&'()'I,JK$0#1234#03$;0E<26#$85$L.A24$;02E024@$G2#B6$GE0$#87"$254#00:;4$856$
Related module Reference
#87"$0#1234#0$"EB63$GE:0$;02E024@$G2#B63=$!"#3#$0#1234#03$80#$A@4#.877#332AB#=$>##$4"#$0#1234#0$
Full description Nested Vectored http://www.arm.com
3:??80@$25$!8AB# C.D$E5$;81# C.F$GE0$4"#20$84402A:4#3=$M87"$0#1234#0$"EB63$GE:0$;02E024@$G2#B63$83$
priority fields. These registers are byte-accessible.
Interrupt Controller
[31:0] SETENA
3"E95H (NVIC)
System memory 31
map 24 23 16 15 System memory map
8 7 0
Function Clocking
IPR59
Power management
PRI_239 PRI_238 PRI_237 Clock distribution
PRI_236
Power management
...
...
PRI_4n
Write: 0 = no effect
...
...
This device supports 16 priority levels for interrupts. Therefore, in the NVIC each source
9:;<( !=B,%62,;/',:44/3&?(&'4
Read: 0 = interrupt disabled in the
1/'4,
K70
IPR supports
@:?(
16 priority
registers contains 4 bits. levels
A*&.'/7&
for interrupts.
For example, Therefore,
IPR0 is shown below: in the NVIC each
source in the IPR registers contains 4 bits. For example, IPR0 is shown below:
1 = interrupt enabled. OFPHDCQ$
ODFHPTQ$
31
I02E024@N$A@4#$EGG3#4$F$
30 29 28 27 26
I02E024@N$A@4#$EGG3#4$D
25
M87"$2?;B#?#54842E5.6#G25#6$;02E024@$G2#B6$785$"EB6$8$;02E024@$<8B:#N$-.DJJ=$!"#$
24 23 22 21 20 19 18 17 16 15 14 13 12 11 10 9 8 7 6
BE9#0$4"#$<8B:#N$4"#$10#84#0$4"#$;02E024@$EG$4"#$7E00#3;E56251$254#00:;4=$,#1234#0$
;02E024@$<8B:#$G2#B63$80#$#21"4$A243$926#N$856$5E5.2?;B#?#54#6$BE9.E06#0$A243$0#86$83$
5 4 3 2 1 0
R 0 0 0 0 0
S#0E$856$215E0#$9024#3= 0 0 0 0 0 0 0 0 0 0 0
OPJHLQ$ IRQ3
I02E024@N$A@4#$EGG3#4$P IRQ2 IRQ1 IRQ0
W
O/H-Q$ I02E024@N$A@4#$EGG3#4$-
>##$!""#$$%&'()*#(+,-)#./01(234+(-#'%$)#-$(5$%&'(+0646$E5$;81# C.C$GE0$?E0#$25GE0?842E5$
8AE:4$4"#$877#33$4E$4"#$254#00:;4$;02E024@$8008@N$9"27"$;0E<26#3$4"#$3EG4980#$<2#9$EG$4"#$254#00:;4$
11 12
3.2.2.2 ;02E0242#3=
Non-maskable interrupt
The non-maskable interrupt request to the NVIC is controlled by the external NMI signal.
!"#$%&'$())*! !"-2#,3.$*4 5676*89(:*800*#,3.$1*#%1%#;%<: +,-
'%./.0.( The pin the NMI signal is multiplexed
=">'!">?,<%>$,/0 on, must be configured for the NMI function to
generate the non-maskable interrupt request.
Vector number the value stored on the stack when an interrupt is serviced.
IRQ number non-core interrupt source count, which is the vector number minus
16.
The IRQ number is used within ARM's NVIC documentation.
register register
Find the IPR number and byte offset for interrupt m as number number
2 3
follows:
ARM Core System Handler Vectors
0x0000_0000 0 ARM core Initial Stack Pointer
0x0000_0004 1 ARM core Initial Program Counter
the corresponding IPR number, n is given by n = m 0x0000_0008 2 ARM core Non-maskable Interrupt (NMI)
0x0000_000C 3 ARM core Hard Fault
0x0000_016C 91 75 2 18
Detect
Ethernet MAC IEEE 1588 Timer Interrupt
Set up the LPT interrupt:
0x0000_0170 92 76 2 19 Ethernet MAC Transmit interrupt Locate the interrupt vector that you want on the Vector Table list
0x0000_0174 93 77 2 19 Ethernet MAC Receive interrupt
from the Kinetis device used
0x0000_0178 94 78 2 19 Ethernet MAC Error and miscellaneous interrupt
0x0000_017C 95 79 2 19
0x0000_0180 96 80 2 20 SDHC
0x0000_0184 97 81 2 20 DAC0
0x0000_0188 98 82 2 20 DAC1
0x0000_018C 99 83 2 20 TSI Single interrupt vector for all sources
0x0000_0190 100 84 2 21 MCG
0x0000_0194 101 85 2 21 Low Power Timer
0x0000_0198 102 86 2 21
Find the NVIC Interrupt Set Enable Register (NVICISERx) for your vector:
0x0000_019C 103 87 2 21 Port control Pin detect (Port A) NVICISER2 for the LPT
module
0x0000_01A0 104 88 2 22 Port control Pin detect (Port B) Then take the modulo value of your IRQ number by 32 to calculate which bit
module
to set in the NVICISER2 register
0x0000_01A4 105 89 2 22 Port control Pin detect (Port C)
module 85%32 = 21
Table continues on the next page...
NVICISER2 |=(1<<21); //Enable LPT interrupts
!"#$%&'()*+%#,-.%#/01*
17 ++
.
- - # 18
:*7:>):7<9'
=*+#&"/3'#/$0$4+'+0#!>?"#&2#'*+#!>?#"345+0)#2++#=$5:+ @ABC#("#/$;+ @A@@D#E(0#4(0+#
:*7:!>:7<9/' ++
.
- - #
:*7:*;:7<9%' ++
=
.
- - #
&"6(04$'&("#$5(3'#'*+2+#63"7'&("2#2++#'*+#,-.!.#%(734+"'$'&("D