Skip to main content
DYann.1
Senior II
March 8, 2023
Question

HAL_Delay

  • March 8, 2023
  • 10 replies
  • 17151 views

Hello,

I tried the Hal_Delay function but it's not work Do you have any idea for this error ?

0693W00000aITvBQAW.pngAnd my code still waits at this loop :

0693W00000aITvqQAG.pngThank you for your helps

Regards

This topic has been closed for replies.

10 replies

DYann.1
DYann.1Author
Senior II
March 8, 2023

Hi,

In this function is something missing ?

0693W00000aITxvQAG.pngthere is no IRQ inside this function ?

LCE
Principal II
March 8, 2023

Have you configured / activated the SysTick?

It looks like you're using CubeMX, there's a a setting somewhere you have to click, quite on top under system or so.

In source activation should be done in the baic MCU config.

DYann.1
DYann.1Author
Senior II
March 8, 2023

Hello,

I'm not familar with the code (I'm a new user), I prefer to go through Cube IDE. I suppose it's this tab I need to activate ?

0693W00000aIUMiQAO.pngAnd I select SysTick probably ?

0693W00000aIUbRQAW.pngno parameters to be configured ? What does that mean ? I specify that I have an evaluation board STM32L552E-EV.

Senior
December 5, 2023

Thank you DYann.1.  I do have the Timebase Source set to SysTick.

LCE
Principal II
March 8, 2023

Or just add this:

	/* use systick as time base source and configure 1ms tick (default clock after Reset is HSI) */
	HAL_InitTick(TICK_INT_PRIORITY); // TICK_INT_PRIORITY = 0
	HAL_NVIC_SetPriority(SysTick_IRQn, 0, 0);
	HAL_NVIC_EnableIRQ(SysTick_IRQn);
 

Senior
December 5, 2023

LCE,

I added this code that flashes an LED between purple and green at 100ms intervals but the code locks at the first call to Hal_Delay().  If I comment out the first while loop so that my delay function is used instead, the LEDs flash as expected so I know the interrupts are enabled (my functions use them):

 

HAL_InitTick(0); // TICK_INT_PRIORITY = 0

HAL_NVIC_SetPriority(SysTick_IRQn, 0, 0);

HAL_NVIC_EnableIRQ(SysTick_IRQn);

 

while(1)

{

HAL_Delay(100);

ledOverride(IC_PUR);

HAL_Delay(100);

ledOverride(IC_GRN);

}

 

while(1)

{

timerDelay(100);

ledOverride(IC_PUR);

timerDelay(100);

ledOverride(IC_GRN);

}

 

Tesla DeLorean
Guru
March 8, 2023

Technically it is classified as a System Handler not an IRQ, and it also doesn't use the HALs callback abstraction.

The MCU doesn't start it automatically, and it needs a clock cycle count that relates the processor's clocking speed with the desired interrupt rate. This is often 1 KHz, but doesn't have to be.

I​t is implemented as a 24-bit down counter.

Tips, Buy me a coffee, or three.. PayPal Venmo (See Profile) Up vote any posts that you find helpful, it shows what's working..
DYann.1
DYann.1Author
Senior II
March 8, 2023

Hello Tesla,

You say : 'and it needs a clock cycle count that relates the processor's clocking speed with the desired interrupt rate'.

Can you give me more detail How I can do it ? Thank you

Tesla DeLorean
Guru
March 8, 2023

If the MCU is clocking at 110 MHz, that's 110,000,000 cycles per second, there are 110,000 cycles in 1ms (1 KHz), if the prescaled clock source is DIV8, that would be 13,750 cycles.

Tips, Buy me a coffee, or three.. PayPal Venmo (See Profile) Up vote any posts that you find helpful, it shows what's working..
DYann.1
DYann.1Author
Senior II
March 9, 2023

Hello Tesla,

After your explanation I try to have 110 MHz, it's ok but I don't understand what do you mean prescaled clock source is DVI8 ? I have this configuration can you show me this prescaler on this picture please ?

0693W00000aIZ8KQAW.pngit seems to me that I have a prescaler of 55 to have 110 MHz.

Karl Yamashita
Principal
March 8, 2023

Upload your IOC file so we can check if you configured it correctly.

If a reply has proven helpful, click on Accept as Solution so that it'll show at top of the post.CAN Jammer an open source CAN bus hacking toolCANableV3 Open Source
DYann.1
DYann.1Author
Senior II
March 8, 2023

Hello,

Sorry I don't know how to upload .IOC file but I can give you the screenshot.

0693W00000aIV2rQAG.png0693W00000aIV3aQAG.png

DYann.1
DYann.1Author
Senior II
March 8, 2023

I try somthing and I don't know if it's work correctely. Please see in this attached.

Karl Yamashita
Principal
March 10, 2023

You IOC file shows the System Tick at priority 7 when by default it is 0, though that is still probably not the problem.

Set a breakpoint at HAL_IncTick() and see if it gets called?

If a reply has proven helpful, click on Accept as Solution so that it'll show at top of the post.CAN Jammer an open source CAN bus hacking toolCANableV3 Open Source
DYann.1
DYann.1Author
Senior II
March 10, 2023

After set a breakpoint in the function HAL_IncTick()

0693W00000aIeznQAC.pngit does not pass in this function, probably I have to write an additional code ?

About System Tick at priority 7, I left the default settings

baydı.1
Associate II
August 4, 2023

Hello, 

      Did you solve this issue? I have encountered same problem. Please indicate if you find the solution.

Thanks

Associate
August 28, 2023

Anyone have a solution to this issue? I wish ST would address this problem

Associate
August 28, 2023
baydı.1
Associate II
September 1, 2023

Thank you UMP-Dan, It also works for me. Best.