- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Hello everyone,
As the title i would love to know how long does it take for PSoC 5LP to process a command?
Thanks,
Hai Lai
Solved! Go to Solution.
- Labels:
-
PSoC 5LP
- Tags:
- psoc 5lp
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Hai Lai,
That can be a complex question.
A 'command' or opcode will will execute depending on your BUS_CLK frequency. On the PSoC5LP this can be a maximum of 80MHz.
Depending if an opcode needs to read or write to EEPROM or peripheral device could slow down the execution speed.
Ultimately, what are you trying to determine? If you're just trying to determine how long it takes to execute a function, there are better methods. One method is to place a framing pulse using a GPIO pin before and after the function.
For example:
main()
{
...
Pin_0_0_Write(1); // Turn on the GPIO pin
function_2_time(); // This is the function to time
Pin_0_0_Write(0); // Turn off the GPIO pin
...
}
Use an scope to determine the timing of the pulse width. This is the timing of the function.
Len
"Engineering is an Art. The Art of Compromise."
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Hai Lai,
That can be a complex question.
A 'command' or opcode will will execute depending on your BUS_CLK frequency. On the PSoC5LP this can be a maximum of 80MHz.
Depending if an opcode needs to read or write to EEPROM or peripheral device could slow down the execution speed.
Ultimately, what are you trying to determine? If you're just trying to determine how long it takes to execute a function, there are better methods. One method is to place a framing pulse using a GPIO pin before and after the function.
For example:
main()
{
...
Pin_0_0_Write(1); // Turn on the GPIO pin
function_2_time(); // This is the function to time
Pin_0_0_Write(0); // Turn off the GPIO pin
...
}
Use an scope to determine the timing of the pulse width. This is the timing of the function.
Len
"Engineering is an Art. The Art of Compromise."
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
LaHa,
Using pin method has some drawbacks. Pin_Write/Read call execution is very slow and takes about 40-60 BUS_CLK cycles each, depending on debug/release mode. It requires o-scope and consumes a hardware pin. This approach works fine if microsecond resolution is sufficient.
If single BUS_CLK resolution is required using system counters provides an alternative solution, see here:
/odissey1
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
/odissey1,
You are correct the pin method has it's drawbacks. (I did realize that it could take 40-60 BUSCLK cycles. I knew that the _Write function has to do some bit shifting and AND'ing. I suppose you can write directly to the register if you needed less BUS_CLKs).
The method with the least latency is the one where the start event starts a very fast timer and then the end event stops the timer. Then the SW can go in and read how many counts have occurred.
Len
"Engineering is an Art. The Art of Compromise."
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
/odissey1,
Thanks for sharing the link. It's a good tutorial on latencies in code and HW.
Len
"Engineering is an Art. The Art of Compromise."
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Hai Lai,
As /odissey1 pointed out there are drawbacks in the pin framing (or toggle) method. However, there is a way to remove the BUS_CLKs from the framing commands.
- Write the following framing code all by itself. Program the chip.
main()
{
...
Pin_0_0_Write(1); // Turn on the GPIO pin
Pin_0_0_Write(0); // Turn off the GPIO pin
...
}
- Using a scope, time the pulse width. This will equal tframe.
- Place the framing around the target function code. Program the chip.
main()
{
...
Pin_0_0_Write(1); // Turn on the GPIO pin
function_2_time(); // This is the function to time
Pin_0_0_Write(0); // Turn off the GPIO pin
...
}
- Using a scope, time the pulse width. This will equal tfunction.
- Subtract tframe from tfunction. The remaining time is the time taken to execute the function without the framing time. You will be accurate to nsecs
Len
"Engineering is an Art. The Art of Compromise."
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Hi All,
on the PSoC5LP = Cortex M3 it is possible to use DWT too. DWT_CYCLE_COUNT (0xE0001004) is the 32bit long upcounter counting BUS_CLOCKs. By overclocking the PSoC5LP on CY8CKIT-059 to 100 MHz is the accuracy - precision 1 BUS_CLOCK (10 nanoseconds).
Tested.
You need only to ....
a. enable TRCENA (bit 24) in the Debug Exception and Monitor Control Register (0xE000EDFC) aka enabling the DWT structure
b. clear all 32 bits in the DWT_CYCLE_COUNT (0xE0001004) aka set / reset the DWT counter to zero
c. enable CYCCNTENA (bit 0) in the DWT_CTRL (0xE0001000) aka enabling counting DWT counter
and
d. read the DWT_CYCLE_COUNT (0xE0001004) aka periodically read the DWT counter content on the fly
#define DWT_CTRL 0xE0001000
#define DWT_CYCLE_COUNT 0xE0001004
#define CORE_DBG_EXC_MON_CTL 0xE000EDFC
uint32 SysCntVal = 0;
....
(*(int*)CORE_DBG_EXC_MON_CTL |= 0x01000000); // = TRCENA
(*(int*)DWT_CYCLE_COUNT) = 0; // = Set counter to Zero
(*(int*)DWT_CTRL) |= 0x1; // = DWT Counter enable CYCCNTENA
....
SysCntVal = (*(int*)DWT_CYCLE_COUNT);
Viktor
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Hi ViDv_264506,
It's great if you provide more project samples, because many people like me are beginers.
Thanks you.
Hai Lai