1
00:00:00,620 --> 00:00:01,740
Hello, welcome back.

2
00:00:01,760 --> 00:00:07,160
In this lesson, we're going to see how to configure a task to execute periodically.

3
00:00:08,390 --> 00:00:16,520
Now we said tasks execute based on the time quanta that is set in the configuration of the art Toscano,

4
00:00:16,940 --> 00:00:20,930
whether it is 10 milliseconds, five milliseconds, etc..

5
00:00:21,390 --> 00:00:28,940
What this means is that each task in a state where the tasks have the same priority, each task would

6
00:00:29,150 --> 00:00:31,100
execute for this amount of time.

7
00:00:32,040 --> 00:00:38,610
And then once this amount of time is exhausted, the next task would execute and then the next one and

8
00:00:38,610 --> 00:00:41,100
then you come back to the the first one again.

9
00:00:41,700 --> 00:00:46,170
This time, what if what if we want a task to execute, see?

10
00:00:47,730 --> 00:00:55,590
Every 50 milliseconds, you don't want to execute for this long, but you wanted to execute 150 milliseconds,

11
00:00:55,590 --> 00:00:57,720
pass the statement out different.

12
00:00:58,560 --> 00:01:05,670
Remember, we're not saying you wanted to execute for 50 milliseconds, but you wanted to execute every

13
00:01:05,880 --> 00:01:12,690
15 milliseconds, in a sense, wanted to be parodic, wanted to execute at a fixed frequency.

14
00:01:13,080 --> 00:01:16,370
Wandy task to start executing at a fixed frequency.

15
00:01:16,730 --> 00:01:22,470
We're going to see how to achieve that, using our using a function that we shall work with here, this

16
00:01:22,470 --> 00:01:24,910
function as part of the delay function.

17
00:01:24,930 --> 00:01:28,230
It's similar to the the delay function we saw earlier.

18
00:01:28,680 --> 00:01:32,240
This function is called the task delay until function.

19
00:01:32,610 --> 00:01:35,530
So you're basically saying delay until this amount of time.

20
00:01:36,060 --> 00:01:41,070
So without talking much, I'm going to go ahead to make a copy of project number 10 over here.

21
00:01:41,940 --> 00:01:52,110
I'll copy number 10 or paste over here and I'll call this eleven and then I'll call this executing tasks

22
00:01:52,110 --> 00:01:52,920
periodically.

23
00:02:08,280 --> 00:02:11,390
OK, and it's opened, I'm going to close these ones here.

24
00:02:12,800 --> 00:02:19,380
When pundits call over here, so over here in that seat over here.

25
00:02:20,130 --> 00:02:22,130
OK, so what are we going to do?

26
00:02:22,130 --> 00:02:25,430
Is we going to nominate Blue to execute periodically?

27
00:02:26,950 --> 00:02:33,400
In this new project, I'm going to delay I'm going to delete this feature delay if I'm right, and I'm

28
00:02:33,400 --> 00:02:41,140
going to come to blue here and inside blue, I'm going to have a number of local variables because it's

29
00:02:41,170 --> 00:02:44,080
simply I this is, um.

30
00:02:44,080 --> 00:02:44,650
Do we need.

31
00:02:44,650 --> 00:02:45,340
I hear.

32
00:02:47,390 --> 00:02:55,070
We don't need our loop, so we can we can forget about I am going to create a ticker tape.

33
00:02:55,100 --> 00:03:00,320
Remember, we created a static type variable, which is just an integer type.

34
00:03:00,540 --> 00:03:04,760
If you go deeper, you realize of what you intended to underscore.

35
00:03:05,510 --> 00:03:11,660
So for readability sake, this has been given to the tick tock, just like we created our own we created

36
00:03:11,660 --> 00:03:17,420
a task profile here, which is also you intended to underscore t so I'm going to create a tick time

37
00:03:17,660 --> 00:03:18,150
variable.

38
00:03:20,550 --> 00:03:24,700
It's also a bit like tick tock, tick, tick type over here.

39
00:03:26,070 --> 00:03:29,940
Let's go to you and then I call this X last.

