Page 1 of 1

registered function on Timerchannel gets not executed

Posted: Tue Nov 24, 2015 8:28 pm
by tlo
Hi,
i try to register a user defined function for a periodic timer interupt on the wipy.
This works:

Code: Select all

tim = Timer(1, mode=Timer.PERIODIC)
tim_a = tim.channel(Timer.A, freq=700)
tim_a.irq(handler=lambda t: pin_step.toggle())

This not. There is no error, the wipy just seems to ignore the handler silently.:

Code: Select all

def stepnext():
    pin_step.toggle()

tim = Timer(1, mode=Timer.PERIODIC)
tim_a = tim.channel(Timer.A, freq=700)
tim_a.irq(handler=lambda t: stepnext())
#I also tried this:
#tim_a.irq(handler=stepnext())
Am i missing something?
Thanks Thilo

Re: registered function on Timerchannel gets not executed

Posted: Tue Nov 24, 2015 10:11 pm
by Oli_
According to some example found in the documentaton, this work like that :

Code: Select all

def stepnext(timer):
    pin_step.toggle()

tim = Timer(1, mode=Timer.PERIODIC)
tim_a = tim.channel(Timer.A, freq=700)
tim_a.irq(handler=stepnext)

Re: registered function on Timerchannel gets not executed

Posted: Tue Nov 24, 2015 10:43 pm
by tlo
Yep, thats it. I seems to have overlooked the parameter of the function.
Thanks a lot!

Re: registered function on Timerchannel gets not executed

Posted: Wed Nov 25, 2015 7:38 am
by pythoncoder
This is surely a bug. Even with

Code: Select all

import micropython
micropython.alloc_emergency_exception_buf(100)
the version where the ISR has no argument quietly fails to run with no error message being reported.