inglewoodpete
Senior Member
OLED interface with High Speed Serial, i2c and Mapped Screen using i2c
A few months ago, I purchased RevEd's AXE133Y Serial OLED package. While the OLED unit itself is fantastic, I was a little disappointed with the 18X2 serial daughterboard. I wanted a faster and more flexible interface.
My solution was to build on the capabilities of the 20X2: High Speed background serial and i2c (slave) interfaces. Also, I could utilise the extra speed of the 20X2.
In recent weeks there has been a flourish of different ideas relating to serial and i2c interfaces for parallel-connected OLED and LCD modules. Each has its merits and I hope my design offers its own alternatives.
The pinout of the 20X2 is not as ideal as that of the 18M2: Port B has 3 pins used for hardware serial (hSerial) and i2c (hi2c) interfaces. Port C has one pin which is input-only.
After some initial speed tests, I decided to use the 4-bit parallel interface mode between the 20X2 and the Winstar OLED module. With the 4-bit interface and the PICAXE whistling along at 64MHz, the entire 16x2 screen can be updated in just over 19 milliseconds. One row can be updated in 9.58 mS: that's 1669 characters per second! So the speed of 4-bit interface is faster than my eyes. There is a minor downside to using the 4-bit interface of the Winstar - you are restricted to just 2 of the 4 available font sets. Something our continental European members should take into account.
So, the features of my design:
Acknowledgement. You will see pieces of Clive Seager's (RevEd's) AXE133 18M2 code in some areas of my program, so I should acknowledge the origins of some of this code.
Pullup resistors are required on the scl and sda lines. I have assumed that they will be provided on the i2c master end.
Code to follow...
A few months ago, I purchased RevEd's AXE133Y Serial OLED package. While the OLED unit itself is fantastic, I was a little disappointed with the 18X2 serial daughterboard. I wanted a faster and more flexible interface.
My solution was to build on the capabilities of the 20X2: High Speed background serial and i2c (slave) interfaces. Also, I could utilise the extra speed of the 20X2.
In recent weeks there has been a flourish of different ideas relating to serial and i2c interfaces for parallel-connected OLED and LCD modules. Each has its merits and I hope my design offers its own alternatives.
The pinout of the 20X2 is not as ideal as that of the 18M2: Port B has 3 pins used for hardware serial (hSerial) and i2c (hi2c) interfaces. Port C has one pin which is input-only.
After some initial speed tests, I decided to use the 4-bit parallel interface mode between the 20X2 and the Winstar OLED module. With the 4-bit interface and the PICAXE whistling along at 64MHz, the entire 16x2 screen can be updated in just over 19 milliseconds. One row can be updated in 9.58 mS: that's 1669 characters per second! So the speed of 4-bit interface is faster than my eyes. There is a minor downside to using the 4-bit interface of the Winstar - you are restricted to just 2 of the 4 available font sets. Something our continental European members should take into account.
So, the features of my design:
- High Speed Serial interface. Works well with async serial speeds up to 76800 baud. It also works at 115200 baud and may be a little more reliable with the newer C.3 firmware, which I do not have yet.
- i2c command mode. Accepts OLED commands and character strings into the slave's scratchpad and executes them like async serial strings. This makes a good alternative to the cheap and nasty i2c interfaces available through EBay.
- i2c memory-mapped mode. In addition to the i2c command mode, the master device can write text directly into an area of the 20X2's scratchpad that maps via software to the OLED's 16x2 screen. This memory mapping allows strings to automatically wrap from the top row to the bottom row. It could easily be modified to work with a 20x4 row LCD or OLED. Also, due to the direct relationship between the scratchpad buffer and the OLED screen, almost all available characters (0-249 & 251-255) of the chosen font set can be used. Refer to the code, below, for more details (definition of constant cEmpty).
Acknowledgement. You will see pieces of Clive Seager's (RevEd's) AXE133 18M2 code in some areas of my program, so I should acknowledge the origins of some of this code.
Pullup resistors are required on the scl and sda lines. I have assumed that they will be provided on the i2c master end.
Code to follow...
Last edited: