I tested the whole functionality of my programmer circuit, and many things work, but some things don't.

It seems to erase the entire contents of an AT89C4051, but it does not successfully program the chip. In fact, it seems nothing is programmed at all.

This is the pseudocode I use for the programmer:

Clear data (Set address 378h to 0)
Reset counter and enable program mode and wait 100us (Set Control 37Ah to 6)
** At this point, Pin 1=0V which is expected
Raise VPP (Set Control 37Ah to 2)    
** Expected 12V at pin 1 but only got 6.8V. Why? I don't know
Raise Step Reset (Set Control 37Ah to 3)    
Wait until system ready
Add 10mS delay
Lower Step Reset (Set Control 37Ah to 2)    
Wait until system ready
Reset count / lower VPP (Set Control 37Ah to 6)    

And for each byte:

Set data (Set Control 378h to data)    
Wait 100uS
Raise Step Reset (Set Control 37Ah to 1)    
Wait until system ready
Wait 2mS    
lower Step Reset (Set Control 37Ah to 0)    
Wait until system ready
Repeat for remaining bytes

For reference, "raise step reset" means the 4017 IC pin is set to high and "lower step reset" means make reset pin low. Once it falls low, the programming enable will stay low for at least 1/2 the time defined by the 555 timer circuit then it will be raised then after the clock is pulsed then the system will be ready.

Just about everything works but there is


When I instructed the system to raise the VPP voltage, it does, but in a weird fashion.

The resistor I use between 12VDC and RST of the micro is 100K only because Atmel's datasheet states that the maximum programming current is 250uA. So by using 100K, I'm using 12VDC/100K=120uA.

So with no microcontroller connected, the operation is accurate. The meter shows very close to 12V. However, when I took a working microcontroller out of a working system and I inserted it into this circuit and measured the voltage after performing the exact same operations, I only get between 6 and 7V.

I looked at other circuits and I haven't seen others use 100K resistors as pull-ups. In fact, I found the pull-up resistor is only 2.7K in the following circuit at: http://www.oocities.org/dinceraydin/8051/index.html


My question is why would such a small resistor be used for programming when the manual clearly states that there is an upper limit to the current that can be provided for VPP?

Am I supposed to violate that spec to make the programmer work?

And for reference, this is my circuit: and the diagonal line in the middle is part of an arrow, not wire. circuit


I searched the Internet and found ANOTHER programmer circuit that uses a LOW VPP resistor (1K).

URL is here: http://students.uta.edu/rx/rxr5243/projects/prog/

Image is here: http://students.uta.edu/rx/rxr5243/projects/prog/schematic.gif


1 Answer 1


If the current through the resistor is 120uA, the voltage across is will be 12V, meaning that you'll actually get 12V-12V=0V at the pin. That upper limit is a limit on what the microcontroller will draw, not a limit on what should be supplied.

What's happening is that the microcontroller is only drawing 60uA or so, but the resistor is dropping 60uA*100K=6V, so the output voltage is 12V-6V=6V. You need a much smaller pull-up resistor, so that the maximum programming current doesn't affect the output voltage much.

If you use a 2.7K resistor, for example, at 250uA the voltage at the pin will be 12-(250uA*2.7k)=11.325V, which is acceptable.

edit: actually, according to the datasheet, it needs to be at least 11.5V. A 2.7K resistor will (almost certainly) work, but technically it should be (12-11.5)/250uA=2Kohm maximum.

  • \$\begingroup\$ Ok then whoever wrote up the datasheet needs help because they should have put that 250uA in the MIN column, not the MAX column. Ok I'll try 2.2K resistor instead since I have a large number of them lying around. \$\endgroup\$
    – user152879
    Jan 27, 2018 at 17:48
  • 2
    \$\begingroup\$ No, the datasheet is correct. 250uA is the maximum current the microcontroller will draw. \$\endgroup\$
    – BeB00
    Jan 27, 2018 at 17:49
  • \$\begingroup\$ Its misleading to me because they titled it "maximum enable current". They should have titled it "maximum current drawn by IC" \$\endgroup\$
    – user152879
    Jan 27, 2018 at 18:05
  • 3
    \$\begingroup\$ Datasheets usually assume a minimum level of electronics knowledge. If they had to include all the context, every datasheet would be hundreds or thousands of pages long. The knowledge in this case is that you can't force an input to sink more current than it "wants" to, so any current limit is clearly a limit on what it draws (it's a bit more complicated than that, but that pretty much sums it up). It's a similar reason to why power supplies are labelled 1A. It doesn't mean they push out 1A all the time, that's just a limit on what they can put out. \$\endgroup\$
    – BeB00
    Jan 27, 2018 at 18:08
  • \$\begingroup\$ Also, if you did want to limit the current while providing a stable voltage, that isn't how you would do it. If you implemented a proper constant voltage current limiting system, everything would actually still work (although that would be unnecessary) \$\endgroup\$
    – BeB00
    Jan 27, 2018 at 18:10

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.