Related to timer problem.

Hello team Renesas,

                  We are currently using RL78/F13 - R5F10BFC for our automotive purpose. We are planning to calculate the algorithm execution time. Here we have configured the timer (1us) for calculating execution time for our algorithm by starting the timer before algorithm and stopped using software breakpoint. A variable is incrementing in the respective timer callback function, and we have got 184 counts after the software breakpoint. For confirming that we have configured another timer as (2us) and executed the same process with same algorithm. As per our expectation it should be around 90 to 92 but the actual count was 9. Further increasing the timer to 3us got 4 as a count, 4us got 2 as a count and so on. Need to confirm whether the issue is related with our process or the timer.



  • Hi ,

    You didn't mention what timer you're using but I'm assuming it's the TAU. I'm using GCC for RL78 and when I configure the TAU's Interval Timer for 1us, jumping to its ISR takes at least 6us (removing the unrelated code lines to the channel being used) under no optimization. This might be because of the overhead that the compiler generates. So, have you confirmed if your 1us is really 1us?

    My other suggestion if you want to measure the execution time of a code block is to set a pin HIGH before executing the code then set the pin to LOW after executing the code. Then just measure the width of the pulse. I measured the time it takes to set a pin HIGH before. I think it was around 309ns. You can just subtract it to the total width of the pulse.

    JB
    If this response, or one provided by another user, answers your question, please verify the answer. Thank you!
    Renesas Engineering Community Moderator
    https://community.renesas.com/
    https://academy.renesas.com/
    https://en-support.renesas.com/knowledgeBase/

  • I might suggest that to measure execution time of code in the software would be to use a free-running timer and simply read the timer at the start and end of the code block of interest.  Take the delta from the measurements as the interval time.  You get much better precision and have a lot less overhead.