0:18
hello and welcome to controllers Tech
0:22
some of you asked me to cover the touch
0:24
gfx for the cheaper displays which uses
0:26
the SBI so before continuing the touch
0:30
gfx series I decided to make a video
0:33
about interfacing these cheaper SBI
0:36
displays this video will cover how to
0:38
interface the I 9341 based SBI display
0:42
with SDM 32 and of course we will be
0:47
gfx I am going to use the Kyle ID in the
0:50
tutorial as the project wasn't working
0:52
with Cube ID it needs a lot of fixes
0:56
with Cube ID and I will do that later
1:00
this is back of the display I am using
1:03
here you can see we have the pins for
1:05
the display and these pins are for the
1:13
touch these are the libraries that we
1:16
will be using in this tutorial I have
1:19
here the library for the I
1:22
9341 driver you can use any other
1:25
display also but you should find a
1:27
working library for your display Drive
1:29
driver the only requirement is that it
1:32
should have a function to draw bit map
1:34
and a function to set window most of the
1:37
drivers do have these functions so it's
1:40
not a problem more importantly the
1:43
driver must use the dma for the big
1:46
transfers if the driver you are using
1:48
satisfies this criteria you can go ahead
1:51
with the video by the way I am using the
1:55
instructions provided in this article I
1:58
will leave this link in the descript
1:59
destion do check it out I can't explain
2:03
the reasons for the steps that we will
2:05
be using otherwise the video will be
2:07
very long so read this article to
2:11
understand the steps that I am going to
2:13
show in this video it's explained
2:16
perfectly here so let's continue and
2:19
open the cube MX like I mentioned this
2:23
project won't work with Cube ID just yet
2:26
so I will be using Kyle ID today I I am
2:30
using SDM 32 f411 Discovery board let's
2:39
pins now first of all we will set the
2:42
clock I am using the external Crystal
2:45
for the clock the crystal on this board
2:48
is 8 MHz and I want to run the system at
3:04
now go to the SBI and enable the full
3:07
duplex mode I am using the SBI 1 because
3:18
so the board rate is set at 25 megabits
3:22
and this is the maximum for this
3:27
board go to NV I C and enable the SBI
3:32
interrupt we need to also add the dma so
3:35
add the dma to transmit direction will
3:39
be from memory to peripheral mode is
3:42
normal and check the use fifo we have
3:45
the three pins now the mossi Miso and
3:49
the clock pins we still need to set up
3:52
the Cs reset and DC pins
4:03
also this driver uses the names like
4:05
reset s1n SS and DC so I am going to
4:11
name the pins in the similar way all the
4:14
three pins need to be set as output
4:27
pins that's it about the pins
4:30
configuration next is the touch gfx
4:33
itself click on software packs select
4:38
components here you can see the touch
4:41
gfx you might need to install it for the
4:44
first time just click the install button
4:46
in front of it not all the boards
4:49
support touch gfx so if you see this
4:52
option grade Out means your board does
4:54
not support it select the touch gfx and
4:58
click okay here it is showing in the
5:01
software pack enable the graphic
5:04
application we need to enable the CRC
5:14
also all right the interface is custom
5:20
565 the display width is
5:22
320 and height is 240 pixels since this
5:27
MCU don't have too much RAM available we
5:30
will use the partial frame buffer if you
5:33
want to read more about this read the
5:36
original article this is it for the
5:38
touch gfx part at last we will configure
5:42
a timer the timer's purpose will be to
5:45
call the sync signal to sync the display
5:48
I am using the timer 2 for this which is
5:51
connected to the apb1 clock you can read
5:55
the data sheet to check the timer's
5:57
connectivity right now the time timer is
6:00
running at 100 MHz and we need to bring
6:16
frequency it is clearly mentioned in the
6:19
article about how much frequency you
6:21
should use anyway I will try to explain
6:33
so my SBI 1 clock is at 25 megabits per
6:36
second means it can transfer 25 million
6:39
bits in 1 second the display size is
6:44
240 the rgb565 takes 2 bytes per pixel
6:49
and that's why multiplying by two the
6:52
total size of the buffer needed in Ram
6:56
kiloby if we consert this to bits this
6:59
is what we get dividing it by the SBI
7:02
speed I got around 50
7:08
milliseconds this is the time the SBI
7:11
will take to transfer one frame buffer
7:14
so the refresh time must be slower than
7:21
this and I got around 20 Hertz that is
7:24
20 frames per second so now we need to
7:27
bring the timer clock down to 20 HZ so
7:30
that we can call the display sync at
7:32
this rate so 100 mahz is the current
7:36
frequency and using a prescaler of 100
7:39
will bring it down to 1
7:41
mahz now the auto reload value of 50,000
7:45
would further reduce this clock to 20
7:48
htz make sure you enable the timer
7:51
interrupt this is it let's generate the
8:02
as I mentioned this doesn't seems to be
8:04
working in Cube ID for now and this is
8:07
why I am using the Kyle
8:11
ID let's open the project folder first
8:15
of all we will copy the library files I
8:18
am copying the display drivers into the
8:25
folder now go to the touch gfx Target
8:29
and copy these data transfer files here
8:32
all right this is done now we will
8:36
application so open the Touch gfx
8:42
file here we don't have any option to
8:44
select any examples so we will go with
8:50
UI it want to reload the project click
8:56
yes now you can design the guis
9:00
requirement for the demonstration
9:02
purpose I am just adding a gauge this
9:06
will not display any value for now as I
9:09
just want to display something on the
9:11
TFT we can check the simulation to see
9:22
look it seems fine so generate the code
9:40
ID first of all we will add the files
9:47
project I will include the touch Library
9:55
later we need to do the same in the
9:57
Target folder add the data transfer
10:10
files now in the main file include the
10:16
Library initialize the display the rest
10:20
will be taken care by this touch gfx
10:23
process function let's build it once to
10:26
see the errors we got one error
10:39
these are basically the instructions to
10:41
make this project work these are already
10:44
taken care of in the data transfer files
10:47
that we added to this project so we will
10:57
out so we have no errors now I forgot to
11:01
include the timer for the sync operation
11:04
start the time base in the interrupt
11:07
mode now after 50 milliseconds an
11:10
interrupt will be triggered and in the
11:12
call back function we will call the sync
11:15
operation looks like this function is
11:18
already defined here let me check the
11:21
cube MX again here it is using the timer
11:24
11 for time base and that explains the
11:27
call back function you can use the
11:30
cystic for the time base but I will
11:32
leave it like this and instead I am
11:36
putting the sync code inside the call
11:52
here I will leave this function here
11:55
comment it out in case you want to refer
11:58
it or all right let's build the code and
12:14
board here you can see we got the images
12:17
we designed in the touch
12:19
gfx so the drivers and the touch gfx all
12:23
are working fine now we will add the
12:26
touch control to this
12:31
the display have separate pins for it
12:33
you can see here basically we need to
12:36
set up another SBI for the touch control
12:40
this display uses the xpt2046
12:43
touch driver here is the source file for
12:54
driver notice here that the pins are
13:01
TCS also it uses SBI 2 so I am also
13:11
same keep the board right around 5
13:17
interrupt we don't need to set up the
13:19
dma for this one three pins are set for
13:23
the SBI now we need to set the remaining
13:26
two the interrupt pin set it as the
13:30
interrupt I am going to name it
13:33
tiq just how it's named in the driver
13:36
and at last the TCS pins as output now
13:40
we need to configure the external
13:52
interrupt set the trigger as the falling
13:55
Edge and pull the pin High
14:01
also enable the nvic for the external
14:07
interrupt everything is set so generate
14:13
code reload Kyle so that new changes can
14:20
included we will come back to this but
14:23
first we need to modify the touch gfx
14:41
I am going to add buttons here to show
14:54
interface so we have Flex button one and
15:00
now we will add the interactions to
15:06
buttons so when the flex button two is
15:08
clicked it will hide the gauge widget
15:12
and similarly when the flex button one
15:14
is clicked it will show the gauge
15:21
widget let's try this in the simulator
15:37
things seems to be working all right
15:46
now Kyle is asking for reload so click
15:57
yes the next thing we need to do is add
16:01
the touch Library files to the
16:15
project so we have added the source and
16:18
header files for the touch and now
16:27
main in the main function ction
16:42
xpt now comes this last file the touch
16:54
CPP we already have the same file in our
16:57
project so we will only copy few
16:59
necessary things into it so first copy
17:03
these entire things including the
17:13
section now we will modify the sample
17:20
function so if you are using any other
17:23
driver make sure it have the functions
17:25
like update which basically updates the
17:29
and a function like is reasonable to
17:31
check the coordinates are valid or not
17:34
instead of is reasonable you can also
17:36
use some calibration function whatever
17:41
library if you check the data transfer
17:44
file that we copied earlier the transmit
17:46
block function uses the two functions
17:48
from the display driver the set window
17:52
function and the draw bit map
17:54
function like I mentioned in the
17:57
beginning these are the only functions
17:59
you need for the display driver to
18:08
work here we have some problem with the
18:12
vsync after the code was regenerated it
18:15
removed the definition of the vsync let
18:23
again all right let's build the code and
18:26
Flash it to the board
18:40
so everything is working great so far
18:44
the touch is responding well and there
18:46
is not much delay in the animations too
18:50
the limitations of using touch gfx in
18:52
such cases is clearly the
18:54
memories the controller I am using does
18:57
not have enough RAM or flash memory to
18:59
be able to handle larger
19:02
projects but if the controller have the
19:04
support for qbi and FMC you can use the
19:08
SD ram and external flash memories to
19:12
limitations this is it for this
19:15
video you can continue watching the
19:17
touch gfx series and try to implement
19:20
those projects in these lowcost
19:23
LCDs if the size is not the problem the
19:27
project will definitely work
19:29
you can read more about the functions we
19:31
used the files we copied and the reason
19:34
behind everything we did in the article
19:36
I showed in the beginning the link to
19:39
the post is in the description you can
19:42
download the project from the
19:44
description too I will try to make this
19:47
work with Cube ID also and if it
19:50
succeeds I will make a quick video about
19:52
it too that's all for today leave
19:56
comments in case of any doubt
19:59
keep watching and have a nice day ahead