Hello.
Welcome back.
In this lesson we're going to see how to set up the cystic timer to generate an interrupt at a fixed
rate.
We're going to set up our cystic timer to generate an interrupt once a second meaning it's period or
its frequency is going to be 1 Hertz and in the interrupt service routine.
We're going to blink out early.
And over here we're just using the LTE blink as an example of a task that can be performed within the
interrupt service routine.
But in your know more and better development applications you can create the cystic interrupt and place
a piece of algorithm there a piece of algorithm that you want to be.
You want to execute periodically.
This can replace the LCD blinking function that we shall be right in there.
So the interrupt service routine can be used for anything.
Just that in this course we simplify things by using LCD to demonstrate everything but really the melodies
can be replaced with your own algorithms your own output devices.
And in fact your own input devices you can read send source when the interrupt occurs without talking
much less create a new project and see how this is done.
Come over here.
You Vision project create a photo for it.
I call this cystic interrupt
quote a project cystic interrupt.
I'll slip my board here.
Tim Fauci 1 2 3 issue of age 6 p.m. and then I select this and then okay on a census I select the call
on the device or select the starts up and then okay over here once that's done I renamed this to the
name of the board.
Team Fauci one two three.
And then I'm going to extend this.
And so this group here going to rename me to AP
and then I'm going to come over here targets options are set up to 16 and then debug group down.
Still there is ICD I can then click over here and then take research and run and then okay and then
okay I'll come over here right click out new item to group main and then I'll give the file a name.
Right now stop by including the port header.
It's this over here.
Now jump straight into it into Main and when stuck by initializing our early.
I'm sure you're used to doing that by now.
Come down here I'll see system control of CTC GPA.
And then this course because we sat in Port f we pass your extra it's your excuse you're over here.
And once that's done we're going to set all of the D GPA to f direction register gonna pass sir x.
Sure.
E over here and this is set or the LCD outputs.
And we do a GPA you have
to enable
this your ex your E over here.
And then we said all of them are stitch two pins.
Once that is done we can configure to cystic put a comment here for you.
Okay let's begin by disabling global interrupt whenever you want to enable interrupt or set up an interrupt.
You first have to disable interrupt globally and we do that by using underscore underscore disable AI
our cue like this.
So would you say would interrupt and I'm going to start by loading the cystic
cystic access to load register over here load and this of course 16 million.
One two three.
One two three minus one like this.
Once that is done we set the system control register we enable cystic through any control register cystic
and then control and then we pass them a seven here.
If you expand this you realize that this corresponds to that bit that would enable cystic.
And then use interrupt and use system clock.
Right.
So this what all of that is encapsulated into seven over here.
So this what we need to do actually.
So once this is done we've got to enable interrupts globally and we do this by saying e and i are queue
like this.
And once that's done we can come over here while 1.
And then we'll have nothing in our while one loop because our blinking is going to happen in the cystic
handler to the cystic unless a callback function.
The system would recognize this automatically.
It's called cystic Floyd cystic underscore handler and we'd need not put the prototype up because it's
a callback function.
We don't have to copy and put it prototype on the top here.
The system would recognize this automatically.
So in the cystic handler we want to perform our competition.
It could be performed digital filtering it could be you could perform your fire filter or DSP algorithms
over here or if you are creating a real time candle you can you know invoke the scheduler over here
to switch to the next task.
But in our example we simply going to toggle an LCD in the system handler for those who you taken my
other course on creating your own real time operating system.
You remember that we use in this cystic handler arsenic time these basically this they can't let that
you know control is a what scheduler to move from one task to the other.
But over here we simply blink an analogy or toggling an entity to we do that by saying keep you f data
register and we are going to read a lady bypasses your ex your two over here like this.
Right.
So let's build and see or click over here to build.