Welcome to the Pycom forum Forum
    • \[\[global:header.categories\]\]
    • \[\[global:header.recent\]\]
    • \[\[global:header.tags\]\]
    • \[\[global:header.popular\]\]
    • Login

    Explore Pybytes | Official Documentation | Report a Firmware Bug/Issue | GitHub

    Pin irq issue

    Scheduled Pinned Locked Moved MicroPython
    3 Posts 2 Posters 1.2k Views 3 Watching
    Loading More Posts
    • Oldest to Newest
    • Newest to Oldest
    • Most Votes
    Reply
    • Reply as topic
    Log in to reply
    This topic has been deleted. Only users with topic management privileges can see it.
    • C Offline
      chrol
      last edited by

      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.
      
      1 Reply Last reply Reply Quote 0
      • L Offline
        LoneTech
        last edited by LoneTech

        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.
        
        1 Reply Last reply Reply Quote 0
        • C Offline
          chrol
          last edited by

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

          1 Reply Last reply Reply Quote 0

          Hello! It looks like you're interested in this conversation, but you don't have an account yet.

          Getting fed up of having to scroll through the same posts each visit? When you register for an account, you'll always come back to exactly where you were before, and choose to be notified of new replies (either via email, or push notification). You'll also be able to save bookmarks and upvote posts to show your appreciation to other community members.

          With your input, this post could be even better 💗

          Register Login
          • 1 / 1
          • First post
            Last post

          Pycom on Twitter

          Pycom