Hi Fabio Benevento,
You don't need the lib, it's very simple, just use systick to calculate the code execute time.
Give you an example from other MCU:
systick_init();
cal_systick_read_overhead();
systick_disable();
systick_init();
logic_op_demo_with_normalc();
systick_disable();
uint32_t cnt_start_value;
uint32_t cnt_end_value;
uint32_t overhead;
void systick_init(void)
{
SYST_CVR = 0x0; //clear current timer value
SYST_RVR = 0x00FFFFFF;
SYST_CSR = SysTick_CSR_CLKSOURCE_MASK | SysTick_CSR_ENABLE_MASK;
}
void systick_disable(void)
{
SYST_CSR &= ~SysTick_CSR_ENABLE_MASK;
}
void cal_systick_read_overhead(void)
{
uint32_t cnt_start_value;
uint32_t cnt_end_value;
cnt_start_value = SYST_CVR;
cnt_end_value = SYST_CVR;
overhead = cnt_start_value - cnt_end_value;
#ifdef DEBUG_PRINT
printf("systick start value: 0x%x\n\r", cnt_start_value);
printf("systick end value: 0x%x\n\r", cnt_end_value);
printf("systick current value read overhead: 0x%x\n\r", overhead);
#endif
}
void logic_op_demo_with_normalc(void)
{
uint32_t cnt_start_value;
uint32_t cnt_end_value;
uint32_t execution_cycle; //actual execution cycle
//configure PTA5 as GPIO
PORTA_PCR5 = PORT_PCR_MUX(1);
//configure PTA5 as output pin
GPIOA_PDDR |= 0x20;
cnt_start_value = SYST_CVR;
GPIOA_PDOR ^= 0x20;
cnt_end_value = SYST_CVR;
execution_cycle = cnt_start_value - cnt_end_value - overhead;
#ifdef DEBUG_PRINT
printf("systick start value: 0x%x\n\r", cnt_start_value);
printf("systick end value: 0x%x\n\r", cnt_end_value);
printf("actual execution cycle for logic operation with normal C code: 0x%x\n\r", execution_cycle);
#endif
}
The above example is used to check the GPIOA_PDOR ^= 0x20; execution time.
Wish it helps you!
Have a great day,
Kerry
-----------------------------------------------------------------------------------------------------------------------
Note: If this post answers your question, please click the Correct Answer button. Thank you!
-----------------------------------------------------------------------------------------------------------------------