Hallo zusammen,
Ich benutze in meinem STM32 Programm mehrere Interrupts.
Einer soll dabei die geringste Priorität kriegen, die anderen also nicht
unterbrechen.
1 | // Configure the NVIC Preemption Priority Bits
|
2 | NVIC_PriorityGroupConfig(NVIC_PriorityGroup_2);
|
3 |
|
4 | NVIC_InitTypeDef NVIC_InitStruct;
|
5 | NVIC_InitStruct.NVIC_IRQChannelCmd = ENABLE;
|
6 | NVIC_InitStruct.NVIC_IRQChannelPreemptionPriority = 0;
|
7 | NVIC_InitStruct.NVIC_IRQChannelSubPriority = 0;
|
8 | NVIC_InitStruct.NVIC_IRQChannel = EXTI9_5_IRQn;
|
9 | NVIC_Init(&NVIC_InitStruct);
|
10 |
|
11 |
|
12 | NVIC_InitStruct.NVIC_IRQChannelPreemptionPriority = 1;
|
13 | NVIC_InitStruct.NVIC_IRQChannelSubPriority = 0;
|
14 | NVIC_InitStruct.NVIC_IRQChannel = WWDG_IRQn;
|
15 | NVIC_Init(&NVIC_InitStruct);
|
Zum Testen benutze ich einen leeren Interrupt, lösche also das IRQ Bit
nicht, wodurch der Interrupt permanent anliegt.
1 | extern "C" void EXTI9_5_IRQHandler(void) {
|
2 | }
|
Mit NVIC_PriorityGroupConfig(NVIC_PriorityGroup_2); lege ich fest, dass
2 Bits für Pre-Emption verwendet werden.
Also wenn ich den Watchdog auf
1 | NVIC_InitStruct.NVIC_IRQChannelPreemptionPriority = 1; oder
|
2 | NVIC_InitStruct.NVIC_IRQChannelPreemptionPriority = 2; oder
|
3 | NVIC_InitStruct.NVIC_IRQChannelPreemptionPriority = 3;
|
setze, darf er den EXTI nicht unterbrechen.
Es klappt aber nur mit 2 und 3, nicht mit 1!
Gleiches Spiel, wenn NVIC_PriorityGroup_3 oder NVIC_PriorityGroup_4
setze.
Nur wenn das oberste Bit im Prioritätsregister gesetzt ist, unterbricht
der Watchdog den EXTI nicht.
Ich will nur wissen, ob ich einen Fehler mache oder der STM32 einen hat.
Danke :)