Pin Interrupts

Questions and discussion about The WiPy 1.0 board and CC3200 boards.
Target audience: Users with a WiPy 1.0 or CC3200 board.
Post Reply
nui_de
Posts: 40
Joined: Fri Oct 23, 2015 3:27 pm

Pin Interrupts

Post by nui_de » Mon Mar 28, 2016 10:17 am

At the moment I do not get the simplest things running, tried the
sample code for interrupts from the documentation:
http://micropython.org/resources/docs/e ... e.Pin.html

Code: Select all

from machine import Pin

def pincb(pin):
    print(pin.id())

pin_int = Pin('GP10', mode=Pin.IN, pull=Pin.PULL_DOWN)
pin_int.irq(mode=Pin.IRQ_RISING, handler=pincb)
This code throws:
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
TypeError: argument num/types mismatch

Shouldn't it be 'trigger=Pin.IRQ_RISING' instead of 'mode=Pin.IRQ_RISING'
However - I can not get the code to run properly. When triggering the Input the Heartbeard LED is
flashing rapidly to signal there was an Error - but I do not get any traceback, nothing. Please Help...

User avatar
danicampora
Posts: 342
Joined: Tue Sep 30, 2014 7:20 am
Contact:

Re: Pin Interrupts

Post by danicampora » Mon Mar 28, 2016 10:44 am

Hello nui_de,

Thanks for reporting the error on the docs, it should indeed be: trigger=Pin.IRQ_RISING as you say. I'll correct the docs ASAP.

With that correction the code works perfectly, bare in mind that you have to test printing on interrupts using the serial terminal, sending data over telnet cannot be done inside ISRs. I think your issue is that you have an old firmware, please make sure to update to the latest one:

https://github.com/wipy/wipy/releases

Cheers,
Daniel

Post Reply