Hello.
Welcome back.
In this lesson we shall give a brief overview of time.
Let's begin by talking about assisted time or the system.
Take timer the system tick timer is present in all cortex microcontrollers irrespective of whether it's
SDM thirty two LPC TLC series etc. This system tick timer allows the system to initiate an action on
a periodic basis.
This action is performed internally at a fixed rate without external signal.
For example in a given application we can use cystic to read a sense of value let's say every 200 milliseconds
cystic is widely used when in real time operating systems so that this system software may interrupt
the application software periodically to monitor and control the system operations and do so few take
in my other course on good and your own real time operating system.
You saw how we use cystic as our time base to control everything and to sort of control our scheduler.
The cystic is a 24 bit down counter driven by either the system clock or an internal oscillator it's
counts down from an initial value to zero when it reaches zero in the next clock.
It's under floors and it raises a flag known as Count and reloads the initial value and starts all over
again.
Now let's take a look at the cystic registers when program in the cystic we need to configure just three
registers we've got the the system control and status register the system reload value register in the
system current value register and which we'll see how to configure these registers programmatically.
Now let's see how to calculate the value to load into the cystic LeWitt register.
Let's say we want an action to occur every second.
If our clock frequency is 16 megahertz we simply need to load 16 million minus one into the cystic load
register and we shall see how this works in code.
Well 60 million minus one because if our process is running at 16 megahertz This means there are 16
million cycles in one second.
So in one second we are able to run 60 million processor cycles and because we count from zero we do
16 million minus one over here.
How about one millisecond.
Let's say we want an auction to occur every millisecond.
How do we compute this.
Well we know there are 60 million cycles in a single second and we also know that one second equals
a thousand milliseconds.
Then this means death 16 million cycles in a thousand milliseconds.
So if 60 million cycles in a thousand milliseconds then how many cycles do we get in a single millisecond
and we compute that by doing a thousand milliseconds divided by thousand equals sixteen thousand cycles
divided by thousand.
And this gives us sixteen thousand.
So therefore in a single millisecond we have sixteen thousand cycles.
So if we want an action to occur every millisecond we have to load sixteen thousand minus one into the
cystic node register.
Now let's take a look at the general purpose timer.
Apart from having the cystic timer in every cortex microcontroller the silicon manufacturers like SD
and XP Texas Instruments.
They also provide additional time is known as general purpose time is and we can use these timers to
create delays and.