cancel
Showing results for 
Search instead for 
Did you mean: 

stm32f100r8 external interrupt

metin �zt�rk
Associate
Posted on April 11, 2018 at 08:09

Hi friends,

I am using stm32f100r8 with standart peripheral driver.

I have planned to use porta1, porta6, portb2, portb3 and portb4 as an external interrupt pin.

I use same config for all of them.

But portb2 and portb3 can not work as an external interrupt pin.

What can be the problem?

Below example, Portb4 can work but Portb2 can not.

define ZC_PORT                               GPIOB

#define ZC_GPIO_CLK                      RCC_APB2Periph_GPIOB

#define ZC_PIN_NUM                      GPIO_Pin_4 // PB4

#define ZC_PORT_SOURCE             GPIO_PortSourceGPIOB

#define ZC_PIN_SOURCE                   GPIO_PinSource4

#define ZC_EXTI_LINE                      EXTI_Line4 // EXTI Line4

#define ZC_EXTI_IRQ                      EXTI4_IRQn // EXTI4 IRQ

#define TRIP18V_PORT                      GPIOB

#define TRIP18V_GPIO_CLK             RCC_APB2Periph_GPIOB

#define TRIP18V_PIN_NUM                GPIO_Pin_2

#define TRIP18V_PORT_SOURCE    GPIO_PortSourceGPIOB

#define TRIP18V_PIN_SOURCE       GPIO_PinSource2

#define TRIP18V_EXTI_LINE             EXTI_Line2

#define TRIP18V_EXTI_IRQ             EXTI2_IRQn

RCC_APB2PeriphClockCmd(ZC_GPIO_CLK, ENABLE);

GPIO_InitStructure.GPIO_Pin = ZC_PIN_NUM;

GPIO_InitStructure.GPIO_Mode = GPIO_Mode_IN_FLOATING;

GPIO_Init(ZC_PORT, &GPIO_InitStructure);

RCC_APB2PeriphClockCmd(RCC_APB2Periph_AFIO, ENABLE);

GPIO_EXTILineConfig(ZC_PORT_SOURCE, ZC_PIN_SOURCE);

RCC_APB2PeriphClockCmd(TRIP18V_GPIO_CLK, ENABLE);

GPIO_InitStructure.GPIO_Pin = TRIP18V_PIN_NUM;

GPIO_InitStructure.GPIO_Mode = GPIO_Mode_IN_FLOATING;

GPIO_Init(TRIP18V_PORT, &GPIO_InitStructure);

RCC_APB2PeriphClockCmd(RCC_APB2Periph_AFIO, ENABLE);

GPIO_EXTILineConfig(TRIP18V_PORT_SOURCE, TRIP18V_PIN_SOURCE);

EXTI_InitStructure.EXTI_Line = ZC_EXTI_LINE;

EXTI_InitStructure.EXTI_Mode = EXTI_Mode_Interrupt;

EXTI_InitStructure.EXTI_Trigger = EXTI_Trigger_Falling;

EXTI_InitStructure.EXTI_LineCmd = ENABLE;

EXTI_Init(&EXTI_InitStructure);

EXTI_InitStructure.EXTI_Line = TRIP18V_EXTI_LINE;

EXTI_InitStructure.EXTI_Mode = EXTI_Mode_Interrupt;

EXTI_InitStructure.EXTI_Trigger = EXTI_Trigger_Falling;

EXTI_InitStructure.EXTI_LineCmd = ENABLE;

EXTI_Init(&EXTI_InitStructure);

NVIC_InitStructure.NVIC_IRQChannel = ZC_EXTI_IRQ;

NVIC_InitStructure.NVIC_IRQChannelPreemptionPriority = 4;

NVIC_InitStructure.NVIC_IRQChannelSubPriority = 0;

NVIC_InitStructure.NVIC_IRQChannelCmd = ENABLE;

NVIC_Init(&NVIC_InitStructure);

NVIC_InitStructure.NVIC_IRQChannel = TRIP18V_EXTI_IRQ;

NVIC_InitStructure.NVIC_IRQChannelPreemptionPriority = 4;

NVIC_InitStructure.NVIC_IRQChannelSubPriority = 0;

NVIC_InitStructure.NVIC_IRQChannelCmd = ENABLE;

NVIC_Init(&NVIC_InitStructure);
1 REPLY 1
Posted on April 11, 2018 at 22:22

Change the input levels on those pins and in debugger observe, whether  the respective bits in GPIOB_ISR do change.

If they do, read out and check/post the EXTI registers' content.

JW