cancel
Showing results for 
Search instead for 
Did you mean: 

Initialization of GPIO pin for MOSFET as switch

ControlFreak
Associate III

I am connecting my GPIO pin of STM32F4 of discovery board to gate of N channel MOSFET and drain of this N channel drives gate of P channel Mosfet and source of P channel Mosfet with turn on my 5VDC devices. I have also connected 2K pull up resistor to Gate of P-channel and N channel other end of resistor is connected to 5VDC. I am using DMC2038LVT for P-channel and N-Channel Mosfet. 

 But I am unable to get 5VDC at output source of P channel. Please find GPIO initialization below.

 RCC_AHB1PeriphClockCmd(RCC_AHB1Periph_GPIOB, ENABLE);

 GPIO_InitStruct.GPIO_Pin = GPIO_Pin_5 ;

 GPIO_InitStruct.GPIO_Mode = GPIO_Mode_OUT;

 GPIO_InitStruct.GPIO_OType = GPIO_OType_PP;

 GPIO_InitStruct.GPIO_Speed = GPIO_Speed_50MHz;

 GPIO_InitStruct.GPIO_PuPd = GPIO_PuPd_NOPULL;

 GPIO_Init(GPIOB, &GPIO_InitStruct);

 GPIO_ResetBits( GPIOB, GPIO_Pin_5);  

Can someone help as to find why I am unable to get 5 V at source of P channel Mosfet

3 REPLIES 3
LMI2
Lead

Do your fets open at 3.3V. That is what you get from STM32F. And do the other voltages make sense.

Besides, P-channel fet source must be at + (5V?) voltage and drain goes to devices using that voltage.

T J
Lead

You would set the port pin with pull down resistor.

You would pull it hi to turn on the N-Channel,

The NChannel would pull down a 10K pullup connected to 5V

that same pin would drive the gate of the PChannel.

Yes, @LIM2 is correct, seems that you may have the Source and Drain reversed.

ControlFreak
Associate III

@LM12, you are right, my source of P channel Mosfet is connected 5VDC and drain is connected to all the devices that requires 5V.(Sorry I mentioned it as "SOURCE" in my earlier post) But is my initialization for GPIO pin is correct?