CircuitGizmos

Electronic Products for Creative Minds

  • Home
  • Gizmo Store/Products
  • Documentation/Datasheets
  • Projects/Libraries
  • GizmoBlog
  • Services/Contact
    • Design
    • Contact Gizmo!
  • Your Gizmo Cart
    • Your Account
You are here: Home / GizmoBlog / MMBasic Language / LCD Modules and Graphics / SPI-connected LCD Displays / ILI9163 LCD Driver

ILI9163 LCD Driver

The MMBasic on the CGMICROMITE2 (and thus the CGMICROKIT product) supports the ILI9341 based displays using a SPI interface. These are 2.2, 2.4 or 2.8 inch displays with a resolution of 240 by 320 pixels and a color depth of 262K/65K. The driver for the display is built in.

An alternate to this display is an ILI9163-based LCD. This graphic display also interfaces via SPI, but it is a small 1.44 inches with a resolution of 128 by 128 pixels.

When this driver is used all of the display orientated features of MMBasic such as drawing lines, circles, text, fonts, etc will operate on this display.

The SPI based display controllers share the SPI interface with the MMBasic program. Sharing the SPI channel is essentially transparent to the BASIC program.

These are the connections required between the LCD display board and a CGMICROMITE2 chip or CGMICROBOARD:

ILI9163 Display Signal description CGMICROMITE2 CGMICROBOARD
LED Power supply for the backlight 3.3V
SCK Display SPI Clock uC Pin 25 uC Pin 4
SDA Display Data In (MOSI) uC Pin 3 uC Pin 5
A0 Display Data/Command Control Configurable uC Pin 21
RESET Display Reset (when pulled low) Configurable uC Pin 22
CS Display Chip Select Configurable uC Pin 23
GND  Ground Ground Ground
VCC LCD supply 3.3V 3.3V

Where a connection is listed as “configurable” then you get to pick the specific micocontroller (uC) pin for the purpose.

J1 on the back side of the LCD display is a jumper that sets the LCD to operate at 3.3V. A solder blob or very short piece of wire should be soldered in place on J1 for 3.3V operation.

Configuring the Driver

Before the driver is loaded you need to change the I/O pins allocated to A0, RESET and CS to reflect your circuit. This is done by editing the ILI9163 driver code.

The I/O pin allocations are set in the call to the subroutine ILI9163 in the first few lines of the driver. The syntax is:

ILI9163 myaddr%, A0-Pin, RESET-Pin, CS-Pin, Orientation

Where:

myaddr% is the address of the CSub (do not change this entry).

A0-Pin is the I/O pin to use for the LCD display A0 signal.

RESET-Pin is the I/O pin to use for the LCD display RESET signal.

CS-Pin is the I/O pin to use for the LCD display CS signal.

Orientation is the orientation of the display (1 = landscape, 2 = portrait, 3 = reverse landscape, 4 = reverse portrait).

A typical configuration for the 28-pin CGMICROMITE2 would be:

ILI9163 myaddr%, 2, 23, 6, 1

Note that you do not need to run the OPTION LCDPANEL command to setup this display; these configuration details are taken care of by the edits described above. Also, because the call to the ILI9163 driver is contained in the subroutine MM.Startup MMBasic will automatically initialize the driver every time the CGMICROMITE2 is powered up or reset.

Loading the Driver

To add the driver to MMBasic you must load the code into the CGMICROMITE2 and cycle the power. You can then test the display by entering GUI TEST LCDPANEL at the command prompt. You should see a series of coloured circles being rapidly drawn on top of each other.

If you are happy with the operation of the driver (ie, GUI TEST LCDPANEL works as expected) you can then run the command LIBRARY SAVE at the command prompt. This will transfer the driver (and any other routines in program memory) to a part of flash memory where they will be available to MMBasic but they will not show when the LIST command is used and will not be deleted when a program is loaded or NEW is used.

Restart the CGMICROMITE2 again and, for all intents and purposes, the driver is part of MMBasic. You can load, edit, run and delete programs as per normal and the driver will remain in memory. The only way that it can be removed is with the LIBRARY DELETE command or if the CGMICROMITE2 is reset to its original default configuration.

