STM32F4 - EXTI flag yardım

Başlatan e-design, 04 Haziran 2016, 14:18:43

e-design

CubeMX kullanarak 4 pin üzerinden kesme oluşturuyorum ve gelen kesmelere karşılık stm32f4 kiti üzerindeki ledleri aktifleştiriyorum.

1-) cubemx üzerindeki ayarlar:GPIO / PB4 pini / GPIO Mode: External interrupt with Rising-Falling edge trigger detection
                                                                   / Pull-down

şeklinde iken gayet sorunsuz çalışmakta fakat ;

2-) cubemx üzerindeki ayarlar:GPIO / PB4 pini / GPIO Mode: External interrupt with Rising edge trigger detection
                                                                   / Pull-down
şeklinde değiştirdiğimde 1 defa kesme geliyor ve artık ikinci kesme gelmiyor. İkinci kesmenin gelmesi için ilgili hattın flaglarını
resetlemem gerekiyor.

void EXTI4_IRQHandler(void)
{
	if(__HAL_GPIO_EXTI_GET_IT(button1_Pin) != RESET)
  {
		HAL_GPIO_WritePin(GPIOB,kirmizi_led_Pin,	HAL_GPIO_ReadPin(GPIOB,	button1_Pin));
		
    __HAL_GPIO_EXTI_CLEAR_IT(button1_Pin);
    HAL_GPIO_EXTI_Callback(button1_Pin);
  }
	
	//__HAL_GPIO_EXTI_CLEAR_FLAG();
	
  HAL_GPIO_EXTI_IRQHandler(GPIO_PIN_4);
}


şeklinde bir düzenleme yaptım ama çalışmadı

her iki çalışma içinde aşağıda yazılı kod var:
#include "stm32f4xx_hal.h"

void SystemClock_Config(void);
void Error_Handler(void);
static void MX_GPIO_Init(void);

int main(void)
{
  HAL_Init();

  SystemClock_Config();
  MX_GPIO_Init();

  while (1)
  {
	HAL_GPIO_TogglePin(GPIOD,	kirmizi_led_Pin);
	HAL_Delay(2000);
		
	HAL_GPIO_TogglePin(GPIOD,	mavi_led_Pin);
	HAL_Delay(2000);
		
	HAL_GPIO_TogglePin(GPIOD,	yesil_led_Pin);
	HAL_Delay(2000);
		
	HAL_GPIO_TogglePin(GPIOD,	turuncu_led_Pin);
	HAL_Delay(2000);
  }
}

void EXTI4_IRQHandler(void)
{
	HAL_GPIO_WritePin(GPIOB,kirmizi_led_Pin,	HAL_GPIO_ReadPin(GPIOB,	button1_Pin));
	
  HAL_GPIO_EXTI_IRQHandler(GPIO_PIN_4);
}

void EXTI9_5_IRQHandler(void)
{
	HAL_GPIO_WritePin(GPIOB,mavi_led_Pin,	HAL_GPIO_ReadPin(GPIOB,	button2_Pin));
	HAL_GPIO_WritePin(GPIOB,turuncu_led_Pin,	HAL_GPIO_ReadPin(GPIOB,	button3_Pin));
	HAL_GPIO_WritePin(GPIOB,yesil_led_Pin,	HAL_GPIO_ReadPin(GPIOB,	button4_Pin));
	
  HAL_GPIO_EXTI_IRQHandler(GPIO_PIN_5);
  HAL_GPIO_EXTI_IRQHandler(GPIO_PIN_6);
  HAL_GPIO_EXTI_IRQHandler(GPIO_PIN_7);
}

