You are on page 1of 7

HANDS-ON MICROCONTROLLERS

Application board
Base camp for high endeavours
Gunther Ewald
and Burkhard Kainka

In the February issue, we


described how you can get
started with the R8C/13
microcontroller module without all too
much effort. The application board
described here gives the module a ‘base camp’
with lots of connections to the outside world,
including a USB interface and two serial ports. There’s also an LCD interface and other
useful features for developing your own applications.

38 elektor electronics - 3/2006


for R8C/13
The starting point for this design was USB/serial adapter the USB port
the question, what do you need to suc- • an LCD interface • a reset switch
cessfully utilise all the major features of • four LEDs that can be connected to • a jumper for the MODE input
the microcontroller with a minimum of port lines
effort? The result is a circuit board with • potentiometer connected to one of
a The USB interface on the board deserves
the following complement of functions: the many analogue inputs special mention. Serial interfaces are
• a power supply socket and 5-V volt- becoming increasingly rare on new PCs,
• two serial interface ports age regulator but asynchronous serial interfaces are
• a USB port using an integrated • option for powering the board via
an fundamentally necessary for communi-

D5 IC2
JP11
1N4002 7805 POWER

K1
EXT USB
+5V +5V
C10 C11 C12 C13
F1
R11
220µ 100n 100n 10µ Polyfuse P1
25V 16V

33k
100mA JP1
ANALOG
+5V 10k +5V JP2
+5V +5V +5V PROG
R9 R10 R17 +5V
JP12 K9 LCD
4k7

4k7

10k

R8
POWER D7 1
K5 K6 K7 K8 VSS
4k7

LED RXD1 TXD1 2


1 32 VDD
1N CNVSS P0.1 P2 3
R7 VO
4148 RESET 4
P0.2
RS
1k

LC DISPLAY 2 x 16
S1 XOUT P0.3 5
C18 R/W
VSS MODE CONTRAST 10k 6
E
D6 100n XIN P0.4 7
D0
RESET VCC P0.5 8
D1
P1.7 P0.6 9
+5V D2
P1.6 P0.7 10
D3
R3 JP6 RXD0 IVCC 11
D3 D4
1k TXD0 P3.0 12
D5
R2 JP4 P1.3 AVSS 13
D2 C1 D6
1k P1.2 P3.1 14
D7
R4 JP5 P1.1 AVCC
D4 100n
1k P1.0 P3.2
R1 JP3 P4.5 P3.3
D1 16 17
1k +5V

TXD0 TXD1
RXD0
SERIAL RXD1 C3
PROGRAMMING R5
C7 C4
K4
1k5

+5V 100n
1 C15 10µ 16V 100n
4 8 17 24
6 4µ7
VDD

JP7
VDD_PLL
VDD_3V3
VDD_233

2 1 19
TXD RST
7 25V USB 5 20
2 RXD VDD
3 K4
V+
8 1 16 12 IC1 9 R13 C9
PROG.

C8
C14 C1+ SHTD_N DSR_N 220k
4 JP8 13 10 R14
EE_CLK DCD_N 220k
9 3 IC3 14 11 R12 10µ 16V 100n
4µ7 C1– K4 EE_DATA CTS_N 220k
5 25V 14 11
T1OUT T1IN USB PL2303 R16
13 12 2 15
R1IN R1OUT DTR_N DP 27 Ω
8 9 3 16
SUB D9 R2IN R2OUT JP9 RTS_N DM
7 10 6 3 K2
T2OUT T2IN RI_N R15
COM 4 C2 USB 22 2 USB-B
PORT C17 C2+ TRI_MODE 27 Ω
MAX232 K4 26 23 1
K3 PLL_TEST LD_MODE
5 15 100n
4µ7
SER.

1 C2–
25V JP10 7 25 6 4 5
6 V- GND GND_PLL
21 18
2 6 K4 GND GND_3V3
C16
7 USB OSC1 OSC2
3 27 28
4µ7 R6 X1
8 25V
47k