This driver was written by Peter Mather.

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
' ILI9163 LCD Driver
' Written and maintained by Peter Mather (matherp) on The Back Shed forum.
 
sub mm.startup
dim myaddr%=peek(cfunaddr ILI9163)
'ILI9163 myaddr%, A0-Pin, RESET-Pin, CS-Pin, Orientation
ILI9163 myaddr%, 2, 23, 6, 1 ' edit to configure the driver
end sub
 
 
CSub ILI9163
00000062
'spi_write_data
27BDFFE0 AFB00014 3C109D00 8E030090 AFBF001C AFB10018 8E02001C 309100FF
8064002C 0040F809 24050006 8E030090 8E02001C 8064002D 0040F809 24050005
3C02BF80 AC515820 3C03BF80 8C625810 30420080 1040FFFD 3C029D00 8C430090
8C59001C 8064002D 3C02BF80 8FBF001C 8FB10018 8FB00014 24050006 27BD0020
8C425820 03200008 00000000
'spi_write_command
27BDFFE0 AFB00014 3C109D00 8E030090 AFBF001C AFB10018 8E02001C 309100FF
8064002C 0040F809 24050005 8E030090 8E02001C 8064002D 0040F809 24050005
3C02BF80 AC515820 3C03BF80 8C625810 30420080 1040FFFD 3C029D00 8C430090
8C59001C 8064002D 3C02BF80 8FBF001C 8FB10018 8FB00014 24050006 27BD0020
8C425820 03200008 00000000
'spi_write_cd
27BDFFD8 AFB0001C 27A20030 00A08021 308400FF AFBF0024 AFB10020 AFA60030
AFA70034 AFA20010 0411FFD2 00000000 1A00000A 00008821 8FA20010 26310001
90440000 24420004 AFA20010 0411FFA6 00000000 1630FFF9 8FA20010 8FBF0024
8FB10020 8FB0001C 03E00008 27BD0028
'main
27BDFF90 AFB0004C 3C109D00 8CC30000 8E020090 AFBF006C AFB20054 AFB70068
AFB60064 AFB50060 AFB4005C AFB30058 AFB10050 A043002E 8CA30000 8E020090
00809021 A043002C 8CE30000 8E020090 24050008 A043002D 8FA30080 8E020090
8C630000 00003021 A0430015 8E030090 8E020010 0040F809 8064002E 8E030090
8E020010 8064002E 00003021 0040F809 24050065 8E030090 8E02001C 8064002E
0040F809 24050006 8E030090 8E020010 8064002C 24050008 0040F809 00003021
8E030090 8E020010 8064002C 00003021 0040F809 24050065 8E030090 8E02001C
8064002C 0040F809 24050006 8E030090 8E020010 8064002D 24050008 0040F809
00003021 8E030090 8E020010 8064002D 24050065 0040F809 00003021 8E030090
8E02001C 8064002D 0040F809 24050006 3C03BF81 8C65F220 3C020661 7CA5D800
3444A053 50A40008 24020050 8C64F220 2443A053 7C84D800 00832026 24020050
2403000C 0064100B 3C039D00 8C630088 00431021 8C430000 24020064 50620198
3C02BF80 00009821 00008021 3C04BF81 8C86F220 3C030661 3C029D00 7CC6D800
3465A053 10C5018C 8C420010 8C85F220 2463A053 7CA5D800 00A31826 24040014
24050003 00A3200B 24050008 0040F809 00003021 3C04BF81 8C86F220 3C030661
3C029D00 7CC6D800 3465A053 10C50178 8C420010 8C85F220 2463A053 7CA5D800
00A31826 24040014 24050003 00A3200B 24050065 0040F809 00003021 3C04BF81
8C86F220 3C030661 3C029D00 7CC6D800 3465A053 10C50164 8C420010 8C85F220
2463A053 7CA5D800 00A31826 24040029 2405000E 00A3200B 24050002 0040F809
00003021 3C04BF81 8C86F220 3C030661 3C029D00 7CC6D800 3465A053 10C50150
8C420010 8C85F220 2463A053 7CA5D800 00A31826 24040029 2405000E 00A3200B
24050065 0040F809 00003021 3C04BF81 8C86F220 3C030661 3C029D00 7CC6D800
3465A053 10C5013C 8C420010 8C85F220 2463A053 7CA5D800 00A31826 2404000E
24050019 00A3200B 24050008 0040F809 00003021 3C04BF81 8C86F220 3C030661
3C029D00 7CC6D800 3465A053 10C50128 8C420010 8C85F220 2463A053 7CA5D800
00A31826 2404000E 24050019 00A3200B 24050065 0040F809 00003021 3C02BF81
8C44FA84 24030001 7C641804 AC44FA84 3C04BF81 8C85FB04 24060003 7CC51804
AC85FB04 3C02BF80 34048060 AC445800 AC435830 24030C00 AC435840 56600005
3C029D00 8C535830 8C505800 8C515840 3C029D00 3C179D00 3C169D00 8E430000
24420188 26F70C68 26D60E7C 3C129D00 02E2B823 02C2B023 02E3B821 02C3B021
8E430090 8E42001C 8064002E 0040F809 24050006 8E420004 0040F809 24042710
8E430090 8E42001C 8064002E 0040F809 24050005 8E420004 0040F809 24042710
8E430090 8E42001C 8064002E 0040F809 24050006 8E420004 0040F809 24042710
24040011 0411FEB7 00000000 8E420004 0040F809 24041388 24050001 24060005
2404003A 0411FED2 00000000 8E420004 0040F809 24041388 24050001 24060004
24040026 0411FECA 00000000 8E420004 0040F809 240403E8 24050001 24060001
240400F2 0411FEC2 00000000 8E420004 0040F809 240403E8 24040013 0411FE99
00000000 240400B6 24050002 240600FF 24070006 0411FEB6 00000000 24020012
24030022 AFA20010 AFA30014 AFA20030 2403001C 2402000A AFA30018 AFA20034
24030042 24020011 AFA30020 AFA20038 240300B7 2402000B 24140015 24150013
240400E0 2405000F 24060036 24070029 AFA30024 AFA2003C 2403002F 24020006
AFA30028 AFA20040 AFB4001C AFB5002C 0411FE97 00000000 2402002D AFA20010
2402000D AFA20014 24020040 AFA20020 24020048 AFA20024 24020053 AFA20028
2402000C AFA2002C 2402001D AFA20030 24020025 AFA20034 2402002E AFA20038
24020034 240400E1 2405000F 24060009 24070016 AFA2003C 24020039 AFA20040
AFB50018 AFB4001C 0411FE79 00000000 24070002 24050002 24060008 240400B1
0411FE73 00000000 8E420004 0040F809 240403E8 24050001 24060007 240400B4
0411FE6B 00000000 8E420004 0040F809 240403E8 24070002 24050002 2406000A
240400C0 0411FE62 00000000 8E420004 0040F809 240403E8 24050001 24060002
240400C1 0411FE5A 00000000 8E420004 0040F809 240403E8 24070063 24050002
24060050 240400C5 0411FE51 00000000 8E420004 0040F809 240403E8 24050001
00003021 240400C7 0411FE49 00000000 8E420004 0040F809 240403E8 24020080
24050005 00003021 00003821 24040033 AFA20010 AFA00014 AFA00018 0411FE3C
00000000 24040029 0411FE16 00000000 8E420004 0040F809 240403E8 8E420090
24030001 80420015 10430052 24030002 5043005B 24040036 24030003 50430063
24040036 24030004 10430042 24040036 30420001 14400028 3C039D00 8C640094
24020080 AC820000 8C630098 AC620000 3C029D00 8C430048 00002021 AC770000
8C43004C 00002821 AC760000 8C430098 8C460094 8C420048 8C670000 8CC60000
AFA00010 8C420000 24C6FFFF 0040F809 24E7FFFF 8FBF006C 3C04BF80 AC935830
00001021 AC905800 00001821 AC915840 8FB70068 8FB60064 8FB50060 8FB4005C
8FB30058 8FB20054 8FB10050 8FB0004C 03E00008 27BD0070 8C640098 24020080
AC820000 8C630094 1000FFD9 AC620000 1000FEDF 2404000E 1000FECB 2404000E
1000FEB7 24040029 1000FEA3 24040029 1000FE8F 24040014 1000FE7B 24040014
8C535830 8C505800 8C515840 1000FE68 3C04BF81 24050001 240600C8 0411FDE4
00000000 3C029D00 8C420090 1000FFB8 80420015 24040036 24050001 24060068
0411FDDB 00000000 8E420090 24030002 80420015 1443FFA9 24030003 24040036
24050001 24060008 0411FDD1 00000000 3C029D00 8C420090 24030003 80420015
1443FFA1 24030004 24040036 24050001 240600A8 0411FDC6 00000000 3C029D00
8C420090 1000FF97 80420015
'DefineRegion
27BDFFD8 AFB00010 3C109D00 8E030090 AFBF0024 AFB40020 AFB3001C AFB20018
AFB10014 8E02001C 00809021 8064002C 00A08821 24050005 00C09821 0040F809
00E0A021 8E030090 8E02001C 8064002D 0040F809 24050005 2403002A 3C02BF80
AC435820 3C03BF80 8C625810 30420080 1040FFFD 3C10BF80 3C029D00 8C430090
8C42001C 8064002C 24050006 8E035820 0040F809 00000000 00121203 AE025820
3C04BF80 8C825810 30420080 1040FFFD 3C03BF80 8C625820 3C04BF80 AC725820
8C825810 30420080 1040FFFD 3C03BF80 00131203 8C645820 3C04BF80 AC625820
8C825810 30420080 1040FFFD 3C03BF80 8C625820 3C04BF80 AC735820 8C825810
30420080 1040FFFD 3C10BF80 3C029D00 8C430090 8C42001C 8064002C 24050005
8E035820 0040F809 00000000 2402002B AE025820 3C03BF80 8C625810 30420080
1040FFFD 3C10BF80 3C029D00 8C430090 8C42001C 8064002C 24050006 8E035820
0040F809 00000000 00111203 AE025820 3C04BF80 8C825810 30420080 1040FFFD
3C03BF80 8C625820 3C04BF80 AC715820 8C825810 30420080 1040FFFD 3C03BF80
00141203 8C645820 3C04BF80 AC625820 8C825810 30420080 1040FFFD 3C03BF80
8C625820 3C04BF80 AC745820 8C825810 30420080 1040FFFD 3C10BF80 3C029D00
8C430090 8C42001C 8064002C 24050005 8E035820 0040F809 00000000 2402002C
AE025820 3C03BF80 8C625810 30420080 1040FFFD 3C029D00 8C430090 8C59001C
8064002D 3C02BF80 8FBF0024 8FB40020 8FB3001C 8FB20018 8FB10014 8FB00010
24050006 27BD0028 8C425820 03200008 00000000
'DrawRectangleSPI
27BDFFC8 3C02BF80 34088060 AFBE0030 AFB7002C 8C5E5830 AFB60028 AFB50024
8C575800 AFBF0034 AFB40020 AFB3001C AFB20018 AFB10014 AFB00010 8FB50048
8C565840 AC485800 24080001 AC485830 0086182A 24080C00 AC485840 14600005
00A7102A 00801021 00C02021 00403021 00A7102A 14400004 3C109D00 00A01021
00E02821 00403821 8E030094 8E020098 28940000 28B30000 28F10000 8C630000
8C420000 28D20000 0014200B 0013280B 0011380B 0080A021 0012300B 00A09821
00E08821 2465FFFF 2444FFFF 0283382B 00C09021 00C3182B 0262302B 0222102B
00A3900A 0082880A 00A7A00A 0086980A 02203821 02403021 02802021 02602821
0411FF2A 00000000 8E030090 8E02001C 8064002C 0040F809 24050006 8E030090
8E02001C 8064002D 0040F809 24050005 24020001 0054A023 00531023 02929021
00512821 70B22802 10A0001C 00151C03 2402FFF8 00153143 00621824 2402FFE0
7EA71340 00C21024 7EB520C0 02A23025 00E33825 24A5FFFF 30E700FF 30C600FF
3C02BF80 AC475820 8C435810 30630080 1060FFFD 3C04BF80 8C835820 AC865820
8C435810 30630080 1060FFFD 3C03BF80 8C635820 14A0FFF3 24A5FFFF 3C029D00
8C430090 8C42001C 8064002D 0040F809 24050006 8FBF0034 3C02BF80 AC5E5830
8FB50024 AC575800 8FBE0030 AC565840 8FB7002C 8FB60028 8FB40020 8FB3001C
8FB20018 8FB10014 8FB00010 03E00008 27BD0038
'DrawBitmapSPI
27BDFFA0 8FA80074 8FA20078 00085943 00026943 2409FFE0 AFB60050 AFB40048
AFB30044 AFB00038 01695824 8FB00070 01A94824 00086403 7D131340 7D1420C0
7C5620C0 3C08BF80 AFB1003C 02C9B025 00C08821 8D095830 AFB5004C 00027403
7C551340 72111002 AFA9001C 8D095800 AFBE0058 AFA90020 2486FFFF 8D095840
00E0F021 00463021 721E1002 AFA90024 34098060 AFBF005C AFB70054 AFB20040
8FB2007C AD095800 24090001 AD095830 24A7FFFF 24090C00 240AFFF8 018A6024
AD095840 01CA5024 00473821 3C029D00 026C9825 028BA025 02AAA825 0080B821
AFA20030 AFA50034 0411FEAB 00000000 8FA20030 24050006 8C440090 8C46001C
8084002C 00C0F809 327300FF 8FA20030 24050005 8C440090 8C42001C 8084002D
0040F809 329400FF 32B500FF 32D600FF 1BC00059 8FA30034 73D11002 AFA30010
2442FFFF 00111823 3C188000 AFB7002C AFA30028 00007021 AFA00014 27180007
241FFFF8 240F0001 3C059D00 3C04BF80 0040B821 AFBE0018 1A00003D 8FA20010
8FA70010 8FBE002C 0000C821 5A200035 27390001 03C05821 02E05021 00004821
012E6821 25A20007 29A30000 0043680B 000D68C3 01586024 0580005D 024D6821
018F6004 01601021 00001821 0442001E 24630001 8CA60094 8CC60000 0046302B
50C00019 24630001 04E20017 24630001 8CA60098 8CC60000 00E6302B 50C00012
24630001 91A60000 00CC3024 10C0003B 00000000 AC935820 8C865810 30C60080
10C0FFFD 3C08BF80 8D065820 AD145820 8C865810 30C60080 10C0FFFD 3C06BF80
8CC65820 24630001 1470FFE0 24420001 25290001 254AFFFF 1531FFD1 01705821
27390001 1730FFC9 24E70001 8FA20010 8FA90014 00501021 AFA20010 8FA30028
8FA20018 25290001 AFA90014 02E3B821 1522FFB9 01D17021 3C029D00 8C430090
8C42001C 8064002D 0040F809 24050006 8FA3001C 3C02BF80 AC435830 8FA90020
8FA30024 8FBF005C AC495800 8FBE0058 8FB70054 8FB60050 8FB5004C 8FB40048
8FB30044 8FB20040 8FB1003C 8FB00038 AC435840 03E00008 27BD0060 AC955820
8C865810 30C60080 10C0FFFD 3C08BF80 8D065820 AD165820 8C865810 30C60080
10C0FFFD 3C06BF80 1000FFC5 00000000 258CFFFF 019F6025 1000FFA1 258C0001
End CSub

Leave a Reply Cancel reply

Your email address will not be published. Required fields are marked *

A Ton of Documentation

Open all | Close all

Projects made by Gizmo, Friends, and Members

open all | close all

Recent GizmoBlog Musings

  • Altair 8800 using a ColorMax!
  • Re-energizing the ColorMax, Pt. 3

Visit us!

  • Facebook

Electronic Products for Creative Minds

CircuitGizmos is your source for electronic products that help you create your embedded projects. Here at CircuitGizmos.com you will find a friendly store filled with creative products and all of the documentation that you need to use these gizmos.

We create devices that we believe make electronics fun, but we also know that our products are used for professional designs. For decades we have designed products for commercial, military, and medical industries. Our gizmos here are great for engineers and hobbyists alike.

Copyright © 2008+ CircuitGizmos, L.L.C. All rights reserved

Image already added

Recently Viewed Products

Copyright © 2021 · Generate Pro Theme on Genesis Framework · WordPress · Log in