Code execution time

cancel
Showing results for 
Search instead for 
Did you mean: 

Code execution time

140 Views
rafaalvescomp11
Contributor II

Hello,

I am using the Freedom KL25Z platform and also the Kinetis Design Studio IDE. I implemented a path planning algorithm for mobile robots and it takes about 11 seconds to execute (I used a stopwatch on my cell phone), but I would like to have a more accurate measurement. The support here indicated me to use systick, gpio with oscillator and monitor. I was unable to configure the gpio and oscillator to measure time. I studied the operation of the systick, which is a countdown timer, I managed to get the current value of the register, but the timer counts too fast not to catch the number of times the timer reaches 0. I locked in this part, what functions can I use or add to measure the execution of the code in KDS, something like, time = final - initial?

Regards,

Rafael

0 Kudos
6 Replies

101 Views
jingpan
NXP TechSupport
NXP TechSupport

Hi Rafael,

Systick is not a one time use component. Systick can trig interrupt periodically. Each time the interrupt happened, the interrupt service code update time record. When count stop, you should add the record and systick value to get the total time.

You can download KL82 SDK from mcuxpresso.nxp.com. In this SDK, there is a wolfssl_benchmark example. It use systick to count encryption/decryption time.

 

Regards,

Jing

61 Views
rafaalvescomp11
Contributor II

Hi Jing,

I downloaded the MCUXpresso IDE, selected the KL82 platform and downloaded the SDK, including the wolfssl_benchmark example. I added the functions of this example to my code, but the code did not compile. Presented the following compilation errors in KDS:


1) return SysTick_Config (CORE_CLK_FREQ / 1000); / * 1 ms period * /
2) currTick = SysTick-> VAL;
3) #define CORE_CLK_FREQ CLOCK_GetFreq (kCLOCK_CoreSysClk)

I made some adjustments but I'm not sure if it is correct, in 2 I put a function of the SysTick component:
currTick = SysTick_PDD_ReadCurrentValueReg (SysTick_DEVICE);

In 3:
#define CORE_CLK_FREQ 48000000 // 48MHz FRDM KL25Z processor clock

In 1, I was unable to find the implementation function of SysTick_Config (CORE_CLK_FREQ / 1000). How do I adjust this part?


Regards,
Rafael

0 Kudos

32 Views
jingpan
NXP TechSupport
NXP TechSupport

Hi,

Please include  <core_cm0plus.h>

 

Regards,

Jing

20 Views
rafaalvescomp11
Contributor II

Hi Jing,

I included the library <core_cm0plus.h> in the main, then added the library files CMSIS_5 / CMSIS / Core / Include /, such as "cmsis_compiler.h" declared in "core_cm0plus.h" in the project's Sources. I compiled the project and the following errors appeared in the file "core_cm0plus.h":

/Sources/core_cm0plus.h:850:41: error: unknown type name 'IRQn_Type'
__STATIC_INLINE void __NVIC_SetPriority (IRQn_Type IRQn, uint32_t priority)
This same error, of variable type declaration 'IRQn_Type', also appeared in other functions.

In function 'NVIC_EncodePriority' and in function 'NVIC_DecodePriority':
../Sources/core_cm0plus.h:905:64: error: '__NVIC_PRIO_BITS' undeclared (first use in this function)
PreemptPriorityBits = (((7UL - PriorityGroupTmp)> (uint32_t) (__ NVIC_PRIO_BITS))? (uint32_t) (__ NVIC_PRIO_BITS): (uint32_t) (7UL - PriorityGroupTmp);

How can I declare this type of variable 'IRQn_Type' and this variable '__NVIC_PRIO_BITS'?

Regards,
Rafael

0 Kudos

7 Views
jingpan
NXP TechSupport
NXP TechSupport

Hi,

#include "fsl_device_registers.h"

#include "core_cm0plus.h"

Include fsl_device_registers first, then include core_cm0plus.h.

 

Regards,

Jing

0 Kudos

92 Views
rafaalvescomp11
Contributor II

Thank you, i will take a look.

 

Regards,

Rafael

0 Kudos