Skip to main content
Visitor II
May 12, 2016
Question

HAL: reset EXTI block

  • May 12, 2016
  • 1 reply
  • 656 views
Posted on May 12, 2016 at 12:08

func 

HAL_DeInit(); // Reset of all peripherals  

does not reset EXTI block,

as it is in HAL_GPIO_DeInit()

    /*------------------------- EXTI Mode Configuration --------------------*/

      tmp = SYSCFG->EXTICR[position >> 2U];

      tmp &= (((uint32_t)0x0FU) << (4U * (position & 0x03U)));

      if(tmp == ((uint32_t)(GPIO_GET_INDEX(GPIOx)) << (4U * (position & 0x03U))))

      {

        /* Configure the External Interrupt or event for the current IO */

        tmp = ((uint32_t)0x0FU) << (4U * (position & 0x03U));

        SYSCFG->EXTICR[position >> 2U] &= ~tmp;

        /* Clear EXTI line configuration */

        EXTI->IMR &= ~((uint32_t)iocurrent);

        EXTI->EMR &= ~((uint32_t)iocurrent);

        

        /* Clear Rising Falling edge configuration */

        EXTI->RTSR &= ~((uint32_t)iocurrent);

        EXTI->FTSR &= ~((uint32_t)iocurrent);

      }

    This topic has been closed for replies.

    1 reply

    Explorer
    February 7, 2025

    This is still an issue 9 years later. Rant:

    • What's even the point of the HAL if it's full of traps like this and for anything but the simplest "blink a led" programs you have to reimplement everything based on the manual anyway?
    • The HAL (stm32xxxx_hal_exti) doesn't even contain the reset values for the IMR registers - why not?
      • They're very precisely defined in the manual, STM knows them, but I have to manually #define them in my program for every MCU I need to support?
    • Given no general way to clear the EXTI in the HAL and the need to manually call HAL_GPIO_DeInit on each pin to reset the IMR, why does CubeMX automatically generate a MX_GPIO_Init function that calls HAL_GPIO_Init on all the pins you've configured in the .ioc project, but not a corresponding MX_GPIO_DeInit?
      • My guess is that half of the metaprogramming is left as an exercise to the reader so hourly contractors don't run out of work...