[EN] ESP32 machine.Timer

This article discusses the use of 4 timers of the ESP32 to be used to run the program when it meets the specified time. Difference Between Using Timer and Delay time.sleep()/time.sleep_ms()/time.sleep_us() is that time delay is a loop to allow the processor to spend time looping to complete the specified amount of time whereas the timer uses the principle of having a function run every time a specified time is reached, so while a timer does not call a function to execute the processor has idle time for other processing, and unlike interrupts, it is a timer interrupt instead of a pin state interrupt connected to an external circuit.

Read More

[TH] ESP32 machine.Timer

บทความนี้กล่าวถึงการใช้ตัวฮาร์ดแวร์ตั้งเวลาหรือไทม์เมอร์ (Timer) ทั้ง 4 ของ ESP32 เพื่อใช้สำหรับการให้โปรแกรมทำงานเมื่อเป็นตามค่าเวลาที่กำหนดไว้ ความแตกต่างระหว่างการใช้ไทม์เมอร์กับการหน่วงเวลา time.sleep()/time.sleep_ms()/time.sleep_us() คือ การหน่วงเวลาคือการวนรอบเพื่อให้หน่วยประมวลผลเสียเวลาไปการวนรอบเพื่อให้ครบกับระยะเวลาที่กำหนด ขณะที่ไทม์เมอร์ใช้หลักการให้ฟังก์ชันทำงานทุกครั้งเมื่อถึงคาบเวลาที่กำหนดไว้ ดังนั้น ขณะที่ไทม์เมอร์ไม่ได้เรียกฟังก์ชันให้ทำงาน หน่วยประมวลผลมีเวลาเหลือหรือค่าว่างงาน (idle time) สำหรับประมวลผลอื่น ๆ ได้ และมีความแตกต่างกับการขัดจังหวะหรืออินเทอร์รัพต์ตรงที่เป็นการขัดจังหวะด้วยตัวตั้งเวลาแทนการขัดจังหวะจากสถานะของขาที่เชื่อมต่อกับวงจรภายนอก

Read More