cancel
Showing results for 
Search instead for 
Did you mean: 

EXTI0 Falling Edge Triggered by Button on PD0 but not PA0

ZThat
Senior

I am having an issue with triggering interrupts with anything other than a button (that sinks to ground when pressed) with an external pullup on port D. I have another line (PA0) on my board that gets pulled low on USB plug-in and uses in internal (rather than external) pull-up. It is not being used for an alternate function. It is completely dedicated as an input in the same way that I have configured the button lines (Fun fact, you can use a single line as both an interrupt and a polled input if you configure it as an interrupt). I observe with a multimeter that the line does indeed go low on plug-in (3.2 to zero volts). I also poll this line to see that it has gone low in order to provide power via USB, which works. This is leading me to believe that I am doing something wrong in software that isn't allowing me to detect the interrupt. I perform the following in code to configure PA0 (the line that doesn't get interrupts)

//Enable the syscfg Clock
    __HAL_RCC_SYSCFG_CLK_ENABLE();
	
	/* Configure Enable Source pin as input */
	GPIO_InitTypeDef GPIO_InitStruct;
	
	GPIO_InitStruct.Pin = GPIO_PIN_0;
	GPIO_InitStruct.Mode = GPIO_MODE_IT_FALLING; //was GPIO_MODE_INPUT  GPIO_MODE_IT_FALLING
	GPIO_InitStruct.Pull = GPIO_PULLUP;
	GPIO_InitStruct.Speed = GPIO_SPEED_FREQ_HIGH;
	HAL_GPIO_Init(GPIOA, &GPIO_InitStruct);   
    
    /* Set Enable Source Interrupt priority */
	HAL_NVIC_SetPriority(EXTI0_IRQn, 9, 0);
    
	/* Enable Enable Source Interrupt */
	HAL_NVIC_EnableIRQ(EXTI0_IRQn);

I also perform the following in code to configure my button lines (which work).

GPIO_InitStruct.Pin = GPIO_PIN_0;
	GPIO_InitStruct.Mode = GPIO_MODE_IT_FALLING;	//was GPIO_MODE_INPUT  GPIO_MODE_IT_FALLING
	GPIO_InitStruct.Pull = GPIO_NOPULL;
	GPIO_InitStruct.Speed = GPIO_SPEED_FREQ_HIGH;
	HAL_GPIO_Init(GPIOD, &GPIO_InitStruct);
	
	/* Set CenterButton Interrupt priority */
	HAL_NVIC_SetPriority(EXTI0_IRQn, 9, 0);
    
	/* Enable CenterButton Interrupt */
	HAL_NVIC_EnableIRQ(EXTI0_IRQn);
 
	/* Set CenterButton Interrupt priority */
	HAL_NVIC_SetPriority(EXTI1_IRQn,9, 0);

Even when I configure the PA0 line as an interrupt and not the PD0 line, I still do not get the interrupt. Does anyone see something wrong here?

I also have an important related question, can you configure two pin 0 lines to provide EXTI0? As you can see, I would like to have both PA0 and PD0 acting as external interrupts.

Thanks!

Zach

2 REPLIES 2
S.Ma
Principal

EXTI has 16 edge sources only not 16x(PORTA+PORTB+PORTC...)

For Px0, choose only one letter

For Px1, choose only one letter.

PA0 xor PD0 (there is a mux inside). Either change the pin or short one with another GPIO like PA1 or PD1.

Gotcha. I appreciate the answer for part 2.

I do still need to know why PD0 is not working for me at all, even when I change PA0 to a normal input. I am using other PA lines as interrupts. But it looks like each EXTI mux is independent, so that shouldn't be an issue.