Programming PIC18F
    
   
    
Home
AllPro Adapter
Windows Driver
Programming PIC18F
Products
References
About Me

Programming PIC18F Chips

 

ICSP

The pin-out for Microchip standard 6-pin connector for In-Circuit Serial Programming (ICSP) is listed in table below

PinFunction
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 only programmer itself without kit 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

It 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 AddressBit7Bit6Bit5Bit4Bit3Bit2Bit1Bit0
300000hCONFIG1LUSBPLLCPUDIV1CPUDIV0PLLDIV2PLLDIV1PLLDIV0
300001hCONFIG1HIESOFCMENFOSC3FOSC2FOSC1FOSC0
300002hCONFIG2LVREGENBORV1BORV0BOREN1 BOREN0 PWRTEN
300003hCONFIG2H WDTPS3 WDTPS2 WDTPS1 WDTPS0 WDTEN
300005hCONFIG3H MCLRE LPT1OSC PBADEN CCP2MX
300006h CONFIG4L DEBUG XINST ICPRT LVP STVREN
300008h CONFIG5L CP2 CP1 CP0
300009h CONFIG5H CPD CPB
30000Ah CONFIG6L WRT2 WRT1 WRT0
30000BhCONFIG6H WRTD WRTBWRTC
30000ChCONFIG7L EBTR2 EBTR1 EBTR0
30000DhCONFIG7H 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

See references page...

 

Home | AllPro Adapter | Windows Driver | Programming PIC18F | Products | References | About Me

 

This page was last updated on 06/20/09