Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

While using the i2c/SPI LCD Backpack Maximum recursion depth exceeded #67

Open
Beau28713 opened this issue Oct 17, 2021 · 3 comments
Open
Assignees

Comments

@Beau28713
Copy link

Beau28713 commented Oct 17, 2021

While using the i2c/SPI LCD Backpack Maximum recursion depth exceeded.

Adafruit CircuitPython 7.0.0 on 2021-09-20; Adafruit Metro M0 Express with samd21g18

Traceback (most recent call last):
File "main.py", line 1, in
File "adafruit_character_lcd/character_lcd_i2c.py", line 31, in
File "adafruit_mcp230xx/mcp23008.py", line 16, in
File "adafruit_mcp230xx/mcp230xx.py", line 16, in
File "adafruit_mcp230xx/mcp23xxx.py", line 14, in
File "adafruit_bus_device/i2c_device.py", line 14, in
RuntimeError: maximum recursion depth exceeded

import time
import board
import busio
import adafruit_character_lcd.character_lcd_i2c as character_lcd


lcd_columns = 20
lcd_rows = 4

i2c = busio.I2C(board.SCL, board.SDA)

lcd = character_lcd.Character_LCD_I2C(i2c, lcd_columns, lcd_rows)

https://github.com/adafruit/Adafruit_CircuitPython_MCP230xx
https://github.com/adafruit/Adafruit_CircuitPython_BusDevice/blob/main/adafruit_bus_device/i2c_device.py

@mmorys
Copy link

mmorys commented Nov 22, 2021

I just experienced the same issue:
CircuitPython 7.1.0 Beta 0; Seeeduino Xiao with SAMD21G18 microcontroller.

Using a 16x2 monochrome LCD with integrated PCF8574T I2C connection.

@xgpt
Copy link

xgpt commented Jan 26, 2022

CircuitPython 7.1.1 ; Seeeduino Xiao with SAMD21G18 microcontroller.

Also experiencing this issue.

Following along with adafruit tutorials

import time
import board
import adafruit_character_lcd.character_lcd_i2c as character_lcd

i2c = board.I2C()  # uses board.SCL and board.SDA
lcd = character_lcd.Character_LCD_I2C(i2c, 16, 2)

lcd.blink = True
lcd.message = "Blinky cursor!"
time.sleep(5)
lcd.blink = False

yields:


Auto-reload is on. Simply save files over USB to run them or enter REPL to disable.
code.py output:
Traceback (most recent call last):
  File "code.py", line 3, in <module>
  File "adafruit_character_lcd/character_lcd_i2c.py", line 31, in <module>
  File "adafruit_mcp230xx/mcp23008.py", line 16, in <module>
  File "adafruit_mcp230xx/mcp230xx.py", line 16, in <module>
  File "adafruit_mcp230xx/mcp23xxx.py", line 14, in <module>
  File "adafruit_bus_device/i2c_device.py", line 14, in <module>
RuntimeError: maximum recursion depth exceeded

@stonehippo
Copy link

This is definitely an issue with the limitations of the M0/SAMD21 boards. I ran into this using an M0 Express, so I tried it with an SAMD51 board (Grand Central M4) and things worked great. The memory available to the M0 is just not large to import the underlying mcp230xx driver. You can see this in the REPL with:

>>> from adafruit_mcp230xx.mcp23008 import MCP23008
MemoryError: memory allocation failed, allocating 640 bytes
>>>

Importing that module is the first thing the I2C implementation does. The same is true when using SPI and the 74hc595 driver.

The answer is to use an M4 or another, more capable board to drive this backpack.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

5 participants