4
C6 C5
9
5 10p 10p
12MHz

050179 - 3 - 11
SUB D9

Figure 1. The circuitry on the application board provides two serial ports, a USB interface and an LC display to connect the R8C daughter board to the outside world.

3/2006 - elektor electronics 39


HANDS-ON MICROCONTROLLERS

If you remove jumpers JP3–JP6, these


USB Port tures of an R8C system as already leads can also be used as four addi-
mentioned in the February issue. The tional analogue inputs. Just add a few
MODE jumper and Reset switch are lines of code, and you have a four-
USB
Transceiver important features. Interface drivers channel digital multimeter with LCD
are also necessary for the RXD1 and display!
CONTROL USB
REGISTER/
CONFIG/
TXD1 leads of the debug interface, A total of seven individual port leads
UNIT SIE STATUS/
CONTROL
which are routed here via JP7 and JP8 have been left open, but you’re bound
to allow either RS232 or USB to be to think of a use for them. Applica-
used. Depending on the jumper set- tions such as an I_C or SPI interface
DOWN
STREAM
UP
STREAM
tings, you can use either the MAX232 and the like can always use an extra
BUFFER BUFFER
and connector K4 or the PL2303 USB lead or two.
controller and a USB link.
CLOCK
SYNTHESIZE In addition to the serial debug inter-
RS-232
SERIAL face (UART1), the R8C/13 has a sec- It takes a bit of juice
INTERFACE
OSCILLATOR EEPROM ond, fully independent serial interface There are two options for powering the
INTERFACE
(UART0) that communicates via the board, which are selected using JP11.
TXD0 and RXD0 leads. As is well Either you can use the power supply
Serial Port I 2 C Bus
known, the MAX232 can handle more connector (K1) and voltage regulator
050179 - 3 - 12 than just two lines – in fact, it can han- IC21, or you can use USB with its built-
dle four. That’s why jumpers JP9 and in 5 V supply voltage.
JP10 and a second serial interface con- If you’re using USB anyhow, it makes
Figure 2. Block diagram of the nector (K3) are on the board. You can sense to dispense with an external
Prolific interface converter. also select either RS232 or USB for the power supply. However, a bit of cau-
UART0 interface. tion is advisable here. According to the
Now for a few words about the micro- USB specification, every USB down
controller ports. The microcontroller port is supposed to be protected
cation with the microcontroller. For that leads are routed to single-row socket against overloads by a PolySwitch pro-
reason, we decided to simply include a headers in order to leave all options tective device. However, painful expe-
USB/serial adapter on the board. open. However, specific functions have rience proves that it just ain’t so. A
In contrast to the equally viable also been assigned to most of the port simple short on the USB supply line
approach of using an external USB leads. Here 8-bit port P0 is intended to results in a small puff of smoke from
adapter, this has the advantage of be used for connecting the LCD mod- the PC motherboard and causes the
allowing the board to be powered via ule, but it can of course be used for corresponding down port to be perma-
the USB port. A total of four jumpers some other purposes if you don’t need nently disconnected from the supply
determine which serial interfaces of an LCD. A standard alphanumeric LCD voltage. For cost reasons, manufactur-
the microcontroller are routed via the can be driven in 4-bit mode using only ers obviously do nothing more than
RS232 ports or the USB port. For six port pins. Leads P0_2 to P0_7 are placing small series resistors in the
instance, you can load and debug pro- thus used by the LCD. supply tracks, which then simply melt
grams via the USB interface, or you can P0_0 is reserved for the debug inter- through.
use the USB interface for serial commu- face (TXD1) and is only available for For this reason, a PolySwitch protective
nication with the microcontroller and user applications if the debug function device (F1) rated at 100 mA is included
your programs. is not used. That still leaves P0_1. As on the application board for the spe-
this lead can also be used as an ana- cific purpose of protecting the PC. That
logue input, a potentiometer providing creates peace of mind and allows you
Microcontroller ports a variable input voltage of 0–5 V can to experiment in a relaxed mood.
The schematic diagram (Figure 1) be connected to it via JP13. A supple-
essentially shows the principal fea- mentary protective resistor (R17) pre-
vents overloading if P0_1 is acciden- USB interface
tally configured as an output while Next we come to the USB interface.
connected to the potentiometer. The The PL2303X, which sports the desig-
two jumper pins can also be used as a nation ‘USB to Serial RS232 Bridge
measurement input. If you want to Controller’, comes from the Taiwanese
connect a sensor that outputs both manufacturer Prolific (sales rep: Glyn).
positive and negative voltages, you Attentive readers may recall having
can use the potentiometer to adjust already seen this Prolific IC in a built-
the zero point to where you need it. in, encapsulated form in an interface
The four lower bits of Port 1 can be converter cable described in the Sep-
connected to the four LEDs via tember 2005 issue of Elektor Electron-
jumpers and series resistors. That’s ics.
ideal for your initial programming exer- This IC is a full-speed USB device for
cises, such as those described in the USB 1.1 and thus compatible with the
February issue. If you haven’t already more recent USB 2.0 interface. That
Figure 3. The virtual COM interface in the tried the ‘blinker’ example program, means the data transmission rate on
Windows XP Device Manager window. now’s your chance to get up to speed. the bus is 12 Mbit/s. R5 connects the

