[go: up one dir, main page]

100% found this document useful (3 votes)
338 views7 pages

PIC18Flash Development Board Guide

The document describes a development board called PIC18Flash that is used to develop programs for the Microchip PIC18F452 microcontroller. The board includes common components like an oscillator, LEDs, buttons, and an LCD interface. It also has special features like in-circuit programming and interfaces to external devices. The document provides details on the board's circuitry and components. It explains how to assemble the printed circuit board and includes a component list.
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
100% found this document useful (3 votes)
338 views7 pages

PIC18Flash Development Board Guide

The document describes a development board called PIC18Flash that is used to develop programs for the Microchip PIC18F452 microcontroller. The board includes common components like an oscillator, LEDs, buttons, and an LCD interface. It also has special features like in-circuit programming and interfaces to external devices. The document provides details on the board's circuitry and components. It explains how to assemble the printed circuit board and includes a component list.
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 7

PIC18Flash Dev

Continuing where the


16 series left off...
Peter Moreton

34

elektor electronics - 1/2005

elopment Board
The development system described in this article continues a
fine tradition of Elektor Electronics microcontroller articles,
and follows in the lineage of the popular PICee board,
AVRee and others. The board described here employs the
most recent and powerful of Microchips PIC family, the 18F
series, and specifically, the PIC18F452.

The PIC18F452 has become the defacto standard part of the 18F series,
and is an obvious choice for people
wishing to move on from designs
using the ubiquitous PIC16F84 and
16F877 devices.
PIC18flash offers the usual development board features of a processor,
clock, some LEDs, some pushbuttons,
an interface to a standard 220 line
LCD display, an RS232 port, a piezo
ceramic sounder and DC power regulation. Special features are:
On-board hardware for ICSP (In-Circuit Serial Programming)
Power I/O for real-world devices such
as solenoids, stepping and DC
motors.
An interface to the Microchip ICD-2
debugger
With this hardware, the free Microchip
MPLAB development environment
and a free demonstration copy of the
C18 compiler, you are able to develop
PIC C code on a standard PC, and
upload it to the PIC18Flash board to
build sophisticated control systems for
many applications including robotics,
home automation, security and more.
A C18 example program is provided,
demonstrating how each subsystem of
the PIC18Flash board is accessed from
the C environment. As a self con-

1/2005 - elektor electronics

tained development environment, the


PIC18Flash board provides an excellent platform for educators and individuals wishing to enter the world of
microcontrollers.

Circuit Description
The circuit diagram of the development system is shown in Figure 1.
Much of the circuit techniques will be
quite familiar to Elektor Electronics
readers, and the 78xx-based power
supplies (IC1; IC2, IC9) and MAX232
RS232 serial interface (IC5) constellations have appeared countless times
beforehand.
The PIC18F452, IC6, is configured in a
standard manner, with the possible
exception of the secondary 32.768 kHz
watch crystal, X1, being provided to
allow real-time clock systems to be
implemented without consideration of
the master clock frequency. The master clock runs at 4 MHz (X2), giving a
throughput of 1 MIPS, and this can be
internally multiplied by a 4PLL to
16 MHz, which results in a processor
throughput of 4 MIPS. Users requiring
still more performance can substitute
a 10-MHz crystal, giving 10 MIPS
when used with the 4PLL.
The 4 MHz fosc value is not chosen
arbitrarily; this clock rate is a good fit
with the PICs USART baud rate generator and enables the generation of

RS232 data at 1.2 to 76.8 kbps with an


accuracy of better than 0.16%.
Processor pins assigned to SPI and I2C
communications are routed to header
K8 for expansion purposes; it is
intended that any add-on hardware
would communicate solely by these
protocols and any communication to a
host computer would be via RS232.
The SPI/I2C header also delivers a
spare processor pin (W; pin 7 on K8)
which can be used for example to bitbang other protocols such as the Dallas One-Wire interface.
In order that the PIC18Flash can perform some real work, the basic board
is equipped with several power
devices intended to permit the control
of relays, solenoids, lamps, DC motors
and stepper motors. Two separately
powered Infineon TLE4207 H-bridges,
IC3 and IC4, are provided, which permit the bidirectional control of two DC
motors, or one bipolar stepper motor.
Two power MOSFET switches are also
provided. Via connector K6, they can
be used to control resistive or inductive
loads such as solenoids and lamps.
A pinheader, K7, for the ubiquitous
2?20 character LCD module is provided, and this is configured as a standard 4-bit interface, with the only
unusual feature being the use (via the
RC2 line) of the PICs PWM module to
provide software control of display
contrast.

