Advertisements

Streaming Radio Player: Timing Tweaks

Slowing the SPI clock and updating the drivers having had no noticeable effect on the OLED display corruption, I once again pondered the SH1106 controller timing specs.

The chip reset seems remarkably slow, even at maximum VCC:

SH1106 - Reset Timing Specs

SH1106 – Reset Timing Specs

I think the relevant code is in the luma.core driver’s serial.py file. On the RPi, it resides in /usr/local/lib/python2.7/dist-packages/luma/core/interface/.

As far as I can tell, the bitbang class handles all the setup and teardown around the actual data transfers, but it’s not clear (to me, anyway) how it interacts with the underlying hardware SPI machinery.

So, let’s add some sleepiness to the Reset code:

        if self._RST is not None:
            self._gpio.output(self._RST, self._gpio.LOW)  # Reset device
            time.sleep(1.0e-3)
            self._gpio.output(self._RST, self._gpio.HIGH)  # Keep RESET pulled high
            time.sleep(1.0e-3)

A few milliseconds, rather than a few (hundred) microseconds, won’t make any perceptible difference.

Similarly, the Chip Select and Address (Command/Data) signals require more delay than might occur between successive Python statements:

SH1106 - SPI Address and Select Timing Specs

SH1106 – SPI Address and Select Timing Specs

This should do the trick, again with excessive delay:

        if self._DC:
            self._gpio.output(self._DC, self._cmd_mode)
            time.sleep(1.0e-3)

... snippage ...

        if self._DC:
            self._gpio.output(self._DC, self._data_mode)
            time.sleep(1.0e-3)

... snippage ...

        if self._CE:
            gpio.output(self._CE, gpio.LOW)  # Active low
            time.sleep(1.0e-3)

... snippage ...

        if self._CE:
            gpio.output(self._CE, gpio.HIGH)
            time.sleep(1.0e-3)

Although it shouldn’t be necessary, I blew away the pyc files to prevent future confusion over who’s doing what with which.

Once again, this will require several weeks to see whether the situation changes for the better.

Advertisements

,

  1. Sena PS410 Serial Server: Capturing HP 8591 Screen Images | The Smell of Molten Projects in the Morning
  2. Streaming Radio Player: CE Timing Tweak | The Smell of Molten Projects in the Morning

Spam comments vanish. Comment moderation may cause a delay.

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Google+ photo

You are commenting using your Google+ account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

w

Connecting to %s