0:13
this is yet another video covering the
0:15
inter-core communication between the
0:17
stm32 CPUs and today we will see how to
0:20
use the free rtos with the open amp
0:24
this is the continuation from the
0:26
previous video so if you haven't watched
0:28
it please watch the previous video first
0:32
I will continue from where I left off in
0:36
we will basically do the same where the
0:39
M7 core which is the master will send
0:42
the data to the M4 core the slave
0:45
the data will be then sent to the UF by
0:50
the explanation has been covered in the
0:52
previous video so I will just focus on
0:57
this is the previous project we covered
1:00
we need to enable the rtos so let's go
1:06
enable the free rtos for cortex M4
1:10
go to the tasks and cues tab
1:13
here the default task is already created
1:16
so we will just change its name to the
1:20
the RX task will be used to receive the
1:25
note that its priority is set to normal
1:29
let's create one more task the TX task
1:33
it will be used to send the data to the
1:37
we will keep its priority lower than the
1:40
RX task so I am setting it to below
1:43
now add one binary semaphore so that we
1:46
can restrict TX task from sending data
1:53
that's it for the cortex M4 enable the
1:56
rtos for the cortex M7
1:59
we will again create two tasks here one
2:02
for sending the data to the slave and
2:04
another one for receiving the data from
2:08
though we are not going to receive any
2:10
data from the slave we still need to
2:12
check for the message to know if the
2:14
service has been destroyed by the slave
2:17
we don't need any semaphore here as we
2:20
will send the data periodically
2:23
since we are using our TOS we need to
2:26
use a Time base other than the systick
2:29
so I am enabling the timer 6 for the
2:32
cortex M7 and timer 7 for the cortex M4
2:36
now select the appropriate time base
2:40
that's it for the configuration click
2:43
save to generate the project
2:45
there is a warning about the new library
2:47
re-entrant but that's all right go ahead
2:50
and generate the code
2:53
let's build both the files once
3:01
I will start with the cortex M4 first
3:10
this part is used to initialize the open
3:12
amp and create the endpoint
3:15
we will put it inside the RX task and it
3:18
will only run once in the beginning
3:21
since the RX task has higher priority it
3:24
will run first and initialize the open
3:45
after the initialization is over it will
3:48
acquire the semaphore so the TX task
3:56
the TX task is responsible for sending
3:58
the data to the uart so this part goes
4:05
we will shield this with the semaphore
4:07
so to send the data first it has to
4:10
acquire the semaphore
4:14
since we are using rtos we will use the
4:17
Malik and free functions to create an
4:26
so the TX task needs to acquire the
4:29
semaphore before sending the data but
4:32
the semaphore is already acquired by the
4:38
therefore once the message is received
4:40
we will free the semaphore so that the
4:43
TX task can acquire it and send the data
4:50
now inside the RX task we will
4:52
continuously check for the data sent by
5:03
finally the RX task is as follows
5:08
once the control enters it the open amp
5:13
then the end point is created and it
5:16
will acquire the semaphore
5:18
then it will continuously check for the
5:20
data sent by the master every 10
5:24
once the data is received the data will
5:27
save in the variable and the semaphore
5:34
after that the TX task will send the
5:36
data to the uart and again try to
5:39
acquire the semaphore
5:49
also the data is defined in the TX task
5:57
that's all for the slave now we will
5:59
write the code for the master
6:04
here I am leaving the message as one
6:07
we will again copy the initialization
6:20
after the initialization is over the RX
6:23
task will check for the message from the
6:45
and now the transmission of data will
6:47
take place in the TX task
6:59
it will run every second
7:02
as I mentioned the slave is not sending
7:05
any data so the check for message is
7:07
only used to check if the service is
7:09
destroyed by the slave
7:13
the master should only check for message
7:15
if the service is created and if it is
7:18
destroyed the open amp will
7:22
all right let's build and Flash the code
7:32
I am using the same debug configuration
7:35
from the previous project
7:42
let's reset the board
7:51
here you can see the message is being
7:53
printed on the console every one second
7:56
so our project is working fine so far
8:02
now let's say I want to de-initialize
8:04
the open amp after some time
8:06
If the message value is equal to 15 the
8:10
slave will de-initialize the open amp
8:12
and also terminate the TX and RX tasks
8:16
this will destroy the service and the
8:18
master should also do the same
8:21
when the tasks are terminated an ideal
8:23
task should run in both the cores and we
8:26
will see this while debugging the
8:29
terminating tasks is not the ideal
8:33
rather you can just suspend them and
8:35
write a separate task for initializing
8:37
the open amp again and then resume the
8:40
tasks to do their job
8:41
I am just terminating them so that the
8:44
TX task does not try to send data while
8:46
the open amp is de-initialized
8:49
for debugging we use the same
8:51
configuration for M7 core but make sure
8:54
the M4 file here is on the top
8:57
then go to the cortexm4 main file and
9:01
create a new debug configuration
9:10
select none under the reset Behavior
9:14
make sure the port number is at least 4
9:19
go to the startup tab double-click on
9:21
the configuration and uncheck the
9:26
now debug using the M7 configuration
9:32
when fully loaded again load the M4
9:40
all right now select both the main files
9:43
using the control button and click run
9:48
the message is being printed
9:50
and it stopped at 14 because as soon as
9:53
it reached 15 the open amp was
9:56
de-initialized and the tasks were
9:59
hence the TX task could not send the
10:02
message to the console
10:04
if you pause the debugger now you can
10:06
see the ideal tasks are running in both
10:15
so we saw how to de-initialize the open
10:18
amp after a certain condition was met
10:21
now let's quickly see how to transfer a
10:23
string or some character data
10:27
here I am creating another variable in
10:32
this is a character pointer
10:34
inside the receive callback function we
10:37
will simply type cast the data into the
10:43
since we are receiving the data in the
10:45
character form we will use the S format
10:51
the rest of the code remains unchanged
10:54
for the master I am first defining the
10:57
string I am going to send
11:04
and while sending the data I am using
11:07
the string length function to calculate
11:11
make sure to add a 1 to the length
11:20
it should be an array
11:23
all right let's run the code again
11:35
you can see the string is being
11:37
displayed on the console
11:39
so I hope you understood how to use the
11:41
open amp with free rtos and how to send
11:45
the string or characters between the
11:48
I will make more videos covering more
11:50
methods to do the same
11:52
I will also make a video covering a
11:55
practical application of inter-core
11:58
that's it for this video
12:01
the link to download the code is in the
12:05
leave comments in case of any doubt
12:08
keep watching and have a nice day ahead