MicroPython_ESP32_psRAM_LoBo icon indicating copy to clipboard operation
MicroPython_ESP32_psRAM_LoBo copied to clipboard

Timer in extended mode and ONE_SHOT mode and timer_no > 4: reshoot() doesn't work.

Open sonnenbrille opened this issue 6 years ago • 1 comments

If the timer is in extended mode and in ONE_SHOT mode and the timer_no is 4 or greater, then the reshoot() function does not work. The ValueError "Timer is not one_shot timer output" is shown.

01  import machine
02
03  tex = machine.Timer(0)
04  tex.init(mode=tex.EXTBASE)
05 
06  tme1 = machine.Timer(4)
07 
08  def tcb(t):
09      print(t)
10      tme1.reshoot()
11    
12  tme1.init(period=700, mode=tme1.ONE_SHOT, callback=tcb)
>>> ping
Traceback (most recent call last):
  File "<stdin>", line 10, in tcb
ValueError: Timer is not one_shot timer.

sonnenbrille avatar Nov 07 '18 18:11 sonnenbrille

Sorry fo the late reply.

There was a small bug in reshot() function preventing extended timers (>=4) o reshot. It is fixed now and will be available in the next week update.

Until the fix is commited, as a workaround you can use the following, it works:

import machine

tex = machine.Timer(0)
tex.init(mode=tex.EXTBASE)

tme1 = machine.Timer(4)

def tcb(t):
    print(t)
    #tme1.reshoot()
    tme1.init(period=700, mode=tme1.ONE_SHOT, callback=tcb)

tme1.init(period=700, mode=tme1.ONE_SHOT, callback=tcb)

loboris avatar Dec 01 '18 15:12 loboris