Sony's Developer World forum

    • Home
    • Forum guidelines

    Upcoming maintenance 

     

    Dear Customers and Partners.

    This website will be undergoing scheduled maintenance on June 14, 2023. Please be aware there may be disruption to the developer portal website and associated services during the scheduled maintenance period.

    This upgrade is essential to ensure the continued performance, reliability, and security of Developer World.

    We apologize for any inconvenience.

     

     

    Timer to measure time elapsed

    Spresense
    2
    2
    2627
    Loading More Posts
    • Oldest to Newest
    • Newest to Oldest
    • Most Votes
    Reply
    • Reply as topic
    This topic has been deleted. Only users with topic management privileges can see it.
    • T
      the_mutt last edited by

      I'm trying to use a timer to measure how long a sound I'm playing is lasting. Is there a register I can read to measure time elapsed?

      1 Reply Last reply Reply Quote
      • K
        KamilTomaszewski DeveloperWorld last edited by

        Hi

        You can use "time()" function for this.

        Example:
        time_t start_time;

        void setup() {
        Serial.begin(115200);
        time(&start_time);
        }

        void loop() {
        time_t cur_time;

        sleep(1);
        Serial.println(time(&cur_time) - start_time);
        }

        Best regards,
        Kamil

        1 Reply Last reply Reply Quote
        • First post
          Last post
        Developer World
        Copyright © 2021 Sony Group Corporation. All rights reserved.
        • Contact us
        • Legal