Skip to main content
parth kothiya
Associate III
Jan 5, 2022 7:14 AM UTC
Question

Is there any bug in code HAL_Delay() not works?

HAL_Delay() function gives infinite delay.

i am toggle led using delay.

below my simple project files.

This topic has been closed for replies.

5 replies

Tesla DeLorean
Guru
Jan 5, 2022 11:35 AM UTC

It needs the SysTick or other TIM source to interrupt and count.

It therefore has some interrupt and priority issues if miss used under interrupt context or callbacks.​

Tips, Buy me a coffee, or three.. PayPal Venmo (See Profile) Up vote any posts that you find helpful, it shows what's working..
TDK
Jan 5, 2022 3:33 PM UTC

You can inspect the source for HAL_Delay and verify it's doing the right thing. It doesn't need to be treated as a black box.

"If you feel a post has answered your question, please click ""Accept as Solution""."
parth kothiya
Associate III
Jan 6, 2022 10:21 AM UTC

as you said i removed HAL_Delay() function and i monitor variable uwTick maimum value of variable is 406 then variable is automatically set to 0 you can see in below image.

that's the problem but why it get automatically reset to 0

so i check reset pins of MCU automatically pulled low continuous time interval so my MCU get RESET i don't know why its automatically pulled low?

0693W00000HqkMUQAZ.bmp

TDK
Jan 6, 2022 3:11 PM UTC

I didn't say to remove HAL_Delay.

Monitor RCC_CSR register at startup to determine the cause of reset.

"If you feel a post has answered your question, please click ""Accept as Solution""."
parth kothiya
Associate III
Jan 7, 2022 2:04 PM UTC

I read rcc_csr before halinit function

It shows internal watchdog timer reset bit set

​I haven't set any watchdog timer in my program.

i preform full chip erase and then i read RCC_CSR it gives same value.

​