Skip to main content
YShko.1
Associate III
January 9, 2023
Question

Why there are two pending registers for interrupt? ,e.g EXTI_PR and ISPR

  • January 9, 2023
  • 5 replies
  • 5761 views

Why there are two pending registers for interrupt? One of them is EXTI_PR and other one is Interrupt Set-pending Registers(ISPR) which is in NVIC controller registers.?

What is the diffrence between them?

Thanks in advance

0693W00000Y7kiOQAR.png0693W00000Y7kiYQAR.png 

This topic has been closed for replies.

5 replies

Pavel A.
Super User
January 9, 2023

This is because EXTI from the ARM point of view is one of vendor-provided peripherals. It supplies several interrupt entries to NVIC. The NVIC is defined by ARM architecture.

​Note also that several EXTI interrupt sources can share one NVIC vector, so you'll need the EXTI register to identify and clear the source.

YShko.1
YShko.1Author
Associate III
January 10, 2023

So for example lets say I want in my code to clear a pending interupt.

Which register i need to go and programmatically clear its bit?

Pavel A.
Super User
January 10, 2023

For example:

void EXTI15_10_IRQHandler(void)
{
 if (__HAL_GPIO_EXTI_GET_IT(GPIO_PIN_11) {
 __HAL_GPIO_EXTI_CLEAR_IT(GPIO_PIN_11);
 __DMB();
 my_handle_EXTI_11();
 } 
 //else ....
}

If you use HAL call HAL_GPIO_EXTI_IRQHandler(GPIO_PIN_11), it will check and clear the EXTI and call a callback defined in your code,

S.Ma
Principal
January 9, 2023

PR are just edge detectors that can be used without interrupts, in regular time interval, for example. Some of exti signal can go trigger interrupt, or become hw trigger signal without it...

gbm
Lead III
January 10, 2023

To clear EXTI interrupt request, clear the flag in EXTI. NVIC ISPR registers are only used when generating the interrupts in software and normally there is no need to use NVIC ICPR - the requests in NVIC are cleared by NVIC hardware when the ISR is invoked.

My STM32 stuff on github - compact USB device stack and more: https://github.com/gbm-ii/gbmUSBdevice
ST Employee
January 17, 2023

Hello @YShko.1​ ,

The EXTI_PR register is read-only and it is used to indicate which external interrupts are pending, while the NVIC_ISPR0-7 registers are writable and used to force interrupts into the pending state.

Both registers are used to indicate which interrupts are pending, but the NVICI_SPR registers can also be used to manually set interrupts to a pending state.

To give better visibility on the answered topics, please click on Accept as Solution on the reply which solved your issue or answered your question.
YShko.1
YShko.1Author
Associate III
January 24, 2023

Thank you very much @Sarra.S​ 

I think i starting to get the idea. So for example I have 4 input pins(3,4,5,6) which are interrupted, and I want to clear all of them, I need to use the void NVIC_ClearPendingIRQ(IRQn_Type IRQn) Function, However it will clear all the pins (4-15)!

How can I clear only pin 6 in this vector?

ST Employee
January 24, 2023

Hello again @YShko.1​,

You can clear a specific pin in the vector by passing the corresponding IRQn_Type into the NVIC_ClearPendingIRQ function.

In fact, the parameter IRQn is the External interrupt number

So you need to find the The IRQnType for pin 6 and then pass into the function to clear the pin 6 interrupt.

Note : For the complete STM32 Devices IRQ Channels list, please refer to the appropriate CMSIS device file of your specific device (stm32xx.h)

Hope that helps!

To give better visibility on the answered topics, please click on Accept as Solution on the reply which solved your issue or answered your question.
YShko.1
YShko.1Author
Associate III
January 24, 2023

Hey @Sarra.S​ 

IRQn_Type is an enum, Here is a picture from stm32f030x8.h :

0693W00000Y92DQQAZ.pngas you can see in the picture I cant choose a specific line, only a vector, e.g EXTI4_15_IRQn which is coresponding to all the lines 4-15. so I dont really understand how can I use this function to a specific line?

thank you for your time!!

Pavel A.
Super User
January 25, 2023

To clear one EXTI source you use __HAL_GPIO_EXTI_CLEAR_IT or call HAL_GPIO_EXTI_IRQHandler. No need to clear the NVIC interrupt, it should clear itself as soon as the EXTI drops its interrupt request.