1. 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.
    Dismiss Notice

Configuring a pin as interrupt ARM Cortex M3 STM32F1xx

Discussion in 'ARM' started by ahmedragia21, Apr 11, 2017.

  1. ahmedragia21

    ahmedragia21 Member

    Joined:
    Apr 5, 2006
    Messages:
    471
    Likes:
    1
    Location:
    Egypt,Cairo
    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();
    }
     
  2. large_ghostman

    large_ghostman Well-Known Member Most Helpful Member

    Joined:
    Jan 7, 2011
    Messages:
    4,725
    Likes:
    532
    Location:
    SCOTLAND
    Which chip is this?
     

Share This Page

  1. This site uses cookies to help personalise content, tailor your experience and to keep you logged in if you register.
    By continuing to use this site, you are consenting to our use of cookies.
    Dismiss Notice