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:

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

And the following on stm32f4xx_it.c:

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

I've got the following code on handling interrupt:

Fullscreen
1
2
3
4
5
6
7
8
9
10
11
12
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 */
}
XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX

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. 

0