uncaught Timer

General discussions and questions abound development of code with MicroPython that is not hardware specific.
Target audience: MicroPython Users.
Post Reply
wwsheldons
Posts: 31
Joined: Wed Dec 02, 2015 1:47 pm

uncaught Timer

Post by wwsheldons » Mon Jun 06, 2016 2:58 am

def rfid_tick(timer):
if rfid_port.any():
beep_on()
start_ns_delay()
def start_rfid_tick():
tim = pyb.Timer(4,freq=5)
tim.callback(rfid_tick)

uncaught exception in Timer(4) interrupt handler
MemoryError:

User avatar
dhylands
Posts: 3457
Joined: Mon Jan 06, 2014 6:08 pm
Location: Peachland, BC, Canada
Contact:

Re: uncaught Timer

Post by dhylands » Mon Jun 06, 2016 3:44 am

You can get more detailed information on the exception by doing:

Code: Select all

import micropython
micropython.alloc_emergency_exception_buf(100)

wwsheldons
Posts: 31
Joined: Wed Dec 02, 2015 1:47 pm

Re: uncaught Timer

Post by wwsheldons » Mon Jun 06, 2016 9:55 am

dhylands wrote:You can get more detailed information on the exception by doing:

Code: Select all

import micropython
micropython.alloc_emergency_exception_buf(100)

what is 'heap is locked'?

User avatar
dhylands
Posts: 3457
Joined: Mon Jan 06, 2014 6:08 pm
Location: Peachland, BC, Canada
Contact:

Re: uncaught Timer

Post by dhylands » Mon Jun 06, 2016 6:30 pm

The heap is locked (i.e. you can't allocate or free from it) while an interrupt handler is running.

User avatar
pythoncoder
Posts: 4479
Joined: Fri Jul 18, 2014 8:01 am
Location: UK
Contact:

Re: uncaught Timer

Post by pythoncoder » Tue Jun 07, 2016 5:22 am

In a nutshell you can't allocate memory in an interrupt handler. The rues on how to write interrupt handlers are explained here: http://docs.micropython.org/en/latest/p ... rules.html.
Peter Hinch

Post Reply