cancel
Showing results for 
Search instead for 
Did you mean: 

The relationship between the System Timer Module counter and the real time

QYRR
Visitor

[Part Number] AEK-MCU-C4MLIT1, SPC58EC80E5

[Environment] SPC5studio 6.0, UDE starterkit 2021.05(x86-64bit), integrated PLS debugger

[demo] SPC58ECxx_RLA AI BMS Test Application for Discovery

[Details]

I am working on a SPC5studio demo about the AI application. Below is a part of code from this demo. It caputers the timer counter value before the AI inference function running, and caputers the counter value again after running. Then it calculates the time interval by subtract them.

uint32_t timerNowUsec(void)
{
  return stm_lld_getcounter(&STMD3);
}

#define BENCHMARK_START(start_) { \
  start_ = timerNowUsec(); \
}

static uint32_t benchMarkEnd(const uint32_t start)
{
  const int32_t elapsed = (int32_t)(timerNowUsec() - start);
  return (elapsed < 0) ? 0 : (uint32_t) elapsed;
}

BENCHMARK_START(start)
// run the inference function here
us = BENCHMARK_END(start);
printf(CLI_RED "Inference time: " CLI_OFF "%.4f (ms) \r\n\n", us / 1000.0f);

 In the above code, it directly sets the value of "us" as the timer counter interval. So we can infer the timer will increases by 1 on each microsecond.

But the system timer clock(FBRIDGE_CLK) is 180MHz, and the prescaler is 90. In theory, it should increase by 2 on each microsecond.

QYRR_0-1728394961821.png

Does anyone know why the difference occurs?

 

 

0 REPLIES 0