Continue to Site

Welcome to our site!

Electro Tech is an online community (with over 170,000 members) who enjoy talking about and building electronic circuits, projects and gadgets. To participate you need to register. Registration is free. Click here to register now.

  • Welcome to our site! Electro Tech is an online community (with over 170,000 members) who enjoy talking about and building electronic circuits, projects and gadgets. To participate you need to register. Registration is free. Click here to register now.

Configuring a pin as interrupt ARM Cortex M3 STM32F1xx

Status
Not open for further replies.
I'm trying to configure Pin PD3 as external interrupt, here is my configuration, but it seems its not working.

void Configure_PD3(void) {
GPIO_InitTypeDef GPIO_InitStruct;

/* GPIO Ports Clock Enable */

RCC_AHBPeriphClockCmd(RCC_AHBPeriph_GPIOD,ENABLE); // enables clock to portD
GPIO_InitStruct.GPIO_Speed = GPIO_Speed_10MHz;
/*Configure GPIO pin : PD3 */
GPIO_InitStruct.GPIO_Pin = GPIO_Pin_3;
GPIO_InitStruct.GPIO_Mode = GPIO_Mode_IN;
GPIO_InitStruct.GPIO_PuPd = GPIO_PuPd_NOPULL;

GPIO_Init(GPIOD, &GPIO_InitStruct);
/* PD3 is connected to EXTI_Line3 */
EXTI_InitStruct.EXTI_Line = EXTI_Line3;
/* Enable interrupt */
EXTI_InitStruct.EXTI_LineCmd = ENABLE;
/* Interrupt mode */
EXTI_InitStruct.EXTI_Mode = EXTI_Mode_Interrupt;
/* Triggers on rising and falling edge */
EXTI_InitStruct.EXTI_Trigger = EXTI_Trigger_Rising_Falling;
/* Add to EXTI */
EXTI_Init(&EXTI_InitStruct);

/* EXTI interrupt init*/
NVIC_SetPriority(EXTI3_IRQn, 0);
NVIC_EnableIRQ(EXTI3_IRQn);
}

void EXTI3_IRQHandler(void)
{
int i = 0;

}

void main() {

// Don't put any variables on the stack here, as FreeRTOS seems to reuse this space.
// This might be valid as this thread will be dead after vTaskStartScheduler().

hardware_init();

Configure_PD3();
}
 
Which chip is this?
 
necro, but if your filename is .cpp, the ISR handler name, as typed by you, will be in c++ by default. But, the compiler might only recognize that function name as the prespecified interrupt handler if it is in C. If so, you need use extern "C" before the handler name to eliminate the C++ name mangling (which changes the function name internally to allow overloading) so the compiler properly associates it.
 
Last edited:
Status
Not open for further replies.

Latest threads

New Articles From Microcontroller Tips

Back
Top