pmeerw's blog

17 Aug 2012

Fri, 17 Aug 2012

Connecting an OLED display to beaglebaord

Tried to connect the Adafruit Monochrome 1.3" 128x64 OLED graphic display to a beagleboard-xm using the following pins on the main expansion header:
27 - GND
23 - SDA
24 - SCL
4 - GPIO 144 (UART2_CTS)
1 - 1.8 V

First, mount the debug file system
mount -t debugfs none /sys/kernel/debug,
mux the pin to GPIO output
devmem 0x48002174 16 0x0004,
and check the result:

# cat uart2_cts 
name: uart2_cts.gpio_144 (0x48002174/0x144 = 0x0004), b ab26, t NA
mode: OMAP_PIN_OUTPUT | OMAP_MUX_MODE4
signals: uart2_cts | mcbsp3_dx | gpt9_pwm_evt | NA | gpio_144 | NA | NA | safe_mode

Next, make GPIO144 accessible
echo 144 > /sys/class/gpio/export,
set the GPIO direction to output
echo out > /sys/class/gpio/gpio144/direction,
and set the output value to high
echo 1 > /sys/class/gpio/gpio144/value.

Finally, we can program the SSD1306 controller (following Adafruit example):

# reset
echo 1 > /sys/class/gpio/gpio144/value
echo 0 > /sys/class/gpio/gpio144/value
echo 1 > /sys/class/gpio/gpio144/value
# initialize
i2cset -y 2 0x3d 0x00 0xae # display off
i2cset -y 2 0x3d 0x00 0xd5 # clockdiv
i2cset -y 2 0x3d 0x00 0x80
i2cset -y 2 0x3d 0x00 0xa8 # multiplex
i2cset -y 2 0x3d 0x00 0x3f
i2cset -y 2 0x3d 0x00 0xd3 # offset
i2cset -y 2 0x3d 0x00 0x00
i2cset -y 2 0x3d 0x00 0x40 # startline
i2cset -y 2 0x3d 0x00 0x8d # charge pump
i2cset -y 2 0x3d 0x00 0x14
i2cset -y 2 0x3d 0x00 0x20 # memory mode
i2cset -y 2 0x3d 0x00 0x00
i2cset -y 2 0x3d 0x00 0xa1 # segregmap
i2cset -y 2 0x3d 0x00 0xc8 # comscandec
i2cset -y 2 0x3d 0x00 0xda # set com pins
i2cset -y 2 0x3d 0x00 0x12
i2cset -y 2 0x3d 0x00 0x81 # contrast
i2cset -y 2 0x3d 0x00 0xcf
i2cset -y 2 0x3d 0x00 0xd9 # precharge
i2cset -y 2 0x3d 0x00 0xf1
i2cset -y 2 0x3d 0x00 0xdb # vcom detect
i2cset -y 2 0x3d 0x00 0x40
i2cset -y 2 0x3d 0x00 0xa4 # resume
i2cset -y 2 0x3d 0x00 0xa6 # normal (not inverted)
i2cset -y 2 0x3d 0x00 0xaf # display on
# transfer frame buffer data
i2cset -y 2 0x3d 0x40 0xff 0xff 0xff 0xff 0xff 0xff 0xff 0xff 0xff 0xff 0xff 0xff 0xff 0xff 0xff 0xff i
i2cset -y 2 0x3d 0x40 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 i
...

     

posted at: 23:03 | path: /projects | permanent link

Made with PyBlosxom