cancel
Showing results for 
Search instead for 
Did you mean: 

EXTI0 and EXTI1 not working PD0 and PD1

Hos
Associate II
Posted on August 13, 2017 at 20:46

Hello people,

My design has buttons on the pins that are normally used for the system x-tal (PD0 and PD1) and a button on PC13.

my MCU: stm32f103c8

This is the code generated by cubeMx:

<code>

/** Configure pins as

* Analog

* Input

* Output

* EVENT_OUT

* EXTI

*/

static void MX_GPIO_Init(void)

{

/* GPIO Ports Clock Enable */

__HAL_RCC_GPIOC_CLK_ENABLE();

__HAL_RCC_GPIOD_CLK_ENABLE();

/*Configure GPIO pin : PC13 */

GPIO_InitStruct.Pin = GPIO_PIN_13;

GPIO_InitStruct.Mode = GPIO_MODE_IT_RISING;

GPIO_InitStruct.Pull = GPIO_NOPULL;

HAL_GPIO_Init(GPIOC, &GPIO_InitStruct);

/*Configure GPIO pins : PD0 PD1 */

GPIO_InitStruct.Pin = GPIO_PIN_0|GPIO_PIN_1;

GPIO_InitStruct.Mode = GPIO_MODE_IT_RISING;

GPIO_InitStruct.Pull = GPIO_NOPULL;

HAL_GPIO_Init(GPIOD, &GPIO_InitStruct);

/*Configure peripheral I/O remapping */

__HAL_AFIO_REMAP_PD01_ENABLE();

/* EXTI interrupt init*/

HAL_NVIC_SetPriority(EXTI0_IRQn, 0, 0);

HAL_NVIC_EnableIRQ(EXTI0_IRQn);

HAL_NVIC_SetPriority(EXTI1_IRQn, 0, 0);

HAL_NVIC_EnableIRQ(EXTI1_IRQn);

HAL_NVIC_SetPriority(EXTI15_10_IRQn, 0, 0);

HAL_NVIC_EnableIRQ(EXTI15_10_IRQn);

}

/******************************************************************************/

/* STM32F1xx Peripheral Interrupt Handlers */

/* Add here the Interrupt Handlers for the used peripherals. */

/* For the available peripheral interrupt handler names, */

/* please refer to the startup file (startup_stm32f1xx.s). */

/******************************************************************************/

/**

* @brief This function handles EXTI line0 interrupt.

*/

void EXTI0_IRQHandler(void)

{

/* USER CODE BEGIN EXTI0_IRQn 0 */

/* USER CODE END EXTI0_IRQn 0 */

HAL_GPIO_EXTI_IRQHandler(GPIO_PIN_0);

/* USER CODE BEGIN EXTI0_IRQn 1 */

/* USER CODE END EXTI0_IRQn 1 */

}

/**

* @brief This function handles EXTI line1 interrupt.

*/

void EXTI1_IRQHandler(void)

{

/* USER CODE BEGIN EXTI1_IRQn 0 */

/* USER CODE END EXTI1_IRQn 0 */

HAL_GPIO_EXTI_IRQHandler(GPIO_PIN_1);

/* USER CODE BEGIN EXTI1_IRQn 1 */

/* USER CODE END EXTI1_IRQn 1 */

}

/**

* @brief This function handles EXTI line[15:10] interrupts.

*/

void EXTI15_10_IRQHandler(void)

{

/* USER CODE BEGIN EXTI15_10_IRQn 0 */

/* USER CODE END EXTI15_10_IRQn 0 */

HAL_GPIO_EXTI_IRQHandler(GPIO_PIN_13);

/* USER CODE BEGIN EXTI15_10_IRQn 1 */

/* USER CODE END EXTI15_10_IRQn 1 */

}

</code>

The __HAL_RCC_AFIO_CLK_ENABLE() function is being called right after boot.

The MCU is running on its internal RCC and that works as expected.

The interrupt on PC13 works, but can not get the interrupt on PD0 and PD1 to work. 

Regards.

1 ACCEPTED SOLUTION

Accepted Solutions
Hos
Associate II
Posted on August 13, 2017 at 21:03

I allready found it @ STM32F103C8Tx_referenceManual.pdf:

9.3.2 Using OSC_IN/OSC_OUT pins as GPIO ports PD0/PD1

The HSE oscillator pins OSC_IN/OSC_OUT can be used as general-purpose I/O PD0/PD1

by programming the PD01_REMAP bit in the AF remap and debug I/O configuration register

(AFIO_MAPR).

This remap is available only on 36-, 48- and 64-pin packages (PD0 and PD1 are available

on 100-pin and 144-pin packages, no need for remapping).

Note: The external interrupt/event function is not remapped. PD0 and PD1 cannot be used for

external interrupt/event generation on 36-, 48- and 64-pin packages.

View solution in original post

2 REPLIES 2
Hos
Associate II
Posted on August 13, 2017 at 21:03

I allready found it @ STM32F103C8Tx_referenceManual.pdf:

9.3.2 Using OSC_IN/OSC_OUT pins as GPIO ports PD0/PD1

The HSE oscillator pins OSC_IN/OSC_OUT can be used as general-purpose I/O PD0/PD1

by programming the PD01_REMAP bit in the AF remap and debug I/O configuration register

(AFIO_MAPR).

This remap is available only on 36-, 48- and 64-pin packages (PD0 and PD1 are available

on 100-pin and 144-pin packages, no need for remapping).

Note: The external interrupt/event function is not remapped. PD0 and PD1 cannot be used for

external interrupt/event generation on 36-, 48- and 64-pin packages.

Posted on August 15, 2017 at 14:57

Hi

oz.h

‌,

Thanks for sharing the solution; This will be helpful for other users on our STM32MCUs forum facing the same kind of issues.

Have a nice day

Khouloud.