Skip to content

STM32: Displayio #2352

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

Merged
merged 5 commits into from
Dec 5, 2019
Merged

STM32: Displayio #2352

merged 5 commits into from
Dec 5, 2019

Conversation

hierophect
Copy link
Collaborator

@hierophect hierophect commented Dec 3, 2019

DisplayIO is back! And... still buggy. Works for the SSD1306, but not the ILI9341 TFT as used on the TFT Featherwing.

A control Saleae for the Atmel M4 Express Feather looks like this:
Screen Shot 2019-12-03 at 5 24 37 PM
One block of data:
Screen Shot 2019-12-03 at 5 29 38 PM
Subblock
Screen Shot 2019-12-03 at 5 29 07 PM

SPI on the Feather looks a bit different:
Screen Shot 2019-12-03 at 5 32 49 PM
Subblocks are a lot larger, and send different (wrong?) data
Screen Shot 2019-12-03 at 5 34 46 PM
Screen Shot 2019-12-03 at 5 35 47 PM

I'm concerned it might be trying to go too fast. The Atmel version is only going at 1MHz, while the STM32 is at 4MHz. The datasheet for the ILI9341 says it should be good up to 10M on writing only, though. I presume the settings for speed are handled by the ILI9341 library, since it isn't exposed in the python code. Wasn't running Saleae fast enough, I see in FourWire that the display is substantially overclocked at 25MHz on both devices.

I'd welcome more input from anyone more familiar with the ILI9341 screen and any quirks it might have with regard to SPI operation.

This should resolve #2308 when solved.

@hierophect hierophect requested review from ladyada and tannewt December 3, 2019 23:01
@tannewt
Copy link
Member

tannewt commented Dec 4, 2019

Please post the full Saleae captures somewhere. I usually start at the reset and compare from there. Make sure the capture has the Reset and Data/Command lines as well as Clock, Enable (aka Chip Select) and MOSI.

@hierophect
Copy link
Collaborator Author

I usually start at the reset and compare from there.

Hmm. On my M4 Express, I don't see any activity on the reset line, when operating or soft/hard rebooting.

@hierophect
Copy link
Collaborator Author

Saleae Captures (for REPL screen shown on keyboard interrupt):
M4 Express:
Atmel REPL output sample.logicdata.zip
STM32:
STM32 REPL output.logicdata.zip

Seeing some pretty clear differences that could be related to pin pull settings. Digging.

@tannewt
Copy link
Member

tannewt commented Dec 4, 2019

I'd suggest slowing down the display when debugging to 1 mhz. If it works then you know it's a speed issue which I've seen when using jumper wires to a display. It also ensure the Saleae can keep up.

Pin pull settings should be off because SPI doesn't use pulls at all.

@hierophect
Copy link
Collaborator Author

@tannewt I mentioned pin pullups since looking at the data it was one of the few differences between the two implementations on the MOSI line. Atmel brings the line up by default, while STM32 just kind of leaves it wherever the last bit was. After doing some reading, though, I see there's really nothing in any spec that indicates it would matter.

I'm more concerned about the clock line:
Atmel:
Screen Shot 2019-12-04 at 1 50 01 PM
STM32:
Screen Shot 2019-12-04 at 1 50 23 PM
STM32 at 1MHz
Screen Shot 2019-12-04 at 2 03 14 PM

I'm kind of confused about the Atmel one - if you showed me that signal by itself, I'd assume it was badly out of sync. But evidently it works. And in at least the clock signal is broken into bytes.

The STM32 clock seems pretty off to me, though. In the 25MHz sample it's grouped in 16 bit intervals, despite the SPI peripheral being correctly set to 8 bit words. And in the 1MHz example, it doesn't appear differentiated into bytes at all. I assume that's an issue?

@tannewt
Copy link
Member

tannewt commented Dec 5, 2019

@hierophect It does look weird. Is that in the file you sent me?

What display breakout are you testing with? Some that support I2C will tie MOSI and MISO together for SDA.

The gap between clock bursts is an artifact of the internal memory transfer rate and size. That is why the STM is 16bit bursts, internally the driver is writing two bytes at a time. It disappears in the 1mhz example because the internal transfer is faster than the SPI.

Does the screen still fail at the 1mhz rate? Could you send me a capture of that? Try adding a reset pin if you can too. That way you know the display's controller chip is in a known state.

@hierophect
Copy link
Collaborator Author

hierophect commented Dec 5, 2019

Fixed. It turned out to be a phase issue. Unlike flash, DisplayIO doesn't currently specify the polarity, but instead fetches whatever the "default" is, which isn't a defined property. In the STM32 implementation, that default wasn't 0,0, which is required for the TFT to work.

@tannewt I've changed the default, but I'd suggest we either add phase and polarity to the Fourwire construct like Baudrate, or make sure they're set to 0,0 by default as a safety measure.

@hierophect
Copy link
Collaborator Author

@ladyada bin 4 u
firmware.bin.zip

@ladyada
Copy link
Member

ladyada commented Dec 5, 2019

woot testing nao!

@tannewt
Copy link
Member

tannewt commented Dec 5, 2019

@hierophect This looks good to me. Let's also make sure that the SPI objects always default to 0,0 as well. If they had, then this would have worked.

@ladyada
Copy link
Member

ladyada commented Dec 5, 2019

tested bin with 2.4" featherwing. REPL terminal and drawing work well - nice work :)

Copy link
Member

@ladyada ladyada left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

approval based on testing only :)

Copy link
Member

@tannewt tannewt left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks good! Thank you!

@tannewt tannewt merged commit 12f64c7 into adafruit:master Dec 5, 2019
@hierophect hierophect deleted the stm32-displayio branch December 5, 2019 18:19
@hierophect hierophect added the stm label Feb 29, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

STM32 - displayio SPI TFT displays not initing/displaying
3 participants