Please help me to write PIC16F628A programmer

(MPLAB PM3, PICSTART Plus, PICkit 2, PICkit 3) Topics covered in this conference relate to all programmers manufactured and distributed by Microchip.

Please help me to write PIC16F628A programmer

Postby alien8 » Thu Nov 12, 2015 11:21 pm

Hello. I've built a JDM Programmer but sadly can't use it, IC-Prog and WinPic800 both fail after writing some words (with verify during programming chosen).
Already tryed several settings (like various deleays in IC-Prog). I don't know what should be fixed in board and wheather it's possible to make it work properly (maybe some problems with my COM port), but anyway I'm sure I could write chip with different software. I need programmer that would retry to write a word after failed attempt. Every programmer I've tryed failed to proceed after first failed attempt to write. I find it really stupid, when OS fails to write data to FDD of HDD it tryes again several times and then asks something like "Retry, Abort, Ignore?", don't know why all those programmers don't use this approach.
As it seems that there's no open source programmer available, I need to write one by myself, and I decided to use pySerial. But I have problems with understanding how JDM works.
Programmer:
Image
I know it sets Vss to -5V but still it's hard for me to understand other details.
I need to control levels of Vpp, Vdd, write to Data and Clock pins. I see that with TxD and RTS I can control levels of Vpp and Vdd, CTS is to be used to read Data and DTR to write, but I don't see how to control Clock while holding Vpp and Vdd high.
From Microchip's specification:
Image
By the way, whatever programmer I use yellow diode doesn't shine, don't know why.
Please tell any suggestions what should I do, I think that I must first set TxD and RTS to 1 (so Vpp is high and Vdd is low), then after pause set RTS to 0 (so Vdd is high) and then start to send data, but how to control Clock?
Here's what I've written with Python:
Code: Select all
#this is intended to read word from memory but all I get are zeros
import serial, time
ser = serial.Serial(0)

def clock_low(): #??? drops Vpp and Vdd
   ser.setBreak(0)
   ser.setRTS(1)

def clock_high(): #???
   ser.setBreak(0)
   ser.setRTS(0)

def output_data(data):
   for i in xrange(len(data)):
      clock_high()
      if data[i] == 0: ser.setDTR(0)
      else: ser.setDTR(1)
      time.sleep(100e-9)
      clock_low()
      time.sleep(100e-9)

def input_data():
   data = []
   time.sleep(1e-6)
   for i in xrange(16):
      clock_high()
      time.sleep(100e-9)
      data.append(int(ser.getCTS()))
      clock_low()
      time.sleep(100e-9)
   return data



ser.setBreak(0)
ser.setRTS(0)
time.sleep(0.1)

ser.setBreak(1)
ser.setRTS(1)
time.sleep(5e-9)

ser.setRTS(0)
time.sleep(5e-9)

output_data([0,0,1,0, 0,0])# this is READ instrucion
data = input_data()
print data# get zeros

ser.close()
alien8
 
Posts: 3
Joined: Thu Nov 12, 2015 10:14 pm

Re: Please help me to write PIC16F628A programmer

Postby Ian.M » Fri Nov 13, 2015 12:11 pm

The JDM programmer requires a serial port that uses 9V or greater RS232 levels and it must still output >8V on TXD while RTS is clamped at -5.5V. Also the RTS line must supply all the PIC's operating current during programming. Most USB <=> serial adapters cant put out enough voltage to run a JDM. Also they are either hideously slow due to the limitations of the USB protocol and the CDC device class needing one packet per transition when bit-banging, or they fail badly when poorly written firmware looses sync between the data lines and the bit-banged handshake lines.

You also aren't doing yourself any favours adding LEDs to the design when the port is already likely to be short of drive capability. If you are going to keep them use ultrabright ones with at least 10K series resistors for the bottom two and 27K for the Vpp LED. Compare with Jens Dyekjær Madsen's original schematic: https://web.archive.org/web/20140803171443/http://www.jdm.homepage.dk/newpics.htm

All PICs with a PGM pin require a 10K pulldown (to Vss) on that pin for normal JDM programming.

Finally you are screwed anyway as the PIC16F628A ICSP specification calls for a bulk erase before memory programming so if a location has been corrupted, it is unlikely that you will be able to correct it by rewriting it.
Ian.M
Verified identity
 
Posts: 94
Joined: Wed May 28, 2014 12:47 am
PIC experience: Professional 1+ years with MCHP products

