Code got stuck at cyhal_system_delay_ms()

Tip / Sign in to post questions, reply, level up, and achieve exciting badges. Know more

cross mob
JoCh_1493306
Level 3
Level 3
25 sign-ins 10 replies posted 10 questions asked

Hi,

I have a test code running on my custom BSP and it somehow got stuck at cyhal_system_delay_ms(). I ran the debug mode and found that inside cyhal_system.c "cy_rtos_delay_milliseconds(milliseconds);" never returns:

pastedImage_0.png

I did include "freertos.h" and "task.h". But even though I don't include these 2 libraries, I still see it got stuck here.

Then I replaced "cyhal_system_delay_ms()" with "CyDelay()" and it works. What is difference between these 2 APIs? And what does it crash at "cyhal_system_delay_ms()"?

Does it have anything to do with the system clock setup?

Thank you!

0 Likes
1 Solution

Your application didn't include freertos.h, but the implementation of cyhal_system_delay does. You just need to have one of the MACROs defined - CY_RTOS_AWARE or COMPONENT_RTOS_AWARE to execute that function with RTOS hooks. Look at your your Makefile. You probably included the RTOS_AWARE component or added the CY_RTOS_AWARE define.

View solution in original post

0 Likes
3 Replies
RodolfoGL
Employee
Employee
250 solutions authored 250 sign-ins 5 comments on KBA

Have you called from a task or from the main loop?

If you called this before starting the scheduler, you would get stuck in there.

0 Likes

Hi,

I called it from the main loop. Even though I don't include "freertos" library, which means no scheduler start is needed, it still doesn't work.

Thanks.

0 Likes

Your application didn't include freertos.h, but the implementation of cyhal_system_delay does. You just need to have one of the MACROs defined - CY_RTOS_AWARE or COMPONENT_RTOS_AWARE to execute that function with RTOS hooks. Look at your your Makefile. You probably included the RTOS_AWARE component or added the CY_RTOS_AWARE define.

0 Likes