Skip to main content
BSANT.17
Associate II
Nov 20, 2018 4:38 PM UTC
Question

STM32F105RC PB6 always stay 0, EXTI never trigg

	// PB6 Main sync pin
	GPIO_InitTypeDef GPIO_InitStructure;
	GPIO_InitStructure.GPIO_Pin = GPIO_Pin_6;
	GPIO_InitStructure.GPIO_Mode = GPIO_Mode_IN_FLOATING;
	GPIO_InitStructure.GPIO_Speed = GPIO_Speed_2MHz;
	GPIO_Init(GPIOB, &GPIO_InitStructure);
 
	// Connect EXTI6 Line to PB6 pin
	GPIO_EXTILineConfig(GPIO_PortSourceGPIOB, GPIO_PinSource6);
 
	//Configure EXTI 6
	EXTI_InitTypeDef EXTI_InitStructure;
	EXTI_InitStructure.EXTI_Line = EXTI_Line6;
	EXTI_InitStructure.EXTI_Mode = EXTI_Mode_Interrupt;
	EXTI_InitStructure.EXTI_Trigger = EXTI_Trigger_Rising_Falling;
	EXTI_InitStructure.EXTI_LineCmd = ENABLE;
	EXTI_Init(&EXTI_InitStructure);
 
	/* Enable the EXTI9_5 Interrupt */
	NVIC_InitTypeDef NVIC_InitStructure;
	NVIC_InitStructure.NVIC_IRQChannel = EXTI9_5_IRQn;
	NVIC_InitStructure.NVIC_IRQChannelPreemptionPriority = 0;
	NVIC_InitStructure.NVIC_IRQChannelSubPriority = 0;
	NVIC_InitStructure.NVIC_IRQChannelCmd = ENABLE;
	NVIC_Init(&NVIC_InitStructure);
 
	NVIC_EnableIRQ(EXTI9_5_IRQn);
 
	/* Clear interrupt flag */
	EXTI_ClearITPendingBit(EXTI_Line6);

Hi, I've got a problem with my EXTI6. I try to get interrupt on falling and rising edges.

I've watched SFR register but I don't understand why it doesn't work.

PB IDR bit 6 always stay to 0 but I'm sure it's not true.

IRQ are enabled, software interrupt trig works perfectly.

I use Eclipse with Std peripheral lib V3.5.0.

Is anyone think about something ?

EDIT : Signal NOT moving when my program running.

Thanks.

    This topic has been closed for replies.

    10 replies

    waclawek.jan
    Super User
    Nov 20, 2018 5:07 PM UTC

    > PB IDR bit 6 always stay to 0 but I'm sure it's not true.

    How do you know that?

    JW

    BSANT.17
    BSANT.17Author
    Associate II
    Nov 21, 2018 8:11 AM UTC

    Oscilloscope.

    waclawek.jan
    Super User
    Nov 21, 2018 8:14 AM UTC

    And did the probe touch PB6 pin directly?

    Until you see PB IDR bit 6 actually change in the debugger, or if examined in the program, it's not proven to change.

    JW

    Chris1
    Associate II
    Nov 20, 2018 5:26 PM UTC

    Have you enabled clocks for GPIOB and AFIO?

    Tesla DeLorean
    Guru
    Nov 20, 2018 9:29 PM UTC

    +1 AFIO required for EXTI config on F1

    Is a pull-up required? How are you driving the pin?

    Tips, Buy me a coffee, or three.. PayPal Venmo (See Profile) Up vote any posts that you find helpful, it shows what's working..
    BSANT.17
    BSANT.17Author
    Associate II
    Nov 21, 2018 8:12 AM UTC

    No Pull-up required.

    BSANT.17
    BSANT.17Author
    Associate II
    Nov 21, 2018 8:14 AM UTC
     /*Configure GPIO pin : PtPin */
     GPIO_InitStruct.Pin = Main_Sync_Pin;
     GPIO_InitStruct.Mode = GPIO_MODE_IT_RISING_FALLING;
     GPIO_InitStruct.Pull = GPIO_NOPULL;
     HAL_GPIO_Init(Main_Sync_GPIO_Port, &GPIO_InitStruct);
     
     /* EXTI interrupt init*/
     HAL_NVIC_SetPriority(EXTI9_5_IRQn, 0, 0);
     HAL_NVIC_EnableIRQ(EXTI9_5_IRQn);

    This code works perfectly in atollic, need to works on eclipse.