8000 Trinket M0: SPI not working correctly · Issue #219 · adafruit/circuitpython · GitHub
[go: up one dir, main page]

Skip to content

Trinket M0: SPI not working correctly #219

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

Closed
deshipu opened this issue Aug 31, 2017 · 7 comments · Fixed by #223
Closed

Trinket M0: SPI not working correctly #219

deshipu opened this issue Aug 31, 2017 · 7 comments · Fixed by #223

Comments

@deshipu
Copy link
deshipu commented Aug 31, 2017

I'm trying to get a ST7735 display to work with Trinket M0, and it seems that Trinket's SPI behaves very strangely. Here is a screenshot of a capture of a fragment of the transmission:

cap1

and here is a close-up on one of the fragments:

cap2

Here's the complete capture for analysis:
cap.logicdata.zip

And here is the code that I used to capture that:

>>> import busio, digitalio, board
>>> from adafruit_rgb_display import st7735
>>> cs = digitalio.DigitalInOut(board.APA102_MOSI)
>>> dc = digitalio.DigitalInOut(board.D0)
>>> rst = digitalio.DigitalInOut(board.D1)
>>> spi = busio.SPI(clock=board.D3, MOSI=board.D4)
>>> d = st7735.ST7735R(spi, cs=cs, dc=dc, rst=rst)

Looking at the capture, two things are immediately striking:

  1. the polarity of the data line is wrong
  2. there are strange blips happening on both clock and data lines in between the actual bytes being transmitted
@tannewt
Copy link
Member
tannewt commented Aug 31, 2017

Which channel is which?

@tannewt
Copy link
Member
tannewt commented Aug 31, 2017

What version of CircuitPython are you using?

@deshipu
Copy link
< 8000 /span>
Author
deshipu commented Aug 31, 2017

Sorry, channel 0 is the clock, channel 1 is the data (channel 2 is the D/C). Running CircuitPython 1.0.0 that came flashed on the Teensy M0.

@deshipu
Copy link
Author
deshipu commented Sep 1, 2017

I figured out where the "blips" are coming from — the BusDevice library is calling spi.configure before every transmission, and that toggles the clock and data lines.

Commenting out that line from BusDevice makes the display work as expected.

@tannewt
Copy link
Member
tannewt commented Sep 1, 2017

Weird! What settings do you have? Configure shouldn't do anything if the setting are the same as before. Relevant code is here: https://github.com/adafruit/circuitpython/blob/master/atmel-samd/common-hal/busio/SPI.c#L171

@deshipu
Copy link
Author
deshipu commented Sep 1, 2017

I didn't touch the default settings — the code I pasted in this bug is the only thing running since reset. I agree it's weird, especially since it only happens on the Trinket M0 — the Feather M0 Express is fine.

@deshipu
Copy link
Author
deshipu commented Sep 1, 2017

Actually, I don't see you setting the self->current_baudrate anywhere in that code?

deshipu pushed a commit that referenced this issue Sep 1, 2017
This prevents the SERCOM from blipping the data line on each
transaction and therefore fixes #219.
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

Successfully merging a pull request may close this issue.

2 participants
0