0:09
hello and welcome to controllers Tech
0:12
few months ago I covered two videos on
0:14
the qbi peripheral in SDM 32 which
0:18
covered how to initialize the qbi write
0:21
data into it and read data from it we
0:24
also saw how to enable the memory ma
0:27
mode and how to execute an application
0:31
memory both of those videos were focused
0:34
on the n25 Q Series and mt25 series nor
0:38
flash memories which already has an
0:40
external loader in the SD's
0:42
record today we will cover the qbi again
0:46
but for the w25 Q Series nor flash
0:50
memories these chips are widely
0:52
available and they are comparatively
0:55
cheaper we will also see how to create
0:58
an external loader so we we can debug
1:00
and load the code into the qbi
1:03
memory we will cover this in two
1:06
parts in the first part we will see the
1:09
connection and also cover the read write
1:12
erase and memory mapped mode for the w25
1:17
memories in the next part we will see
1:20
how to create an external loader for a
1:22
specific controller and memory device
1:24
and how to debug the external memory
1:26
using the external loader you can find
1:30
more details about the SDM 32 qbi in the
1:37
4760 here you can see the list of
1:40
microcontrollers that support the
1:43
qbi more detailed info about these
1:45
controllers can be seen
1:47
below here you can see the list of
1:50
microcontrollers along with the maximum
1:54
details you need to check the notes
1:56
provided with the microcontrollers
1:58
before you start with the
2:01
qbi for example the stdm
2:05
32446 series has the Note 4 it says that
2:09
the lqfp only supports bank one with
2:13
lines so if you have the nucleo F 446
2:17
board it does not support the
2:20
qbi basically the low pin development
2:23
boards by STD do not support the qbi so
2:27
make sure to check the availability here
2:30
I have the L 496 development board and
2:33
it supports the maximum speed of 60 MHz
2:36
in the single data rate mode also the
2:40
maximum space in the memory mapped mode
2:45
MB you can check more details about the
2:52
PDF SD has a repository on the GitHub
2:56
which contains the qbi drivers for few
3:01
in my previous video about the qbi I
3:04
showed how we need to use this driver
3:07
project they don't have the drivers for
3:10
the wind Bond chips but we can create
3:14
modifications we will use this
3:16
repository to create an external loader
3:18
for our board but in the next
3:21
tutorial all right let's start the cube
3:26
project I am using The nucleo L4 96
3:31
board give some name to the project and
3:38
finish let's set up the clock first I am
3:42
using the internal oscillator to
3:44
generate the maximum 80 MHz clock for
3:47
CPU now go to the connectivity and
3:50
enable the quad SBI bank one with quad
3:53
lines we will configure the parameters
3:56
later let's set up the pins first
4:03
here is the schematics of the board I am
4:05
using and you can see the pins allocated
4:10
quadpy I will set up these pins in the
4:32
here is the connection between the w25
4:35
Q32 and the MCU the flash memory is
4:39
powered with 3.3 volts and the rest of
4:42
the pins are connected to their
4:44
respective counterparts on the board all
4:46
right now we will configure the
4:48
parameters as per my clock setup APB 1
4:52
and 2 both are running at 80 MHz so the
4:55
quadpy should also be at the same clock
4:58
you can check out the clock diagram in
5:00
the data sheet to see which bus is
5:02
connected to the quby anyway right now
5:05
the quats clock is at 80 MHz but the
5:08
board supports the maximum clock of 60
5:11
MHz as we saw in the beginning so I am
5:14
using a prescaler of one which actually
5:17
is the value two and it will reduce the
5:22
mahz set the fifo threshold to four and
5:25
the sample shifting half cycle The Flash
5:29
side can be calculated using the formula
5:31
shown here I have 4 megab memory so the
5:40
21 now go to the project manager code
5:43
generator and check generate peripheral
5:48
files click save to generate the
5:52
project here you can see the quby file
5:55
has been generated separately with our
5:58
configuration I have the quby source and
6:00
header file with the required
6:02
modification for the w25 Q Series
6:05
memories let's copy the user code zero
6:08
and the user code one in the respective
6:21
position now copy the content of the
6:23
header file in the quby header
6:40
let's build the code once to check for
6:48
errors if you are using any other memory
6:51
size you need to modify the memory size
6:54
here the block size the sector size and
6:57
the page size remains the same
7:00
throughout the w25 Q Series so you don't
7:03
need to worry about them the chip
7:06
commands are also the same but I would
7:08
advise to cross check them with the data
7:11
once our qbi driver is ready so let's
7:15
test it Define a buffer to store the
7:18
data to be written into the memory and
7:20
another buffer where we will save the
7:24
memory in the main function initialize
7:30
we will erase the entire chip and then
7:32
write the data into the
7:34
memory this location zero is with
7:37
respect to the memory it is basically
7:41
memory now we will read 100 bytes of
7:44
data from the same memory
7:46
location all right let's build the
7:50
code we don't have any errors so let's
7:53
debug it now I am setting a breakpoint
7:57
at the read function and you can see
7:59
that the right buffer contains the data
8:01
to be written let's run the debugger now
8:05
the chipper raay takes around 10 to 20
8:07
seconds to complete all right we have
8:10
hit the break point so the right is
8:13
complete the read buffer is empty right
8:16
now let's step over this statement the
8:20
read buffer now has the data which we
8:22
stored in the memory we read 100 bytes
8:26
so the rest of the data in the buffer is
8:28
FF hex this is because the entire chip
8:31
was erased and hence it contains the
8:34
FFX so we were able to write and read
8:37
the data from the memory if we try to
8:40
access the memory in the memory window
8:42
we can't access it to access the memory
8:46
here the MCU must see the flash memory
8:48
as a part of it and this is where the
8:50
memory map mode comes
8:55
in let's enable the memory mapped mode
9:00
now we will comment out the read
9:02
function and copy the data from the
9:04
memory location to the read buffer using
9:06
mem copy the memory location 90 million
9:10
hex is the address for the qbi and it
9:13
Remains the Same for most of the SDM 32
9:16
controllers anyway you can confirm it in
9:19
the reference Manual of your
9:21
controller go to the system and memory
9:25
overview here you can see the memory
9:27
distribution for this m see you the quby
9:31
flash is located at the address 90
9:35
hex note that the locations for the
9:37
external memories are already defined
9:40
the MCU even though the memories are not
9:43
connected so if you connect them in
9:45
future you need to use these memory
9:48
locations for the respective
9:50
memories I have stored the data at the
9:53
beginning of the memory so I am
9:55
accessing it at the address 90 million
9:57
hex let let's include the string header
10:00
file for the mem copy
10:02
function all right let's build and debug
10:09
now I am setting a breakpoint at the
10:12
while loop so it will hit once all the
10:16
completed the arrays will again take
10:20
seconds all right we have hit the breako
10:23
which means everything above was
10:26
processed we have the data in the read
10:29
buffer so the mem copy function
10:31
succeeded the fact that we can use the
10:34
mem copy function simply means that the
10:36
MCU now sees the external flash memory
10:39
as the internal memory we can also
10:42
browse the memory in the memory window
10:44
and this is only possible if the memory
10:46
is being treated as the internal memory
10:49
so the memory mapped mode worked and we
10:52
were able to map the external memory as
10:54
the internal memory this is it for this
10:58
video I hope you understood how to work
11:00
with w25 qor flash memories using the
11:04
qbi peripheral in the next tutorial we
11:07
will see how to make an external loader
11:10
for our MCU with the qbi Flash and how
11:13
to debug The Flash using the loader we
11:16
will later use the qbi flash to store
11:19
the data for the lvgl and touch gfx
11:23
applications this is it for
11:25
today you can download the code from the
11:29
description leave comments in case of
11:32
any doubt keep watching and have a nice