35

K2

1
6
2
7
3
8

+5V

D13

2x
10MQ060N

+5V

PGC

PGD

43

44

3
4
5
6

16

C17

18

C18

15p

R5

D10

10

IC7

20

15p
32.768kHz

MCLR

29

27

26

25

42

20

PGM

+5V

C8

100n

C6

35

100n
12

RA5/AN4

RC3/SCK

PSP5/RD5

RD3/PSP3

RD2/PSP2

RD1/PSP1

RD0/PSP0

IC6

RB4

PSP4/RD4

RE0/RD/AN5
RE1/WR/AN6

PSP7/RD7
PSP6/RD6

RA2/AN2

RA1/AN1

RA0/AN0

INT/RB0

RB1

RB2

PGM/RB3

RC2/CCP1

RE2/CS/AN7

34

23
24
31
21
22
30
41
9
10

33
32

39
38
37
36

19

11

15

R18

100n

C23

22p

C20

OSC2

RC0/T1OSO

IC8

14

4MHz

14

OSC1

100n

C7

+5V

22p

C19

13

RC1/T1OSI

RA3/AN3

X2

PIC18F452

MCLR/THV

PGC/RB6

PGD/RB7

RX/RC7

TX/RC6

SDO/RC5

SDI/RC4

RB5

SCL

RA4/T0CKI

SS

K8
2

MCLR

PGD

SPI/I2C/1W/GPIO

R15

+5V

+5V

R17

C13

R14

+12V

D12

R12

S3

BS
170

T4

S2

10

R9
1k5

S1

D9

X1

18

IC8.B
IC8.C

R1

BS170

+5V

680
D2

D8

R4

16

C11

TXD

17

RXD

16

+5V

11

15

R13

12

10

15

14

6
R7

D6

7805

IC1

C4

R3

IC5

R1OUT

T1IN

R1IN

T1OUT

T3

R19

1-W

PGC

5
6

8
R2OUT
T2IN

R2IN

C2+

C12
1

13

V-

MAX232

T2OUT

C2

SDO

V+

C1+

3
14
13

7
4

C1

C15
1

C16
5

IC7
&

C2

R2

D7

C14

13

11

D7
15

RS

22

22

LCD

K7

EN

IC8.D

R22
19
EN

7
12

8
11

74HCT541

D1

1N4001
100n

+12V

1k5

R6
D3

2
4
6
8

C9

25V

C10

25V

10
12
14
16

IN2

14

13

+12V'

OUT2

EF

10 11 12

OUT1
IC3
TLE4207G

IN1

INH

T2

K5

BZ1

2x
DC MOTOR

R16

K6

100n

C24

+12V'

2x
DC LOAD

IC9

C21

7812

100n

D5

14

13

+12V'

OUT2

IN2

D4

D11

1N4001

25V

C26

+12V

10 11 12

EF

OUT1
IC4
TLE4207G

IN1

INH

T1

2x
10MQ060N

100

R8

K9

+5V

2x
IRLL024N
100

R10

V+

100

An important feature of the PIC18Flash


system is the provision of onboard programming electronics. This enables
the user to flash the microcontroller
without having to remove the PIC from

9
5

R21

C25
100n

100n

IC2
7812

C5

040010 - 11

10k

10k

RJ-11
K3

K4
1
14
2
15
3
16
4

R11
C22
100n

IC8.A
K1

C1
470
25V
C3

1k

4k7
100n

1k

17
5
18
6
19
7
20
8

10

12

4k7

its socket and load it into a standalone


programmer.
In 1996, the Tait Classic programmer
design was widely published,
enabling the PIC16 series to be programmed using a PC parallel port and
some simple software. Since then,
many variations on the Tait theme

Introducing the
MTSP programmer

Finally, an RJ-11 header, K2, is provided to enable the use of Microchips


ICD-2 in circuit programmer / debugger, which enables the target hardware to be debugged in real-time. The
user should take care not to use the onboard (MTSP) programmer and the
ICD-2 interface at the same time!

21
9
22
10
23
11
24

1
IC8.E
1

100n

CONTRAST
1k

680

4k7
680

