1
00:00:00,790 --> 00:00:01,210
Hello.

2
00:00:01,240 --> 00:00:01,900
Welcome back.

3
00:00:01,900 --> 00:00:08,110
In this lesson we're going to see how to set up the cystic timer to generate an interrupt at a fixed

4
00:00:08,200 --> 00:00:09,040
rate.

5
00:00:09,070 --> 00:00:15,700
We're going to set up our cystic timer to generate an interrupt once a second meaning it's period or

6
00:00:15,700 --> 00:00:19,910
its frequency is going to be 1 Hertz and in the interrupt service routine.

7
00:00:19,920 --> 00:00:21,770
We're going to blink out early.

8
00:00:21,940 --> 00:00:28,090
And over here we're just using the LTE blink as an example of a task that can be performed within the

9
00:00:28,090 --> 00:00:29,560
interrupt service routine.

10
00:00:29,560 --> 00:00:36,700
But in your know more and better development applications you can create the cystic interrupt and place

11
00:00:36,700 --> 00:00:41,280
a piece of algorithm there a piece of algorithm that you want to be.

12
00:00:41,350 --> 00:00:44,200
You want to execute periodically.

13
00:00:44,200 --> 00:00:49,790
This can replace the LCD blinking function that we shall be right in there.

14
00:00:49,810 --> 00:00:53,440
So the interrupt service routine can be used for anything.

15
00:00:53,440 --> 00:01:00,100
Just that in this course we simplify things by using LCD to demonstrate everything but really the melodies

16
00:01:00,100 --> 00:01:04,950
can be replaced with your own algorithms your own output devices.

17
00:01:05,140 --> 00:01:12,580
And in fact your own input devices you can read send source when the interrupt occurs without talking

18
00:01:12,580 --> 00:01:15,970
much less create a new project and see how this is done.

19
00:01:15,970 --> 00:01:17,020
Come over here.

20
00:01:17,060 --> 00:01:21,370
You Vision project create a photo for it.

21
00:01:21,810 --> 00:01:24,880
I call this cystic interrupt

22
00:01:30,200 --> 00:01:33,830
quote a project cystic interrupt.

23
00:01:34,440 --> 00:01:35,580
I'll slip my board here.

24
00:01:35,580 --> 00:01:43,320
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

25
00:01:44,060 --> 00:01:49,650
on the device or select the starts up and then okay over here once that's done I renamed this to the

26
00:01:49,650 --> 00:01:50,530
name of the board.

27
00:01:50,550 --> 00:01:52,880
Team Fauci one two three.

28
00:01:53,250 --> 00:01:54,740
And then I'm going to extend this.

29
00:01:54,750 --> 00:01:59,130
And so this group here going to rename me to AP

30
00:02:02,450 --> 00:02:09,350
and then I'm going to come over here targets options are set up to 16 and then debug group down.

31
00:02:09,350 --> 00:02:15,380
Still there is ICD I can then click over here and then take research and run and then okay and then

32
00:02:15,380 --> 00:02:23,180
okay I'll come over here right click out new item to group main and then I'll give the file a name.

33
00:02:23,840 --> 00:02:28,020
Right now stop by including the port header.

34
00:02:28,080 --> 00:02:29,410
It's this over here.

35
00:02:29,420 --> 00:02:38,290
Now jump straight into it into Main and when stuck by initializing our early.

36
00:02:38,480 --> 00:02:42,670
I'm sure you're used to doing that by now.

37
00:02:42,950 --> 00:02:48,950
Come down here I'll see system control of CTC GPA.

38
00:02:49,730 --> 00:02:57,680
And then this course because we sat in Port f we pass your extra it's your excuse you're over here.

39
00:02:57,810 --> 00:03:09,880
And once that's done we're going to set all of the D GPA to f direction register gonna pass sir x.

40
00:03:10,070 --> 00:03:10,520
Sure.

41
00:03:10,520 --> 00:03:15,720
E over here and this is set or the LCD outputs.

