Interrupciones
Interrupciones
13 Reserved N/A —
… … … …
o System_LPC17xx.c
o Startup_LPC17xx.s
IRQ
12 12
o Inactive:
n The exception is not active and not pending.
o Pending:
n The exception is waiting to be serviced by the processor.
n An interrupt request from a peripheral or from software can
change the state of the corresponding interrupt to pending.
o Active:
n An exception that is being serviced by the processor but has not
completed.
n An exception handler can interrupt the execution of another
exception handler. In this case both exceptions are in the active
state.
o Active and pending
n The exception is being serviced by the processor and there is a
pending exception from the same source.
o To disable exceptions:
n PRIMASK
o A 1-bit register, when this is set, it allows nonmaskable
interrupt (NMI) and the hard fault exception; all other
interrupts are masked.
n FAULTMASK
o A 1-bit register, when this is set, it allows only the NMI and all
other interrupts and fault handling exceptions are disabled.
n BASEPRI
o A register of up to 8-bits (depending on the bit-width
implemented for the priority level). It defines the masking
priority level. When this is set, it disables all interrupts of the
same or lower level; higher priority interrupts are still allowed.
o Exception enables.
o Setting or clearing exceptions to/from the
pending state.
o Exception status (Inactive, Pending, or Active).
Inactive is when an exception is neither Pending nor
Active.
o Priority setting (for configurable system
exceptions)
o The exception number of the currently executing
code and highest pending exception.
o The PRIGROUP field allows us to change the size of the preemption group
field and priority subgroup. On reset this field defaults to priority group
zero.
o So, for example, if our MCU has four active priority bits we could select
priority group 5, which would give us four levels of preemption each with four
levels of subpriority.
o Each priority register is divided into four eight bit priority fields,
each field being assigned to an individual interrupt vector.
o LPC176x Interrupt Vectors starts at ISR #16 (vector offset
0x40)
o Lower numbers are higher priority.
o The LPC17xx only uses 5 bits of this field to implement 32
levels of priority.
n However, you should note that the active priority bits are in the upper 5
bits of each priority field.
o By default the priority field defines levels of priority with level
zero the highest and 32 the lowest.
o Format the priority field into priority groups (pre-emption) and
subgroups (sub-levels).
o We have two interrupts in our system - EINT0 and GPIO Interrupt (shared
with EINT3 channel) and we want to assign both interrupts under different
groups where EINT0 has a higher pre-empting priority than GPIO
Interrupt (EINT3):
n We can set PRIGROUP to 4 which will define 3 groups (3 bits) and 2 sub-levels (2 bits).
n We set priority field (bit 23:19) of EINT0 to 0 so it will 00000 which means EINT0 is from
group 0 and has sub-priority of 0 within group 0.
n We set priority field (bit 15:11) of GPIO Interrupt (EINT3) to 4 so it will be 00100 which
means GPIO Interrupt (EINT3) is from group 1 and has sub-priority of 0 within group 1.
n So if GPIO Interrupt is in the process of being serviced and if EINT0 is triggered, then EINT0
will be immediately serviced and upon completion, CPU will finish where if left off in the GPIO
Interrupt ISR routine (example of Nested Interrupt – Pre-emption).
o We have two interrupts in our system - EINT0 and GPIO Interrupt (shared
with EINT3 channel) and we want to assign both interrupts under the
same group with different sub-priorities where GPIO Interrupt has a
higher sub-priority than EINT0:
n We can set PRIGROUP to 4 which will define 3 groups (3 bits) and 2 sub-levels (2 bits).
n We set priority field (bit 23:19) of EINT0 to 2 so it will 00010 which means EINT0 is from
group 0 and has sub-priority of 2 within group 0.
n We set priority field (bit 15:11) of GPIO Interrupt (EINT3) to 1 so it will be 00001 which
means GPIO Interrupt (EINT3) is from group 0 and has sub-priority of 1 within group 0.
n So if both interrupts take place at the same time, GPIO Interrupt will be serviced first and then
EINT0 Interrupt (example of Tail-Chaining)
31 24 23 16 15 8 7 0
o It always run until the enable bit in the SYSTICK Control and
Status register is cleared.
o 2 configurable Clock
sources.
o Initialization (3 steps)
n Step1: Specify the RELOAD value.
n Step2: Clear the counter via NVIC_CURRENT
n Step3: Set CLK_SRC=1, interrupt action (INTEN), and enable counter
(ENABLE) via NVIC_CTRL.
Address 31-24 23-17 16 15-3 2 1 0 Name
$E000E010 0 0 COUNT 0 CLK_SRC INTEN ENABLE NVIC_ST_CTRL_R
$E000E014 0 24-bit RELOAD value NVIC_ST_RELOAD_R
$E000E018 0 24-bit CURRENT value of SysTick counter NVIC_ST_CURRENT_R
o CMSIS function:
n SysTick_Config(uint32_t ticks)
o CMSIS is a vendor-independent
hardware abstraction layer (HAL)
for the Cortex-M processor series.
Only Ext.
Interrupt.
o The registers in the various UARTs can now be referred in the user
code as shown below:
n LPC_UART1->DR // is the data register of UART1.
n Access Definitions for each peripheral. In case of multiple peripherals that are using
the same register layout typdef, multiple access definitions exist (LPC_UART0,
LPC_UART2).
o #define SysTick ((SysTick_Type *) Systick_BASE) /* SysTick access definition */
core_cmInstr.h
No añadir en la
nueva versión !! core_cmFunc.h
o system_LPC17xx.c
uint32_t SystemCoreClock
= __CORE_CLK;
/*!< System Clock
Frequency (Core Clock)*/
5 bits
(LPC17xx)
o core_cm3.h: