1
00:00:02,940 --> 00:00:04,770
Delegates Welcome back.

2
00:00:04,800 --> 00:00:10,010
So in this lesson we're going to learn how to use multiple ADC channels.

3
00:00:10,160 --> 00:00:16,670
We did DMA I'm going to stun my Cuban mix and in this project I'm going to use to ADC Chanos.

4
00:00:16,840 --> 00:00:22,570
So I come over here create a new project I click and then I select my board.

5
00:00:22,570 --> 00:00:31,060
That's the discovery board then it's this one here for than it is this a double click to choose

6
00:00:34,740 --> 00:00:36,500
so once that is done I come over here.

7
00:00:36,520 --> 00:00:44,760
Claire or pins and this time I'm going to use channel 1 and Channel 2 so I can right click a one here

8
00:00:45,240 --> 00:00:52,320
and set it as a DC one input one and then a P2 as ADC 1 input 2.

9
00:00:52,590 --> 00:00:58,560
Once that is done we'll leave the clock configuration the same which the default setting now come to

10
00:00:58,560 --> 00:01:06,610
the configurations stop and then click under analogue here will click ADC 1 and then we come to parameter

11
00:01:06,610 --> 00:01:14,130
certain Mr said the ADC and this time we can reduce our ADC quick by providing a pre-schooler divide

12
00:01:14,130 --> 00:01:17,590
of 8 and then we can keep the resolution the same.

13
00:01:18,120 --> 00:01:22,580
And in this project what we want is we want to use the continuous mode.

14
00:01:22,590 --> 00:01:30,680
So I'm going to enable continuous mode here and I'm going to enable DMA here and I'm going to enables

15
00:01:30,680 --> 00:01:34,390
con mode as well like this enable.

16
00:01:34,630 --> 00:01:41,350
Then once that is done we come here and then because we've got two channels we said the number of conversions

17
00:01:41,350 --> 00:01:48,050
to two and then once we set a number of conversions to two you see the number of ranks have increased

18
00:01:48,050 --> 00:01:48,660
here.

19
00:01:48,740 --> 00:01:53,860
If I'm to set the number of conversions to 1 their rank will be just one rank.

20
00:01:53,960 --> 00:02:00,360
So because we are using to Chanos we said the number of conversions here to 2 like this.

21
00:02:00,380 --> 00:02:10,120
So I'm going to said the rank number one for China number one and then rank number two when set it to

22
00:02:10,120 --> 00:02:16,600
China number two like this and I'm going to say the sampling time to for eighty cycles.

23
00:02:16,720 --> 00:02:19,140
Green said this to four psychos as well.

24
00:02:19,830 --> 00:02:22,900
And then this is all there is to it.

25
00:02:23,530 --> 00:02:29,280
So remember if you have any questions as usual just send me a message or leave in the form.

26
00:02:29,680 --> 00:02:35,260
Once that is done we come to DME settings because we using DME and don't worry about using DME.

27
00:02:35,260 --> 00:02:42,550
Here we're going to treat the DME module on its own right to when we get here what we have to do is

28
00:02:42,670 --> 00:02:49,780
add DMA and when we add we select we select ADC 1 cos that's the only peripheral we've initialized and

29
00:02:49,780 --> 00:02:53,020
we want to check the data with size.

30
00:02:53,140 --> 00:02:55,720
This one here says half would fit.

31
00:02:55,720 --> 00:03:00,390
So let's just set it to a word which is 32 bit data size.

32
00:03:00,490 --> 00:03:06,250
What we want is one in a circular manner so that when is stores India in the memory of course up to

33
00:03:06,250 --> 00:03:06,810
the top.

34
00:03:07,720 --> 00:03:12,450
So we change here to a circular circular mode.

35
00:03:12,670 --> 00:03:16,810
Then once that is done actually this there isn't much to do.

36
00:03:16,810 --> 00:03:17,990
Just click OK.

37
00:03:18,100 --> 00:03:25,360
Then we generate the project click over here to generate the code and then I'll give my project a name.

38
00:03:25,390 --> 00:03:29,820
I'll call this ADC Kimi

39
00:03:32,810 --> 00:03:39,590
and then I'll select my two chain which they call you visioned version 5 and I click Okay over here

40
00:03:40,280 --> 00:03:48,590
and then it generates the code and then once it's done I click over here to open the project and then

41
00:03:48,590 --> 00:03:50,340
the project is open.

42
00:03:50,450 --> 00:03:57,330
So like I do always I'm just going to rebuild everything by clicking here.

43
00:03:57,920 --> 00:03:59,120
I just explained this a bit

44
00:04:03,540 --> 00:04:04,130
right.

45
00:04:04,150 --> 00:04:05,840
Zero errors to a is.

46
00:04:05,860 --> 00:04:14,530
So once this is done remember we assigned our PINs PSU and we use in p a one in P two we can verify

47
00:04:14,530 --> 00:04:15,150
that here.

48
00:04:15,240 --> 00:04:21,400
P1 appear to be a 1 is our ADC Channel 1 and Pier 2 so our ADC Channel 2.

