- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Hi,
If the debug tool does not have the feature for counting the number of cycles (for example, PSoC Creator and ModusToolbox), there are several ways to measure with the timer as follows:
- GPIO output + oscilloscope
GPIO is output as High / Low and measured with an oscilloscope. It is effective when measuring a long time.
- Systick timer
It is effective when simply measuring the number of cycles, but it may be used in other time-related APIs.
- DWT (data watchpoint and trace)
It is an ARM emulation function for cortex M3/M4 and can be used when the debugger is not using it.
- Peripheral timer (Clk_timer)
Slower than CPU frequency.
- CP15 time stamp counter
Available on ARM Cortex A and R, but not Cortex M.
In this time, I attached a sample of Cycle measurement using DWT which would be not used often. Please use it if you are interested.
Note: DWT can only be measured from Debugging of PSoC Creator.
SampleCode:
The program just calls the DWT counter value for the function you want to measure in main_cm4.c based on the sample program of "CE223001-PSoC 6 MCU UART printf" and calculates the difference. the key points of this program as below.
DWT registers:
#define DWT_CTRL 0xE0001000
#define DWT_CYCLE_COUNT 0xE0001004
DWT setting:
(*(int*)DWT_CTRL) |= 0x1; // Counter enable
(*(int*)DWT_CYCLE_COUNT) = 0; // Set counter to Zero
Call DWT counter:
SysCntVal = (*(int*)DWT_CYCLE_COUNT);
CyDelay(10); // API to be measured
SysCntVal = (*(int*)DWT_CYCLE_COUNT) - SysCntVal;
I checked this program on PSoC 6 BLE Pioneer Kit CY8CKIT-062-BLE.
Thanks,
- Labels:
-
PSoC 6
- Tags:
- dwt
- psoc 6 creator
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
NoTa,
Does it going to work on PSoC5 and PSoC4?
/odissey1
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Hi odissey1,
This feature is on ARM Cortex M3 and M4.
Unfortunately, PSoC 4 is not available.
I am not sure about PSoC 5 because I don't have the board.
I would be grateful if someone could confirm with PSoC 5.
Thanks,
Kenshow
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Hi,
Originally, DWT is a function used by the debug tool. It is used for cycle measurement between breakpoints and profiling functions, and is used by third party debug tools.
I hope Modus Toolbox and PSoC Creator will be able to display cycle counts using this feature.
Thanks,
Kenshow
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Dear Kenshow-san,
We appreciate your contribution for this.
Best regards.