1
00:00:00,210 --> 00:00:00,530
Hello.

2
00:00:00,540 --> 00:00:01,240
Welcome back.

3
00:00:01,240 --> 00:00:04,800
In this lesson we shall give a brief overview of time.

4
00:00:05,250 --> 00:00:09,080
Let's begin by talking about assisted time or the system.

5
00:00:09,080 --> 00:00:16,590
Take timer the system tick timer is present in all cortex microcontrollers irrespective of whether it's

6
00:00:16,770 --> 00:00:26,820
SDM thirty two LPC TLC series etc. This system tick timer allows the system to initiate an action on

7
00:00:26,820 --> 00:00:28,890
a periodic basis.

8
00:00:28,890 --> 00:00:34,290
This action is performed internally at a fixed rate without external signal.

9
00:00:34,470 --> 00:00:42,630
For example in a given application we can use cystic to read a sense of value let's say every 200 milliseconds

10
00:00:43,410 --> 00:00:52,050
cystic is widely used when in real time operating systems so that this system software may interrupt

11
00:00:52,080 --> 00:00:59,300
the application software periodically to monitor and control the system operations and do so few take

12
00:00:59,300 --> 00:01:03,660
in my other course on good and your own real time operating system.

13
00:01:03,660 --> 00:01:11,020
You saw how we use cystic as our time base to control everything and to sort of control our scheduler.

14
00:01:11,100 --> 00:01:19,840
The cystic is a 24 bit down counter driven by either the system clock or an internal oscillator it's

15
00:01:19,850 --> 00:01:25,920
counts down from an initial value to zero when it reaches zero in the next clock.

16
00:01:25,920 --> 00:01:34,140
It's under floors and it raises a flag known as Count and reloads the initial value and starts all over

17
00:01:34,140 --> 00:01:35,220
again.

18
00:01:35,220 --> 00:01:41,580
Now let's take a look at the cystic registers when program in the cystic we need to configure just three

19
00:01:41,580 --> 00:01:49,380
registers we've got the the system control and status register the system reload value register in the

20
00:01:49,380 --> 00:01:56,680
system current value register and which we'll see how to configure these registers programmatically.

21
00:01:56,690 --> 00:02:02,100
Now let's see how to calculate the value to load into the cystic LeWitt register.

22
00:02:02,120 --> 00:02:05,510
Let's say we want an action to occur every second.

23
00:02:06,410 --> 00:02:14,160
If our clock frequency is 16 megahertz we simply need to load 16 million minus one into the cystic load

24
00:02:14,210 --> 00:02:18,250
register and we shall see how this works in code.

25
00:02:18,320 --> 00:02:27,740
Well 60 million minus one because if our process is running at 16 megahertz This means there are 16

26
00:02:27,740 --> 00:02:30,920
million cycles in one second.

27
00:02:30,950 --> 00:02:38,750
So in one second we are able to run 60 million processor cycles and because we count from zero we do

28
00:02:38,750 --> 00:02:42,140
16 million minus one over here.

29
00:02:42,230 --> 00:02:44,030
How about one millisecond.

30
00:02:44,060 --> 00:02:47,570
Let's say we want an auction to occur every millisecond.

31
00:02:47,570 --> 00:02:49,390
How do we compute this.

32
00:02:49,400 --> 00:02:57,310
Well we know there are 60 million cycles in a single second and we also know that one second equals

33
00:02:57,470 --> 00:02:59,980
a thousand milliseconds.

34
00:03:00,420 --> 00:03:06,360
Then this means death 16 million cycles in a thousand milliseconds.

35
00:03:06,360 --> 00:03:15,360
So if 60 million cycles in a thousand milliseconds then how many cycles do we get in a single millisecond

36
00:03:15,630 --> 00:03:23,400
and we compute that by doing a thousand milliseconds divided by thousand equals sixteen thousand cycles

37
00:03:23,460 --> 00:03:25,200
divided by thousand.

38
00:03:25,290 --> 00:03:28,770
And this gives us sixteen thousand.

39
00:03:29,160 --> 00:03:35,640
So therefore in a single millisecond we have sixteen thousand cycles.

40
00:03:35,640 --> 00:03:43,860
So if we want an action to occur every millisecond we have to load sixteen thousand minus one into the

41
00:03:43,860 --> 00:03:46,290
cystic node register.

42
00:03:46,350 --> 00:03:49,110
Now let's take a look at the general purpose timer.

43
00:03:49,110 --> 00:03:57,060
Apart from having the cystic timer in every cortex microcontroller the silicon manufacturers like SD

44
00:03:57,090 --> 00:03:59,150
and XP Texas Instruments.

45
00:03:59,310 --> 00:04:04,980
They also provide additional time is known as general purpose time is and we can use these timers to

46
00:04:04,980 --> 00:04:05,940
create delays and.
