Programming PIC18F Chips

ICSP
The pin-out for Microchip standard 6-pin connector for In-Circuit Serial Programming (ICSP) is listed in table below:
|
Pin |
Function |
| 1 |
_MCLR/Vpp (programming voltage) |
| 2 |
Vcc(+5V) |
| 3 |
GND |
| 4 |
Data |
| 5 |
Clock |
| 6 |
LVP (low-voltage programming mode control) |
PICkit 2
PICKit 2 Starter Kit is the low cost ICSP programmer for Flash PICs with USB interface introduced recently by Microchip. Only subset of PIC microcontrollers is supported, but the list is including all the recent devices from PIC16 and PIC18 families. The software upgrades are free and Microchip updates them in timely fashion. Even more, the source code and schematic are freely available. You can buy PICkit2 programmer from Microchip Direct for $35 (Microchip part number PG164120).

My first PIC programmer was Melabs EPIC device with parallel port interface. After upgrading my PC I have realized that parallel port became legacy these days, as the most of new PC motherboards do not have it all. The another annoying part about Melabs programmers in general is that even if you buy the full package (hardware + software) upgrades are not free and only beta stuff available for download. I have successfully burned all my PIC18F2455 and 2450 chips using PICkit 2 and would definitely recommend it.

PIC programmer in a hour
t was just a proof of concepts. Here is the thing: If you do not have a PIC programmer around - what would you do? Many PIC programmer schematics available on the Web due the ease ICSP protocol. Surprisingly enough the most of them using parallel port interface, like EL Cheapo programmer. Accessing parallel port programmatically under Windows 2000/XP is a real pain and requires special kernel-mode driver. I have opted in favor of the serial-port based JDM2 as the most simplest one. The programmer schematic was shown in below with all the updates required to program PIC18F chips.

I was built it on the small prototype stripboard from Futurlec. The top and bottom stripboard layout is shown here. All the traces are cut at holes with 9/64 drill bit rotating by fingers.

The next step was trying to use the different software. WinPic800 failed miserably, even thought it claims to support JDM interface and PIC18F2450 and 18F2455 chips but WinPic done well, see the picture below.

Using WinPic for programming PIC18F245X controllers got some pitfalls. First, it requires the Microchip device files to be installed in WinPic devices folder. Those files are part of Microchip IDE and not included in WinPic installation. Basically you have to download and install Microchip IDE, locate the file you needed and copy them to WinPic devices folder. For programming PIC18F2455 you would need PIC18F2455.dev file. Note, then WinPic would complain if the device file for particular chip is missing if you try to program without it. Second, WinPic it doesn't check the configuration word properly, as the devices have user-configurable memory space from 300000h-30000Dh, see table below. Two config registers are missing, namely CONFIG3L(300004h) and CONFIG4H(300007h). PICkit2 is aware about that and handles it properly, but WinPic is trying to program it as contiguous memory block and failing on verification.
| Memory Address |
Bit 7 |
Bit 6 |
Bit 5 |
Bit 4 |
Bit 3 |
Bit 2 |
Bit 1 |
Bit 0 |
| 300000h |
CONFIG1L |
— |
— |
USBPLL |
CPUDIV1 |
CPUDIV0 |
PLLDIV2 |
PLLDIV1 |
PLLDIV0 |
| 300001h |
CONFIG1H |
IESO |
FCMEN |
— |
— |
FOSC3 |
FOSC2 |
FOSC1 |
FOSC0 |
| 300002h |
CONFIG2L |
— |
— |
VREGEN |
BORV1 |
BORV0 |
BOREN1 |
BOREN0 |
PWRTEN |
| 300003h |
CONFIG2H |
— |
— |
— |
WDTPS3 |
WDTPS2 |
WDTPS1 |
WDTPS0 |
WDTEN |
| 300005h |
CONFIG3H |
MCLRE |
— |
— |
— |
— |
LPTOSC |
PBADEN |
CCP2MX |
| 300006h |
CONFIG4L |
DEBUG |
XINST |
ICPRT |
— |
— |
LVP |
— |
STVREN |
| 300008h |
CONFIG5L |
— |
— |
— |
— |
— |
CP2 |
CP1 |
CP0 |
| 300009h |
CONFIG5H |
CPD |
CPB |
— |
— |
— |
— |
— |
— |
| 30000Ah |
CONFIG6L |
— |
— |
— |
— |
— |
WRT2 |
WRT1 |
WRT0 |
| 30000Bh |
CONFIG6H |
WRTD |
WRTB |
WRTC |
— |
— |
— |
— |
— |
| 30000Ch |
CONFIG7L |
— |
— |
— |
— |
— |
EBTR2 |
EBTR1 |
EBTR0 |
| 30000Dh |
CONFIG7H |
— |
EBTRB |
— |
— |
— |
— |
— |
— |
The simple solution would be just inject two extra lines in Hex file to avoid WinPic confusion:
:0100000034CB
:010001000EF0
:010002003FBE
:010003001EDE
:0100040000FB
:01000500807A
:01000600C138
:0100070000F8
:0100080008EF
:0100090000F6
:01000A000FE6
:01000B00E014
:01000C000FE4
:01000D0040B2
:00000001FF
Another free PIC Programmer can be used with this interface is PICPgm. It is working "out of the box" and doesn't require Microchip IDE device files.


PIC Programmers on the Web
|