multiple interrupt question

The official pyboard running MicroPython.
This is the reference design and main target board for MicroPython.
You can buy one at the store.
Target audience: Users with a pyboard.
JimTal001
Posts: 176
Joined: Thu Jul 30, 2015 4:59 pm

Re: multiple interrupt question

Post by JimTal001 » Thu Sep 03, 2015 8:23 pm

I tried your code and of course it worked as expected. I then modified it adding the RTC sleep to see what happens. It crashed (meaning no response from REPL and SD card).

I used pyb.usb_mode('CDC+MSC') in the boot.py

Code: Select all

import pyb
import micropython
micropython.alloc_emergency_exception_buf(100)

rtc = pyb.RTC()
rtc.wakeup(10000) # every 10 sec

led1 = pyb.LED(4) # 4 = Blue
led2 = pyb.LED(3) # 3 = Yellow

pin = pyb.Pin('SW', pyb.Pin.IN, pull=pyb.Pin.PULL_UP)

def callback(line):
	led1.toggle()
	if pin.value(): # 1 = not pressed
		led2.off()
	else:
		led2.on()

ext = pyb.ExtInt(pin, pyb.ExtInt.IRQ_RISING_FALLING, pyb.Pin.PULL_UP, callback)

def mainloop():
	while True:
		print("wakeup time")
		pyb.delay(1000)
		pyb.stop() # go to sleep until next wakeup			

mainloop()

JimTal001
Posts: 176
Joined: Thu Jul 30, 2015 4:59 pm

Re: multiple interrupt question

Post by JimTal001 » Thu Sep 03, 2015 9:42 pm

You are correct, I moved the pin to X1 and it works fine.

Any comment about the RTC.wakeup() and Interrupt issue I posted earlier?

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

Re: multiple interrupt question

Post by dhylands » Thu Sep 03, 2015 10:00 pm

Your code actually seems to be working fine.

On the usb-serial REPL, I only ever see the very first output of 'wakeup time'.

However, if I connect a USB-to-serial converter on UART6 (Y1/Y2) and modify the code to do:

Code: Select all

uart = pyb.UART(6,115200)
pyb.repl_uart(uart)
print("REPL is also on UART 6 (Y1=Tx Y2=Rx)")
then this is what I see on UART6:

Code: Select all

>>> import rtc_int
REPL is also on UART 6 (Y1=Tx Y2=Rx)
wakeup time
wakeup time
wakeup time
wakeup time
wakeup time
wakeup time
wakeup time
wakeup time
wakeup time
wakeup time
wakeup time
wakeup time
wakeup time
wakeup time
What's happening is that the USB REPL stops working because the board is going to sleep and it stops responding to the host. When you say that the sdcard stops working, I think you mean that the USB Mass Storage connection stops working, and I think that's for the same reason.

JimTal001
Posts: 176
Joined: Thu Jul 30, 2015 4:59 pm

Re: multiple interrupt question

Post by JimTal001 » Thu Sep 03, 2015 10:19 pm

Great! my usb serial converter should be coming in today.
Thanks!!

Post Reply