SC_05_2008_dspic_pic_programmer.pdf
(
7612 KB
)
Pobierz
By
Mauro Grassi)
This low-cost unit can program all dsPIC30F series
microcontrollers in the DIP package, along with most PIC
microcontrollers. It's easy to build and uses standard parts.
P
ICS ARE NOW ONE of the most
widely used microcontrollers. Like
all micros, they greatly simplify many
electronic designs, are reconfigurable
in the field and allow projects that
would be unwieldy or overly com
plex without them. In addition, extra
features can often be added retrospec
tively to the firmware.
Although the PIC family of micro
controllers is well known (we have
published many projects that employ
PICs), Microchip also manufactures
the lesser-known dsPIC30F series of
microcontrollers.
These are microcontrollers with
similar peripherals to those found
on standard PICs but which have an
enhanced instruction set augmented
with DSP (digital signal processing)
type operations. They are 16-bit mi
crocontrollers and are surprisingly
powerful, running at speeds in the
tens of MIPs (millions of instructions
per second).
62
SILICON CHIP
Dedicated single-cycle DSP opera
tions like MAC (multiply and accumu
late) allow them to perform real-time
signal processing using multiple 40-bit
accumulators. They also incorporate
hardware multiplication and division
and have surprisingly fast ADC acqui
sition modes. These features make
them well-suited to many digital signal
processing applications.
One such device, the dsPIC30F4011,
will feature in a new digital Musicol
our lightshow project to be published
soon in SILICON CHIP. This particular
device can perform a real-time FFT
(Fast Fourier Transform) on audio
band signals with ADC acquisition
modes that can operate at up to IMS/s
(l
million samples per second).
It
runs
at close to 30MIPs and has 48kB of
program memory.
most older PIC programmers cannot
program them. This is due to incom
patibilities with the pin-outs of the
dsPIC family.
As a result, we have designed
this simple, low-cost dsPIC and PIC
programmer.
It
can program all the
dsPIC30F family of microcontrollers
that are available in a DIP package, as
well as almost all regular PICs.
It
uses
freely-available software (for the PC)
and is easy to build.
By the way,
if
you have ever wanted
to experiment with DSPs (digital signal
processors), the dsPIC30F series is a
good starting point. Microchip offers
a lot of documentation and source
code for free on their website
www,
microchip.com.
Programming procedure
Our new programmer is based on
the original COM84 style programmer
- so named because it was designed to
program 16F84 microprocessors from
si/iconchip.com.au
Programming them
The dsPIC30F series of micro
controllers are extremely useful but
a serial port. There are really three
lines which are necessary to program
most PICs and microcontrollers in
the dsPIC30F family: CLOCK (PGC),
DATA (PGD) and Vpp (programming
voltage).
Incidentally, the dsPIC30F family
has two programming modes - en
hanced and standard. The enhanced
mode is faster and requires a program
ming executive or "bootloader" to be
programmed in first. However, this
programmer uses only the slower
ICSP mode that is standard across the
PIC family (ICSP
=
In-Circuit Serial
Programming) .
If
you are interested in the details of
the ICSP protocol. refer to the Micro
chip website at www.microchip.com
(look for the "memory programming
specifications ").
Programming mode is entered by
raising Vpp up to around 13V. Data
is then programmed into the micro
controller by serially shifting com
mands and data using the PGC and
PGD lines.
The PGC line synchronises the ex
change of serial bits, while the PGD
line contains the data. The PGD line
is bidirectional, allowing reading and
writing of the microcontroller.
For example, there is a command
code for "Erase" which will erase the
flash memory of the microcontroller.
There are also commands for "Writ
ing" and "Reading" pages, etc. As
soon as the microcontroller enters
programming mode, it starts listening
for commands.
Features
(1)
(2)
(3)
(4)
(5)
Will program all dsPIC30F series microcontrollers in the DIP package
Will program most PICs in DIP package
Uses PC freeware WinPIC for Windows
Connects to the serial (RS232) port of a PC
Very low cost
Minimum Supported Devices
('others
may also work)
10F series
10F200/202/204/206 (E) (*)
12F series
12F508/509 (E)
12F609/615 (E)
12F629/675 (E) (*)
12F635/636/639 (E)
12F683 (E)
16F series
16F610/616 (E)
16F627/627A/628/628A (*)
l'
6F630/631/636/639/676/677/684/685/687/688/689 (E)
16F648/648A
16F716
16F731737174176177
16F818/819
16F84/84A/87/88 (*)
16F870/871/872
16F873/873A/874/874A/876/876A/877/877A (*)
16F913/914/916/917
18F series
18F2220/2320/4220/4320
18F2331/2431/4331/4431
18F2420/2520/4420/4520
18F2450/4450
18F2455/2550/4455/4550 (*)
18F2480/2580/4480/4580
18F2525/26204525/4620
18F2439/2539/4439/4539
18F242/252/442/452/
18F2585/4585/2680/4680
18F248/258/448/458
18F2682/2685/4682/4685
(*)
dsPIC30F series
dsPIC30F2010 (*)
dsPIC30F2011/3012 (*)
dsPIC30F2012/3013 (*)
dsPIC30F3010 (*)
dsPIC30F3011 (*)
dsPIC30F3014/4013 (*)
dsPIC30F4011 (*)
dsPIC30F4012 (*)
Circuit details
To successfully program a PIC or
dsPIC series microcontroller, we must
be able to control the PGC, PGD and
VPP lines in the correct fashion. The
SILICON CHIP dsPIC/PIC Programmer
achieves this by giving control of
these lines to the software running on
a Pc. This software program is called
"WinPIC". and it makes sure that the
correct procedure is followed for a
particular device.
Fig.1 shows the circuit details. As
can be seen, the dsPIC/PIC Program
mer has two distinct supply rails (+5V
&
+13.6V) and these are derived from
the DC supply rail using two 3-termi
nal regulators (REG1
&
REG2). S1 is the
power on/off switch, LED1 provides
power indication and diode D1 pro
vides reverse polarity protection.
REG2 is an LM317T variable voltage
siliconchip.com.au
=
tested
&
passed. (E)
=
requires external connection or adaptor socket.
voltage to: V
=
1.25 x (1+ R2/R1). Note,
however, that slight manufacturing
variations mean that the 1.25 factor
can be anywhere between 1.2 and 1.3
in actual practice.
In this case, R1
&
R2 have been se
lected so that REG2 regulates its output
to 13.6V in typical conditions. This
provides the MCLR-barlVpp voltage
for the microcontroller which should
MAY 2008
regulator. Its output is determined by
the bias applied to its AD] terminal,
as determined by the voltage divider
formed by the 120Q resistor and the
series 1.1kQ
&
82Q resistors.
If
R1 is the resistance between
the OUT and AD] terminals (120Q
in our case) and R2 is the resistance
between AD] and GND (1182Q), then
the LM317T will regulate its output
63
1 PC board, code 07105081,
122 x 120mm
1 adaptor PC board, code
07105083,52 x 19mm
1 16V 400mA DC plugpack
1 SPOT right-angle PC-mount
toggle switch (S1)
1 PC-mount 2.5mm DC socket
(CON1)
1 OB9 female right-angle socket
(CON2)
1 0lP14 IC socket
1 0lP16 IC socket
2 0lP40 ZIF sockets
2 jumper shunts
1 8-pin OIL header with 2.54mm
spacing
1 6-pin OIL header with 2.54mm
spacing
1 500mm length of 0.7mm tinned
copper wire
4 M3 x 6mm screws
2 M3 nuts
2 M3 x 10mm screws
4 9mm long M3 tapped spacers
Semiconductors
1 MAX232A RS232 line driver
receiver (IC1)
1 74LS04 hex inverter (IC2)
1 BC337 NPN transistor (01)
1 BC327 PNP transistor (02)
1 7805 5V regulator (REG 1)
1 LM317T regulator (REG2)
3 1N4004 diodes (01-03)
1 red 3mm LED (LE01)
Capacitors
1 10llF 16V electrolytic
7 11lF 16V electrolytic
2 100nF monolithic (code 100n
or 104)
2 22pF ceramic
Resistors (O.25W, 1%)
62.2k11
1
8211
1 1.1k11
1 12011
33911
ideally be between 12.8V and 13.1Y.
However, anything from 13.4V to
13.8V is actually OK at REG2's output,
since this is fed through transistor
switch Q2 and series diode D2 before
being applied to the MCLR-barlVpp
(master clear/programming voltage)
pin of the microcontroller to be pro
grammed.
In operation, the regulated 13.6V
rail from REG2 is switched on and off
64
SILICON
CHIP
by PNP transistor Q2 which in turn is
switched on and offby NPN transistor
Q1. When pin 3 (Tx) of the serial port
is high, it will switch Ql on, in turn
switching Q2 on and applying around
13V to the MCLR-barlVpp pin on the
microcontroller to be programmed.
Conversely, when pin 3 of the serial
port is low, Ql will be off and therefore
Q2 will also be off. In this case, the
2.2k11 resistor on D2's cathode will
pull the MCLR-barlVpp pin low.
Basically, on a PIC or dsPIC micro
controller, the MCLR-bar/Vpp pin acts
either as a Reset (oV) or a programming
voltage pin (around 13V for PICs or
between 9V and 13V for a dsPIC30F
series microcontroller). When MCLR
bar/Vpp is low, the microcontroller is
in the Reset state (meaning that all its
configurable pins are high impedance
inputs). When it is high (around VDD
=
+SV). the microcontroller runs in
program mode and if it is at Vpp the
microcontroller will enter program
ming mode.
It was a deliberate design decision
to switch the MCLR-barlVpp line be
tween OV and Vpp rather than between
VDD and Vpp. This was done to avoid
possible damage to the microcontroller
being programmed.
To
explain, if the MCLR-barlVpp
line were switched between VDD and
Vpp, the program would run on the
microcontroller when programming
finishes.
If
that program were to dri ve
the output pins (as digital outputs or
as peripheral outputs), it could cause
excessive currents to flow and damage
the output stages of those pins.
That's because the ZIF sockets have
many power connections to accom
modate different PICs and dsPICs (+SV
and GND). As a result, some of the
microcontroller's output pins could
be shorted to +SV or to ground if the
program were to run.
For this reason, the Vpp pin is
switched from OV to 13V so that the
microcontroller is never in the run
ning mode.
Ofcourse, if you were to incorporate
this programmer onto a PC board that
catered for ICSP (in-circuit-serial-pro
gramming) then you would have this
line switch from VD D(+SV) to 13Vand
the reset would occur on any transition
from 13V down to sY. Refer to the sec
tion entitled "External Programming
Using CON3") for more details.
Note that some PIC microcontrollers
can be configured to disable the Reset
.function of the MCLR-barlVpp pin, al
lowing it to be used for an alternative
(multiplexed) function. This should be
avoided when using this programmer
with a dsPIC or PIC plugged into a ZIF
socket, for the reasons outlined above
(this does not apply when using CON3
to program an external device).
Regulator REGI is used to derive
the +SV rail and this is used to power
ICl, IC2 and the microcontroller being
programmed. This +SV rail is bypassed
using 10llF, 11lF and 100nF capacitors,
while a 11lF capacitor also bypasses
REGl's input.
Control lines
The relevant lines used in the RS
232 serial interface to control the
dsPIC/PIC Programmer are derived
from pins 3,4, S, 7
&
8.
Pin S is the ground connection while
pins 3, 4
&
7 (respectivelyTx, DTR and
RTS) are outputs from the serial port.
In particular, pins 4
&
7 are digital
outputs, while pin 3 is usually the
Transmit line of the serial port. These
are controlled by the WinPIC software
on the PC as appropriate.
Finally, pin 8 (CTS) is an input pin
and this is used to read data from the
microcontroller, as required to verify
or read the state of the memory.
ICI is a MAX232 RS-232 line driver
receiver. Its job is to translate between
the RS-232 voltage levels (ie, :t:l0V)
at the serial port and the TTL levels
(O-SV) used by the microcontroller. As
mentioned, pins
4
&
7 of the serial port
are standard digital outputs and these
are connected directly to ICI.
In operation, the MAX232 actually
inverts the levels and so its outputs at
pins 9
&
12 are fed to inverter IC2a
&
IC2f (part of a 74LS04 hex inverter) to
invert them back again.
Pin 7 of the serial port controls the
PGC (CLOCK) line and is applied to
the microcontroller via ICl, IC2a and
a 3911 resistor (to limit the current). In
addition, a 22pF ceramic capacitor is
used to filter any high-frequency noise
on this line.
Pin 4 controls the PGD line (DATA)
output. When it goes low, so does
the pin 12 output of inverter IC2f.
Diode D3 allows a low level from
IC2f to drive the PGD line but blocks
high-level signals from IC2f. A 2.2k11
pull-up resistor is used instead to pull
this line high. This allows the WinPIC
software to read the PGD line from the
microcontroller via pin 8 of the serial
siliconchip.com.au
port (ie, after sending pin 4 of the se
rial port high].
So the PGD line is actually "bi-di
rectional" and is used as an output
when writing to the microcontroller
and as an input when reading from
the microcontroller.
Note that, as with the
PCC
line, the
PGD line is fed via a 390 resistor and is
filtered using a 22pF ceramic capacitor
to reduce spurious noise.
Two ZIF (zero insertion force] sock
ets are used to accept the microcontrol
ler to be programmed. ZIF SKT1 is
used for dsPIC30F series microcontrol
lers and they should always be aligned
with their pin 1 going to pin 1 of the
ZIF socket.
Alternati vely, ZIF SKT2 should be
used for programming standard PICs
like the 16F88. As before, pin 1 of the
microcontroller goes to pin 1 of the
ZIF socket.
Note, however, that the 10F and 12F
series ofPICs are not compatible with
the onboard ZIF socket. These must be
programmed via an external adaptor
board, as described later, or by using
CON3 and a breadboard.
~
+
-
I
8.
z
L
!
!!:!
0
~
z
M
~
'"
I I
,.
~o-£,t;ll~~~"'~~~&~!~~~~!
MMM
MMMMM
NNNN
NNN
~,
+
;:;
Q
-<
~
JI III
II I I I
II)
U
l5:
1'
D
;;;\
1999
UII
_NM~~~~~~O-NM~~~~~~'
u..
99~~99~~~99
N
II)
~
99
I I
'"
....
...
N
I I
I I I I I I I I
;:;(
D
;:;
!!:!
-<
r--'
,
'"
I?'\
-<~'"
,
I I
11
l U I
~
c:
.~"
~o-£,t;ll~~~"'~o~&~ :~~~~-
MMM
M
MMMM
NNNNNNNN
II)
u
II)
l5:
I:::
g0
~
~
g
D
,.
""C
..
_NM~~~~m~O-NM~~~~m~
II)
~
N
999999
I II II I
'99-999~9~~
I
I
I
u..
~
L
....
II II
~
ClO
,
~
>
~~
+
'";,~,
•
I
~~I
I~
. .
~
l!o<lQ:
..
u
!l:
~
~g;;
~I
y,·u
External programming
CON3 is a 6-pin header and its pin
out is arranged as shown in Table
1.
It
can be used to access the five relevant
lines required to program both PICs
and dsPICs externally (see the section
entitled "External Programming Using
CON3" below].
For example, if your PIC is not
actually compatible with the pin
ning of ZIF SKT2 (eg, if you have a
PIC10F202), then you may use this
connector to access the relevant lines.
These lines can be connected to, say,
a breadboard, to program your PIC off
the PC board. Of course, you can also
use this connector to program micro
controllers in circuit as well.
,.;
'0
'+
"
......
08
w""::'u
M
a
0
1"'::\
0
~
N
~CJ"Y'"
'"
.
58
ClO
....
"!
~
,
?;
"
u-O ....
N
~
M
~.~
II/")
M_
... w
c.:: .
~~
Z
~H"
~
...
~
H.H'·
0
u..
...
...
Q.
. .1
5
'"
l:;
+
....
...
u..
,.
....
...
N
U'-w
~t-
~
::
.
0'0
~~
~r'
...
g
c:
~
-
N
M
0
a
8(
~
g
I',
~F-
~>
~-
~
B
~
Q
,.
~;
...
H~'-
...
~
D
'"
....
...
-:;:IIrl"
~
u..
'::
~
N
~
,.
.~
~.
~
e.
~
r--=rt
1+1'
0()
i::!
N
~
+:.,
~
t
I'·
~
...
~~
M
C'I
::1
~
••
~
~I
.E
~
~
0
ii<
0
l::!
0
:Ii
:Ii
on
...
a;
C
a;
CD
a
a;
U
U
Jumper settings
Finally, there is an 8-pin header
which accepts jumper shunts JP1-JP4.
However, only two of the four posi
tions should ever be shorted at any
one time. Table 2 shows the jumper
functions.
In practice, you must set these ac
cording to the microcontroller being
programmed. Either JP1 or }P2 (but
not both] must be shorted according
to the type of dsPIC being programmed
in ZIF SKTl, while JP3 or JP4 (but
not both] must be shorted according
siliconchip.com.au
~~
\/\//\/\
F1'
.5
~
~
;0
~!~
I:::
M
8
1• •
+
..
. .
-~.J
~
~
"
~II
a
00
I
~
~
I
ClO
~
0
8
1
~I;;;
~~a~!,,-
gw -
N
III
M
.
~
I
,.
0
~
0
0
5
·-z
Q
.
-
en
"a
MAY 2008
65
.
..
-
"
HEADER
~
ICSP
..
3· • -
S •
•
t;;:
CON3
1~.
"'ll
0
en
~
to the type of PIC being programmed
in ZIF SKT2.
IfJPl is shorted, it connects the PGC
line to pin 8 of ZIF SKTl. This caters
Pin
1
2
3
4
5
Description
MCLR-barNpp
-----
GND
GND
+5V rail (Voo)
PGC
----
6
PGD
for some dsPIC30Fxxxx micro con
trollers that require the programming
clock on pin 8. Alternatively, if JP2 is
shorted,
it
connects pin 8 of ZIF SKTI
to ground and this caters for the rest of
the dsPIC30Fxxxx family that require
a ground corinectionat pin 8.
JP3 and
JP4
select which pin the
MCLR-bar/V
pp
programming line is
connected to on ZIF SKT2. If JP3 is
shorted,
it
connects the programming
line to pin 4 ofZIF SKT2 and this suits
micro controllers such as the popular
16F88. Alternatively, some microcon
trollers require the programming volt
age to be applied to pin 1 and this is
selected by installing JP4 instead.
Warning: it is quite possible to
damage a microcontroller installed
in either ZIF socket by incorrectly
setting jumpers JP1-JP4, so check
Tables 2
&
4 carefully before insert
ing a microcontroller into its socket
and applying power. However, a more
likely outcome is that you will not
damage the microcontroller (as they
usually have protection diodes) but the
programming will not be successful.
In summary, you must install ei
ther JPl or JP2 (but NOT both) when
programming a dsPIC and either JP3
or JP4 (but NOT both) when program
ming a PIC.
Jumper Number
Description
Short to make
p-in
8 of
ZIF
SKT1 the PGC
p-in
Short to make
pin
8 of
ZIF
SKT1
GND
Short to make
pin
4 of
ZIF
SKT2 the IMCLRN_P_P-"--_----'
Short to make
pin
1 of
ZIF
SKT2 the IMCLRNPP
pin
External Programming
Using CON3
The 6-pin header CON3 can be used
to program a PIC or dsPIC that's either
mounted in-circuit on a separate board
or installed on a breadboard. For exam
ple, this is one way of programming a
PIC microcontroller that doesn't have
siliconchip. com.au
JP1
JP2
JP3
JP4
66
~
--~r---
SIUCON CHIP
Plik z chomika:
gasma
Inne pliki z tego folderu:
UV_Light_Box_2.rar
(6417 KB)
UV_Light_box.rar
(4485 KB)
SC_Radar_Speed_Gun_Pt1.pdf
(5169 KB)
SC_Universal_Charger_Pt2.pdf
(6219 KB)
SC_Universal_Charger_Pt1.pdf
(5244 KB)
Inne foldery tego chomika:
1992
1993
1994
1995
1996
Zgłoś jeśli
naruszono regulamin