49
00:04:21,400 --> 00:04:26,630
So what we're going to do is we're going to create an array of size 2 to store the resource of both

50
00:04:26,630 --> 00:04:34,270
the channels which come here in demand at TFR I'm going to come here I'll put it here make it global

51
00:04:34,870 --> 00:04:42,130
and I'm going to use you into 32 underscore T and I'm going to call it sense of value this time it's

52
00:04:42,220 --> 00:04:50,600
it's an array with size 2 and right here we need just one line of code to start the ADC and stock conversion

53
00:04:51,170 --> 00:05:04,490
and it is it is called a D.C. start DMA and we can double click here to see the parameters of this function

54
00:05:05,420 --> 00:05:07,430
and we can see the parameters.

55
00:05:07,560 --> 00:05:18,890
It says here is the ADC type typedef the ADC Hondo and then this one here is way to store the resource.

56
00:05:18,900 --> 00:05:21,130
This one here is the length.

57
00:05:21,130 --> 00:05:27,620
Like it says the length of data to be transferred from ADC pair forward to memory and P data here is

58
00:05:27,620 --> 00:05:32,360
the disk the destination buffer address and then the handler.

59
00:05:32,810 --> 00:05:41,850
Okay so I'm just going to come here and our ADC handle has been declared to us H A ADC 1.

60
00:05:41,890 --> 00:05:45,030
I just copy this and then bring it here.

61
00:05:47,260 --> 00:05:49,780
Would it embossed Amberson sign like this.

62
00:05:52,630 --> 00:05:57,150
And then the reader would just created to store the resource.

63
00:05:57,160 --> 00:06:01,160
I put it here and we looking for two resorts.

64
00:06:01,360 --> 00:06:04,330
So I put you here and that's all we need to do.

65
00:06:04,330 --> 00:06:11,290
So what I've done here in my setup is of connected to potential meters to one to be a one and another

66
00:06:11,290 --> 00:06:12,620
one to two.

67
00:06:12,670 --> 00:06:18,730
So I'm going to download onto my board and then go to the debug view and see whether indeed the changes

68
00:06:18,820 --> 00:06:21,870
occur as I turn my potential meter.

69
00:06:22,120 --> 00:06:31,840
So before I do that actually I'll just come to my debugger here and set this to reset and run like this

70
00:06:31,920 --> 00:06:33,730
and then okay and then okay.

71
00:06:34,030 --> 00:06:35,410
Then I click here to reboot

72
00:06:38,790 --> 00:06:44,320
and then I download onto my board so to test the code I'll just click over here to go to the debugger

73
00:06:50,550 --> 00:06:56,430
what I'm going to do is I'm going to add this to the watch window by double click in right click to

74
00:06:56,430 --> 00:06:58,270
watch window 1.

75
00:06:58,320 --> 00:07:03,600
Then I'll expand this and then I'll disable hexadecimal display like this.

76
00:07:03,600 --> 00:07:08,220
And once they start I'm going to click here to run the code and we'll see what happens.

77
00:07:08,220 --> 00:07:14,580
So currently I've position both potential meter to the opposite direction which would give the lowest

78
00:07:14,580 --> 00:07:15,480
value.

79
00:07:15,620 --> 00:07:21,390
So I'm going to run the code and I'm going to turn to potential meter to the other end of the to the

80
00:07:21,390 --> 00:07:25,940
other end which will give the maximum value of the potential meter.

81
00:07:26,150 --> 00:07:33,240
And that would in effect give the maximum voltage reading to the ADC so I'll click here to run and as

82
00:07:33,240 --> 00:07:40,750
I said there's the lowest value so I'm going to turn one potential meter as you can see it's showing

83
00:07:40,750 --> 00:07:47,310
the highest value so I'm going to change this channel to the highest finally as well just by turning

84
00:07:47,310 --> 00:07:50,570
the knob to the opposite direction.

85
00:07:51,110 --> 00:07:53,590
And as you can see it's also changed by others.

86
00:07:53,670 --> 00:07:58,530
So this is how we enable the ADC with DMA capability.

87
00:07:58,530 --> 00:08:04,810
And this is the best way to use multi-channel ADC by enabling them in this way that we've done.

88
00:08:04,860 --> 00:08:08,930
If you want to use five channels you can use the same method we just showed.

89
00:08:09,150 --> 00:08:11,440
Just by going through what we did.

90
00:08:11,640 --> 00:08:15,990
If you use in five channels you're going to have five rungs and you're going to go through five set

91
00:08:15,990 --> 00:08:17,700
of configurations.

92
00:08:17,700 --> 00:08:25,530
Over here over here if we are to use five channels then things like this.

93
00:08:25,530 --> 00:08:31,410
This would change to five and when we get to rank we would have to set a rank of five different channels

94
00:08:31,980 --> 00:08:32,900
and the rest.

95
00:08:33,060 --> 00:08:34,860
This side remains the same too.

96
00:08:34,920 --> 00:08:36,000
This is all there is to it.

97
00:08:36,000 --> 00:08:41,270
If you have any questions or you need more explanation don't hesitate to send me a message.

98
00:08:41,390 --> 00:08:42,570
Now see you in the next.
