OLED driver for Micro-controller using FPGA

Introduction


           


                   
         In this tutorial we are going to design OLED driver for micro-controllers which has less memory  .In OLED tutorials  we have interfacing of I2C OLED display with micro-controller. We used Arduino as a microcontroller. Arduino has ATMEGA328 micro-controller which has 32kb flash memory and 2kb RAM so while programming we were not considering memory as a critical resources. But if we want to interface OLED to low cost micro-controller there will some major challenges . let's see what are these problems

Problem



1) For storing small and large English font & large Devanagari font , it requires nearly 17kb flash memory so microcontroller need to have flash memory greater than 17kb. But low cost microcontrollers like STM8S, ATTiny85/45 etc. has flash memory around 8kb. So it is not possible to store above 17kb fonts in these micro-controllers. 





2) Also we saw in printing Indian fonts tutorial  , unlike English , Devanagari font has almost all word in which two characters need to combine together with OR operation to make one word . For example , क्या , हिन्दी , मराठी in these words we need to do OR operation of two characters. For this OR operation it require RAM greater than 1kb.  Many low cost micro-controllers has RAM less than or equal to 1kb.

Solution


            So , our solution for this is to design a driver which store the font in it. Driver will take the inputs from micro-controller via UART and drive the OLED via I2C. 


following image shows the format need to be followed for sending the command



            In above image , string has 3 parts start ,code and end . 

For example , to turn ON the display first we need to send hex number '0x00' then we need to send character 'I' and at the end we need to send hex number '0xFF'.


Similarly , to display the string we need to follow following format 






    
                From above example , you will have question that why did string "ihndI" used for displaying "हिन्दी" on display and "marazI" is used for displaying "मराठी" on display? reason for this is we used "SHIVAJI05" and this font is mapped on our English keyboard as shown in the following image
 

            In above keyboard there are two Devanagari characters on each key. For example,  "K" key has क and  on same key upper one  corresponds to uppercase "K" and lower one क corresponds to lower case "k". 




            following table shows some devanagari words and there equivalent English string that need to be sent to OLED driver to print that devanagari word 
Devanagari Word English Equivalent string
मराठी marazI
हिन्दी ihndI
घर Gar
लाकूड laakuD
पंछी pMCI


Implementation in Hardware

            For implementation on Hardware we used Deo-nano FPGA board. Following is the overall block diagram of the hardware design

Overall block diagram


Overall Block diagram


OLED_controller : Top Verilog Module block diagram





OLED_driver : Verilog Module block diagram



In our design we have implemented English font with three sizes (2, 3 and 4) and character range is from ASCII code 32(SPACE) to 127 (DEL) . For Devanagari too we have implemented the three sizes mentioned above (i.e. 2, 3 and 4) and it has all characters from ASCII code 32(SPACE) to 127 (DEL). But to optimize the code and to have a better utilization of memory as per our needs we have commented the font size 4 for English and font size 2 & 4 for Devanagari although they are still present in the code and are accessible by uncommenting as per user's needs. 

You can download the original Quartus Project file from the following link
Download example Microcontroller embedded C code from following link

  

                 


                     





Comments