void SystemClock_Config(void)
{

  RCC_OscInitTypeDef RCC_OscInitStruct;
  RCC_ClkInitTypeDef RCC_ClkInitStruct;

  __HAL_RCC_PWR_CLK_ENABLE();

  __HAL_PWR_VOLTAGESCALING_CONFIG(PWR_REGULATOR_VOLTAGE_SCALE1);

  RCC_OscInitStruct.OscillatorType = RCC_OSCILLATORTYPE_HSE;
  RCC_OscInitStruct.HSEState = RCC_HSE_ON;
  RCC_OscInitStruct.PLL.PLLState = RCC_PLL_ON;
  RCC_OscInitStruct.PLL.PLLSource = RCC_PLLSOURCE_HSE;
  RCC_OscInitStruct.PLL.PLLM = 8;
  RCC_OscInitStruct.PLL.PLLN = 336;
  RCC_OscInitStruct.PLL.PLLP = RCC_PLLP_DIV2;
  RCC_OscInitStruct.PLL.PLLQ = 4;
  if (HAL_RCC_OscConfig(&RCC_OscInitStruct) != HAL_OK)
  {
    Error_Handler();
  }

  RCC_ClkInitStruct.ClockType = RCC_CLOCKTYPE_HCLK|RCC_CLOCKTYPE_SYSCLK
                              |RCC_CLOCKTYPE_PCLK1|RCC_CLOCKTYPE_PCLK2;
  RCC_ClkInitStruct.SYSCLKSource = RCC_SYSCLKSOURCE_PLLCLK;
  RCC_ClkInitStruct.AHBCLKDivider = RCC_SYSCLK_DIV1;
  RCC_ClkInitStruct.APB1CLKDivider = RCC_HCLK_DIV4;
  RCC_ClkInitStruct.APB2CLKDivider = RCC_HCLK_DIV2;
  if (HAL_RCC_ClockConfig(&RCC_ClkInitStruct, FLASH_LATENCY_5) != HAL_OK)
  {
    Error_Handler();
  }

  HAL_SYSTICK_Config(HAL_RCC_GetHCLKFreq()/1000);

  HAL_SYSTICK_CLKSourceConfig(SYSTICK_CLKSOURCE_HCLK);
  HAL_NVIC_SetPriority(SysTick_IRQn, 0, 0);
}
static void MX_GPIO_Init(void)
{

  GPIO_InitTypeDef GPIO_InitStruct;

  /* GPIO Ports Clock Enable */
  __HAL_RCC_GPIOH_CLK_ENABLE();
  __HAL_RCC_GPIOD_CLK_ENABLE();
  __HAL_RCC_GPIOA_CLK_ENABLE();
  __HAL_RCC_GPIOB_CLK_ENABLE();

  /*Configure GPIO pin Output Level */
  HAL_GPIO_WritePin(GPIOD, yesil_led_Pin|turuncu_led_Pin|kirmizi_led_Pin|mavi_led_Pin, GPIO_PIN_RESET);

  /*Configure GPIO pins : yesil_led_Pin turuncu_led_Pin kirmizi_led_Pin mavi_led_Pin */
  GPIO_InitStruct.Pin = yesil_led_Pin|turuncu_led_Pin|kirmizi_led_Pin|mavi_led_Pin;
  GPIO_InitStruct.Mode = GPIO_MODE_OUTPUT_PP;
  GPIO_InitStruct.Pull = GPIO_NOPULL;
  GPIO_InitStruct.Speed = GPIO_SPEED_FREQ_LOW;
  HAL_GPIO_Init(GPIOD, &GPIO_InitStruct);

  /*Configure GPIO pins : button1_Pin button2_Pin button3_Pin button4_Pin */
  GPIO_InitStruct.Pin = button1_Pin|button2_Pin|button3_Pin|button4_Pin;
  GPIO_InitStruct.Mode = GPIO_MODE_IT_RISING_FALLING;
  GPIO_InitStruct.Pull = GPIO_PULLDOWN;
  HAL_GPIO_Init(GPIOB, &GPIO_InitStruct);

  /* EXTI interrupt init*/
  HAL_NVIC_SetPriority(EXTI4_IRQn, 1, 0);
  HAL_NVIC_EnableIRQ(EXTI4_IRQn);

  HAL_NVIC_SetPriority(EXTI9_5_IRQn, 1, 0);
  HAL_NVIC_EnableIRQ(EXTI9_5_IRQn);

}

void Error_Handler(void)
{
  while(1) 
  {
  }
}

#ifdef USE_FULL_ASSERT

void assert_failed(uint8_t* file, uint32_t line)
{

}

#endif