- 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