Skip to main content
lhoan.1
Associate II
December 1, 2020
Solved

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

  • December 1, 2020
  • 17 replies
  • 6216 views

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.

This topic has been closed for replies.
Best answer by TDK

> 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;

17 replies

TDK
December 1, 2020

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""."
lhoan.1
lhoan.1Author
Associate II
December 2, 2020

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

Ons KOOLI
Associate
December 1, 2020

Hi Ihoan.1,

Can you please share your .ioc file ?

Regards,

Ons.

lhoan.1
lhoan.1Author
Associate II
December 2, 2020

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
December 2, 2020

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);

lhoan.1
lhoan.1Author
Associate II
December 2, 2020

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

DDong.2
Associate
December 2, 2020

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 */

lhoan.1
lhoan.1Author
Associate II
December 3, 2020

Thanks all.

Finally, The timer work when I replace HAL Driver with LL Driver. So I think there is a bug on STM32CubeIDE Compiler when built HAL code. Because everything works well with Keil C.

TDK
TDKBest answer
December 3, 2020

> 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""."
lhoan.1
lhoan.1Author
Associate II
December 3, 2020

Hi, STM32CubeIDE already write these two above command in my code. And I already called the HAL_TIM_Base_Start_IT(&htim1) function after TIM1 was initialized

lhoan.1
lhoan.1Author
Associate II
December 3, 2020

Thank @TDK​ very much!

After disabled Slave Trigger mode. The Timer work well. Now I'm wondering why with the same configuration, Code compiled by KeilC work but not with SMT32CubeIDE. Is that a bug on KeilC? :D

TDK
December 3, 2020

Again, more likely to be a bug in your code rather than a bug in the compiler. The hardware is obviously the same between the two and the compilers are mature and don't have glaring errors like this. It probably isn't the same configuration.

"If you feel a post has answered your question, please click ""Accept as Solution""."
Ons KOOLI
Associate
December 7, 2020

Hi Ihoan.1,

Please mark this question as answered if your problem is well solved.

Best Regards,

Ons.