40
00:03:31,100 --> 00:03:40,610
Wake up or last week time, the last time he was awake, essentially, and then I'm going to grab this

41
00:03:41,030 --> 00:03:41,750
this bit here.

42
00:03:42,520 --> 00:03:49,210
Remember, the functions that delay or the block functions require you to pass takes as an argument.

43
00:03:49,660 --> 00:03:53,560
Because of that, we have this macro that allows us to convert our time to Tick's.

44
00:03:54,310 --> 00:03:56,530
OK, this time I'm going to call this.

45
00:03:57,940 --> 00:03:58,450
Spirit.

46
00:04:00,770 --> 00:04:08,390
And then 500 M is a past 500 here, so we would want this function or this task to execute every five

47
00:04:08,390 --> 00:04:09,380
hundred milliseconds.

48
00:04:10,000 --> 00:04:15,490
OK, so now we're going to see gets us the current take account.

49
00:04:15,980 --> 00:04:20,090
So I'll see over here X to ask.

50
00:04:21,400 --> 00:04:22,540
Get to take account.

51
00:04:25,930 --> 00:04:31,720
Like this, and it's going to be stored in this variable, right, once that is done, we're going to

52
00:04:31,720 --> 00:04:32,560
come over here.

53
00:04:32,640 --> 00:04:38,590
Our function v task to lay onto V task delayed until it takes two arguments.

54
00:04:38,590 --> 00:04:42,190
It takes to the last wake up time and then the period.

55
00:04:43,020 --> 00:04:49,990
OK, so we're going to see if your task is the name of the function V task delay until.

56
00:04:53,700 --> 00:05:00,000
The first argument is the address of this rebel and the reason we passed the outrace of this rebel rather

57
00:05:00,000 --> 00:05:07,200
than simply to develop, was that last week up time is going to be updated automatically.

58
00:05:08,140 --> 00:05:14,260
So this variable is going to be updated after then after execution when this line executes the new last

59
00:05:14,260 --> 00:05:14,630
week.

60
00:05:14,830 --> 00:05:17,700
Time would be stored in this variable.

61
00:05:18,040 --> 00:05:20,670
So it's not going to be the old one that we read from here.

62
00:05:21,360 --> 00:05:25,450
OK, so the next argument is the period XP right over here.

63
00:05:30,560 --> 00:05:31,020
Right.

64
00:05:31,130 --> 00:05:34,400
So let's build and see the click over here to build.

65
00:05:39,030 --> 00:05:41,040
And then quicker to get onto the boat.

66
00:05:42,830 --> 00:05:43,760
Number 11 here.

67
00:05:45,150 --> 00:05:45,960
Then OK.

68
00:05:53,020 --> 00:05:53,470
Switch.

69
00:05:57,710 --> 00:06:02,960
Then let's see, so blue is the one expected to execute periodically.

70
00:06:03,990 --> 00:06:04,490
Let's see.

71
00:06:06,180 --> 00:06:07,350
We place this in blue.

72
00:06:08,960 --> 00:06:10,400
OK, so let's run and see.

73
00:06:11,780 --> 00:06:12,060
Blue.

74
00:06:12,350 --> 00:06:16,880
OK, so every 500 blue kicks in its rich ones.

75
00:06:19,850 --> 00:06:20,280
Right.

76
00:06:20,690 --> 00:06:21,410
So this is it.

77
00:06:21,740 --> 00:06:28,430
So in some applications, you require a task to execute with a precise period or precise frequency.

78
00:06:29,180 --> 00:06:30,950
This is one of the ways to achieve that.

79
00:06:30,980 --> 00:06:35,830
Another way to achieve that, of course, would be to create a hardware interrupt using a timer.

80
00:06:37,020 --> 00:06:44,610
Because with a hardware timer, you can come a time to arm, to create and interrupt every 500 times

81
00:06:44,610 --> 00:06:47,940
or 50 times or 100 times, right.

82
00:06:47,960 --> 00:06:54,980
But in an amateur system, if you need an artist's version of that, you can use the V task delay until

83
00:06:54,990 --> 00:06:56,250
function over here.

84
00:06:56,850 --> 00:06:59,860
So this all there is and I'll show you the next lesson of the.