42
00:03:15,990 --> 00:03:17,940
And we do a GPA you have

43
00:03:21,380 --> 00:03:22,160
to enable

44
00:03:25,490 --> 00:03:28,420
this your ex your E over here.

45
00:03:28,420 --> 00:03:31,440
And then we said all of them are stitch two pins.

46
00:03:31,900 --> 00:03:41,270
Once that is done we can configure to cystic put a comment here for you.

47
00:03:41,780 --> 00:03:49,640
Okay let's begin by disabling global interrupt whenever you want to enable interrupt or set up an interrupt.

48
00:03:49,640 --> 00:03:56,910
You first have to disable interrupt globally and we do that by using underscore underscore disable AI

49
00:03:56,960 --> 00:03:58,100
our cue like this.

50
00:03:58,370 --> 00:04:02,660
So would you say would interrupt and I'm going to start by loading the cystic

51
00:04:07,240 --> 00:04:14,050
cystic access to load register over here load and this of course 16 million.

52
00:04:14,050 --> 00:04:14,920
One two three.

53
00:04:14,920 --> 00:04:18,130
One two three minus one like this.

54
00:04:18,130 --> 00:04:25,990
Once that is done we set the system control register we enable cystic through any control register cystic

55
00:04:27,690 --> 00:04:33,460
and then control and then we pass them a seven here.

56
00:04:33,460 --> 00:04:44,970
If you expand this you realize that this corresponds to that bit that would enable cystic.

57
00:04:44,970 --> 00:04:56,230
And then use interrupt and use system clock.

58
00:04:56,260 --> 00:04:56,930
Right.

59
00:04:56,950 --> 00:05:00,390
So this what all of that is encapsulated into seven over here.

60
00:05:00,490 --> 00:05:02,490
So this what we need to do actually.

61
00:05:02,530 --> 00:05:10,060
So once this is done we've got to enable interrupts globally and we do this by saying e and i are queue

62
00:05:10,180 --> 00:05:11,260
like this.

63
00:05:11,410 --> 00:05:15,360
And once that's done we can come over here while 1.

64
00:05:15,550 --> 00:05:20,970
And then we'll have nothing in our while one loop because our blinking is going to happen in the cystic

65
00:05:20,980 --> 00:05:24,160
handler to the cystic unless a callback function.

66
00:05:24,160 --> 00:05:26,590
The system would recognize this automatically.

67
00:05:26,920 --> 00:05:37,390
It's called cystic Floyd cystic underscore handler and we'd need not put the prototype up because it's

68
00:05:37,390 --> 00:05:38,450
a callback function.

69
00:05:38,470 --> 00:05:41,450
We don't have to copy and put it prototype on the top here.

70
00:05:41,470 --> 00:05:44,830
The system would recognize this automatically.

71
00:05:44,830 --> 00:05:48,000
So in the cystic handler we want to perform our competition.

72
00:05:48,010 --> 00:05:56,440
It could be performed digital filtering it could be you could perform your fire filter or DSP algorithms

73
00:05:56,440 --> 00:06:03,130
over here or if you are creating a real time candle you can you know invoke the scheduler over here

74
00:06:03,130 --> 00:06:05,350
to switch to the next task.

75
00:06:05,500 --> 00:06:11,380
But in our example we simply going to toggle an LCD in the system handler for those who you taken my

76
00:06:11,440 --> 00:06:15,240
other course on creating your own real time operating system.

77
00:06:15,250 --> 00:06:21,440
You remember that we use in this cystic handler arsenic time these basically this they can't let that

78
00:06:21,890 --> 00:06:25,770
you know control is a what scheduler to move from one task to the other.

79
00:06:26,380 --> 00:06:34,450
But over here we simply blink an analogy or toggling an entity to we do that by saying keep you f data

80
00:06:34,450 --> 00:06:40,700
register and we are going to read a lady bypasses your ex your two over here like this.

81
00:06:40,990 --> 00:06:41,450
Right.

82
00:06:41,620 --> 00:06:44,530
So let's build and see or click over here to build.
