cancel
Showing results for 
Search instead for 
Did you mean: 

osDelay returns too early

KAgga.1
Associate III

Hello There,

I'm working on an app utilizing STM32H7A3 with CMSIS-OS2.
I'm facing a problem with osDelay(). Most of the time it returns too early than the actual delay. While HAL_Delay() always works fine.

I have debugged osDelay(3500) with oscilloscope. It's giving a delay of 141ms.
The before and after ticks were also 5537 and 5678 respectively.
Freertos tick rate is 1000Hz.

I have also tried setting the delay between 500 and 3500. But the actual one comes out to be 100-200ms.
Any help is appreciated.

Regards,

Keshav Aggarwal

13 REPLIES 13
KAgga.1
Associate III

Can anyone help me on this?

Pavel A.
Evangelist III

What is your MCU core clock source and rate? Have you used CubeMX/IDE to generate clock setup code?

 

Yes I used CubeIDE. Below is the clock configuration.

KAgga1_1-1707888310116.png

 

@Pavel A. I think the issue is with the Freertos/CMSIS_OS2 as osThreadSuspend/osThreadResume is conflicting with osDelay.
I also checked the stacks. They were fine.