2023-01-09 08:02 AM
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
2023-01-09 09:01 AM
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.
2023-01-09 10:39 AM
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...
2023-01-09 11:56 PM
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?
2023-01-10 01:06 AM
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,
2023-01-10 05:12 AM
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.
2023-01-17 05:55 AM
Hey, i can see now that inside the stm32foxx_hal_gpio.c libary
there is the following code:
void HAL_GPIO_EXTI_IRQHandler(uint16_t GPIO_Pin)
{
/* EXTI line interrupt detected */
if(__HAL_GPIO_EXTI_GET_IT(GPIO_Pin) != 0x00u)
{
__HAL_GPIO_EXTI_CLEAR_IT(GPIO_Pin);
HAL_GPIO_EXTI_Callback(GPIO_Pin);
}
}
When an interrupt is triggered, the HAL_GPIO_EXTI_Callback function will automatically clear any pending interrupts on line 6, meaning that you don't need to manually clear the pending interrupts. Is that correct?
2023-01-17 06:02 AM
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.
2023-01-24 04:31 AM
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?
2023-01-24 04:57 AM
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.