0:09
hello and welcome to controller Tech
0:12
this is yet another video on the w25 Q
0:15
Series external flash memory and today I
0:18
will continue covering the h750
0:21
microcontroller that I covered in the
0:23
previous video in the last video we saw
0:26
how to use the external flash memory on
0:28
this controller how to use the memory
0:31
mapped mode and how to create the
0:34
Loader 2 weeks ago I made a video about
0:37
the lvgl on SDM 32 covering how to store
0:40
the Assets in the external flash
0:43
memory I also mentioned that we will
0:45
load the entire lvgl from external flash
0:49
using the xip execute in place this
0:53
video was supposed to be covering that
0:55
but it was getting very lengthy and that
0:57
is why I decided to cover the XI P
1:00
separately so basically in today's video
1:03
we will see how to load an application
1:06
from the external flash
1:08
memory there are going to be two
1:10
projects in this video the first one
1:12
will be used to make the control jump to
1:14
the external memory and the second
1:16
project will contain the application in
1:20
memory let's start the cube ID and
1:25
project we will create the project from
1:27
the existing ioc file
1:31
here I am choosing the cube file of the
1:33
Quad SBI project we created in the
1:36
video let's rename this project to boot
1:43
flash all right our basic setup is
1:46
already here which includes the clock
1:48
setup and the quad SBI
1:50
setup we only need to reconfigure the
1:54
mpu here we have already created a
1:56
memory region for the quad SBI with 8
2:00
size inside this region we will create
2:03
another region of 1 megabytes in size
2:06
starting from the beginning of the Quad
2:08
SBI memory the mpu configuration should
2:12
be the same for this region but we will
2:14
also allow instruction access to this
2:17
region that is all we need to configure
2:20
in the cube MX click save to generate
2:23
project the quads spr files in this
2:26
project are newly generated and hence
2:28
they don't have the data from the
2:31
project let's delete these files and
2:34
instead we will copy the files from the
2:46
project these files contain the
2:49
functions needed to make the quad SBI
2:56
work all right now in the main function
2:59
initi initialize the quad SBI and enable
3:02
the memory mapped mode now we will make
3:05
the jump to the external
3:16
memory here we are defining the function
3:19
that will make the jump to the external
3:22
memory here is the address of the cor
3:25
SBI memory where the function will make
3:27
the jump too let's copy the rest of the
3:30
code after the memory maed mode is
3:33
enabled here we first disable the
3:36
cache make sure both cach are enabled
3:40
before you call the functions to disable
3:42
them if you have not enabled the cache
3:45
comment out these lines you can enable
3:51
configuration I am enabling them as it
3:53
improves the system performance by a
4:03
we can now leave these statements to
4:05
disable the cache now disable theistic
4:09
interrupt then configure the reset
4:11
Handler and set the stack pointer
4:14
finally make the jump to the address
4:17
let's build and debug the
4:24
project I am setting a break point to
4:27
this statement let's run the debugger
4:31
all right we have hit the break point
4:33
let's step over this statement now we
4:37
have reached the statement which will
4:39
make the jump to the external memory
4:42
when we step over this statement the
4:44
control enters the heart fault this is
4:47
fine because there is no executable
4:49
program in the external memory right now
4:52
hence we got the hard fault here now we
4:56
need to store an application in the
4:58
external flash memory
5:03
project choose the board give some name
5:06
to the project and click
5:10
finish today we will run a very simple
5:13
application from our external flash
5:16
where we will just blink a
5:17
LED here is the schematic of the board I
5:20
am using and you can see the LED is
5:25
pa1 all right we will start with the
5:27
clock setup first I am choosing the
5:31
external Crystal to provide the clock
5:34
the board has 25 mahz Crystal on it and
5:37
I am running the system of 400
5:40
mahz Now set the pin pa1 as the
5:46
output we will configure the mpu just
5:49
like we did in another project enable
5:52
the first region set the address to 90
5:56
million hex the external flash memory is
5:59
8 MB in size all access is permitted
6:04
disable the instruction access disable
6:07
the sharability permission and enable
6:10
the cachable and buffable
6:12
permissions enable another region with
6:14
the same address the region size should
6:17
be 1 megab and permit all the access
6:21
enable the instruction access to this
6:23
region disable the sharable permission
6:26
and enable the cachable and buffable
6:30
that is all we need to configure in the
6:32
cube MX click save to generate the
6:35
project open the flash script and modify
6:40
parameters set the start address to 90
6:42
million hex and the length to 8
6:45
mbes basically we are setting the
6:48
external flash memory as our main flash
6:51
now open the system source file and
6:54
scroll down to the system initialization
6:56
function we need to relocate the vector
6:59
table to the external flash so first
7:02
reset the configuration register to zero
7:05
and then assign the quad SBI address to
7:07
the vector table offset
7:09
register that's all the configuration we
7:11
need let's write the main function now
7:15
as I mention today we will just blink
7:17
the LED so toggle the pin pa1 every 1
7:20
second inside the while loop let's build
7:23
the project now since this entire
7:26
project will be loaded to the external
7:28
flash memory we need the external loader
7:33
operation here is the loader that we
7:35
created in the previous video I am
7:38
copying it to the main project folder
7:41
here it is inside the project folder
7:44
let's create the debug configuration for
7:47
this project we will add the external
7:50
loader which we just copied into the
8:04
the download is verified but the control
8:06
is not in the main function just reset
8:10
the debugger here you can see the
8:12
control is in the main function now
8:15
let's run the debugger you can see the
8:18
LED on the board is blinking every
8:21
second our application is running fine
8:24
on the external flash memory you can
8:27
even see the current execution address
8:30
the address is located in the external
8:32
flash memory so everything is working
8:36
fine we were able to successfully run
8:39
the application from the external flash
8:41
memory this was a simple test
8:44
application in the next video we will
8:46
run the entire lvgl project from
8:48
external flash itself this is it for
8:51
this video I hope you understood
8:54
everything explained in the video leave
8:57
comments in case of any doubt
9:00
keep watching and have a nice day ahead