Therefore, a call to this function always returns a non-negative value ranging from 0 to TICKS_MAX inclusive, which is indicative of the milliseconds in mentioned range passed onwards an arbitrary point of time. It is called TICKS_PERIOD, which is equal to one more than TICKS_MAX. The wrap-around value used as the maximum range is always in the power of 2 so that it remains the same across the MicroPython implementation irrespective of the port. Though, the millis() function in Arduino returns a time interval in milliseconds from the boot-up of the Arduino board, the time.ticks_ms() assumes an arbitrary point of time for reference. It is somewhat similar to millis() function in Arduino. Time.ticks_ms(): This method returns the number of milliseconds passed onwards an arbitrary reference. If 0 is passed as the argument, the delay will equal the time spent executing the interrupt service routine. If used for a timer interrupt, the delay can extend till the execution of the interrupt service routine is finished. A positive number or zero can be passed as an argument. Time.sleep_us(us): This is yet another blocking method that provides a delay in microseconds. If it is used for a timer interrupt, the delay can extend till the execution of the interrupt service routine is finished. A positive number or zero can be passed as an argument to this method. Compared to time.sleep(), this method is more precise. Time.sleep_ms(ms): This is another blocking method that provides a delay in milliseconds. Once the method is called, the controller stops the execution of the user program for the set number of seconds. Some ports allow specifying the delay time as a floating-point number. Time.sleep(seconds): This blocking method provides a delay in seconds. The time module provides the following time, date, and delay-related functions. The time setting can be done manually through a network protocol or a battery backup. The time-related functions of MicroPython query the OS/RTOS or RTC for maintaining or setting date and time. A built-in RTC may manage this in the case of microcontroller ports. It is important to note that the setting and maintenance of calendar time depends upon the OS or RTOS installed on the supported port like in Raspberry Pico. The MicroPython time-related functions are compatible with embedded ports, which use the epoch of 00:00:00 UTC instead of the POSIX systems epoch of 00:00:00 UTC. This module is a re-implementation of a CPython module of the same name. MicroPython provides a time module for time delays, intervals, and date-time maintenance. Finally, we will use the aforementioned concepts to design an ESP8266 ticker. Then, we will examine timers available in ESP8266 and ESP32. This article will explore timers and the implementation of timer interrupts in MicroPython. Some of these timers may be reserved for specific functions like networking or Wi-Fi, while the remaining timers could be utilized within the user’s application. All MicroPython ports have one or more timers. The timer interrupts are often used when precise timing is required without a fraction of error. Timers and timer interrupts are of great use in microcontroller applications. Timers are one of the common hardware features in all microcontrollers.
0 Comments
Leave a Reply. |
AuthorWrite something about yourself. No need to be fancy, just an overview. ArchivesCategories |