Hello.
Welcome back.
In this lesson we are going to see how to write a drive for a while.
Cystic time.
And then we going to use the cystic to create a delay function to create precise delays in this experiment.
I'm gonna create a new project by coming over here.
New York Vision Project I store it in this forward I've created a name called the cystic
and my port is Tim for C 1 2 3 0 8 6 p.m.
and then under this UMC is select to call on a device Austerlitz startup.
Okay
I'm gonna come over here.
My target is the team full support team for C 1 2 3 Use you each.
I'll just make it to 4 see 1 2 3.
And um she was group here.
This is up and then create a new fault here.
This is a mate.
Oh.
Make it s mean that s cool it made notice like this.
Okay so um we're gonna write a driver for the cystic timer so the cystic timer is a cool pair for all
of um cortex M and what I mean by copay for is that this this is included this is included in the architecture.
So this is not ordered by the silicon manufacturer.
And what I mean is this.
Okay.
Before I continue.
For those of you who don't know the UM WE SAY UM cortex M for cortex M 3 etc..
Um is a company based in Cambridge UK.
And this company does not manufacture any hardware.
They don't produce hardware.
If Tesco excellent engineers who come up with designs and then they sell the license of their designs
to people to companies I should say so.
S t microelectronics has it license from um Texas Instruments has a license from um.
Apple has a license from some source a license from um while we has a license from up I could go on
and on.
In fact it was estimated that over 90 percent of mobile phones out there use um architecture.
But the one used in mobile phones is the cool text a architecture not a cortex m a stance for application
M stands for microcontroller.
So we are dealing with the cortex microcontroller right.
So when I say since this is part of the core architecture I mean when you buy the license or when you
sign up for a license from um the car designed to give you a full context M cystic is part of it.
So it is up to me with a silicon manufacturer to add at a peripheral such as the ADC that you are to
the US be the SBI ITC etc. those at a per force are included by this uh by the by the silicon manufacturer
but by the cystic timer is part of the call peripheral.
So mean in the court we write over here for cystic should work on an equal text M for board the same
way because the address is the same.
This is not decided by the silicon manufacturer right.
So because of this to get the M to get the address of the cystic registers we are going to go to the
cortex M We're going to go to the cortex and generic use a guide rather than go to a what team for C
datasheet.
We're going to go to the generic you said guide provided by arm with regards to quote text M for so
you can just come to books over here and select cool text M for generic use a guide.
Right.
This is it.
This document is provided by arm.
Right.
So what we want to do is find the um find the cystic register this um in the generic use guide.
Let's see.
This should be a page that tells us the Memory map of the copay froze.
Okay so over here we we have context M for poor folks.
So all of this is included in cortex M for us the call when you buy devices.
So I'm gonna click on the cystic timer over here.
Let's see what we have.
Okay yeah.
This the cystic time.
So these are the cystic Regis this and over here.
It gives a short um short so explanation for cystic.
It says the process has a 24 but 24 it s type system timer narcissistic sort of what cystic is an abbreviation
of assistant timer.
This time a count down from a reload value to zero re lowest.
Then it reps to the value in the cystic reload uh fully register.
I think that is a R V R is reload value register.
Right.
So each item registers machine will need for our cystic timer so we have to create symbolic names for
these registers.
Right.
So let's start of uh let's start with the cystic control register.
This one here since they control and that is register we're going to call this we're going to give this
registered in name and Vic system control register because when you take a look at the um the driver's
provided by the silicon manufacturer we can take a look at your Texas Instruments your team 4C 1 2 3
0 8 6 p.m. dot age 5 that is often provided by Texas Instruments for people who do want to write the
bare metal code.
We take a look at this head of the name.
They've given this registers we're going to use the same naming convention.
So it's often called n Vic and Vic um it s written like this and Vic and n VIX times for ness uh ness
that effect or interrupt controller and then SD for cystic and then we say C T C T R O for control and
then R for register and this the address here we just get it.
This is the address for this is the control register.
So it does the naming convention which we use for this right after the.
Let's see.
We also need the um the cystic reload value register.
We're going to call this one and Vic and I echo SD and this called reload on let's school R and then
we give a symbolic name.
Uh this the symbolic name will bring the actual register.
The actual code.
There we go.
So after this let's take a look at the next register.
This is the current value register.
Copy it.
We simply are going to call this cystic current to register.
I'll say and Vic SD current on the score.
Are you.
Q You and this.
Right.
So these are the three important registers we need for this experiment.
We don't need this last one the collaboration register we don't need it so we can read up a bit uh about
this.
So this is the control register the control register as you can see we have better numbers you were
1 2 to 3 to 15 our reserved but 16 is used for the count flag bit 17 to 31 are reserved.
Let's see the meaning.
Okay.
It's 16 counts luck This returns one.
If the time I counted to zero since the last time this was read.
So this is where we use this flag to check what out a what time out hustle kit which is located at bits
number 16 of the offices the control register and button number two indicates the clock source.
What are we using an external clock or an internal clock which is a process a clock.
This is between number two if we are using our internal process a clock we have to parse one two bits
number 2 over here.
Code clock source it's number 1 is known as the tick interrupt.
This enables systemic exception request and it s s 0 counting down to zero does no I said just take
exception requests weren't counted down to zero except to basically use this to enable the system interrupt
or exception and then bits number zeros to enable the counter.
In other words to a neighborhood assisted time timeout so we use pit number zero to do that when we
pass one we've enabled it to one policy we've disabled it so that is the system control register right
and the rule load register specifies this that the value to load into the cystic um current value register.
Right.
And over here it s it s twenty four bit the maximum value we can load into the reload registers 24 bit
from zero to twenty three over here and over here it's reserved.
So we load our value here to reload value can be any value in the range of your x years or 1 2 0 x and
this is the maximum 24 bit value.
Okay.
So okay so you can come back it can come back and read more about the Sestak if you want to learn more
for that but we're going to create symbolic names to represent these other things such as things like
the clock so screws in the clocks also enable disable the tick interrupt and enable disable the timer
will create symbolic names to use for those um I'm gonna come down here and I'm going to say and Vic
gets the control count this would represent the count of luck we'll see it can you and I'm simply going
to pass this
this pits number sixteen This sets bits number sixteen to one in the control register and then I'll
say and fake
s t control clock SOS.
This will allow us to select into our process a clock source or an external clock source.
Q You
I'm going to pass one to that particular bit and if you explain this for you would realize that one
enables the bits that select the process a clock source for us and then next interrupt enable when I
use an interrupt in this example.
But when we start dealing with interrupt you need this as the control and then into enable a queue you
I'm gonna pass this here
next is to enable
and we enable through the control register and Vic as the control register enable
c e q you over here and then we know pit 0 is for enabling.
And then next a reload value you gonna say n fake SD.
Um s t reload would put us in the reload register.
M P to you and then we're going to use the maximum 24 bit value Okay so I just put a comment to this
what it can't flag.
This over here is for cluck sauce.
This is for interrupt enable or interrupt
and enable counter mode.
And then there's the current load value
right.
So the next thing we have to do is bring in the um the registers for a while the registers for our LCD
because we want to make an LCD blink.
So because we've already learned how to create symbolic names for our registers which in regards to
GPL your output would need not do that from scratch.
I'm just going to copy it from the previous project and bring it over here.
Copy this pasted over here like this.
So we've got we've got a direction to teach to enable the data register.
Yeah.
And then um symbolic names for enabling GPL u f as well as our LCD and then not a symbolic name to turn
off the red LCD.
We're gonna be using the red LCD here right.
Right.
So we are done assigning symbolic names to our relevant registers.
Let's continue into next lesson.
Let's implement to what driver.
I'll see you later.