Skip to main content
July 19, 2025
Solved

My projects don't work after upgrading Cube IDE to 1.19.1

  • July 19, 2025
  • 1 reply
  • 484 views

I used Cude IDE version 1.18.1. successfully then upgraded and wrote the second project (timer). I'm using Nucelo-64 STM32 F411RE with clock rate 84Mhz.  
My new project is to use the TIM4 with the settings: PSC: 8399, CP: 10000 to toggle the LED per second. The LED doesn't turn on/off whatsoever. (My prior project - to use the user button - doesn't work either!)
My files: lib.hpp

 
#ifndef INC_LIB_HPP_
#define INC_LIB_HPP

#if __cplusplus
extern "C" {
#endif

void run();
void HAL_GPIO_EXTI_Callback(uint16_t);
void HAL_TIM_PeriodElapsedCallback(TIM_HandleTypeDef *);

#if __cplusplus
}
#endif
#endif

lib.cpp:

#include "main.h"
#include "lib.hpp"
#include <stdio.h>

auto pressed = 0u;
auto flag = false;

void HAL_GPIO_EXTI_Callback(uint16_t GPIO_Pin)
{
	if(GPIO_Pin == B1_Pin)
		flag = true;
	else flag = false;
}

 void HAL_TIM_PeriodElapsedCallback(TIM_HandleTypeDef *htim)
{
	 HAL_GPIO_TogglePin(LED_GPIO_Port,LED_Pin);
}

void run() {
	while (1) {
		if(flag){
			pressed++;
			flag = false;
			HAL_GPIO_WritePin(LED_GPIO_Port, LED_Pin, GPIO_PIN_SET);
		}

		else
			HAL_GPIO_WritePin(LED_GPIO_Port, LED_Pin, GPIO_PIN_RESET);
	} // End of while (1)
}

main.c file is rather big hence attached below.

 

    This topic has been closed for replies.
    Best answer by

    The problem is with 

    else
     HAL_GPIO_WritePin(LED_GPIO_Port, LED_Pin, GPIO_PIN_RESET);

     in while(1) in run. Since flag is by default false, the else part will execute forever not letting the toggle function work properly. 

    1 reply

    Super User
    July 19, 2025

    So what debugging have you done to find what's going on ?

    Have you tried the examples provided by CubeIDE?

    July 19, 2025

    Not sure how to debug this issue.
    I've already done projects for blinking the LED and playing with the user button, using the same IDE and MCU, successfully. 

    I added the line below to the header:

    extern TIM_HandleTypeDef htim4; 

    Also modified the function in lib.cpp: 

     void HAL_TIM_PeriodElapsedCallback(TIM_HandleTypeDef *htim)
    {
    	 if(htim == &htim4)
    		 HAL_GPIO_TogglePin(LED_GPIO_Port,LED_Pin);
    }

    I get no warnings/errors yet no expected result. 

    Super User
    July 19, 2025

    @TechyAry wrote:

    Not sure how to debug this issue.


    For a start, is it ever reaching the line where you toggle the pin?