Pin irq issue



  • Hi,

    I am trying a very simple "if button pressed" scenario - and my wipy doesn't like it.

    I have tried based on a class and based on a simple method - with and without parameters. Every time I press the button on the expansion board I get the error message below the code.

    I guess it is really picky about something - I just wish it would be better at explaining what...

    Has anyone else been able to use an interrupt handler?

    from machine import Pin
    import micropython
    micropython.alloc_emergency_exception_buf(100)
    counter=0
    led2=machine.Pin('P9',mode=Pin.OUT,pull=Pin.PULL_UP)
    class Interrupter(object):
        def button_handler(pin):
            return
    #    main.counter=1
    #    led2(0)
    #    led2.toggle()
    
    inter = Interrupter()
    
    button=Pin('P10',mode=Pin.IN, pull=Pin.PULL_UP)
    button.irq(trigger=Pin.IRQ_FALLING,handler=inter.button_handler)
    
    

    Error message:

    connected with Linksys3, channel 11
    MicroPython v1.8.6-13-ge1a0670 on 2016-11-18; WiPy with ESP32
    Type "help()" for more information.
    >>> Guru Meditation Error of type LoadProhibited occurred on core   0. Exception was unhandled.
    Register dump:
    PC      :  40081882  PS      :  00060031  A0      :  800816bf  A1      :  3ffd49e0  
    A2      :  3ffb11f0  A3      :  0000000d  A4      :  3ffd4a98  A5      :  00400461  
    A6      :  ffffffff  A7      :  00000001  A8      :  80081882  A9      :  3ffd49c0  
    A10     :  00000000  A11     :  3ffc4a60  A12     :  3ffc4a60  A13     :  00000000  
    A14     :  00000001  A15     :  00000001  SAR     :  00000020  EXCCAUSE:  0000001c  
    EXCVADDR:  00000000  LBEG    :  00000000  LEND    :  00000000  LCOUNT  :  00000000  
    CPU halted.
    


  • I still can't get this to work with 1.0.0b1 firmware :(



  • I have (by the way, your method is missing a self argument, which led to an unhandled exception), but it seems to be broken now (0.9.5.b1). Code that used to work produces LoadProhibited, apparently inside mp_irq_handler.

    >>> from machine import Pin
    >>> led=Pin('G16',mode=Pin.OUT)
    >>> button=Pin('G17',pull=Pin.PULL_UP)
    >>> irq=button.irq(trigger=Pin.IRQ_FALLING, handler=lambda b: led.toggle())
    >>> Guru Meditation Error of type LoadProhibited occurred on core   0. Exception was unhandled.
    Register dump:
    PC      :  400819fa  PS      :  00060031  A0      :  80081767  A1      :  3ffd5430
    A2      :  3ffb1170  A3      :  0000000d  A4      :  3ffd54e8  A5      :  00400461
    A6      :  ffffffff  A7      :  00000001  A8      :  800819fa  A9      :  3ffd5410
    A10     :  00000000  A11     :  3ffc54a0  A12     :  3ffc54a0  A13     :  b33f0000
    A14     :  b33fffff  A15     :  00060d23  SAR     :  0000001b  EXCCAUSE:  0000001c
    EXCVADDR:  00000000  LBEG    :  00000000  LEND    :  00000000  LCOUNT  :  00000000
    CPU halted.
    

Log in to reply
 

Pycom on Twitter