I'm struggling to get SPI working, either hard or soft.
Issuing a soft SPI write produces a clock burst of the specified frequency but the data pin is stuck low. I've tried different data pins to no effect. I am using the machine.SoftSPI constructor.
If anyone has got hard or soft SPI output to work, please could you post your SPI initialisation code.
[SOLVED] SPI on the Pico: has anyone made it work?
- pythoncoder
- Posts: 5956
- Joined: Fri Jul 18, 2014 8:01 am
- Location: UK
- Contact:
[SOLVED] SPI on the Pico: has anyone made it work?
Peter Hinch
Index to my micropython libraries.
Index to my micropython libraries.
Re: SPI on the Pico: has anyone made it work?
I have adapted a driver for an oled display using sh1122. It is using SPI. Code is here viewtopic.php?f=14&t=9769 it runs without any problem on my Pico.
Re: SPI on the Pico: has anyone made it work?
Hello Peter, I have used your flash_spi driver to attach a SPI flash chip as drive. Start-up code:
Code: Select all
from machine import SPI, Pin
import os
spi = SPI(0, baudrate=10_000_000, polarity=1, phase=1,
sck=Pin(18), mosi=Pin(19), miso=Pin(16))
from flash_spi import FLASH
cspins = (Pin(17, Pin.OUT, value=1),)
flash = FLASH(spi, cspins, cmdset=False)
os.mount(flash, "/spi")
print(os.listdir("/spi"))
- pythoncoder
- Posts: 5956
- Joined: Fri Jul 18, 2014 8:01 am
- Location: UK
- Contact:
Re: SPI on the Pico: has anyone made it work?
Thanks both, I'll try again; maybe I was suffering from "finger trouble".
@Roberthh interesting that you are using hard SPI on nonstandard pins. I didn't know you could do that on the rp2, although the Pi Pico doc hints at it by referring to "default SPI pins".
@Roberthh interesting that you are using hard SPI on nonstandard pins. I didn't know you could do that on the rp2, although the Pi Pico doc hints at it by referring to "default SPI pins".
Peter Hinch
Index to my micropython libraries.
Index to my micropython libraries.
Re: SPI on the Pico: has anyone made it work?
I just did that w/o reading the docs. I just had looked at the Pinout. But i had glanced before into the code and noticed that is checked for a variety of pins for being valid.
- pythoncoder
- Posts: 5956
- Joined: Fri Jul 18, 2014 8:01 am
- Location: UK
- Contact:
Re: SPI on the Pico: has anyone made it work?
Well I don't know what I was doing yesterday but today it's working fine. Thanks for the pointers.
Peter Hinch
Index to my micropython libraries.
Index to my micropython libraries.
Re: [SOLVED] SPI on the Pico: has anyone made it work?
So does uC on the rp2040 support SPI and I2C? I was holding off because I thought they weren’t able to do either yet.
Re: [SOLVED] SPI on the Pico: has anyone made it work?
Both SPI and I2C work with Micropython on RP2.