This discussion has been locked.
You can no longer post new replies to this discussion. If you have a question you can start a new discussion

Calculation of time

Hi Team,

Does it have some functions to calculate the working time from the starting point on nrf52850 chips?

Best,

Gaosheng

Parents Reply Children
  • Oh, I see - thank you for clarifying.

    There is no innate function for checking time since chip startup, but you could start a timer at the beginning of your main function and read that out later to see how long time the device has been on for. This will however only capture that time that code has been executing on the chip, so it does not encompass the time it took to power up and run the code to start the timer.

    What are your requirements for your timing - how accurate does it need to be, and what resolution are you looking for?

    Best regards,
    Karl

  • Hi Karl,

    My requirement is to calculate the time from the starting point to the drown-out. I want to preserve the value on flash memory. Then next time, I can read from the flash memory. The resolution I think it is ms level.

    Best, 

    Gaosheng

  • Hello again, Gaosheng

    Aha, I see - then I suggest setting up an RTC or app_timer instance at the beginning of your main(), and then write its value to FLASH every so often. Using the RTC or app_timer instance will have a lower power consumption as well as a lower accuracy than using the TIMER peripheral for this task. Since you only need accuracy in the ms magnitude it will be totally fine to use the low power options for this.

    Best regards,
    Karl

  • Hi Karl,

    Thanks! The last question: Do you have any examples for recording time?

    With best regards,

    Gaosheng

  • From your other tickets it seems that you are using the nRF5 SDK, in which case you can see a demonstration of the RTC peripheral usage in the RTC peripheral example, or you could read about the app_timer library here - the app_timer library is also extensively used in the BLE peripheral examples in the SDK, if you want to see its usage demonstrated.

    Best regards,
    Karl

Related