8 years, 1 month ago.

Why is the performance of us_ticker_read() so poor?

Hello,
Since mbed revision #121 (mbed-dev revision #136) the resolution of us_ticker_read() function for NUCLEO-F103RB boards has been severely deteriorated (from 1us to about 1ms = 1000 times)! In addition, the function randomly returns time stamps that are in the past. This has negative impact on the performance of the wait() family of functions too.
As a result, components requiring precise timing (e.g. DS1820 etc.) do not work anymore.
A simple remedy would be to modify the us_ticker_read() function (see mbed-dev revision #135) as follows:

us_ticker.c

uint32_t us_ticker_read()
{
    uint32_t counter;

    if (!us_ticker_inited) us_ticker_init();
  
    counter = TIM_MST->CNT;
    counter += (uint32_t)(SlaveCounter << 16);
    
    return counter;
}



This issue has been fixed with mbed release 128. Thanks mbed/ST team. We appriciate your effort!

Question relating to:

Affordable and flexible platform to ease prototyping using a STM32F103RBT6 microcontroller.

2 Answers

8 years ago.

Zoltan,

Thanks for the update.

This issue has been fixed with mbed release 128. Thanks mbed/ST team. We appriciate your effort!

Best Regards,

Andrea, team mbed

Accepted Answer

I've the same problem currently on the mbed web for the STM32F103RB Nuceo... How can I get the current used release and how can I update it ? Or, how can I do a workarround ?

Best regards, Jean-Noel

posted by Chiper Le Renard 29 Nov 2016

Chiper,

Please update your mbed library to the latest revision :)

Regards,

Andrea, team mbed

posted by Andrea Corrado 30 Nov 2016

Hi Andrea, I've just right click on the mbed library symbol and selected the "update" choice. I can see I'm now in the release 130. But the issue remains. My program test is the following :

  1. include "mbed.h"

Serial pc(USBTX,USBRX,115200); Timer globalTimer;

float gt=0.; float T2=0.; int i=0;

int main() { globalTimer.start(); pc.printf("START\n"); while(1) { gt = globalTimer.read(); if (T2 > gt) pc.printf("ERROR %d\n",i++); T2 = gt; } }

Result : you get a lot of "ERROR" messages.

posted by Chiper Le Renard 30 Nov 2016

I see the example was not clear within my previous post ... the program test is the following :

include "mbed.h" Serial pc(USBTX,USBRX,115200); Timer globalTimer; float gt=0.; float T2=0.; int i=0;

int main() { globalTimer.start(); pc.printf("START\n");

while(1) { gt = globalTimer.read(); if (T2 > gt) pc.printf("ERROR %d\n",i++); normaly you should never get ERROR message ! T2 = gt; } }

Result : you get a lot of "ERROR" messages. (I also tried with read_us() function : same result...)

The function randomly returns time stamps that are in the past... Is it possible to fix this issue ?

posted by Chiper Le Renard 01 Dec 2016
8 years, 1 month ago.

I also had problems with us_ticker_read() on the Nucleo 411RE board and build 122. The function also randomly returns time stamps that are in the past and then counted from the past up again. But it could also be, that the function did a reset of the timer. I am not really sure at the moment.