Designed inductance snubbing can reduce problems. There are many approaches here. You will see diodes, zeners, and RC snubbers. You should consider those.
Most microcontrollers have protection diodes to their power rails (along with mosfet body diodes.) But these diodes have limited ability to handle current. Most microcontroller protection diodes can't handle more than 1 to 2mA. Some can't handle even near that much. So you MUST read the datasheet and find out what the specifications say about this. A proper design will use this information.
A protection circuit on the base drive to the BJT may include two resistors instead of one with BAV99 external diodes to rails at the middle of the resistor pair to help snub the voltage spikes before they arrive at the pin. So, for example, if an 11kΩ base resistor is acceptable for the BJT switch drive, you might break that up into a 1kΩ and a 10kΩ, with the 1kΩ nearest the micro pin and the 10kΩ directly to the base. The BAV99 pair would be at the middle of that pair, going between +5 and ground. The voltage at that point will be rarely above 0.4V above +5. Then the 1kΩ resistor will limit the input current to a reasonable figure. But again, you need to observe the datasheet here, as well. If timing allows you to do this, you may also include a capacitor from a BAV99 to ground to deal with fast dV/dt rates and pump still more current away from the node before it reaches the microcontroller pin.
My guess is that you did not use a current limiting resistor in the transistor base and you connected the 12V backwards so that the transistor CB junction was forward biased, the result would be that you connected -12V through the transistor to the pic. Assuming the relay is in series with the collector, it would still be enough current to damage the PIC output
Even if the 12V was not reversed, the relay coil inductance may have generated a high voltage transient if you did not use a clamping diode accross the relay coil. Any time you connect a relay to a transistor, you MUST clamp the coil flyback voltage or it will destroy the transistor and possibly more.
http://en.wikipedia.org/wiki/Flyback_dio...
"burn the circuit through the base" ? do you mean can the circuit burn out, damage, the transistor. Yes.
"connected a pic(micro-controller) to the base of a transistor (5v),and the other 2 terminals to a relay and voltage source (12v)" Have to see a schematic, but that does not appear to be a workable circuit.
"can the tranitor burn the pic" ? What is a pic?
You need to explain this a lot better.
If you connect the pic to the base of a transistor with no base resistor, it could damage one or the other.
can a transistor (bjt) burn the circuit through the base?
i connected a pic(micro-controller) to the base of a transistor (5v),and the other 2 terminals to a relay and voltage source (12v),can the tranitor (2n2222) burn the pic?