40 elektor electronics - 3/2006


D+ lead of the USB connector to 3.3 V
to signal a full-speed device to the PC.
That causes the PC to load a driver for
a virtual serial interface. Such a driver
allows serial interfaces to be operated
at transmission rates up to 1,228,800
baud (that’s 1.2 Mbaud!). In line with
the capabilities of the R8C/13, various
standard baud rates are used here. The
virtual serial interface behaves exactly
the same as a real RS232 interface for
downloading and debugging programs.
Figure 2 shows the internal structure
of the IC, which consists of a USB
transceiver, a serial interface, and two
data buffers. The data buffers support Figure 4. Configuring the buffer sizes and COM port number.
fast, uninterrupted data transfers, with
data blocks being packed into individ-
ual USB frames. It is also possible to
connect an I_C EEPROM to store user face converter using the Prolific IC is ware form. For example, the PC used
configuration settings, but that option connected), Windows will automati- for our tests had only COM1 present on
isn’t used here. cally locate the appropriate driver and the motherboard, but it also had an
The non-inverted RXD and TXD signals load it. After that, your PC will have an interface card with COM3 and COM4.
are available at the serial side of the additional serial interface that can be In that case it’s a good idea to name
converter and can be connected directly used just like a normal RS232 interface. the virtual interface ‘COM2’ (see Fig-
to the R8C. The inputs of the PL2302X If you have already installed several ure 3), especially since many older pro-
are compatible with 3.3-V and 5-V logic such interface converters, Windows grams only support COM1 and COM2.
levels. The TXD, DTR and RTS outputs will assign a high COM number to the Problems with high COM numbers
provide either 3.3-V or 5-V logic levels, new virtual interface. In that case, it’s have also been observed with the FDT
depending on the voltage connected to recommended to use Advanced Set- download program, so you should at
pin 4. In this case, this voltage is 3.3 V tings to rename the interface, for exam- least keep the number in the single-
from the internal voltage regulator of ple to ‘COM2’. You can usually ignore digit range.
the PL2303. That means the level any message saying that this interface In some cases it may be necessary to
applied to the serial input of the R8C/13 is already in use, because it refers to configure the FIFO buffer of the virtual
is 3.3 V, although the level actually another virtual interface that is not interface to the smallest possible size
expected there is 5 V. That’s permissi- used at the same time. All you need to (Figure 4) in order to obtain reliable
ble, though, because the R8C/13 can know is which serial interfaces are communication. That’s because with a
also be operated at 3.3 V, and besides actually present in your PC in hard- large buffer size, it’s theoretically pos-
that a 3.3-V signal at the RXD input of
the microcontroller is adequate even
when it’s operated at 5 V. All inputs of
the R8C regard any voltage above
0.2 VCC as a logic ‘high’ level. COMPONENTS D7 = 1N4148
IC1 = PL2303X (Prolific)
IC2 = 7805

