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

The timer flag is set immediately

I am learning to use timer without interruptions(with flags). The STM32CubeMX generates the values configuration. But at the moment of initialization, it does not wait for the set time to be set automatically. I have seen in this and other forums they give solutions to problems that have interruption enabled. Try but It did not work for me. The only code I have written is in the loop.What I want to generate is that the led is off for 1 second and generate a small pulse when it is on but without interruptions, but I have realized that the timer does not even wait that second.UPDATE: Perform tests with the oscilloscope to see if there was a pulse, this through for (int e = 1; e <= 60000; e ++) that can be seen as a comment but even so the part in which the pin was in RESET state it was still practically nil

Fullscreen
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
#include "main.h"
#include "stm32f4xx_hal.h"
/* USER CODE BEGIN Includes */
/* USER CODE END Includes */
/* Private variables ---------------------------------------------------------*/
TIM_HandleTypeDef htim2;
TIM_HandleTypeDef htim3;
/* USER CODE BEGIN PV */
/* Private variables ---------------------------------------------------------*/
/* USER CODE END PV */
/* Private function prototypes -----------------------------------------------*/
void SystemClock_Config(void);
static void MX_GPIO_Init(void);
static void MX_TIM2_Init(void);
static void MX_TIM3_Init(void);
XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX

0