- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
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.
"Engineering is an Art. The Art of Compromise."
Solved! Go to Solution.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
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.
Cy_SysTick_ServiceCallbacks function is called during init
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
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
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
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.
Cy_SysTick_ServiceCallbacks function is called during init
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
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
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
You are correct. I realized it also when reviewing the Cypress-supplied SysTick callback service code.
"Engineering is an Art. The Art of Compromise."
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
hi @Len_CONSULTRON ,
Yups, I found it on this document
And try to check on each function of SysTick ( ARM timer ).
is there any concern from you ?
Warm regards,
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
No concern.
Regrettably, the function Cy_SysTick_GetCountFlag() is virtually useless once the SysTick resource is started.
"Engineering is an Art. The Art of Compromise."