CODING AND
ACTIVATING THE
MC68HC908MR16 ADC
Looking at the MC68HC908MR16
datasheet, I found that the MC68HC
908MR16 houses a 10-channel analog-to-digital converter module with
10 bits of resolution (0x3FF or
0b1111111111 full scale). In a nutshell,
the MC68HC908MR16 employs an
analog multiplexer to select one of 10
analog input channels that feed
a successive approximation-based
analog-to-digital converter subsystem,
which signals the end of an analog-to-digital conversion by raising a flag or
generating an interrupt request. The 10-
bit analog-to-digital conversion result
is placed in a pair of special-purpose
MC68HC908MR16 data registers, ADRH
and ARDL. For now, let’s put the
MC68HC908MR16 datasheet aside and
see what the ADC Bean can do for us.
The BEAN configuration process
for the ADC BEAN is identical to that
of the RS-232 and LED_BIT Beans we
configured previously. I accessed the
Bean Selector window and double-clicked the ADC Bean to insert it into
the new ADC project, which is called
MR16_ADC. I noticed that the analog
input was assigned to the I/O pin that
I was using for the LED. I still want to
blink the LED as a run indicator and I
don’t want to change or throw away
the LED code I’ve already written. So,
I deleted the newly inserted ADC
Bean and moved to the Port I/O
folder in the Bean Selector window.
Once there, I double-clicked on the
BitIO Bean and inserted it into my new
MR16_ADC project. Once I saw that the
LED had once again assumed my
desired position on Port B, I configured
the LED_BIT Bean to match the
configuration I laid out in the previous
RS-232 application we just discussed. I
then reinserted the ADC Bean, saw that
it was assigned to the next available
Port B I/O pin, named it ANALOG, and
started the Bean configuration process.
The Bean Inspector wouldn’t let
me enter anything that would
jeopardize the functionality of the
MC68HC908MR16 analog-to-digital
■ SCHEMATIC 1
+5VDC
C3
.1
C4
.1
C5
.1
J1
VCC U1
9
C6 50
40
.1 12
10
54
41
11
PTA0 55
56
57
58
59
60
61
62
18
19
20
21
22
23
24
D1
LED
ADC INPUT
GND 2
RST 4
IRQ 6
PTA0 8
PTC2 10
PTC3 12
PTC4 14
PTA7 16
1
3
5
7
9
11
13
15
R3
10K
PTA7
+5VDC
MON08 HEADER
VDDAD
VDDAD
VDD
VREFH
VSSAD
VSSAD
VSS
VREFL
PA0
PA1
PA2
PA3
PA4
PA5
PA6
PA7
PD0
PD1
PD2
PD3
PD4
PD5
PD6
PF0
PF1
PF2
PF3
PF4
PF5
PB0
PB1
PB2
PB3
PB4
PB5
PB6
PB7
PC0
PC1
PC2
PC3
PC4
PC5
PC6
PE0
PE1
OSC1 PE2
OSC2 PE3
PE4
PWM1 PE5
PWM2 PE6
PWM3 PE7
PWM4
PWM5 RST
PWM6 IRQ
PWMGND CGMXFC
42
43
44
45
46 RXD
47 TXD
63
64
1
2
3
4
5
6
7
8
13
14
15
16
17
32
33
34 VCC
35
36
37
38
39
49
48 IRQ C8
51
.1
C7
.022
PTC2
PTC3
PTC4
Y1 4.9152 MHz
3
+
AIRTRONICS 94102 SERVO
1A
R1 10M
C1 C2
20p 20p
52
53
25
26
27
28
30
31
29
-
2
R2
100K
MC68HC908MR16
U3
TXD 2
1
RXD 3
20
T1IN T1OUT
T2IN T2OUT
R1OUT R1IN
R2OUT R2IN
V-V-
C2+
C2+
C2-
C2-
5 TXOUT
18
4 RXIN
19
NOTES:
1. LED D1 HAS BUILT-IN CURRENT LIMIT RESISTOR
RXIN
JR2A
9
8
7
6
5
4
3
2
1
9
8
7
6
5
4
3
2
1
TXOUT
11
15
12 16
17 10
DB9 FEMALE
SP233ACP VCC
SP233ACP BYPASS CAP SP233ACP PIN 7 = +5VDC
SP233ACP PINS 6, 9 = C9 .1
GND
28
March 2006