Liebes Forum,
ich programmiere einen STM32F303 und verwende auch die stm32_library. An
einer bestimmten Stelle im Code möchte ich einen Software-Interrupt
auslösen.
Die Initialisierung für den Software-Interrupt, seht ihr unten im Code.
Den Interrupt auslösen habe ich mit folgendem Code versucht:
1 | EXTI->SWIER |= (uint32_t)(0x1 << EXTI_Line2); // generate software interrupt(EXTI_Line2)
|
2 | *(volatile uint32_t*)(((uint32_t)&(EXTI->SWIER)) + ((EXTI_Line2) >> 5U) * 0x20U)
|
3 | |= (uint32_t)(1U << (EXTI_Line2& 0x1FU));
|
Die Initialisierung:
1 | #define EXTI2_Line2_Mask ((uint32_t)(0x1UL << (EXTI_Line2& 0x1FUL)))
|
2 | #define EXTI2_Line2_BaseAddresse ((uint32_t)(((EXTI_Line2) >> 5U) * 0x20U))
|
3 |
|
4 | uint32_t *pEXTI_Line2;
|
5 |
|
6 | void Init_EXTI_2(EXTI_InitTypeDef *pEXTI_InitStruct)
|
7 | {
|
8 | pEXTI_InitStruct->EXTI_Line = EXTI_Line2;
|
9 | pEXTI_InitStruct->EXTI_Mode = EXTI_Mode_Interrupt;
|
10 | pEXTI_InitStruct->EXTI_Trigger = EXTI_Trigger_Rising;
|
11 | pEXTI_InitStruct->EXTI_LineCmd = ENABLE;
|
12 |
|
13 | pEXTI_Line2 = (uint32_t*)(((uint32_t)&(EXTI->PR)) + EXTI2_Line2_BaseAddresse);
|
14 | *pEXTI_Line2 |= EXTI2_Line2_Mask; // clear pending EXTI 2 interrupt
|
15 |
|
16 | EXTI_Init(pEXTI_InitStruct); // enable software interrupt line
|
17 |
|
18 | NVIC_SetPriority(EXTI2_TS_IRQn, 10);
|
19 | NVIC_EnableIRQ(EXTI2_TS_IRQn);
|
20 | }
|
21 |
|
22 | //------------------------------------------------------------------------------
|
23 | void EXTI2_IRQHandler(void)
|
24 | {
|
25 | if((*pEXTI_Line2 & EXTI2_Line2_Mask) != 0U)
|
26 | {
|
27 | // Code
|
28 | *pEXTI_Line2 |= EXTI2_Line2_Mask; // clear pending EXTI 2 interrupt
|
29 | ade791x_calc_values();
|
30 | }
|
31 | else
|
32 | {
|
33 | // *pEXTI_Line3 |= EXTIx_LineMaskExceptActiv; // clear others pending EXTI x interrupts
|
34 | }
|
35 | }
|
Der Interrupt wird leider nicht ausgelöst. Ich bin für jeden Tipp
dankbar!!
LG