5

I'm trying to get the external interrupt running on a Nucleo-F030R8 and hit a wall.

Everything is configured and runs just fine in step mode but when I'm connecting my board to another testboard with a simple jumper wire and run the same code, an External Interrupt is triggered even when that testboard (a second Nucleo-F302R8, which should only produce a single signal peak that I want to measure with the first) is not turned on.

I'm using a mix of the HAL Library from STM and a bit code of my own.

Has somebody eventually encountered a similar problem? I'm using the System Workbench for STM32.

Part of the ISR, Interrupthandler is cut

void EXTI0_1_IRQHandler(void)
{
   /* USER CODE BEGIN EXTI0_1_IRQn 0 */
   if ((EXTI->IMR & EXTI_IMR_MR0) && (EXTI->PR & EXTI_PR_PR0))
   {
       int_flag_pin.copen = 1;
   }
   if ((EXTI->IMR & EXTI_IMR_MR1) && (EXTI->PR & EXTI_PR_PR1))
   {
      int_flag_pin.ma1 = 1;
   }

   /* USER CODE END EXTI0_1_IRQn 0 */
   HAL_GPIO_EXTI_IRQHandler(GPIO_PIN_0);
   HAL_GPIO_EXTI_IRQHandler(GPIO_PIN_1);
   /* USER CODE BEGIN EXTI0_1_IRQn 1 */

   /* USER CODE END EXTI0_1_IRQn 1 */
}

Between setting the Pin low and change rising, the Interrupt triggers.

TEST_GPIO_Port->BSRR = (uint32_t) TEST_Pin;
//HAL_GPIO_WritePin(TEST_GPIO_Port, TEST_Pin, GPIO_PIN_RESET);      
TEST_GPIO_Port->BRR = (uint32_t) TEST_Pin;
change_rising(0);

Update:

Could it be that resetting the Pin through BSRR or BRR generates an interrupt? I'm checking my code step-by-step and everytime the pin is getting resetted the interrupt is generated.

HelpingHand
  • 1,294
  • 11
  • 27
  • too bad these kind of topics don't get a lot of views, i'd help you if i knew anything about it. – DarkMukke Oct 18 '17 at 12:59
  • 2
    This code looks more like CMSIS but not HAL. The possible reason is that you don't clean interrupt bit before exiting handler. This enforce handler to be called again and again. – Yuriy Oct 18 '17 at 13:59
  • I simply didn't copied the part were the interrupt bit is cleared into this post. The interrupt is triggered after tine pin is set low and the function change_rising is called. That's happening after a reset of the chip. – Heiko Thober Oct 18 '17 at 19:26
  • 1
    you do not clear the interrupt flag so the interrupt will be triggered "ad infinitum". if clear the flag just before the exit from the interrupt there may be not enough time to this clear to propagate thorough the bus and the interrupt will be triggered again. To avoid it : clear it early enough, use barrier instructions or read the flag after clearing. – 0___________ Oct 19 '17 at 00:05
  • I'd run my code in step-by-step mode and watched the Pending Interrupt Register. There is no Interrupt registered until I write into the BRR register. The Flag is cleared in the ISR, with the HAL function: HAL_GPIO_EXTI_IRQHandler(GPIO_PIN_0); Should I do this up front after enabling the Interrupt? – Heiko Thober Oct 19 '17 at 05:18
  • 2
    Could you also paste part with EXTI/GPIO initialization? How is `GPIO_InitTypeDef.Mode` configured? Maybe it's `GPIO_MODE_IT_RISING_FALLING`? [page 57](https://www.st.com/content/ccc/resource/technical/document/user_manual/2f/71/ba/b8/75/54/47/cf/DM00105879.pdf/files/DM00105879.pdf/jcr:content/translations/en.DM00105879.pdf) – pan-mroku Jul 06 '18 at 12:40

1 Answers1

0

if TEST_Pin is GPIO_PIN_0 or GPIO_PIN_1 pin, you will receive irq legally. EXTI0_1_IRQHandler catches irq from any port but from #0 or #1 pin.

Oleksandr
  • 11
  • 1