This discussion has been locked.
You can no longer post new replies to this discussion. If you have a question you can start a new discussion

Extern variable not working.

I've got a STM32CubeMX made project for running on stm32f401re using proteus. I need e shared variable named "mode" on two compiling units named main.c and stm32f4xx_it.c.

I've got the following definition on main.c:

char mode = 0; // 0: welcome, 1: timer running, 2: timer paused, 3: shutdown

And the following on stm32f4xx_it.c:

extern char mode; // 0: welcome, 1: timer running, 2: timer paused, 3: shutdown

I've got the following code on handling interrupt:

void EXTI0_IRQHandler(void)
{
  /* USER CODE BEGIN EXTI0_IRQn 0 */
	if (mode!=3){
		mode = 1;
  }
  /* USER CODE END EXTI0_IRQn 0 */
  HAL_GPIO_EXTI_IRQHandler(GPIO_PIN_0);
  /* USER CODE BEGIN EXTI0_IRQn 1 */

  /* USER CODE END EXTI0_IRQn 1 */
}

The interrupt routine is called fine but the mode doesn't change, since the function of the microcontroller doesn't change as I've programmed on main.c file. 

Parents Reply Children
No data