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

SPI bus getting reinitialized to 10 MHz #31

Open
pdg137 opened this issue Dec 15, 2022 · 1 comment
Open

SPI bus getting reinitialized to 10 MHz #31

pdg137 opened this issue Dec 15, 2022 · 1 comment

Comments

@pdg137
Copy link
Contributor

pdg137 commented Dec 15, 2022

In SPI mode, it seems that before each write the bus gets reinitialized to a hard-coded 10 MHz:

SH1106/sh1106.py

Lines 280 to 282 in 5374dc5

def write_cmd(self, cmd):
self.spi.init(baudrate=self.rate, polarity=0, phase=0)
if self.cs is not None:

SH1106/sh1106.py

Lines 292 to 294 in 5374dc5

def write_data(self, buf):
self.spi.init(baudrate=self.rate, polarity=0, phase=0)
if self.cs is not None:

It works on my devices at that speed, but the SH1106 seems to only be rated for 2 or 4 MHz depending on Vdd. And since the user already initialized the SPI object, why change the speed that they presumably selected? Maybe they want to go faster or slower. It also seems like this will introduce some unnecessary delays and risks glitches on the output pins depending on what init() does exactly.

@robert-hh
Copy link
Owner

I cannot tell why this was introduced, only when. Maybe another slow device was used on the bus at the same time, and thus the SPI bus for the display had to be reinitialized before writing. And instead doing that at every call of one of the sh1106 methods, it's done in the driver.
But your are right. The datasheet says 4MHz for Vcc >= 2.4V. I seems that no one complained until then about the 10 MHz, or people just have set it to 4. Best is to remove these lines, making no assumption about the usage.

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