0:07
hello everyone welcome to controllers
0:11
tech today in this video I will show you
0:14
guys how to interface us t79 2-0
0:18
128 by 64 graphical LCD with stm32 I am
0:25
using stm32 f103 controller and I will
0:29
explain you all the functions using
0:32
datasheet so watch the entire video
0:35
properly let's start by creating the
0:38
project in cube MX first
1:10
in this tutorial I will use the serial
1:13
connection for the st7 9 to 0 and for
1:17
that we have to select 4 pins as output
1:20
from the controller I will explain about
1:22
these pins in a while
1:30
next we have to use some delays in
1:33
microseconds and so I am going to select
1:36
a timer to create those delays I have
1:39
already made a video about this topic
1:42
you can watch on the top right corner of
1:44
your device also I will leave the link
1:57
now complete the rest of the setup and
2:22
next we need to copy the delay library
2:25
and the st7 nine to zero library files
2:29
into the project and after copying them
2:32
also include them in the project
2:54
let's take a look at the delay library
2:57
as I am using time of 1 for the delay I
3:00
am going to make some changes here in
3:14
that's it for the timer set up in the
3:17
library let's build this and check for
3:20
the errors if any everything looks good
3:25
till now let's take a look at the st7
3:28
nine to zero library file and see how
3:31
these functions work so about those four
3:35
pins we selected as output in the cube M
3:38
X they are connected as follows a five
3:42
is connected to enable in the LCD a six
3:45
is connected to our s pin of the LCD a
3:48
seven is connected to our W pin of the
3:51
LCD B zero is connected to reset pin of
3:55
the LCD this is the connection of the
3:58
microcontroller to the LCD this is a
4:01
five pin this is a six pin this is a 7
4:06
pin this is B zero pin
4:20
and this one here is PSB which should be
4:24
grounded to use the serial mode
4:38
if you are using any other pinout you
4:42
must define here about the clock CSS ID
5:01
so first of all this function replaces
5:05
the SPI transfer SPI doesn't always
5:09
so I intend not to use it here also we
5:13
can transfer the data same way as the
5:16
SPI does and that is first write the bit
5:20
by the high although and then toggle the
5:23
clock next sending commands to the LCD
5:27
now if you take a look at the data sheet
5:30
it says that when C s will be high only
5:33
then the clock will be accepted so first
5:36
we will pull the CS pin high next before
5:40
sending the actual command or data we
5:43
have to send a synchronizing byte
5:56
which consists of zero cross f8 and then
6:00
our w RS and zero for sending the
6:10
command we have to make RS 0 after
6:14
sending the synchronizing byte we have
6:17
to send higher data byte followed by
6:36
and at last pull the CS back to low
6:40
indicating end of transfer data is also
6:44
sent in the same way except this time RS
6:48
will be one in the synchronizing byte
7:03
next in order to initialize the LCD we
7:07
have to follow some pattern of commands
7:09
first of all we have to toggle the reset
7:12
and wait for more than 40 milliseconds
7:27
next we have to send the function set
7:30
command for the 8-bit mode and wait for
7:33
more than 100 microseconds again send
7:36
the function set command for the 8-bit
7:39
mode and wait for more than 37
7:51
next send the display on/off control
7:55
command and wait for more than 100
7:57
microseconds I am keeping everything
8:00
zero right now we will turn it on in the
8:03
end next send the display clear command
8:07
and wait for more than 10 milliseconds
8:14
and in the end send the entry mode
8:18
command to increment cursor to the right
8:21
with no shift and turn the display on
8:23
this ends the initialization of the LCD
8:39
to turn on the graphic display again we
8:43
have to follow some set of commands
8:45
first select the 8-bit mode then turn on
8:48
the extended instruction set and at last
8:50
the graphic mode we have to write them
8:53
separately as mentioned in the datasheet
9:23
to draw any graphic to the display we
9:26
have to first set the vertical
9:28
coordinates and then the horizontal
9:30
coordinates of the display after that
9:32
write the upper byte followed by the
9:35
lower byte and we do the same for the
9:38
bottom half of the screen also display
9:41
Klee a command can clear display in both
9:44
graphic mode and text mode
10:02
tense string command can print the
10:05
string on the specific row and column of
10:08
the display this only works in the text
10:28
let's write the program and display
10:31
something now first we have to
10:34
initialize the delay and then initialize
10:37
the LCD here i am writing few strings to
10:41
different rows and columns of the
10:43
display let's build it and flash it to
11:11
of course there is I usual error about
11:15
the resetting go to the configuration
11:17
debugger generate a script and change it
11:21
to software system reset
11:30
so as you can see it works pretty well
11:45
let's try to display a bitmap on this
11:47
display now I have this image here of
11:50
the st and i will use to convert it
12:09
go to the image mode index and change it
12:13
to the one bit black and white okay
12:17
things don't look good here this is
12:20
probably due to the saturation of colors
12:22
let's fix it follow closely what I am
13:12
and now if you change it you will get
13:17
the black-and-white image next change
13:20
the size and export it to the BMP format
14:15
next I am using LCD assistant for
14:18
changing it to the hex format
15:08
copy the code inside the program
15:23
I already have a bitmap dot H file and I
15:29
am going to copy in this itself right
15:32
now I have two bitmaps and I will
15:45
we have to first turn on the graphic
15:48
mode I am going to display a bitmap then
15:50
wait for few seconds than after clearing
15:53
it display the another bitmap
16:04
I forgot to include the header file in
16:07
the project okay let's build it and
16:31
as you can see this is the first bitmap
16:35
and this is the second one I will reset
16:39
the controller once more
16:56
other than these we can also draw
16:59
different shapes such as circles
17:02
triangles rectangles and so on I have
17:07
just put them at random places
17:30
here you can see all of these functions
17:33
together remember that if you want to
17:36
write the text again you have to disable
17:39
the graphic mode this is it guys hope
17:43
you understood everything in the video
17:45
you can download the code from the link
17:48
in the description leave comments in