please dont rip this site

The 16F877 programming saga

by Fred Maher

Dear James,

Before I get deep  into the  programmer you have kindly sent me I'd like to go over the more general topic  of programming the 16F877 family.

                  I'm beginning to think that there is some sort of knowledge  problem associated with the 16F877 chip. At first I had  mentally   assumed my lack of success as  due to the typical learning curve. Delving into  the atmosphere around this chip, things began to change a little as I realized that the problem was not mine alone and that the help to get you out of the mire was surrounded in mirk. Still even so, there are always two groups, those who have no problem and those who have (with the first timers making up the group in difficulties.)

In the present situation   I get the idea that those of us with difficulties are in that state because there is absolutely no support literature on  the PROGRAMMING PROCESS  and the three ways to achieve this in the case of the chip under consideration.

I've  been in touch with a lot of people and frankly it is very much a case of this is my way and it works.  

Now as an engineer one of the basic tools  when  I am working that  I use or create is documentation and there aint much of that flying around reference programming the 16F877 and ilk, so I feel that you gurus in the PICLIST should fill the partial vacuum. Also Micro chip has apparently documentation but not very complete.

My particular journey through this information desert has led me to gather together the information  available  on the PIC itself  and then try and build the programmer available using the software available.  So let me pass onto you my little hoard of programming savvy.

I just said there were various ways of programming these new generation PICs which are  combinations of

Methods

  1. Bootloading,
  2.  Low voltage programming
  3. High voltage programming

Ports

  1. Serial port  programming
  2. Parallel port programming

Fine now for beginner  you need something that is pretty foolproof as the typical start up scene is you blindly do all the things someone ( expert) says you should do and get that first " Hello world "program into the new  widget and  then proudly show it to your pet dog. You need to see something quickly.  

Lets look  at METHODS and  PORTS then try and  talk about  which are the most suitable for beginners.

1 . Bootloading   

Definitely complicated for a beginner for two reasons. 

a) The "program to load the program" concept with the necessary offsets sounds a little daunting  for a beginner who wants something which can be programmed directly.

b) You have to program this  bootloading program to load the initial program. This sounds even more off-puting  and also encloses a logical paradox in the sense ... to get your first program going you need to have a working program...gotcha

2. LVP low voltage programming

This sounds really neat, just a single supply and you are there. Well the  hidden snag   is that  the  chip has to be brand new , factory fresh and in the default  factory LVP configuration.  If you  don't get immediate results, get nervous and do an initial erase,  which is bad bad bad;  or even worse you start fiddling around  with the options your programmer software gives you as default, then Murphy's law almost guarantees  that you will have set the combination needed to wipe out the factory preinstalled configuration.  So rule  LVP out for the moment as well

3. HVP high voltage programming

HVP sounds like a retreat into the bad old days  when it was the only way, so why chose it? There is one overpowering reason..... YOU CAN CONFIGURE WHAT EVER YOU WANT..  The good news enclosed in that line is that  when you put your foot in it, code protect or what have you, then you can rub out and start anew. Get back to square one again so to speak.

So for me this is definitely the way to go to get started.  

 

Serial v Parallel port

Now above we have also listed the two common ways to connect your PIC Programmer to your computer, the parallel or the serial port. At this point I should say either will do, however  I didn't manage to get a  serial port signal to program my PIC but  yes I did do it with the signal from the parallel port. 

Is there any difference? At first sight no because both load the data bit by bit into the 16F877. However there are some practical things like the serial port offers the possibility of powering the Programmer, the parallel port is very limited in this respect. The serial port also with a slower data transfer and larger output swing will take a bit longer to load the PIC but on the other hand will  be more immune to noise and pulse reflections, and you can use a long cable between PC and Programmer.

Has the parallel port then no advantage? Well the noise tolerance is worse, the cable length is more critical but the  programming loading can be faster providing the 16F877 can  accept its  program  data with sufficient rapidity.  

Anyway I was forced into deciding for the parallel  port  data transfer because of some gremlin  on my serial ports.

Painless parallel ports

Now if the above has been a  bit anti-parallel port usage, maybe we can get round the mentioned problems with little effort.

The logical step is to see why the cable length is normally quoted  by programmer authorsb as to be  something like  "not more than one foot" or some other short distance  equally horrible  as all your junk box cables are 3 meters long. 

The IEEE specifications talks about  a minimum of 10  meters  normal, and up to 30m with precautions , being possible. Well   I think 2 metres  is a comfortable length and with semi-decent cable should not be too prone to noise capture. The  parallel port o/p swings are not 0 to 5V but nearer 0 to 3V. However this in itself is more of an interface problem rather than a noise problem. The possible, and probable reflections need a little working on. Any bit of cable  has wires, these wires are transmission lines when things start getting a bit faster.  The basic transmission line property is that if you don't terminate in the correct impedance, then the pulse gets reflected back from the load towards the originating transmitter. If the mismatch is really bad, then  the wire gets filled up with bouncing pulses all being about the size of the wanted one. The system  data transfer gets lost. as it doesn't and can't  know  the difference between the wanted and the reflected data bits. 