Driver installation
LIST IC3 = MAX232

Miscellaneous:
You may have already used a Prolific Resistors: JP3-JP6,JP12 = jumper
USB adapter with your system. In that R1-R4,R7 = 1kΩ JP7-JP11 = 3-way SIL pinheader
case, the interface will be recognised R5 = 1kΩ5 K1 = 2-way PCB terminal block, lead
as soon as the board is connected to R6 = 47kΩ pitch 5mm
the PC. If it isn’t, or if you experience R8,R9,R10 = 4kΩ7 K2 = USB socket, type B for PCB
R11 = 33kΩ mounting
problems using the USB port, you R12,R13,R14 = 220kΩ K3,K4 = 9-way sub-D socket, angled
should install the latest version of the R15,R16 = 27Ω pins, PCB mount
driver. You can obtain the driver by R17 = 10kΩ K5-K8 = 16-way SIL pinheader
downloading the file 050179-3-11.zip P1,P2 = 10kΩ K9 = LCD module, 2x16 characters
from the Elektor Electronics website S1 = pushbutton with 1 make contact
Capacitors: (e.g. TS695)
(www.elektor-electronics.co.uk). It con- C1-C4,C8,C11,C12,C18 = 100nF F1 = 100 mA Polyfuse
tains the file ‘PL-2303 Driver C5,C6 = 10pF X2 = 12MHz quartz crystal
Installer.exe’. C7,C9,C13 = 10µF 16V radial PCB, bare, order code 050179-1
Run the driver installer file before con- C10 = 220µF 25V PCB, ready-assembled and tested, order
necting the board. Any older version of C14-C17 = 4µF7 25V radial code 050179-92
the driver present in the PC will be LCD with backlight, order code
Semiconductors: 030451-72
deleted automatically when the new D1-D4,D6 = LED Poly-LED display, order code
driver is installed. The next time the D5 = 1N4002 030451-73
board is connected (or another inter-

3/2006 - elektor electronics 41


HANDS-ON MICROCONTROLLERS

050179-1

Figure 5a. The track and ...

42 elektor electronics - 3/2006


S1 P1 P1.0 050179-1
0 +

JP1
Prog. Analog
K1

JP2
R11 R17
Reset

LCD1
C18
RxD1 TxD1
CNVSS P0.1
D7

R10
res P0.2

R9

D5
Xout P0.3
R8 Vss mod
R2 Xin P0.4
C10
Vcc P0.5
R3
P1.7 P0.6
C11

JP3JP5JP4JP6
P1.6 P0.7

D1 D4 D2 D3
RxD0 IVcc

IC2
TxD0 P3.0
P1.3 AVss
P1.2 P3.1

C1
P1.1 AVcc
P1.0 P3.2
R1 P4.5 P3.3 C12

C13
R4

K7
K5

K6

K8
C14 JP11
ext

Power
100mA
C17 X1

F1
K3 USB C9
USB

C7
C3
JP9

C6
C5
ser.
IC3 JP10 C4

IC1
JP8 R13

K2
Serial prog.
COM port K4 R12
programming

C8
JP7
C2 R14
K4 USB

JP12

R16

R15
K3 C15

R6

R5
C16

P2
R7
Power LED
D6 Contrast LCD

Figure 5b. ... component layouts of the double-sided circuit board.

Figure 6. The fully assembled prototype board. The component overlay is slightly different from the production version shown in Figure 5.

3/2006 - elektor electronics 43


HANDS-ON MICROCONTROLLERS

sible for the PC software to be


waiting for reply while the
query is still stuck in the buffer.
If errors occur when download-
ing programs into the flash
memory of the microcontroller,
reducing the size of the buffer may
improve the situation.

Board assembly
The printed circuit board (Figure 5) is
also available fully assembled so
readers with relatively little soldering
experience don’t have to worry about JP 11:
problems with the Prolific IC (IC1), toward K7/K8
which is only available in a 28-lead (‘ext’ position,
SMD package (SSOP-28). If you assem- with power coming
ble the circuit board yourself, you from an external supply)
should start with this IC because it’s JP 3–6: fitted (LEDs
easier to solder if the board is other- connected)
wise empty. JP 12: fitted (‘Power’ LED
connected)
Numerous Elektor Electronics SMD JP 2: fitted (debug mode) KD30 debugger
projects have shown that they can be JP 7–10: toward IC3 (both interfaces Up to now, we’ve only described how
soldered without using special SMD via RS232) to download finished programs into
tools. Start by soldering two diagonally the microcontroller and run them.
opposite leads in place, after first care- You should check the supply voltage on When you’re developing a program,
fully positioning the IC. A check with the board before plugging in the especially one that’s relatively com-
a loupe will show whether you have a R8C/13 daughterboard, in order to plex, it’s helpful to use a debugger.
steady hand. If necessary, you can still avoid any risk to the microcontroller. That allows you to interrupt the pro-
adjust the position relatively easily at LED D6 should light up after you con- gram at any desired location, view
this stage. Continue by soldering an nect an AC adapter with 9-V DC out- memory contents, execute single
entire row of leads with a sufficient put. The voltage measured on K6 steps, and much more.
amount of solder. Any excess solder between pin 5 VSS (Pin 5) and pin 7 The microcontroller must always be in
can be easily removed afterwards with (VCC) must have a value of +5 V. After debug mode when you use the debug-
a length of solder wick. If your final verifying this, disconnect the AC ger, which means that jumper JP2
inspection with a loupe does not reveal adapter and plug in the daughter board must remain fitted. The Reset button
any solder bridges, everything is OK. while no power is applied to the board. isn’t necessary in this case, because
The author has also found that strong Now comes the most exciting moment! you can only use software commands
reading glasses (3 dioptre) are an Reconnect the 9-V AC adapter. The from the debugger to start and stop
excellent alternative to a loupe. ‘Power’ LED will light up. Connect K4 your program.
They’re almost as good as stereo to the COM1 serial port of the PC. You We’ve prepared an extensive descrip-
microscope, at only a fraction of the can immediately download a program tion of how to get started with the
price. now, because JP2 is configured for debugger and placed it on the Elektor
debug mode. Use the FDT program as Electronics website at www.elektor-
The remaining components shouldn’t described in the February 2006 issue of electronics.co.uk. Deeopnding on the
present any special difficulties. You Elektor Electronics. A good choice for amount of feedback we get, a special
can omit the pin headers (K5 and K8) if your first download is the ‘port_toggle’ R8C activity page may also be created,
desired. If you wish, you can later con- program. The programming tool will so check out the website.
nect flat cable here or wire only the indicate whether the download (050179-3)
connections you actually need to the process completed successfully.
prototyping area. A socket header has Next, remove jumper JP2 and briefly References:
proven to work well as an LCD connec- press the Reset button. The four LEDs www.glyn.com
tor. The matching LCD module can connected to Port P1 should start www.glyn.de
then be fitted with long pin headers blinking. E-mail: elektor-r8c@glyn.de
and simply plugged into the board. If you want to use the USB interface, fit
JP7 and JP8 in the proper positions
R8C forum:
(toward the USB connector). That will
Initial test connect RXD1 and TXD1 to the USB
For hints and tips about using the
R8C/13 board, check out the ‘R8C 16-
Before using the board for the first converter IC. After that, you must con- bit Micro Starter Kit’ topic in our Forum
time, you should re-inspect the compo- figure FDT to use the virtual COM menu at www.elektor-electronics.co.uk.
nent assembly and solder joints and fit interface. Everything else works Naturally, we would be pleased if you
the necessary jumpers. The following exactly the same as with a real RS232 post your own tips and tricks on this
jumper settings are important: interface. forum for the benefit of other readers.

44 elektor electronics - 3/2006

You might also like