Cy_SysTick_GetCountFlag() Issue.

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

cross mob
lock attach
Attachments are accessible only for community members.
Len_CONSULTRON
Level 9
Level 9
Beta tester 500 solutions authored 1000 replies posted

Hi,c

I have potentially detected a Cy_SysTick_GetCountFlag() Issue.

Problem:  Cy_SysTick_GetCountFlag() inconsistently reports a SysTick counter reached 0 count.

Attached is a MTB project highlighting the issue.

Project summary:

  • Targeted for the CY8CPROTO-063-BLE although any PSoC6 board will suffice.
  • Uses retarget-io to the standard debug terminal @ 115.2Kbps.
  • Sets up a SysTick with:
    • CLK_LF as the source (CLK_LF routed to WCO)
    • Reload = (1<<16)-1 =  65535.  This is to have the wrap-around for the SysTick every 2 secs.
    • Callback is Set.
    • Cy_SysTick_GetCountFlag() called in for(;;) loop

The code is very simple.

If the systick_wrap variable is incremented in the Callback ISR, "SysTick counter wrapped!" is printed to the terminal.

If the getcount_flag variable is incremented in the Callback ISR, "GetCount_Flag received!" is printed to the terminal.

Expectations:

The optimum result is that every 2 secs the terminal should have:

SysTick counter wrapped!

GetCount_Flag received!

Actual Observations:

Every 2 secs,  either "SysTick counter wrapped!" OR "GetCount_Flag received!" is printed.

Modified code:

If I comment out lines 133-136 in main.c (disabling the Cy_SysTick_GetCountFlag() call and leaving the Callback enabled)

I get "SysTick counter wrapped!" EVERY 2 secs!

If I comment out line 112 in main.c (disabling the Callback but enabling the Cy_SysTick_GetCountFlag() call)

I get "GetCount_Flag received!" erratically.

I realize some SysTick API calls clear the Count flag as a side-effect.  Once in the for(;;) loop, Only the Callback and the Cy_SysTick_GetCountFlag() is called.

Len

Message was edited by: Len This issue has been reproduced in PSoC Creator as well. Project Attached.

Len
"Engineering is an Art. The Art of Compromise."
0 Likes
1 Solution
Andri-setyabudi
Level 5
Level 5
50 likes received 50 sign-ins 25 solutions authored

Hi @Len_CONSULTRON , 

I think the reason why you got  "GetCount_Flag received!" erratically,  while you comment out line 112.

Because of the interrupt callback has been defined to call "Cy_SysTick_GetCountFlag()" inside Cy_SysTick_ServiceCallbacks.

The flag is cleared once the "Cy_SysTickGetcoutFlag()" function has been executed. 

IMG-20230411-WA0003.jpg

 Cy_SysTick_ServiceCallbacks function is called during init 

IMG-20230411-WA0004.jpg

I tried to comment out line 112 and put "Cy_SysTick_DisableInterrupt()" after Cy_SysTick_Init and i got the message "GetCount_Flag received!" every 2 seconds

IMG-20230411-WA0005.jpg

since the count flag will be cleared automatically on interrupt event, i think you can't get  

" SysTick counter wrapped !" and "GetCount_Flag received!" on your terminal for every 2s

 

Warm regards, 

Andri Setyabudi

View solution in original post

4 Replies
Andri-setyabudi
Level 5
Level 5
50 likes received 50 sign-ins 25 solutions authored

Hi @Len_CONSULTRON , 

I think the reason why you got  "GetCount_Flag received!" erratically,  while you comment out line 112.

Because of the interrupt callback has been defined to call "Cy_SysTick_GetCountFlag()" inside Cy_SysTick_ServiceCallbacks.

The flag is cleared once the "Cy_SysTickGetcoutFlag()" function has been executed. 

IMG-20230411-WA0003.jpg

 Cy_SysTick_ServiceCallbacks function is called during init 

IMG-20230411-WA0004.jpg

I tried to comment out line 112 and put "Cy_SysTick_DisableInterrupt()" after Cy_SysTick_Init and i got the message "GetCount_Flag received!" every 2 seconds

IMG-20230411-WA0005.jpg

since the count flag will be cleared automatically on interrupt event, i think you can't get  

" SysTick counter wrapped !" and "GetCount_Flag received!" on your terminal for every 2s

 

Warm regards, 

Andri Setyabudi

@Andri-setyabudi 

You are correct.  I realized it also when reviewing the Cypress-supplied SysTick callback service code.

Len
"Engineering is an Art. The Art of Compromise."
Andri-setyabudi
Level 5
Level 5
50 likes received 50 sign-ins 25 solutions authored

hi @Len_CONSULTRON , 

Yups, I found it on this document 

Andrisetyabudi_0-1681367688512.png

And try to check on each function of SysTick ( ARM timer ).

is there any concern from you ? 

Warm regards, 

 

0 Likes

@Andri-setyabudi ,

No concern.

Regrettably, the function Cy_SysTick_GetCountFlag() is virtually useless once the SysTick resource is started. 

Len
"Engineering is an Art. The Art of Compromise."
0 Likes