cancel
Showing results for 
Search instead for 
Did you mean: 

External IRQ control via Cortex library or via HAL library

LVara.1
Associate II

Hi, I'm trying to use IRQ Software calls with Nucleo-F4 boards in STMCubeMx 1.8 environment.

The UM1725 - Rev 7, pag. 346, tells me to use the HAL_Generate_SWI.

The call, included in stm32f4xx_hal_exti, requires you to define two simple structures: EXTI_HandleTypeDef and EXTI_ConfigTypeDef and the test program seems to work.

I have noticed that when I generate the configuration code with MX, the NVIC libraries are still used for interrupts , present in stm32f4xx_hal_cortex. In the Cortex Library there in no SW IRQ generation call.

The questions are these:

for external interrupts, when to use the library in stm32f4xx_hal_exti and when to use those in stm32f4xx_hal_cortex?

 Anyone have an example of SWI interrupt handling for F4 models? (nothing in the web)

 Many Thanks.

LV

15 REPLIES 15
Pavel A.
Evangelist III

@Community member​ From your questions it looks like you are very new to STM32.

If so, you can find helpful online STM32 education materials on STM32L4.

The STM32L4 family is similar to F4.

See the NVIC and EXTI presentations.

The HAL EXTI functions program the unit that signals the NVIC hardware. It generates several interrupt signals, from pin or other resources. Mapping individual or blocks of pins.

The NVIC is used for all the other interrupt sources too.

Tips, Buy me a coffee, or three.. PayPal Venmo
Up vote any posts that you find helpful, it shows what's working..
LVara.1
Associate II

Thank you for the interesting emails, but maybe I'm not clear in my doubts.

In trying to generate a software interrupt, I wanted to use tools

high-level like HAL libraries (register programming is possible as I used to 30 or 40 years ago, but now it's a bit boring, and maybe I'm not old enough anymore).

In fact, in the file stm32f7xx_hal_exti (NOT in stm32f4xx_hal_cortex) I found a useful call:

HAL_Exti_GenerateExti (), and I tried to read up on UM1725.

In the 2017 version of this document it does not mention it. Strange.

In the 2021 version I found some pages.

But here are some notes:

a)

the documentation talks about "line_X", not GPIO_PIN_X. No problem it's about doing some simple #define (me, not MX).

b)

The documentation talks about defining a CallBack of type void ..mmm .. the call back in use with the HAL_GPIO_EXTI_IRQHandler calls use one parameter: the GPIO_PIN_X. I'll make my own callBack.

c)

The documentation does NOT clarify how to recognize the HW call from the SW calls ... mmmm ....

In short, perhaps with an example project (perhaps STM) I could clarify some doubts.

Note: Document UM1725 - Rev 7 there are several silly errors; for example at 25.2.2 point 3 (I didn't have time to read it all).

Thanks

LV

Pavel A.
Evangelist III

> In trying to generate a software interrupt

Trigger an EXTI interrupt by software? Trigger some other interrupt by software? Trigger SWI?

You may be having A/B problem.

 __HAL_GPIO_EXTI_GENERATE_SWIT(pinmask) // For pins 0 thru 15, arguable EXTI[0..21] on an L4

__HAL_GPIO_EXTI_GENERATE_SWIT(1 << 8); // -> EXTI9_5_IRQHandler

LL_EXTI_GenerateSWI_0_31(uint32_t ExtiLine); // large subset of these

LL_EXTI_GenerateSWI_32_63(uint32_t ExtiLine) // typically some subset of these

HAL_EXTI_GenerateSWI(EXTI_HandleTypeDef *hexti) // subset of the EXTI source 0..63

These will go into the EXTIxx_IRQHandlers (say EXTI1, or EXTI_PVD(16), TAMP(21), RTC)

You can generate ANY NVIC interrupt via NVIC->STIR, ie USART6_IRQHandler

Tips, Buy me a coffee, or three.. PayPal Venmo
Up vote any posts that you find helpful, it shows what's working..

#define __HAL_ETH_WAKEUP_EXTI_GENERATE_SWIT()         EXTI->SWIER|= ETH_EXTI_LINE_WAKEUP

Vectors

...

        DCD   ETH_WKUP_IRQHandler        ; Ethernet Wakeup through EXTI line

Tips, Buy me a coffee, or three.. PayPal Venmo
Up vote any posts that you find helpful, it shows what's working..

It could be the right way. But from which document (or which documents) did you get the information? I always wish to be well documented, there are always side effects.

I would like to deepen the study on HAL_EXTI_GenerateSWI (); if I understand correctly, there MUST exist an external pin to be used as a possible sw interrupt generator, but this raises numerous practical questions: a) who generated the interrupt? the HW or the SW? b) how to manage a possible callback? (read my clarification carefully)

Many thanks

LVara.1
Associate II

I don't quite understand your A / B concerns. Can you clarify better? Do you mean conflicts on the BUS? I accept all suggestions, I am trying to create a document on SW interrupt on M4micro Thanks LV

ARM documents the NVIC

ST documents the EXTI->SWIER

You're generating it in software, write some memory location or flag your downstream software can act against. Use something you're not architecturally using for anything else.

My reading of the docs is that the bit will remain pending in the SWIER score board until you clear it via the PR register, so you should be able to see that, and validate the behaviour as needed.

Don't have EXTI4_IRQHandler() call into the HAL, you won't get a call-back and you can service it there and then.

>>The documentation does NOT clarify how to recognize the HW call from the SW calls

At the register level, I don't think it cares. It's just another cheap method, like SVC x, to TRAP into system space, perhaps blocking other interrupts, with lesser priority, in the process. The pending status gets clear using standard methods.

Tips, Buy me a coffee, or three.. PayPal Venmo
Up vote any posts that you find helpful, it shows what's working..