I get from 1 to 10 ticks of this timer before it hangs. If I replace the sleep with pass or any code it does not hang.
Any ideas?
Sam
Code: Select all
import time, utime
from machine import Timer
def display_timer(timer):
global count
count+=1
if count == 1000:
count =0
print('tick,',end='')
tim = Timer()
tim.init(freq=1000, mode=Timer.PERIODIC, callback=display_timer) # 400
count = 0
if __name__ == '__main__':
try:
while True:
#pass
utime.sleep_ms(1)
# When 'Ctrl+C' is pressed, the following will be executed.
except KeyboardInterrupt:
tim.deinit()
print("All done.")