Vikas Singh
Vikas Singh

Reputation: 21

Using external interrupt on port B of stm32f030

I am using STM32F0308 Dicovery Board. I want to use external interrupt on PIN11 of PORTB. Problem is that I am not able to invoke the PORTB. Microcontroller is still uses PIN11 of PORTA. I know that pins of ports are clubbed together but I am specifying PORTB still micro is using PORTA. I think there is some problem in this code line

SYSCFG->EXTICR[3] = SYSCFG_EXTICR3_EXTI11_PB;  

Here is code

#include"stm32f0xx.h"
volatile int portBPin10Counter;

void EXTI4_15_IRQHandler(void)
{
  if(EXTI->PR & EXTI_PR_PR11)
  {
     EXTI->PR |= EXTI_PR_PR11;
     portBPin10Counter++;
  }
}

int main(void)
{
  RCC->AHBENR |=RCC_AHBENR_GPIOBEN;

  GPIOB->MODER &= ~GPIO_MODER_MODER11;
  GPIOB->PUPDR &= ~GPIO_PUPDR_PUPDR11;

  SYSCFG->EXTICR[3] =SYSCFG_EXTICR3_EXTI11_PB;

  EXTI->RTSR |= EXTI_RTSR_TR11;
  EXTI->IMR |= EXTI_IMR_MR11;

  NVIC_EnableIRQ(EXTI4_15_IRQn);
  NVIC_SetPriority(EXTI4_15_IRQn,1);

  while(1)
  {
  }
}

Upvotes: 2

Views: 1356

Answers (1)

A.K.
A.K.

Reputation: 849

You need to enable clock for SYSCFG. I don't have F0 files at hand, just looking at the manual:

RCC->APB2ENR |= RCC_APB2ENR_SYSCFGEN;

Otherwise, writing to SYSCFG->EXTICR has no effect.

Upvotes: 2

Related Questions