i am trying to use a 2n2222 to amplify the signal from the mc to switch irf 9540 pmos, however if i increase the switching frequency from more than 1 khz, it takes more time for 2n2222 reach its peak, and consequently pmos switching is delayed.
if i remove irf 9540 from the collector of 2n2222, it works fine, even at higher frequencies(~20khz)
That is not a good way of driving a MOSFET. Firstly you are exceeding the maximum gate voltage which is 20V but more importantly you are simply relying on a 3.3k resistor to turn the MOSFET on. With 1300pF of gate capacitance that will be slow. You need a circuit which charges the gate capacitance quickly as well as discharges it quickly. That will need either a proper driver IC or two drive transistors to make a push-pull driver.
That is not a good way of driving a MOSFET. Firstly you are exceeding the maximum gate voltage which is 20V but more importantly you are simply relying on a 3.3k resistor to turn the MOSFET on. With 1300pF of gate capacitance that will be slow. You need a circuit which charges the gate capacitance quickly as well as discharges it quickly. That will need either a proper driver IC or two drive transistors to make a push-pull driver.
i think you are right, when i analyzed the wave forms through an oscilloscope, the output of collector takes a long time to reach 24, and that causes the delayed switching.
and for exceeding Vgs, what should i do? i have to operate with the given parameters.