Code execution time

cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 

Code execution time

2,960 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
Reply
9 Replies

2,920 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

2,881 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
Reply

2,852 Views
jingpan
NXP TechSupport
NXP TechSupport

Hi,

Please include  <core_cm0plus.h>

 

Regards,

Jing

2,840 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
Reply

2,827 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

2,816 Views
rafaalvescomp11
Contributor II

Hello Jing, 

I researched the #include “fsl_device_registers.h" and found the file included in an SDK, the KSDK.
I downloaded and installed KSDK 1.3.0 on IDE KDS 3.2.0, I am using the Windows 7 operating system. However, when I compile any project, the error below appears:

make all

Cannot run program "make": O sistema não pode encontrar o arquivo especificado.

Error: Program "make" not found in PATH

PATH=[C:\Freescale\KDS_v3\eclipse\..\bin;C:\Freescale\KDS_v3\eclipse\..\toolchain\bin;C:/Freescale/KDS_v3/eclipse//features/com.somniumtech.jre.win32.win32.x86_1.7.0.76/jre/bin/client;C:/Freescale/KDS_v3/eclipse//features/com.somniumtech.jre.win32.win32.x86_1.7.0.76/jre/bin;C:/Freescale/KDS_v3/eclipse//features/com.somniumtech.jre.win32.win32.x86_1.7.0.76/jre/lib/i386;C:\Windows\system32;C:\Windows;C:\Windows\System32\Wbem;C:\Windows\System32\WindowsPowerShell\v1.0\;C:\Program Files\PuTTY\;C:\Freescale\KDS_v3\eclipse]

And when I debug any project now this error appears:

Problem Occurred

An error has occurred. See error log for more details.

java.lang.NullPointerException

An error has occurred. See error log for more details.

java.lang.NullPointerException

 

I tried to go to Project → Properties → C / C ++ Build → Tool Chain Editor and change Gnu Make Builder to CDT internal Builder, but it didn't work. Do you know what may be causing these errors?

 

0 Kudos
Reply

2,786 Views
rafaalvescomp11
Contributor II

I uninstalled the KDS software and SDK and installed it again and it worked to compile and debug an example program using Processor Expert.

0 Kudos
Reply

2,771 Views
jingpan
NXP TechSupport
NXP TechSupport

Hi,

If possible, I suggest MCUXpresso IDE 11.3.  It is our most update IDE, it support KL25 SDK v2.x.

 

Regards,

Jing 

2,912 Views
rafaalvescomp11
Contributor II

Thank you, i will take a look.

 

Regards,

Rafael

0 Kudos
Reply