Re: Please help me to write PIC16F628A programmer

Postby alien8 » Fri Nov 13, 2015 4:16 pm

Thanks for reply, but no, I do belive I can write this chip without fixing board, still if I'll manage to make my programmer tool it will be useful for other people.
I had similar problems with programming PIC on Amiga 1200 (LPT programmer), it was OK for some bytes, but then programming failed probably because of bad sync.
And it was really unexpected because Amiga 1200 boards are the same, so I expect that LPT of my Amiga is just like LPT of the author of the programmer. There's DevPic package with scheme: http://aminet.net/dev/cross/devpic.lha. Then I decided that the problem was that I tryed to write PIC16F628A that differs from PIC16F628.
But finally I found way how to burn chip on Amiga: the programmer (picprog) had a special mode, here's a quote from readme:
"It has intelligent programming algorithm -
before location programming it will read old value and will program
location only if it is different. As a result, programming of new
version of code may take only some milliseconds."
So as long as I remember I bulk erased chip and then started to write it using this feature, and it took several attempts but all ended well.
Thus even if writing some location failed it's still possible to rewrite it and go on. O'Kay, I'm going to learn source of picprog now, hope it helps me.
alien8
 
Posts: 3
Joined: Thu Nov 12, 2015 10:14 pm

Re: Please help me to write PIC16F628A programmer

Postby Ian.M » Fri Nov 13, 2015 8:21 pm

It depends. If a bit is '1' when it should be '0' you can have another shot at it, but if whatever glitched took it to '0' you are S.O.L.

I strongly recommend an updated Davit Tait 'Classic' style parallel port programmer design on a real hardware parallel port, not a USB one. Use a 74LS06 or 07 for level shifting, with PMOS high side switches for Vdd and Vpp, fed from adjustable regulators and, with the right software you can cope with most devices.

For reference here's the tait classic schematic:
Image
(from http://picpgm.picprojects.net/hardware.html)
If using PMOSFETs, replace R1,R4 with zero ohm links.

WxPic is open source, and it is based on DL4HF's WinPIC, which was reliable and easily customisable.

If you need a USB interface, many of the FTDI USB UART chips support bitbanging efficiently using their own drivers. Microsoft's CDC class driver as used by most generic USB UART chips has slow and broken bitbanging. Avoid!
Ian.M
Verified identity
 
Posts: 94
Joined: Wed May 28, 2014 12:47 am
PIC experience: Professional 1+ years with MCHP products

Re: Please help me to write PIC16F628A programmer

Postby alien8 » Fri Nov 13, 2015 9:58 pm

Thank You, this is great stuff. I have LPT and COM ports on the board.
And, yes, as long as I remember when I tryed to program PIC with Amiga I always got 0x3FFF or something like read after failed write operation. If there were zero bits they were set properly, and this is what I see now with IC-Prog. Like I write 0x0001 and after bad write I read 0x3FE1.
alien8
 
Posts: 3
Joined: Thu Nov 12, 2015 10:14 pm

Re: Please help me to write PIC16F628A programmer

Postby Ian.M » Fri Nov 13, 2015 10:53 pm

Incidentally, with a 74LS06 or '07, and adjustable Vpp and Vdd you could go right down to 2.5 Vdd and Vpp=Vdd to support ICSP of the latest PIC16F1xxx parts in direct battery powered applications. The reason to use MOSFETs is for their low Rds_on, so the PIC actually gets the voltage the regulator is set to.

Proper low voltage programming is an increasing necessity - There was a case a few years back of a genuine Microchip programmer putting 5V out and blowing the s--t out of the LiPO battery powering the PIC, resulting in the total destruction by fire of the developer's desk.

If you want to experiment with ICSP capable of releasing the PIC to run and maybe even bit-banged debugging, take the bottom end of R3 to the spare gate output on U3 with a pullup to that point consisting of a 2K2 resistor and a series Schottky diode from the target Vdd rail, and drive the gate input from a spare parallel port pin. You can also delete the 5v rail wire above U3A, and connect the top end of R8,R9 to the collector (or drain if a PMOSFET) of Q1 so when the '06/'07's outputs are all off, there is no voltage to any pin of the PIC socket.
Ian.M
Verified identity
 
Posts: 94
Joined: Wed May 28, 2014 12:47 am
PIC experience: Professional 1+ years with MCHP products


Return to Programmers

Who is online

Users browsing this forum: No registered users and 2 guests