简体   繁体   中英

stm32 interrupt configurations goes wrong

Good morning, I am dealing with a problem of turing off interrupts on selected pin while another one is set. My MCU is stm32f4xx.
I mean that, I have set PC0, PC1, PC2, PC3, PB14, PB15 on GPIO_MODE_IT_FALLING detect and when I set the pin PA1, PA2, PA3, PA4 as GPIO_MODE_IT_RISING_FALLING detect, PC and PB do not works.
If PC-PB is set individually it works. If I set additional PA1-4 the pins PC-PB just forgot about interrupt. Code below for every PC0-3 and PB14-PB15:

GPIO_InitTypeDef GPIO_InitStruct = {0};
GPIO_InitStruct.Pin = FAULT1_Pin;
GPIO_InitStruct.Mode = GPIO_MODE_IT_FALLING;
GPIO_InitStruct.Pull = GPIO_PULLUP;
HAL_GPIO_Init(GPIOC, &GPIO_InitStruct);

HAL_NVIC_SetPriority(EXTI0_IRQn, 5, 0); // EXTI0_IRQn changes on dependently on selected pins e.g. EXTI15_10_IRQn
HAL_NVIC_EnableIRQ(EXTI0_IRQn); // here the same

and after I iterate for every pin PC0-3 and PB14-15 I am using the same pattern for PA2-PA4 like this:

GPIO_InitTypeDef GPIO_InitStruct = { 0 };
GPIO_InitStruct.Pin = GPIO_PIN_1;
GPIO_InitStruct.Mode = GPIO_MODE_IT_RISING_FALLING;
GPIO_InitStruct.Pull = GPIO_PULLUP;
HAL_GPIO_Init(GPIOA, &GPIO_InitStruct);
/* EXTI interrupt init*/
HAL_NVIC_SetPriority(EXTI1_IRQn, 5, 0);
HAL_NVIC_EnableIRQ(EXTI1_IRQn);
HAL_NVIC_SetPriority(EXTI2_IRQn, 5, 0);
HAL_NVIC_EnableIRQ(EXTI2_IRQn);
HAL_NVIC_SetPriority(EXTI3_IRQn, 5, 0);
HAL_NVIC_EnableIRQ(EXTI3_IRQn);
HAL_NVIC_SetPriority(EXTI4_IRQn, 5, 0);
HAL_NVIC_EnableIRQ(EXTI4_IRQn);

and then the interrupt on pins PC, PB disappear. Only iterrupts from PA works fine. How to write a program that allows PC, PB and PA interrupts works? I am also using FreeRTOS, maybe here is a problem?

Sadly this is a "feature" of the STM32 family. What you want cannot be done.

You have to arrange your pinout to account for this: You can only have an interrupt on one letter for each number (eg: PA2 or PB2 not both).

Another limitation is that numbers 5-9 and 10-15 share interrupts. You can have interrupts on eg: PA5,PB6,PA7,PB8,PC9 but they will cause the same handler to run. Obviously you can then read the GPIO input in the handler but if the signal is momentary and has gone away by the time the handler runs you will not know which signal occurred.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM