This thread has been locked.

If you have a related question, please click the "Ask a related question" button in the top right corner. The newly created question will be automatically linked to this question.

TMS570LC4357 & WFI & clock couter.

Other Parts Discussed in Thread: TMS570LC4357, TMS570LS3137

Because I don't know details about Cortex-R5 core integration I would like to ask if does exist any way how to count clock cycles continuously.

We are using PMU unit and cycle counter PMCCNTR to measure program execution time in high precision. SW can store timestamps based on PMCCNTR with event information. And we can see in diagnostic  how to SW passes over check points with high precision.

But there is problem. It works perfectly on Cortex-R4 based TMS570LS3137, but not on Cortex-R5 based TMS570LC4357. Reason is simple. In first case counter is still running during standby caused by WFI instruction. In second case not.

Is there some workaround to keep PMCCNTR running continuously? Or some details about integration of Cortex-R5 into TMS570LC4357?

Thanks, Jiri

PS: I read ARM documentation ARM DDI 0460D and ARM DDI 0406C.b but it does not describe why these two processors have different behavior.

  • Jiri,
    I will forward your question to our LC43x expert, and he will be rsponding soon.
    Regards,QJ
  • Hi Jiri,

    I'm at about the same place you are, except I don't even see in the ARM documents any place where it's clearly stated what the PMU is *supposed* to do when a WFI is executed and the CPU enters standby. I would suspect that it is supposed to stop counting though, because they talk about turning off the clock to most logic.

    When you execute the WFI on the LS3137 are you also preceding it with code to enter one of the low power modes?

    In any case - I'll need to research this one. If you have an urgent need you might have to use one of the system level counters like the RTI that isn't affected by the WFI as something to calibrate the PMU against. i.e. if you spend the majority of time sleeping you could use the RTI to accumulate a 'total time' or 'total cycles' count ... but then use the more accurate PMU to measure the time various tasks are executing as a percentage of the CPU's waking time.

    Anyway, I'm filing this one in my 'challenge question' folder -- it's a good one.

    Best Regards,
    Anthony
  • Code for both processors is same (diffrence is in boot code, but not later if I ignore bug in ethernet buffer enddian)

    We are using WFI in RTOS background loop. Energy is not problem, but this can reduce MCU heat production (significant on edge condition with 85degC environment)

  • Jiri,

    We performed some file comparisons / diffs of the performance monitoring unit counter for both the R5 and the R4F.
    In both cases the logic was the same, and the clock that the counter ran off of was the same. And as far as we can tell, this is the same clock that the entire integer unit gets so it's hard to imagine it running during a true WFI.

    So, you've got us wondering about the results you've reported on the TMS570LS3137. Is there any way that the clock may not have actually stopped? for example could the WFI have exited almost immediately?

    Also what sort of current are you measuring in the case of the WFI on the 3137? that could be a clue..

    Talked to one of my colleagues (Charles Tsai) and he thought it might be a little tough to just 'see' the clock stop because the ECLK pin monitors the clock inputs to the Cortex, whereas we're looking at some indication of whether the clock gating inside the cortex was effective.
    So that's why I'm thinking a current measurement might be a good indicator of the effectiveness of your WFI test on the 3137.
  • Hi Jiri,

    Wondering if you had a chance to double check your results on the 3137 - since we're not seeing a difference in the PMU logic when we look at the RTL.
  • Till this moment I made only some tests. Now I am 100% sure, that both MCUs types execute WFI instruction. And I am 100% sure, that MCU really wait "inside" this instruction. It is same on both MCUs (same source code, same tests, same result except cycle counter)
    Next week I will try to do some more investigations (for ex measure ECLK and we will measure current)
    I don't know if some related engineer will be available on Embedded world next week (we will have some meeting with TI next thursday at EW). If yes, I can show it.

    If I undersund you correctly, behavior of TMS570LC4357 is correct. Therefore we must focus to TMS570LS3137.
    Frankely spoken, power consumption of MCU is not significat for us (if it not make heat). Simply because we can use computing power of MCU to save energy in bigger scale. But fact, that same source code have differnet behavior on similar (or "same") controlers force us to find where is differnce.
  • Ok, thanks Jiri. I know TI MCU will be at EW but I don't think anyone from our applications team will be there that would be this deep into the TMS570LS3137.

    Yes it seems to us like the 4357 is behaving correctly. There might be something keeping the LS3137 from going fully to sleep.

    If you have an example on the LS3137 that can run on one of our HDKs and show this behavior, we could analyze here.

    Thanks and Best Regards,
    Anthony