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

Sharp Display SPI RP2040 #31

Open
wfwAnthony opened this issue May 1, 2023 · 4 comments
Open

Sharp Display SPI RP2040 #31

wfwAnthony opened this issue May 1, 2023 · 4 comments

Comments

@wfwAnthony
Copy link

It seems that there is an issue initializing the SPI in the sharp driver on the RP2040. I've tried switching to SoftSPI for the SPI.LSB with no success.

I'm not too experienced with MicroPython so I may looking in the wrong spot.

Possibly adding a setup example for the Sharp displays could help.

@peterhinch
Copy link
Owner

SPI on RP2040 works: I have used it extensively with various displays. I recommend specifying the pins to use as the defaults are undocumented. Please could you post your hardware_setup.py.

@wfwAnthony
Copy link
Author

from machine import Pin, SPI, freq
import gc

from drivers.sharp.sharp import SHARP as SSD
freq(250_000_000)  # RP2 overclock
# Create and export an SSD instance
pcs = Pin(2, Pin.OUT, value=1)
spi = SPI(0, sck=Pin(6), mosi=Pin(7), miso=Pin(4))
gc.collect()  # Precaution before instantiating framebuf
ssd = SSD(spi, pcs)

from gui.core.ugui import Display
# Create and export a Display instance
# Define control buttons
nxt = Pin(19, Pin.IN, Pin.PULL_UP)  # Move to next control
sel = Pin(16, Pin.IN, Pin.PULL_UP)  # Operate current control
prev = Pin(18, Pin.IN, Pin.PULL_UP)  # Move to previous control
increase = Pin(20, Pin.IN, Pin.PULL_UP)  # Increase control's value
decrease = Pin(17, Pin.IN, Pin.PULL_UP)  # Decrease control's value
display = Display(ssd, nxt, sel, prev, increase, decrease, 4)  # Encoder

I receive an error

NotImplementedError: LSB

from machine import Pin, SoftSPI, freq
import gc

from drivers.sharp.sharp import SHARP as SSD
freq(250_000_000)  # RP2 overclock
# Create and export an SSD instance
pcs = Pin(2, Pin.OUT, value=1)
spi = SoftSPI(sck=Pin(6), mosi=Pin(7), miso=Pin(4), baudrate=2_000_000, firstbit=machine.SoftSPI.LSB)
gc.collect()  # Precaution before instantiating framebuf
ssd = SSD(spi, pcs)

from gui.core.ugui import Display
# Create and export a Display instance
# Define control buttons
nxt = Pin(19, Pin.IN, Pin.PULL_UP)  # Move to next control
sel = Pin(16, Pin.IN, Pin.PULL_UP)  # Operate current control
prev = Pin(18, Pin.IN, Pin.PULL_UP)  # Move to previous control
increase = Pin(20, Pin.IN, Pin.PULL_UP)  # Increase control's value
decrease = Pin(17, Pin.IN, Pin.PULL_UP)  # Decrease control's value
display = Display(ssd, nxt, sel, prev, increase, decrease, 4)  # Encoder

When replacing with SoftSpi to try and get around the LSB I get

ValueError:firstbit must be MSB

@peterhinch
Copy link
Owner

I can replicate this. You have indeed found a bug in the RP2 implementation of SPI. The Sharp displays require LSB-first implementation of SPI and, as you have discovered, this is unsupported. (My testing was with STM, before RP2 was available).

I will raise an issue.

@peterhinch
Copy link
Owner

I'm afraid we're in the hands of the maintainers now.

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

2 participants