1k5

IC8.F

IC8 = 74HCT14

680

12

11

13

SDA
680

1k5

elektor electronics - 1/2005

36

680

25
13

4k7

D6

RW
D4

D5

Figure 1.The circuit diagram of the PIC18Flash board reveals a classic microcontroller design.

Printed circuit board


assembly
The PIC18Flash board (Figure 2) uses
a mixture of pin-thru-hole and SMD
technologies in order to produce a PCB
that is both compact and yet quite
easy to assemble. Ready-made printed
circuit boards for this project (doublesided, through-plated) are available
from our Readers Services under no.
040010-1. All surface mount components are 1206 size or larger, and can
be soldered using a fine soldering iron
and tweezers. Similarly, there are several surface mount ICs to be fitted.
It is advisable to assemble the PCB in
the following sequence:
1. Power supply. Once the PSU parts
are installed, test that 5 V and 12
V exist and the PSU LEDs D2 and
D3 light up.
2. All SMD resistors, capacitors and
remaining LEDs.
3. All small-outline ICs.
4. All remaining pin-thru-hole (leaded)
parts.

1/2005 - elektor electronics

S3

T1

T2

R14

R8

D13

R17

D5

R1

D4

R19
R15

S1

R16

D12
R5

X2

T4

C6

IC6

C8

D6

C20
C18

IC9

K8

IC3

C10

C11

C9

X1
C24

C26

IC5

R18

R9

C14

C7

C15

C17
C12

Bz1

R4 R3 R2

C19

R7

R11

C22

040010-1

C23

IC7

C16

S2

D10 D9 D8 D7

T3

C2

C4

K4

K6

R12

D2

R21
R13

IC8

DC
LOAD

R6

C5

IC1

R22
C25

K7

C1

D1

K1

C3

IC2
D3

R10

C13

K2

K3

IC4

C21

D11

The MTSP design criteria were:


Must support HVP (high voltage programming). LVP (low voltage) programmers are easier to construct,
but if the user inadvertently un-sets
the LVP enable bit, then LVP is disabled and the part can only be reprogrammed in a HVP programmer.
Must use a standard interface, and
be supported by a good, public
domain software programmer. MTSP
implements the Tait Classic or Tait
Serial interface and can be programmed using the freeware ICProg.
Must be able to remain in circuit during the program-test-debug cycle.
MTSP tri-states PGD/PGC and raises
MCLR to allow the target processor
to run while not in program mode.
The MTSP port is accessed via printer
connector K4.

K9 V+

K5

have appeared, and several good software programmers have been written
with (David) Tait hardware support.
The original Tait design does not work
correctly with the PIC18F series, so we
present a new implementation of the
Tait standard, compliant with the
PIC18F and with a low component
count. The design is called MTSP My
Tait Serial Programmer. (note that
serial indicates that the hardware
programs the PIC serially, using a PC
parallel interface.)

2 x DC motor

Figure 2. PCB artwork designed for the PIC18Flash board


(board available ready-made).

COMPONENTS
LIST
Resistors:
All resistors SMD, case shape 1206
R1-R5,R7 = 680
R6,R9,R21,R22 = 1k5
R8,R10 = 100
R11,R13,R14,R15 = 4k7
R12,R18,R19,R20 = 1k
R16,R17 = 10k
Capacitors:
All capacitors SMD, case shape 1206
unless otherwise indicated
C1 = 470F 25V radial
C2-C8,C21-C25 = 100nF
C9,C10 = 22F 25V radial
C11-C16 = 1F
C17,C18 = 15pF
C19,C20 = 22pF
C26 = 470F 25V radial
Semiconductors:
D1,D11 = 1N4001
D2,D3,D6-D10 = LED
D4,D5,D12,D13 = 10MQ060N
T1,T2 = IRLL024N
T3,T4 = BS170
IC1 = 7805

