4 years, 4 months ago.

Is it possible to run ticker object for more than 30 min?

I want to read log adc samples with a sampling rate of 0.01 seconds. So I used a ticker to create a timer and print adc data on terminal. But it is observed that about after 30 mins the terminal stops displaying any data on it. I use NRF52 microcontroller. Is it possible to using ticker object for more than 30 mins duration(I need around 8 hours data sampling continously)?

Yes, it should work. Otherwise it is a bug. Since the NRF timer code has been one large bug in the paste, are you running the latest mbed version?

posted by Erik - 03 Sep 2017

Hi Erik. Yes, I am using latest version of mbed.

posted by Manoj G. 04 Sep 2017

1 Answer

4 years, 4 months ago.

Internally the Ticker object (and Timers and Timeouts) uses a int32_t to count time in us. 2^31 us = 35.79 minutes.

If you need a lower resolution clock to run for a longer time then the best solution is to set a Ticker or Timeout to run at a 1ms rate and then use that to create a clock that gives you 1ms resolution. That will then give you just under 25 days before you need to worry about roll overs.

Accepted Answer

Hi Andy, Thanks for your answer. But I don't get it how I can change the resolution of the ticker object. Is it possible for you to paste a code snippet on how to set resolution to 1 ms? Or do you mean to say to use ticker object instead of ticker_us object for running code? Regards, Manoj

posted by Manoj G. 04 Sep 2017

You don't change the resolution. Ticker and Ticker_us are two ways to configure the same thing.

You create your own counter either as an object or a counter that runs at whatever speed you want.

posted by Andy A 04 Sep 2017

Well, Thanks for the help. Finally I found it was not the problem with Ticker object rather it was some other problem. May be with BLE, included in my code. Regard, Manoj.

posted by Manoj G. 04 Sep 2017