cancel
Showing results for 
Search instead for 
Did you mean: 

Code generated and built by STM32CubeIDE can not start the timer and systick ?

lhoan.1
Associate II

Hi,

I have generated and built code by STM32CubeIDE but the SysTick and Timer not work. I set breakpoint but the interrupt function just not run. GPIO feature work normal. But when I create the project by STM32CubeMX with the same configuration and built code by KeilC then everything work good. So is that a bug of SMT32CubeIDE? I'm using STM32F103C8T6 on board Bluepill. I don't want to use KeilC anymore because it not free. What should i do now?

Thank for your advice.

1 ACCEPTED SOLUTION

Accepted Solutions
TDK
Guru

> So I think there is a bug on STM32CubeIDE Compiler when built HAL code.

Probably more likely there was a bug in your code. Having the timer set up in slave trigger mode will require you to actually trigger it, which your code doesn't do.

> sSlaveConfig.SlaveMode = TIM_SLAVEMODE_TRIGGER;

> sSlaveConfig.InputTrigger = TIM_TS_ITR0;

If you feel a post has answered your question, please click "Accept as Solution".

View solution in original post

17 REPLIES 17
TDK
Guru

How do you know it's not working? If you debug and hit pause, where is the CPU executing instructions?

If you feel a post has answered your question, please click "Accept as Solution".
Ons KOOLI
Senior III

Hi Ihoan.1,

Can you please share your .ioc file ?

Regards,

Ons.

Hi, I have upgraded to STM32CubeIDE 1.5.0, and the systick works now. But the timer still not work. Everything in the main while (1) still works normally except the timer interrupt. I tried to set breakpoint in Timer interrupt function, but nothing hit this breakpoint

Please see the attached file for detail

Hi, I have upgraded to STM32CubeIDE 1.5.0, and the systick works now. But the timer still not work. Everything in the main while (1) still works normally except the timer interrupt. I tried to set breakpoint in Timer interrupt function, but nothing hit this breakpoint

Please see the attached file for detail

DDong.2
Associate II

Please check if your code have user code as below.

In MX_TIM2_Init(void) add the following.

 /* USER CODE BEGIN TIM2_Init 2 */

 LL_TIM_EnableIT_UPDATE(TIM2);

 /* USER CODE END TIM2_Init 2 */

After MX_TIM2_Init() add the following

 /* USER CODE BEGIN 2 */

 LL_TIM_EnableCounter(TIM2);

Hi, Thank for your advice.

But it is low layer library. I'm using HAL library and have no way to implement those function from low layer library

And here is the main.c file

Add a line as below in MX_TIM1_Init(void)

 /* USER CODE BEGIN TIM1_Init 2 */

 HAL_TIM_Base_Start_IT(&htim1);

 HAL_TIM_Base_Start(&htim1);

 /* USER CODE END TIM1_Init 2 */

Hi. I did as you said. but the timer still doesn't work!