IC2,IC9 = 7812
IC3,IC4 = TLE4207G
IC5 = MAX232ACSE (SMD case)
IC6 = PIC18F452-I/L
IC7 = 74HCT541
IC8 = 74HCT14
Miscellaneous:
K1,K9 = 2-way PCB terminal block, lead
pitch 5mm
K2 = 6-way RJ11 connector, PCB mount
K3 = 9-way sub-D socket (female),
angled pins, PCB mount
K4 = 25- way sub-D plug (male), angled
pins, PCB mount
K5,K6 = 4-way PCB terminal block, lead
pitch 5mm (or 2 off 2-way)
K7 = 16-way boxheader
K8 = 10- way boxheader
S1,S2,S3 = miniature pushbutton, 1
make contact, e.g., DTS61K (6 x 6mm)
BZ1 = AC buzzer
X1 = 32.768kHz quartz crystal
X2 = 4MHz quartz crystal
44-pin PLCC socket for IC6.
20-pin DIL socke for IC7
14-way DIL socket for IC8
PCB, order code 040010-1, see
Readers Services page
Disk, misc. software utilities, order code
040010-11 or Free Download

37

this program in compatibility mode for


option and select Windows 2000 in the
drop down box; see Figure 3.`
Now run icprog.exe and you will be
prompted to configure the programmer
interface; see Figure 4.
Select Settings, Options, Misc and
select the Enable NT/2000/XP Driver
checkbox, and set Process Priority to
High; see Figure 5.
Click Yes to install the icprog.sys
driver when prompted and finally
select the PIC18F452 microcontroller
type as shown in Figure 6.

Uploading
the demo firmware
using IC-Prog
Download the Elektor PIC18Flash
demonstration firmware, file number
040010-11.zip from the Free Downloads page at www.elektor-electronics.co.uk and unpack the zip file to a
suitable folder.

Figure 3. Our finished and tested prototype of the PIC18Flash development board.

We recommend fitting the 74HCT541


and the 74HCT14 in sockets.
Once the board is fully populated,
apply a power supply of roughly 15
VDC to K1 and confirm that the
PIC18Flash board draws a quiescent
current of around 50 mA. Once the
board has powered up correctly, it is
time to attach an LC display, flash the
CPU and test each subsystem on the
board.

Flashing
the demo firmware
Traditionally, one writes and loads a
flash-an-LED or Hello World program
to test a microcontroller board. Here, a
successfully blinking LED confirms
that the CPU is powered, has a viable
clock, and is executing code. We have
provided self-test firmware which not

38

only flashes LEDs but also exercises


the serial port, the sounder, the LCD,
the MOSFET switches, the H-Bridges
and the real time clock. The constructor should upload this demo firmware,
PIC18flash.hex to the microcontroller
using the IC-Prog programming software to fully test the PCB. The source
code, PIC18flash.c can then be used as
a template for further developments.

Configuring IC-Prog
Download
the
archive
files
icprog105c.zip and icprog_driver.zip
from www.ic-prog.com and extract
icprog.exe and icprog.sys to a suitable
folder on your hard drive.
If you are running Windows 2000 or
Windows XP, you should enable
access to the parallel port as follows:
right click on icprog.exe, and select
the Compatibility tab. Check the Run

Connect a short parallel cable between


the PC printer port and the PIC18Flash
MTSP port K4, run IC-Prog and select
File, Open File, PIC18flash.hex. Now
click Command, Program All to
upload the demo firmware. At the end
of the program / verify sequence, the
PIC CPU will start to run, and will
begin to cycle through a sequence of
hardware subsystem tests.
Each test is depicted on the LCD display and are:
1. LCD display test. Data is displayed
on the LCD display.
2. Speaker test. A sequence of audio
tones is generated.
3. LED test. The on-board LEDs are
illuminated in sequence.
4. DC Load test. 12-V DC loads connected to JPXX and JPXX are energized.
5. H-Bridge test. 12-V DC motors connected to K5 are spun in forward
and reverse directions.
6. RS232 comms test. Data is emitted
from the RS232 port, K3, at a baudrate of 9600,8,N,1 and this data
can be viewed by connecting the
port to a PC COM port and using
Hyperterminal or similar to display
the data stream.
7. Real Time Clock (RTC) test. Tests
the 32-kHz crystal timebase and
runs forever. Hours and Minutes
can be incremented using the
pushbuttons.

elektor electronics - 1/2005

PIC18F452 Features

2 capture compare (CCP) & pulse width modulation (PWM)


modules

The PIC18F452 has a similar pinout to the venerable

Master Synchronous Serial Port (MSSP) supporting SPI & I2C

PIC16F877 and as such is a natural upgrade to that device,

Addressable USART supporting RS232 and RS485

but offers much higher capabilities and performance:

Parallel slave port (PSP)

High Performance Harvard RISC CPU optimized for C compiler usage

10 bit analogue to digital converter (ADC)

Linear program and data memory,

100,000 erase/write cycle endurance on Flash ROM

32K Flash ROM, 1536 bytes RAM, 256 bytes EEPROM

1,000,000 erase/write cycle endurance on EEPROM

10 MIPS performance at 40 MHz clock

EEPROM data retention of >40 years

16 bit instructions, 8 bit data path

Self-programmable, and programmed code protection

4 separate Timer modules (Timer0,1,2,3)

Power on reset, power up timer, oscillator startup timer

25-mA sink & source current

Low power sleep mode

3 external interrupt pins

x4 PLL on main oscillator

High & low priority level assignments for interrupts

In circuit programming (ICSP) and in circuit debugging (ICD)

Secondary oscillator for timekeeping using a watch xtal

Wide operating voltage of 2.0 V to 5.5 V

Programmable low voltage detection and brown out reset

About the Author


Peter Moreton (42) has been
involved with computers and electronics since his youth. Working for
various international banks, he has
architected computer networks that
span the globe. He welcomes email
correspondence at
peter.moreton@virgin.net and will
host firmware updates and circuit
ideas at:
http://freespace.virgin.net/
peter.moreton

Figure 4. IC-Prog properties.

Figure 5. IC-Prog Programming.

1/2005 - elektor electronics

Figure 6. IC-Prog Driver.

39

resultant HEX file uploaded to the


PIC18Flash system.

Using an RS232
bootloader
There are three ways to load firmware
into PIC18Flash:
1. MTSP using the parallel port;
2. ICD-2 using the RJ-11 port;
3. RS232 bootloader.
The MTSP method provides a low-cost
method of bootstrapping code into the
uC, whereas the ICD-2 approach
requires an expensive external debugger, but on the positive side
enables firmware to be debugged in
real time within MPLAB.
Figure 7. IC-Prog uC Selection.

Compiling the demo


firmware using
MPLAB/C18
The demo firmware is written in C
and designed to be used as a basis
for custom application development,
since it provides a template showing
how each of the PIC18Flash subsys-

tems can be manipulated from the C


environment.
You should download and install the
latest releases of MPLAB and
C18demo from www.microchip.com,
and from within MPLAB, select Project, Open, PIC18flash.mcp. C source
code can now be edited and then
compiled by hitting F10 and the

A TinyBoot Tutorial
To enable the PIC18Flash board for serial loading of firmware, simply follow these
steps:
1. Using the IC-Prog/MTSP programmer, upload Tinybld18F.hex to the PIC18Flash
board.
2. Connect a spare COM port to the PIC18Flash board using a DB9DB9 cable (this
RS232 cable should not be crossed, i.e., pins 2 and 3 should be straight
through).
3. Run TinybldWin.exe, select the COM port; select an application firmware hex file
(e.g., PIC18flash.hex); cycle the PIC18flash power supply and within 5 seconds of
applying power, click Write Flash.
The Tinyboot bootloader (Figure 8) is configured to watch for hex data arriving on
the RS232 port for 5 seconds from power-up or reset, after which time the firmware
application code will be activated.

Figure 8. Tiny BootLoader in action.

40

An RS232 bootloader is a small stub


program that is initially flashed into
the microcontroller by a traditional programmer. At power-up it communicates with a PC through the serial
interface in order to erase and program
the microcontrollers flash memory. If
no PC client communication is
detected, the bootloader passes control to the main firmware application
on the uC.
The RS232 bootloader method requires
only a Windows COM port and
enables firmware upgrades to be easily
applied to products in the field. To
take advantage of this programming
method, the user must first use MTSP
or ICD-2 to initially flash the bootloader
code. Once the bootloader is in place,
you can use a PC bootloader client to
upload your PIC *.hex firmware.
There are many freeware bootloaders
available on the Internet, and we have
tested several suited to use with the
PIC18F, including the Tiny Bootloader
which is included in the support zip
file, and is described in the inset.
(040010-1)

Web Links
Microchip: www.microchip.com
IC-Prog: www.ic-prog.com
Basic18: www.midwest-software.com
Tiny Boot:
www.ac.ugal.ro/staff/ckiku/software/
picbootloader.htm
Further reading
Goodbye 16, Welcome PIC18F, Elektor
Electronics October and November 2003.

elektor electronics - 1/2005

You might also like