Electronic – 8051 – Can an NPN transistor be driven

8051npnpnp

I have a PCB in front of me now, with the following circuit on it:

enter image description here

Despite looking fairly easy, this doesn't work as it should. After delving into some info about 8051 ports, I started to suspect that, despite measuring 4.9 Volts on the outputs, ports are actually not sourcing current, they are sinking. Then I saw this (page 138):

8051 Microcontrollers: Hardware, Software and Applications

Image from book: . M. Calcutt,Frederick J. Cowan,G. Hassan Parchizadeh

Here, the author claims he is doing what I am trying to do. Is he right or wrong? Could this be done with the right choice of resistors? Or can this only be done with an PNP?

Best Answer

I quickly looked at the datasheet for the AT89C51CC03 (page 7 and 8 of this). It reveals port 3 has indeed a sinking output, and there is a weak pull-up which explains your voltage reading. If you want to wire that as you have it, use port 0, which has a push-pull output.