The solution is relatively simple as  in our case we terminate  each line where it enters the programmer with the IEEE specification impedance, which is about 470 ohms. No coils nor capacitors,   no coaxial cable just a simple resistor!  There is  one little   practical point to be aware of  here.  Some parallel port line driver output chips may have a little trouble sourcing the required  current. After all the 3V high would mean 6ma per line  and to keep costs down they may have used chips that can only drive a load  with  less  current appetite. Well my own compromise here is that most line drivers can source 3ma so lets  go less still and use say two milliamps. Then the terminating resistor needed is now increased to 1k5.

Is this enough to  avoid the reflections? Well considering that the cable is no more than 2 meters long, yes it is enough   protection for that length of cable.

Any other serious parallel port problems? Not really, except avoid running  the pc to pcb cable along the  mains wiring , though  crossing at right angle should not be a problem.

Selecting the software

Now although I  name names below, I will not  try and compare technical merits  of each program for the simple reason I'm not qualified to do such a job. 

Let's just say there are  quite a few software programs on  offer   for  the 16F877  written by famous net names such as:-

All good softwares, and all offering support for existing  programming units.  Unfortunately I got into a mess trying to adapt  these softwares to the  programmers I was building.  I'm sure they are all good and that given a little time it was just a question of finding the write combination of programmer  and software. 

BJ high voltage programmer

Yes  I decided to build my own  programmer to meet my own  beginner needs and at the same time be capable of flexible operation.   So the basic specification  was very simple, just two  little mods to the BJHV programmer, basically 

The parallel port  pins used depend obviously on  the pins the programming software  uses. So initially this was a little open  as I tried  various softwares. I eventually settled on the winpicprog by Nigel as it has a very useful window for fiddling about with the hardware settings. I was able to find a combination that worked with my BJ programmer

But I was by now  building the programmer with one of those little battery eliminators that you plug directly into the wall socket and give you a selectable range of DC  voltage output. . Now it turned out that  the one I selected, a typical taiwan model, offered good filtering and load regulation. I was lucky as I have seen some really  grotty products that are  just recifiers with almost zero filtering. 

Anticipating that sort of poor filtering, I  built in two things to the programmer power supply. Good filtering and current limiting.  You cab Spice simulate all off the performance , which I did.  This power supply bit has to offer a good stabilized 5V dc output, ideally from a monolithic chip such as L7805  in the big metal format for really cool   indestructible operation. it did it. 

The next part was a little more involved, but not much. I wanted a light to go on when   programming was in operation. The circuit shows how.  Then there was the little matter of what programming voltage to use.  Also how to apply it when needed to the 16F877. 

I tried and managed to program the 16F877 with this Vpp voltage  anywhere between  9 and 16 V before I read  the microchip data sheet  again, this time correctly  and found to my horror that the absolute maximum voltage was 14V.  But nothing had died so I settled on 13V, not  that I am superstitious  but it seemed about right . I built in a pot to change this  stabilized output if a lower /different  voltage were to be needed at some future date. 

The  parallel port data lines were all terminated with as we discussed earlier 1k5 resistors and the 74HCT573 used as a level shifter /buffer did exactly what it was supposed to do, change the 0 to 3V incoming pulses to 0 to 5V for onward routing to the PIC data and clock i/p's.

So that really winds up how to get your little PIC to market with no pain.

 


So James these are my thoughts on  16F877 programmers. I'd like one of your real experts to fill in  the wooly bits and then maybe you could get it up on the beginners help section, because getting help on getting up and running is very sketchy , believe me.  I f you want the final  programmer theoretical circuit  and  PCB  layout, it is all documented and built and working and at your disposition..

 

Cheers Fred

 

 

 

 

 

 

David A Cary Says:

Up: PIC Microcontroller Programmers http://massmind.org/techref/microchip/devprogs.htm

double up: PIC Microcontrollers http://massmind.org/techref/microchip
+

See:


file: /Techref/microchip/16F/877/programming.htm, 13KB, , updated: 2012/4/26 08:15, local time: 2024/11/22 01:40,
TOP NEW HELP FIND: 
3.136.22.204:LOG IN

 ©2024 These pages are served without commercial sponsorship. (No popup ads, etc...).Bandwidth abuse increases hosting cost forcing sponsorship or shutdown. This server aggressively defends against automated copying for any reason including offline viewing, duplication, etc... Please respect this requirement and DO NOT RIP THIS SITE. Questions?
Please DO link to this page! Digg it! / MAKE!

<A HREF="http://massmind.org/Techref/microchip/16F/877/programming.htm"> Programming the 16F877</A>

After you find an appropriate page, you are invited to your to this massmind site! (posts will be visible only to you before review) Just type a nice message (short messages are blocked as spam) in the box and press the Post button. (HTML welcomed, but not the <A tag: Instead, use the link box to link to another page. A tutorial is available Members can login to post directly, become page editors, and be credited for their posts.


Link? Put it here: 
if you want a response, please enter your email address: 
Attn spammers: All posts are reviewed before being made visible to anyone other than the poster.
Did you find what you needed?

 

Welcome to massmind.org!

 

Welcome to massmind.org!

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

  .