我使用裸奔方式
先定义
#define NVIC_ISER0 (*(volatile unsigned long *) 0xE000E100)
#define NVIC_ICER0 (*(volatile unsigned long *) 0xE000E180)
我使用rtc秒中断定义如下
#define dis_rtc_g_it NVIC_ICER0 |= 1<<3
#define en_rtc_g_it NVIC_ISER0 |= 1<<3 //rtc全局中断
开始我写
en_rtc_g_it;
程序可以正常运行,也可以进秒中断
但是在某个地方我需要关闭它,于是我写
dis_rtc_g_it;
结果所有的中断都关了,包括timer等。
后来我干脆程序一开始不写en_rtc_g_it;,只写dis_rtc_g_it;,结果所有的中断还是都关闭了。
请问是什么原因呢,下面是官方文档
寄存器说明---------------------------------
4.2.3 Interrupt clear-enable registers (NVIC_ICERx)
Address offset: 0x00 - 0x0B
Reset value: 0x0000 0000
Required privilege: Privileged
The ICER0-ICER2 registers disable interrupts, and show which interrupts are enabled.
31 30 29 28 27 26 25 24 23 22 21 20 19 18 17 16
CLRENA[31:16]
rc_w1 rc_w1 rc_w1 rc_w1 rc_w1 rc_w1 rc_w1 rc_w1 rc_w1 rc_w1 rc_w1 rc_w1 rc_w1 rc_w1 rc_w1 rc_w1
15 14 13 12 11 10 9 8 7 6 5 4 3 2 1 0
CLRENA[15:0]
rc_w1 rc_w1 rc_w1 rc_w1 rc_w1 rc_w1 rc_w1 rc_w1 rc_w1 rc_w1 rc_w1 rc_w1 rc_w1 rc_w1 rc_w1 rc_w1
Bits 31:0 CLRENA[31:0]: Interrupt clear-enable bits.
Write:
0: No effect
1: Disable interrupt
Read:
0: Interrupt disabled
1: Interrupt enabled.
地址---------------------------------
NVIC register map
The table provides shows the NVIC register map and reset values. The base address of the
main NVIC register block is 0xE000E100. The NVIC_STIR register is located in a separate
block at 0xE000EF00.
void NVIC_SetPendingIRQ (IRQn_t IRQn) Set IRQn pending
void NVIC_ClearPendingIRQ (IRQn_t IRQn) Clear IRQn pending status
uint32_t NVIC_GetActive (IRQn_t IRQn)
Return the IRQ number of the active
interrupt
void NVIC_SetPriority (IRQn_t IRQn, uint32_t priority) Set priority for IRQn
uint32_t NVIC_GetPriority (IRQn_t IRQn) Read priority of IRQn
void NVIC_SystemReset (void) Reset the system
Table 36. CMSIS functions for NVIC control (continued)
CMSIS interrupt control function Description
Table 37. NVIC register map and reset values
Offset Register
31
30
29
28
27
26
25
24
23
22
21
20
19
18
17
16
15
14
13
12
11
10
9
8
7
6
5
4
3
2
1
0
0x000
NVIC_ISER0 SETENA[31:0]
Reset Value 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
0x004
NVIC_ISER1 SETENA[63:32]
Reset Value 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
0x008
NVIC_ISER2
Reserved
SETENA
[67:64]
Reset Value 0 0 0 0
0x080
NVIC_ICER0 CLRENA[31:0]
Reset Value 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
0x084
NVIC_ICER1 CLRENA[63:32]
Reset Value 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
0x088
NVIC_ICER2
Reserved
CLRENA
[67:64]
Reset Value 0 0 0 0
向量表--------------------------------
0 7 settable WWDG Window Watchdog interrupt 0x0000_0040
1 8 settable PVD
PVD through EXTI Line detection
interrupt
0x0000_0044
2 9 settable TAMPER Tamper interrupt 0x0000_0048
3 10 settable RTC RTC global interrupt 0x0000_004C |