Skip to main content
BSANT.17
Associate II
November 20, 2018
Question

STM32F105RC PB6 always stay 0, EXTI never trigg

  • November 20, 2018
  • 3 replies
  • 2821 views

	// 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.

    3 replies

    waclawek.jan
    Super User
    November 20, 2018

    > 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
    November 21, 2018

    Oscilloscope.

    waclawek.jan
    Super User
    November 21, 2018

    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
    November 20, 2018

    Have you enabled clocks for GPIOB and AFIO?

    Tesla DeLorean
    Guru
    November 20, 2018

    +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 VenmoUp vote any posts that you find helpful, it shows what's working..
    BSANT.17
    BSANT.17Author
    Associate II
    November 21, 2018

    No Pull-up required.

    BSANT.17
    BSANT.17Author
    Associate II
    November 21, 2018
     /*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.