0:08
hello and welcome to controllers Tech
0:12
this is the third video in The w25q
0:15
Flash series and today we will cover how
0:20
I planned this video to cover the right
0:22
operation also but the video turned out
0:25
very lengthy and therefore I have split
0:27
them into two separate videos
0:30
this video will cover how we enable and
0:32
disable the right and how to erase a
0:35
particular sector or number of sectors
0:38
in the next video we will see how to
0:40
perform the right operation on a page or
0:45
this is the continuation from the
0:47
previous video where we saw how to
0:49
perform the read operation
0:51
the data was stored at some particular
0:54
locations but in different sectors
0:57
as we will erase those particular
0:59
sectors today let's quickly see the
1:04
the first set of data is stored on page
1:06
1 at an offset of 85.
1:13
if we read the device starting from page
1:15
0 we get the data at an offset of 341.
1:20
there is another set of data located in
1:23
another sector on page 17.
1:26
let's see the data sheet now
1:29
here is the sector arrays instruction
1:33
along with sector arrays we can also
1:35
perform 32 kilobytes or 64 kilobytes
1:41
or erase the entire chip
1:44
basically sector is the minimum memory
1:46
segment that we can erase
1:49
we cannot erase a single page or a
1:54
if you want to update even a single byte
1:56
of memory you need to erase the entire
2:00
the sector arrays command erases the
2:03
four kilobytes memory segment by setting
2:07
but before performing the arrays we
2:10
should first execute the right enable
2:14
the method to send the instruction is
2:16
the same we send the instruction
2:18
followed by the 24-bit address
2:21
let's see the right enable instruction
2:25
the write enable instruction sets the
2:27
right enable latch in the status
2:31
this must be done before we perform a
2:33
right operation the arrays operation or
2:36
update security in status registers
2:39
the instruction code is 6 hex
2:46
let's write a new function write enable
2:51
the procedure to send the instruction is
2:54
we pull the Cs pin low
2:57
send the instruction to the device
3:03
let's give a small delay just to be safe
3:07
just like write enable there is an
3:10
instruction to disable the right
3:12
the process is the same just the command
3:36
now we have the right enable instruction
3:38
so let's erase the sector
3:41
the command is sent in the similar way
3:43
we sent other commands
3:45
pull the Cs pin low send the instruction
3:48
along with the memory address and then
3:54
let's write a function to erase the
3:56
sector whose parameter will be the
3:58
number of sector we want to erase
4:01
Define the data array to be sent
4:04
now calculate the memory address using
4:08
each sector contains 16 pages and each
4:11
page contains 256 bytes so the memory
4:15
address will be sector number times 16
4:20
now before we send the command enable
4:24
the command is sent in the similar
4:27
manner We performed the read operation
4:29
the instruction to erase the sector is
4:34
and we don't need to send the dummy
4:37
after the data has been copied in the
4:40
data array send the data to the SBI
4:43
we need to send different number of
4:47
after sending the command disable the
4:53
if you check the AC Electrical
4:56
characteristics of the device you can
4:58
find the time requirement to perform
5:02
for erasing the sector the maximum time
5:05
required is 400 milliseconds
5:08
let's give a delay of 450 milliseconds
5:12
so this completes the sector arrays
5:15
let's define it in the header file so
5:18
that we can call it from the main file
5:21
in the main file we read the data from
5:24
two different locations and both were in
5:31
we will read the data then erase the
5:34
sector and then read the data again
5:37
this will confirm whether the data was
5:39
erased from the given location or not
5:50
let's build and debug the code
5:54
since we are reading data from the
5:55
location where it is stored we will get
5:58
the data in the beginning of the RX
6:00
buffer all right let's run the code now
6:04
here you can see we have received the
6:06
data now run the sector arrays command
6:10
and when we read the data again from the
6:13
same location we get FF hex
6:16
this means the data was erased from the
6:19
first location actually the entire
6:23
Now read the data from the second
6:25
location which is in sector 1. here we
6:31
Now erase sector 1. and when we read
6:35
again the data is replaced with FF hex
6:39
this data is permanently gone now
6:42
if we reset the debugger and try to read
6:45
the data again we will just find FFX at
6:50
so we have successfully erased the first
6:54
erasing a sector is necessary as I
6:57
mentioned this is the minimum memory
6:59
segment that we can erase
7:01
when we perform the right operation we
7:04
need to erase a sector before writing
7:08
this is because the write can be only
7:10
performed on those memory locations
7:12
whose current value is FF hex
7:15
if a memory location already has some
7:17
data we cannot replace that data we have
7:20
to first erase it and then write new
7:24
we will cover the page right in the next
7:26
video which will be out in three days
7:29
this is it for this video
7:32
I hope you understood how to erase a
7:35
the link to download the code is in the
7:38
description of the video
7:40
leave comments in case of any doubt
7:42
keep watching and have a nice day ahead