The following photo shows the top and bottom of the
Imagine developing a surface-mount project and being able to update the
program while the chip is soldered to the board.
These chips are not a "computer on wheels" but they will get
you started into the world of programming and thinking of ideas that
could lead you down the path of invention.
SETTING UP On your desktop you will need 4 icons:
At the beginning you can
create 3 folders and name them as above.
In the MPASM folder you will
have MPASM and you will select
and a third folder with
PICkit2v2.exe and ".inc files" The following diagram shows a SURFACE MOUNT PC Board with a PIC12F629 chip and IN-CIRCUIT PROGRAMMING socket made from 5 tinned copper wires.
The photo identifies each of the pins for the surface-mount chip:
The photo below shows fine
enamelled wire (0.2mm) connecting the programming pins to an 8-pin IC
socket:
The names of each of the pins for the 8-pin IC socket:
1. What is a PICkit 2? The PICkit 2 is a USB in-circuit prototype programmer manufactured
(and sold) by
Microchip. The PICkit 2 contains an 18F2550 chip. This chip can update its code
(write to its own FLASH memory). The PICkit 2 contains a bootloader that
makes this possible. You can use this feature to update the firmware of
your PICkit 2. With the latest version of MPLAB (7.41) it should be possible to use
the PICkit 2 as an ICD (in-circuit debugger, like ICD1 or ICD2), but
only with the PIC16F917. So far I have not been successful with this.
The PICkit 2 is an in-circuit programmer, which means that it does
not have a ZIF or similar socket to plug the target chip (the chip to be
programmed) in. Instead it has a connector for a 6-pin, which you must
connect to the target chip. With some care this enables you to program
the target chip without removing it from its circuit. To be really sure that a PIC is correctly and long-term reliably
programmed it must be verified (by reading the code back and comparing
it to the original) at the low and high extremes of the power supply
voltage that it will be used with. Microchip calls a programmer that can
do this a 'production' programmer. A programmer that does not have this
capability is called a 'prototype' programmer, indicating that it should
not be used for development only, not for production work. The PICkit2
hardware has a limited ability for varying the supply voltage for the
target chip (it can only regulate down from the voltage supplied by the
USB connection, and its only reference is that voltage), and the current
PICkit2 software uses this ability only to reduce the supply voltage to
3.3V for chips that cannot use a higher voltage. Hence the PICkit2 is
called a 'prototype' programmer. Generally speaking a bootloader is a (small) program, which sole
purpose is to load another program (the application) into memory (and
probably to start that application). In the context of FLASH
microcontrollers a bootloader is a program that can write an application
program to the FLASH memory of the microcontroller (it can of course
write only to the part of the FLASH that is not occupied by the
bootloader itself). The PICkit 2 contains a bootloader that will takes
control when the PICkit 2 is powered. When the bootloader does not find
an application program already in FLASH, or it finds the PICkit 2 button
pressed, it will remain in control. Otherwise it will pass control to
the application program (the PICkit 2 firmware itself). When the bootloader is in control it will blink the Busy LED. 5.
How can I download/update the PICkit2 firmware'? The PICkit 2 XP program supplied by Microchip has a menu entry
'Download PICkit 2 OS firmware' under 'tools'. This will instruct the
PICkit 2 application to pass control to the firmware and let you pick a
.hex file to be downloaded. If your PICkit 2 contains the bootloader but no application the
bootloader will remain in control (the Busy LED will blink). When you
start the PICkit PC program it will take some time during which nothing
seems to happen (don't panic). Then a window appears that allows you to
choose the application .hex file to download. This also takes some time.
Then the normal PICkit 2 application window will appear, but it shows a
nonsense message about a strange firmware version. You can ignore that
message.
6. The software in my PICkit 2 seems to be corrupt, what can I do?
If an application is present in the PICkit 2 but it is corrupted (or
it is not the PICkit 2 firmware) you can not use the normal software
update method. Instead you must plug the PICkit 2 in (USB cable) while
pressing the button. This forces the bootloader to invalidate the
application and take control. Now you can proceed as stated in the
previous answer. 7. What is the
purpose of that button? The PICkit2 has a small black button right above the power LED. When
it is pressed while the USB connection is made the bootloader will claim
control instead of activating the PICkit2 firmware. This can be used to
update a damaged firmware. The PICkit2 hardware has two 24LC512 EEPROMs. With the current
firmware these EEPROM are not used. With appropriate firmware (which to
my knowledge does not yet exist) the PICkit2 could be used as a
stand-alone programmer: use a PC to load the software update into the
EEPROMs, drive to the device you want to update, plug the PICkit2 in,
press the button, and the new software is programmed into the device.
The device must provide power to the PICkit2, and the target PIC must be
one that can be programmed with a Vdd-before-Vpp sequence. 8. Which USB driver do I
need? You don't need a special USB driver, the PICkit 2 uses the HID (Human
Interface Device) driver that is part of Windows XP. 9.
I get 'USB device not recognised', what should I do? This problem is often reported by PICkit 2 users. I don't have a
definitive solution, but some thing seem to help: disconnect the PICkit 2 from the target circuit before you
connect the USB cable
plug the USB connector in slowly (this increases the time
between the power contacts connecting and the data contacts
connecting)
when you get the error, disconnect, wait a few seconds, and
reconnect.
contrary to the above, some people have reported that you must
wait a long time (>30 seconds?) before you attempt to reconnect. I
suspect that this is a cure for a different problem.
if the PICkit 2 is connected to a HUB, disconnect the HUB from
the PC and reconnect (I still saw the 'USB device not recognised'
error but the device did work!)
(a bit experimental) during experiments with a PICkit 2 clone I
am designing I noticed that the 'USB device not recognised' was
produced by the PICkit 2 application, never by the bootloader, and
also never immediately after the application was downloaded and
started by the bootloader. The USB part of the application and
bootloader work a bit different, so I reasoned that maybe the
bootloader does a better job on the USB initialisation. But the
original bootloader does not initialise the USB, except when no
application is present, or the button is pressed. So I modified the
bootloader to *always* initialise the USB, wait a second, shut down
the USB, and then start the application (if present). You can hear
this: when you plug it in you hear a USB attach, USB detach, and a
final USB attach. So far I never got the 'USB device not recognised'
with this modified bootloader. To use this bootloader you will have
to re-program your PICkit 2. When you open it you will notice a
strip of 6 pads at the edge of the PCB. These pads can be used to
(re) program the 18F2550 in the PICkit 2 with .... a PICkit
WHERE TO, FROM HERE? |