The command "clock()" doesn't work correct for me, also the command "time()".
It always returns the 2^32-1.
My code looks like this:
clock_t begin = clock();
my_algo();
clock_t end = clock();
Normally the values of the variables should be different but in both variables (begin and end) are the same numbers... Always 4294967295 (2^32-1).
I am using a LPC4357 with LPCXpresso 8.1.4.
The clock-function comes from time.h from redlib....
I cannot use the RTC example from LPC Open, because it can only count seconds....
Solved! Go to Solution.
Have you read this thread?
time () does nothing | www.LPCware.com
i.e you have to implement __sys_time() yourself as the library has no idea of your hardware. It has to run on any cortex microcontoller.
You can count the number of cpu cycles or instructions by using the Data Watchpoint and Tracing feature (DWT) of ARM.
Example code tested on LPC1549:
// enable the use DWT |
*DEMCR = *DEMCR | 0x01000000;
// Reset cycle counter
*DWT_CYCCNT = 0;
// enable cycle counter
*DWT_CONTROL = *DWT_CONTROL | 1 ;
uint32_t cpuCycles = *DWT_CYCCNT;; |
/* Do something */
cpuCycles = *DWT_CYCCNT-cpuCycles;
float time=1.0*cpuCycles/Chip_Clock_GetSystemClockRate();
Hello,
To measure the executiotime of my functions, i set a portbit at the begin and clear it at the end of the function.
With an Oscilloscope i can read the Pulsewidth.
Know, that the times differ to the Compiler Optimization settings.
Ok, thank you for your help! You're right!
I had to make it via semihosting: WhatIsSemiHosting - ** Code Red Support Site **
I linked the main application against semihosting in the project properties and enabled semihosting in the board.h
Here did I find the solution: Using printf()
Thank you! :smileyhappy:
Hi,
thank you for your reply.
Yes, I saw this thread and I'll read it again now.
I'm running my code on a cortex m4. I have the LPC-Link2 for debugging.
I'll also look it up whether I have to implement __sys_time() anywhere.
I'll let you know the result :smileyhappy:
Have you read this thread?
time () does nothing | www.LPCware.com
i.e you have to implement __sys_time() yourself as the library has no idea of your hardware. It has to run on any cortex microcontoller.