question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Problem with spi and MicroPython

See original GitHub issue

I ran into an issue trying to use Blinka under Micropython on a Raspberry Pi Pico. I was trying to see if I could use an “airlift” with the esp32spi library. The first problem had simple “workaround”: The esp32spi library uses time.monotonic() but time.monotonic() is not provided by the micropython time module… It looks like a simple fix is to just use time.time() use MP but it does mean a lot of CP code won’t work without modification… I did make that change and ran into some more significant issues that may indicate bigger problems, but I wanted to point out the time.monotonic issue to see if I was missing some thing simple to get around it.

The second issue may be more significant: after replacing the time.monotonic() called with time.time() in adafruit_esp32spi.py I ran into this

MPY: soft reboot
MicroPython v1.15 on 2021-04-18; Raspberry Pi Pico with RP2040
Type "help()" for more information.
>>> 
>>> 
>>> import esp32spi_simpletest
ESP32 SPI webclient test
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File "esp32spi_simpletest.py", line 50, in <module>
  File "adafruit_esp32spi/adafruit_esp32spi.py", line 335, in status
  File "adafruit_esp32spi/adafruit_esp32spi.py", line 324, in _send_command_get_response
  File "adafruit_esp32spi/adafruit_esp32spi.py", line 232, in _send_command
  File "adafruit_bus_device/spi_device.py", line 76, in __enter__
  File "/lib/busio.py", line 377, in configure
AttributeError: type object 'SPI' has no attribute 'MSB'
>>> 

Any suggestions on how to proceed?

Issue Analytics

  • State:open
  • Created 2 years ago
  • Comments:16 (11 by maintainers)

github_iconTop GitHub Comments

1reaction
tannewtcommented, Jun 2, 2021

Looks like time is implemented per-port in MicroPython. Here is the STM one: https://github.com/micropython/micropython/blob/master/ports/stm32/modutime.c

0reactions
makermelissacommented, Nov 9, 2022

I think this is heavily related to #7 (as a great idea for a potential fix).

Read more comments on GitHub >

github_iconTop Results From Across the Web

SPI not working - MicroPython Forum (Archive)
Unhappily the issue is not solved. My new code : Code: Select all from machine import SPI from machine import Pin cs =...
Read more >
Possible bug with Hardware SPI(1) on ESP32-S3 · Issue #8634
I think that MicroPython does that remap because it is a better way than to follow the datasheet map, so the user can...
Read more >
Issue with machine spi not working as expected
I got a program working on my raspberry pi 4 using the SPIDEV library. I am working on converting the code to micropython...
Read more >
MicroPython Hardware: SPI Devices - Adafruit
This guide will explore how to use SPI with MicroPython. In particular MicroPython on ... In particular if you see the following error:....
Read more >
MicroPython ESP8266 SPI interface sends wrong data
MicroPython ESP8266 SPI interface sends wrong data ... As you can see, there are moving ones and moving zeros in this test. The...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found